From eb095fd6dcac4c51a8fa42283796c2c2aecaaccd Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Fri, 18 Nov 2022 22:21:52 +0900 Subject: [PATCH] Add missing link about custom message option to rule docs (#6475) This change also adds test cases to prevent such mistakes. --- lib/rules/__tests__/index.test.js | 17 +++++++++++++++++ lib/rules/custom-media-pattern/README.md | 2 ++ lib/rules/custom-property-pattern/README.md | 2 ++ lib/rules/keyframes-name-pattern/README.md | 2 ++ lib/rules/selector-class-pattern/README.md | 2 ++ lib/rules/selector-id-pattern/README.md | 2 ++ lib/rules/selector-nested-pattern/README.md | 2 ++ 7 files changed, 29 insertions(+) diff --git a/lib/rules/__tests__/index.test.js b/lib/rules/__tests__/index.test.js index 30056afb8d..75b0a41330 100644 --- a/lib/rules/__tests__/index.test.js +++ b/lib/rules/__tests__/index.test.js @@ -31,3 +31,20 @@ describe('fixable rules', () => { expect(rulesListDoc).toMatch(new RegExp(`^.+\\b${name}\\b.+\\(Autofixable\\)\\.$`, 'm')); }); }); + +describe('custom message option', () => { + test.each(Object.keys(rules))( + '"%s" should describe a custom message option in the doc', + async (ruleName) => { + const jsFile = path.join(__dirname, '..', ruleName, 'index.js'); + const jsCode = await fs.promises.readFile(jsFile, 'utf8'); + + // NOTE: If all rules support a custom message option, we should remove this `if` statement. + if (!jsCode.includes('\tmessageArgs: [')) return; + + const doc = await fs.promises.readFile(jsFile.replace('index.js', 'README.md'), 'utf8'); + + expect(doc).toContain('`message` secondary option'); + }, + ); +}); diff --git a/lib/rules/custom-media-pattern/README.md b/lib/rules/custom-media-pattern/README.md index fdbbff1d13..eafb61f574 100644 --- a/lib/rules/custom-media-pattern/README.md +++ b/lib/rules/custom-media-pattern/README.md @@ -9,6 +9,8 @@ Specify a pattern for custom media query names. * The pattern of this */ ``` +The [`message` secondary option](../../../docs/user-guide/configure.md#message) can accept the arguments of this rule. + ## Options `regex|string` diff --git a/lib/rules/custom-property-pattern/README.md b/lib/rules/custom-property-pattern/README.md index b2e81f0409..e622432511 100644 --- a/lib/rules/custom-property-pattern/README.md +++ b/lib/rules/custom-property-pattern/README.md @@ -9,6 +9,8 @@ a { --foo-: 1px; } * The pattern of this */ ``` +The [`message` secondary option](../../../docs/user-guide/configure.md#message) can accept the arguments of this rule. + ## Options `regex|string` diff --git a/lib/rules/keyframes-name-pattern/README.md b/lib/rules/keyframes-name-pattern/README.md index c1b46beaef..7eabbdf541 100644 --- a/lib/rules/keyframes-name-pattern/README.md +++ b/lib/rules/keyframes-name-pattern/README.md @@ -9,6 +9,8 @@ Specify a pattern for keyframe names. * The pattern of this */ ``` +The [`message` secondary option](../../../docs/user-guide/configure.md#message) can accept the arguments of this rule. + ## Options `regex|string` diff --git a/lib/rules/selector-class-pattern/README.md b/lib/rules/selector-class-pattern/README.md index f394739f56..4760e8393c 100644 --- a/lib/rules/selector-class-pattern/README.md +++ b/lib/rules/selector-class-pattern/README.md @@ -13,6 +13,8 @@ This rule ignores non-outputting Less mixin definitions and called Less mixins. Escaped selectors (e.g. `.u-size-11\/12\@sm`) are parsed as escaped twice (e.g. `.u-size-11\\/12\\@sm`). Your RegExp should account for that. +The [`message` secondary option](../../../docs/user-guide/configure.md#message) can accept the arguments of this rule. + ## Options `regex|string` diff --git a/lib/rules/selector-id-pattern/README.md b/lib/rules/selector-id-pattern/README.md index 967ea3f160..bfac93ae59 100644 --- a/lib/rules/selector-id-pattern/README.md +++ b/lib/rules/selector-id-pattern/README.md @@ -9,6 +9,8 @@ Specify a pattern for ID selectors. * These ID selectors */ ``` +The [`message` secondary option](../../../docs/user-guide/configure.md#message) can accept the arguments of this rule. + ## Options `regex|string` diff --git a/lib/rules/selector-nested-pattern/README.md b/lib/rules/selector-nested-pattern/README.md index c7476bdef8..23a9e13fb4 100644 --- a/lib/rules/selector-nested-pattern/README.md +++ b/lib/rules/selector-nested-pattern/README.md @@ -14,6 +14,8 @@ Specify a pattern for the selectors of rules nested within rules. Non-standard selectors (e.g. selectors with Sass or Less interpolation) and selectors of rules nested within at-rules are ignored. +The [`message` secondary option](../../../docs/user-guide/configure.md#message) can accept the arguments of this rule. + ## Options `regex|string`