diff --git a/tests/tools/check-rule-examples.js b/tests/tools/check-rule-examples.js index 76dfbda304fa..df75cc9c135b 100644 --- a/tests/tools/check-rule-examples.js +++ b/tests/tools/check-rule-examples.js @@ -61,7 +61,7 @@ describe("check-rule-examples", () => { "\x1B[0m \x1B[2m12:1\x1B[22m \x1B[31merror\x1B[39m Syntax error: 'import' and 'export' may appear only with 'sourceType: module'\x1B[0m\n" + "\x1B[0m \x1B[2m20:5\x1B[22m \x1B[31merror\x1B[39m Nonstandard language tag 'ts': use one of 'javascript', 'js' or 'jsx'\x1B[0m\n" + "\x1B[0m \x1B[2m23:7\x1B[22m \x1B[31merror\x1B[39m Syntax error: Identifier 'foo' has already been declared\x1B[0m\n" + - "\x1B[0m \x1B[2m31:1\x1B[22m \x1B[31merror\x1B[39m Example code should contain a configuration comment like /* eslint no-restricted-syntax: error */\x1B[0m\n" + + "\x1B[0m \x1B[2m31:1\x1B[22m \x1B[31merror\x1B[39m Example code should contain a configuration comment like /* eslint no-restricted-syntax: \"error\" */\x1B[0m\n" + "\x1B[0m\x1B[0m\n" + "\x1B[0m\x1B[31m\x1B[1m✖ 5 problems (5 errors, 0 warnings)\x1B[22m\x1B[39m\x1B[0m\n" + "\x1B[0m\x1B[31m\x1B[1m\x1B[22m\x1B[39m\x1B[0m\n" diff --git a/tools/check-rule-examples.js b/tools/check-rule-examples.js index 9013f1d0e9a7..a05af69a3bc4 100644 --- a/tools/check-rule-examples.js +++ b/tools/check-rule-examples.js @@ -11,9 +11,9 @@ const matter = require("gray-matter"); const markdownIt = require("markdown-it"); const markdownItContainer = require("markdown-it-container"); const { promisify } = require("util"); -const meta = require("../docs/src/_data/rules_meta.json"); const markdownItRuleExample = require("../docs/tools/markdown-it-rule-example"); const ConfigCommentParser = require("../lib/linter/config-comment-parser"); +const rules = require("../lib/rules"); //------------------------------------------------------------------------------ // Typedefs @@ -55,7 +55,7 @@ function tryParseForPlayground(code, parserOptions) { async function findProblems(filename) { const text = await readFile(filename, "UTF-8"); const { title } = matter(text).data; - const isRuleRemoved = !Object.prototype.hasOwnProperty.call(meta, title); + const isRuleRemoved = !rules.has(title); const problems = []; const ruleExampleOptions = markdownItRuleExample({ open({ code, parserOptions, codeBlockToken }) { @@ -96,7 +96,7 @@ async function findProblems(filename) { ); if (!hasRuleConfigComment) { - const message = `Example code should contain a configuration comment like /* eslint ${title}: error */`; + const message = `Example code should contain a configuration comment like /* eslint ${title}: "error" */`; problems.push({ fatal: false,