Files
med-notes/.pnpm-store/v10/files/81/1a33c5bd9ada82bdf422af06fc315f283c4c6182155259288c88a7e0935293227fc3c8083fcd385191280cb66a7b5b3594b5f3a062f0fd267f3b9662b66dc5
2025-05-09 05:30:08 +02:00

50 lines
1003 B
Plaintext

/**
* @fileoverview Rule to disallow empty static blocks.
* @author Sosuke Suzuki
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Disallow empty static blocks",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-empty-static-block",
},
schema: [],
messages: {
unexpected: "Unexpected empty static block.",
},
},
create(context) {
const sourceCode = context.sourceCode;
return {
StaticBlock(node) {
if (node.body.length === 0) {
const closingBrace = sourceCode.getLastToken(node);
if (
sourceCode.getCommentsBefore(closingBrace).length === 0
) {
context.report({
node,
messageId: "unexpected",
});
}
}
},
};
},
};