Skip to content

Commit ca0bb8c

Browse files
authored
Merge pull request #149 from bmish/fixable-suggestions-combined-notice
2 parents c5ae40f + b5adccd commit ca0bb8c

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ And how it looks:
153153
| `--config-emoji` | Custom emoji to use for a config. Format is `config-name,emoji`. Default emojis are provided for [common configs](./lib/emojis.ts). To remove a default emoji and rely on a [badge](#badge) instead, provide the config name without an emoji. Option can be repeated. |
154154
| `--ignore-config` | Config to ignore from being displayed. Often used for an `all` config. Option can be repeated. |
155155
| `--ignore-deprecated-rules` | Whether to ignore deprecated rules from being checked, displayed, or updated (default: `false`). |
156-
| `--rule-doc-notices` | Ordered, comma-separated list of notices to display in rule doc. Non-applicable notices will be hidden. Choices: `configs`, `deprecated`, `fixable`, `hasSuggestions`, `requiresTypeChecking`, `type` (off by default). Default: `deprecated,configs,fixable,hasSuggestions,requiresTypeChecking`. |
156+
| `--rule-doc-notices` | Ordered, comma-separated list of notices to display in rule doc. Non-applicable notices will be hidden. Choices: `configs`, `deprecated`, `fixable`, `fixableAndHasSuggestions`, `hasSuggestions`, `requiresTypeChecking`, `type` (off by default). Default: `deprecated,configs,fixable,fixableAndHasSuggestions,hasSuggestions,requiresTypeChecking`. |
157157
| `--rule-doc-section-exclude` | Disallowed section in each rule doc. Exit with failure if present. Option can be repeated. |
158158
| `--rule-doc-section-include` | Required section in each rule doc. Exit with failure if missing. Option can be repeated. |
159159
| `--rule-doc-title-format` | The format to use for rule doc titles. Defaults to `desc-parens-prefix-name`. See choices in below [table](#--rule-doc-title-format). |

lib/rule-notices.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const NOTICE_TYPE_DEFAULT_PRESENCE_AND_ORDERING: {
2828
[NOTICE_TYPE.DEPRECATED]: true, // Most important.
2929
[NOTICE_TYPE.CONFIGS]: true,
3030
[NOTICE_TYPE.FIXABLE]: true,
31+
[NOTICE_TYPE.FIXABLE_AND_HAS_SUGGESTIONS]: true, // Potentially replaces FIXABLE and HAS_SUGGESTIONS.
3132
[NOTICE_TYPE.HAS_SUGGESTIONS]: true,
3233
[NOTICE_TYPE.REQUIRES_TYPE_CHECKING]: true,
3334
[NOTICE_TYPE.TYPE]: false,
@@ -104,6 +105,7 @@ const RULE_NOTICES: {
104105

105106
// Simple strings.
106107
[NOTICE_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).`,
108+
[NOTICE_TYPE.FIXABLE_AND_HAS_SUGGESTIONS]: `${EMOJI_FIXABLE}${EMOJI_HAS_SUGGESTIONS} This rule is automatically fixable by the [\`--fix\` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).`,
107109
[NOTICE_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).`,
108110
[NOTICE_TYPE.REQUIRES_TYPE_CHECKING]: `${EMOJI_REQUIRES_TYPE_CHECKING} This rule requires type information.`,
109111
};
@@ -131,8 +133,19 @@ function getNoticesForRule(
131133
// Alphabetical order.
132134
[NOTICE_TYPE.CONFIGS]: configsEnabled.length > 0,
133135
[NOTICE_TYPE.DEPRECATED]: rule.meta.deprecated || false,
134-
[NOTICE_TYPE.FIXABLE]: Boolean(rule.meta.fixable),
135-
[NOTICE_TYPE.HAS_SUGGESTIONS]: rule.meta.hasSuggestions || false,
136+
137+
// FIXABLE_AND_HAS_SUGGESTIONS potentially replaces FIXABLE and HAS_SUGGESTIONS.
138+
[NOTICE_TYPE.FIXABLE]:
139+
Boolean(rule.meta.fixable) &&
140+
(!rule.meta.hasSuggestions ||
141+
!ruleDocNotices.includes(NOTICE_TYPE.FIXABLE_AND_HAS_SUGGESTIONS)),
142+
[NOTICE_TYPE.FIXABLE_AND_HAS_SUGGESTIONS]:
143+
Boolean(rule.meta.fixable) && Boolean(rule.meta.hasSuggestions),
144+
[NOTICE_TYPE.HAS_SUGGESTIONS]:
145+
Boolean(rule.meta.hasSuggestions) &&
146+
(!rule.meta.fixable ||
147+
!ruleDocNotices.includes(NOTICE_TYPE.FIXABLE_AND_HAS_SUGGESTIONS)),
148+
136149
[NOTICE_TYPE.REQUIRES_TYPE_CHECKING]:
137150
rule.meta.docs?.requiresTypeChecking || false,
138151
[NOTICE_TYPE.TYPE]: Boolean(rule.meta.type),

lib/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export enum NOTICE_TYPE {
3838
CONFIGS = 'configs',
3939
DEPRECATED = 'deprecated',
4040
FIXABLE = 'fixable',
41+
FIXABLE_AND_HAS_SUGGESTIONS = 'fixableAndHasSuggestions', // Consolidated notice for space-saving.
4142
HAS_SUGGESTIONS = 'hasSuggestions',
4243
REQUIRES_TYPE_CHECKING = 'requiresTypeChecking',
4344
TYPE = 'type',

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,7 @@ exports[`generator #generate successful updates the documentation 2`] = `
660660
661661
💼 This rule is enabled in the following configs: 🌐 \`all\`, ✅ \`recommended\`.
662662
663-
🔧 This rule is automatically fixable by the [\`--fix\` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
664-
665-
💡 This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
663+
🔧💡 This rule is automatically fixable by the [\`--fix\` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
666664
667665
<!-- end rule header -->
668666
## Rule details
@@ -966,9 +964,7 @@ exports[`generator #generate with --rule-list-columns shows the right columns an
966964
967965
❌ This rule is deprecated.
968966
969-
🔧 This rule is automatically fixable by the [\`--fix\` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
970-
971-
💡 This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
967+
🔧💡 This rule is automatically fixable by the [\`--fix\` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
972968
973969
<!-- end rule header -->
974970
"

0 commit comments

Comments
 (0)