source: imaps-frontend/node_modules/eslint/lib/rules/no-empty-static-block.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @fileoverview Rule to disallow empty static blocks.
3 * @author Sosuke Suzuki
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Rule Definition
9//------------------------------------------------------------------------------
10
11/** @type {import('../shared/types').Rule} */
12module.exports = {
13 meta: {
14 type: "suggestion",
15
16 docs: {
17 description: "Disallow empty static blocks",
18 recommended: false,
19 url: "https://eslint.org/docs/latest/rules/no-empty-static-block"
20 },
21
22 schema: [],
23
24 messages: {
25 unexpected: "Unexpected empty static block."
26 }
27 },
28
29 create(context) {
30 const sourceCode = context.sourceCode;
31
32 return {
33 StaticBlock(node) {
34 if (node.body.length === 0) {
35 const closingBrace = sourceCode.getLastToken(node);
36
37 if (sourceCode.getCommentsBefore(closingBrace).length === 0) {
38 context.report({
39 node,
40 messageId: "unexpected"
41 });
42 }
43 }
44 }
45 };
46 }
47};
Note: See TracBrowser for help on using the repository browser.