Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): recommended-requiring-type-checking config
BREAKING CHANGE: removed some rules from recommended config
- Loading branch information
1 parent
428567d
commit fe15245
Showing
26 changed files
with
284 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/eslint-plugin/src/configs/recommended-requiring-type-checking.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "./configs/base.json", | ||
"rules": { | ||
"@typescript-eslint/await-thenable": "error", | ||
"@typescript-eslint/no-for-in-array": "error", | ||
"@typescript-eslint/no-misused-promises": "error", | ||
"@typescript-eslint/no-unnecessary-type-assertion": "error", | ||
"@typescript-eslint/prefer-includes": "error", | ||
"@typescript-eslint/prefer-regexp-exec": "error", | ||
"@typescript-eslint/prefer-string-starts-ends-with": "error", | ||
"require-await": "off", | ||
"@typescript-eslint/require-await": "error", | ||
"@typescript-eslint/unbound-method": "error", | ||
"no-var": "error", | ||
"prefer-const": "error", | ||
"prefer-rest-params": "error", | ||
"prefer-spread": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/eslint-plugin/tools/validate-configs/checkConfigRecommendedRequiringTypeChecking.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import plugin from '../../src/index'; | ||
import { logRule } from '../log'; | ||
|
||
const prefix = '@typescript-eslint/'; | ||
|
||
function checkConfigRecommendedRequiringTypeChecking(): boolean { | ||
const { rules } = plugin; | ||
|
||
const recommendedRequiringTypeChecking = | ||
plugin.configs.recommendedRequiringTypeChecking.rules; | ||
const recommendedNames = new Set( | ||
Object.keys(recommendedRequiringTypeChecking), | ||
); | ||
|
||
return Object.entries(rules).reduce<boolean>((acc, [ruleName, rule]) => { | ||
if ( | ||
!rule.meta.deprecated && | ||
rule.meta.docs.recommended !== false && | ||
rule.meta.docs.requiresTypeChecking === true | ||
) { | ||
const prefixed = `${prefix}${ruleName}` as keyof typeof recommendedRequiringTypeChecking; | ||
if (recommendedNames.has(prefixed)) { | ||
if ( | ||
recommendedRequiringTypeChecking[prefixed] !== | ||
rule.meta.docs.recommended | ||
) { | ||
logRule( | ||
false, | ||
ruleName, | ||
'incorrect setting compared to the rule meta.', | ||
); | ||
return true; | ||
} | ||
} else { | ||
logRule(false, ruleName, 'missing in the config.'); | ||
return true; | ||
} | ||
} | ||
|
||
logRule(true, ruleName); | ||
return acc; | ||
}, false); | ||
} | ||
|
||
export { checkConfigRecommendedRequiringTypeChecking }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.