Skip to content

Commit f7a5686

Browse files
fix(tasks): make typescript recommended section more accurate (#13015)
The typescript plugin issue shows some rules as recommended when they are actually stylistic. Fix the logic here, by only marking the rule as recommended when the value is recommended or when it is an object with a recommended key.
1 parent 43b1c5a commit f7a5686

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tasks/lint_rules/src/eslint-rules.mjs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,19 @@ const loadPluginTypeScriptRules = (linter) => {
103103

104104
const prefixedName = `typescript/${name}`;
105105

106-
// Presented but type is `string | false`
107-
rule.meta.docs.recommended = typeof rule.meta.docs.recommended === 'string';
106+
// Recommended can either be
107+
// - a string describing which configuration it belongs to (recommended, strict, stylistic)
108+
// - an object with a `recommended` property (ban-ts-comment)
109+
// - undefined
110+
let isRecommended = rule.meta.docs.recommended;
111+
if (typeof isRecommended === 'object' && isRecommended !== null) {
112+
isRecommended = isRecommended.recommended === true;
113+
} else if (typeof isRecommended === 'string') {
114+
isRecommended = isRecommended === 'recommended';
115+
} else {
116+
isRecommended = false;
117+
}
118+
rule.meta.docs.recommended = isRecommended;
108119

109120
linter.defineRule(prefixedName, rule);
110121
}

0 commit comments

Comments
 (0)