Skip to content

Commit d645efb

Browse files
authored
Merge pull request #126 from bmish/notice-type-info
2 parents ca27f38 + 37148dd commit d645efb

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

lib/rule-notices.ts

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
EMOJI_FIXABLE,
55
EMOJI_HAS_SUGGESTIONS,
66
EMOJI_CONFIGS,
7+
EMOJI_REQUIRES_TYPE_CHECKING,
78
} from './emojis.js';
89
import { getConfigsForRule } from './configs.js';
910
import type {
@@ -22,6 +23,7 @@ enum MESSAGE_TYPE {
2223
DEPRECATED = 'deprecated',
2324
FIXABLE = 'fixable',
2425
HAS_SUGGESTIONS = 'hasSuggestions',
26+
REQUIRES_TYPE_CHECKING = 'requiresTypeChecking',
2527
}
2628

2729
/**
@@ -96,6 +98,7 @@ const RULE_NOTICES: {
9698
// Simple strings.
9799
[MESSAGE_TYPE.FIXABLE]: `${EMOJI_FIXABLE} This rule is automatically fixable by the [\`--fix\` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).`,
98100
[MESSAGE_TYPE.HAS_SUGGESTIONS]: `${EMOJI_HAS_SUGGESTIONS} This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).`,
101+
[MESSAGE_TYPE.REQUIRES_TYPE_CHECKING]: `${EMOJI_REQUIRES_TYPE_CHECKING} This rule requires type information.`,
99102
};
100103

101104
/**
@@ -118,6 +121,8 @@ function getNoticesForRule(rule: RuleModule, configsEnabled: string[]) {
118121
[MESSAGE_TYPE.DEPRECATED]: rule.meta.deprecated || false,
119122
[MESSAGE_TYPE.FIXABLE]: Boolean(rule.meta.fixable),
120123
[MESSAGE_TYPE.HAS_SUGGESTIONS]: rule.meta.hasSuggestions || false,
124+
[MESSAGE_TYPE.REQUIRES_TYPE_CHECKING]:
125+
rule.meta.docs?.requiresTypeChecking || false,
121126
};
122127

123128
return notices;

test/lib/__snapshots__/generator-test.ts.snap

+32-14
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,6 @@ exports[`generator #generate Scoped plugin name determines the correct plugin pr
7979
"
8080
`;
8181

82-
exports[`generator #generate adds extra column to rules table for TypeScript rules updates the documentation 1`] = `
83-
"<!-- begin rules list -->
84-
85-
💼 Configurations enabled in.\\
86-
💭 Requires type information.
87-
88-
| Name | Description | 💼 | 💭 |
89-
| :----------------------------- | :--------------------- | :------- | :-- |
90-
| [no-bar](docs/rules/no-bar.md) | Description of no-bar. | | 💭 |
91-
| [no-foo](docs/rules/no-foo.md) | Description of no-foo. | ![all][] | |
92-
93-
<!-- end rules list -->"
94-
`;
95-
9682
exports[`generator #generate config that extends another config generates the documentation 1`] = `
9783
"## Rules
9884
<!-- begin rules list -->
@@ -474,6 +460,38 @@ exports[`generator #generate rules that are disabled generates the documentation
474460
"
475461
`;
476462

463+
exports[`generator #generate shows column and notice for requiresTypeChecking updates the documentation 1`] = `
464+
"<!-- begin rules list -->
465+
466+
💼 Configurations enabled in.\\
467+
💭 Requires type information.
468+
469+
| Name | Description | 💼 | 💭 |
470+
| :----------------------------- | :--------------------- | :------- | :-- |
471+
| [no-bar](docs/rules/no-bar.md) | Description of no-bar. | | 💭 |
472+
| [no-foo](docs/rules/no-foo.md) | Description of no-foo. | ![all][] | |
473+
474+
<!-- end rules list -->"
475+
`;
476+
477+
exports[`generator #generate shows column and notice for requiresTypeChecking updates the documentation 2`] = `
478+
"# Description of no-foo (\`test/no-foo\`)
479+
480+
💼 This rule is enabled in the \`all\` config.
481+
482+
<!-- end rule header -->
483+
"
484+
`;
485+
486+
exports[`generator #generate shows column and notice for requiresTypeChecking updates the documentation 3`] = `
487+
"# Description of no-bar (\`test/no-bar\`)
488+
489+
💭 This rule requires type information.
490+
491+
<!-- end rule header -->
492+
"
493+
`;
494+
477495
exports[`generator #generate successful updates the documentation 1`] = `
478496
"# eslint-plugin-test
479497
Description.

test/lib/generator-test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ describe('generator', function () {
495495
});
496496
});
497497

498-
describe('adds extra column to rules table for TypeScript rules', function () {
498+
describe('shows column and notice for requiresTypeChecking', function () {
499499
beforeEach(function () {
500500
mockFs({
501501
'package.json': JSON.stringify({
@@ -546,6 +546,8 @@ describe('generator', function () {
546546
await generate('.');
547547

548548
expect(readFileSync('README.md', 'utf8')).toMatchSnapshot();
549+
expect(readFileSync('docs/rules/no-foo.md', 'utf8')).toMatchSnapshot();
550+
expect(readFileSync('docs/rules/no-bar.md', 'utf8')).toMatchSnapshot();
549551
});
550552
});
551553

0 commit comments

Comments
 (0)