diff --git a/.gitignore b/.gitignore index d5f19d8..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ node_modules -package-lock.json diff --git a/rules/semi.js b/rules/semi.js index 7d6c472..4813dfa 100644 --- a/rules/semi.js +++ b/rules/semi.js @@ -67,38 +67,31 @@ const report = (context, node, missing) => { }); }; -const checkForSemicolon = (node, context) => { - const options = context.options[1]; - const exceptOneLine = options && options.omitLastInOneLineBlock === true; - - const sourceCode = context.getSourceCode(); - const lastToken = sourceCode.getLastToken(node); - - if (context.options[0] === "never") { - if (isUnnecessarySemicolon(context, lastToken)) { - report(context, node, true); - } - } else { - if (!isSemicolon(lastToken)) { - if (!exceptOneLine || !isOneLinerBlock(context, node)) { - report(context, node); - } - } else { - if (exceptOneLine && isOneLinerBlock(context, node)) { - report(context, node, true); - } - } - } -} - const semiRuleWithClassProperty = ruleComposer.joinReports([ semiRule, context => ({ - ClassProperty(node) { - checkForSemicolon(node, context); - }, - ClassPrivateProperty(node) { - checkForSemicolon(node, context); + "ClassProperty, ClassPrivateProperty"(node) { + const options = context.options[1]; + const exceptOneLine = options && options.omitLastInOneLineBlock === true; + + const sourceCode = context.getSourceCode(); + const lastToken = sourceCode.getLastToken(node); + + if (context.options[0] === "never") { + if (isUnnecessarySemicolon(context, lastToken)) { + report(context, node, true); + } + } else { + if (!isSemicolon(lastToken)) { + if (!exceptOneLine || !isOneLinerBlock(context, node)) { + report(context, node); + } + } else { + if (exceptOneLine && isOneLinerBlock(context, node)) { + report(context, node, true); + } + } + } }, }), ]);