Skip to content

Commit

Permalink
Add missing link about custom message option to rule docs (#6475)
Browse files Browse the repository at this point in the history
This change also adds test cases to prevent such mistakes.
  • Loading branch information
ybiquitous committed Nov 18, 2022
1 parent d1705d0 commit eb095fd
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/rules/__tests__/index.test.js
Expand Up @@ -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');
},
);
});
2 changes: 2 additions & 0 deletions lib/rules/custom-media-pattern/README.md
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/custom-property-pattern/README.md
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/keyframes-name-pattern/README.md
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/selector-class-pattern/README.md
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/selector-id-pattern/README.md
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/selector-nested-pattern/README.md
Expand Up @@ -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`
Expand Down

0 comments on commit eb095fd

Please sign in to comment.