Skip to content

Commit 4972ecd

Browse files
chore: enabled most of strict-type-checked internally (#7339)
* chore: enabled most of strict-type-checked internally * Update packages/eslint-plugin/src/util/getOperatorPrecedence.ts Co-authored-by: Brad Zacher <[email protected]> * Explicit DefinitionBase and other touchups --------- Co-authored-by: Brad Zacher <[email protected]>
1 parent 0eb86fd commit 4972ecd

31 files changed

+56
-55
lines changed

.eslintrc.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ module.exports = {
2020
extends: [
2121
'eslint:recommended',
2222
'plugin:eslint-plugin/recommended',
23-
'plugin:@typescript-eslint/recommended-type-checked',
23+
'plugin:@typescript-eslint/strict-type-checked',
2424
'plugin:@typescript-eslint/stylistic-type-checked',
25-
// TODO: consider enabling strict-type-checked
2625
],
2726
parserOptions: {
2827
sourceType: 'module',
@@ -53,7 +52,10 @@ module.exports = {
5352
// make sure we're not leveraging any deprecated APIs
5453
'deprecation/deprecation': 'error',
5554

56-
// TODO(#7138): Investigate enabling these soon ✨
55+
// TODO(#7338): Investigate enabling these soon ✨
56+
'@typescript-eslint/consistent-indexed-object-style': 'off',
57+
'@typescript-eslint/no-unnecessary-condition': 'off',
58+
'@typescript-eslint/no-dynamic-delete': 'off',
5759
'@typescript-eslint/prefer-nullish-coalescing': 'off',
5860

5961
// TODO(#7130): Investigate changing these in or removing these from presets
@@ -85,6 +87,12 @@ module.exports = {
8587
'@typescript-eslint/no-explicit-any': 'error',
8688
'@typescript-eslint/no-non-null-assertion': 'off',
8789
'@typescript-eslint/no-var-requires': 'off',
90+
'@typescript-eslint/prefer-literal-enum-member': [
91+
'error',
92+
{
93+
allowBitwiseExpressions: true,
94+
},
95+
],
8896
'@typescript-eslint/unbound-method': 'off',
8997
'@typescript-eslint/restrict-template-expressions': [
9098
'error',

packages/ast-spec/tests/ast-node-types.type-test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ type TakesString<T extends Record<string, string>> = T;
1212
type _Test =
1313
// forcing the test onto a new line so it isn't covered by the expect error
1414
// If there are any enum members that don't have a corresponding TSESTree.Node, then this line will error with "Type 'string | number | symbol' is not assignable to type 'string'."
15+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
1516
TakesString<AllKeys> | void;

packages/eslint-plugin/src/rules/default-param-last.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default createRule({
2424
* @private
2525
*/
2626
function isOptionalParam(node: TSESTree.Parameter): boolean {
27-
return 'optional' in node && node.optional === true;
27+
return 'optional' in node && node.optional;
2828
}
2929

3030
/**

packages/eslint-plugin/src/rules/explicit-function-return-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export default createRule<Options, MessageIds>({
138138
case AST_NODE_TYPES.Property: {
139139
if (
140140
parent.key.type === AST_NODE_TYPES.Identifier &&
141-
parent.computed === false
141+
!parent.computed
142142
) {
143143
funcName = parent.key.name;
144144
}

packages/eslint-plugin/src/rules/naming-convention-utils/enums.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum Selectors {
5050
type SelectorsString = keyof typeof Selectors;
5151

5252
enum MetaSelectors {
53+
/* eslint-disable @typescript-eslint/prefer-literal-enum-member */
5354
default = -1,
5455
variableLike = 0 |
5556
Selectors.variable |
@@ -79,6 +80,7 @@ enum MetaSelectors {
7980
Selectors.classProperty |
8081
Selectors.objectLiteralProperty |
8182
Selectors.typeProperty,
83+
/* eslint-enable @typescript-eslint/prefer-literal-enum-member */
8284
}
8385
type MetaSelectorsString = keyof typeof MetaSelectors;
8486
type IndividualAndMetaSelectorsString = MetaSelectorsString | SelectorsString;

packages/eslint-plugin/src/rules/naming-convention-utils/parse-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function parseOptions(context: Context): ParsedOptions {
8787
const result = getEnumNames(Selectors).reduce((acc, k) => {
8888
acc[k] = createValidator(k, context, normalizedOptions);
8989
return acc;
90+
// eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter
9091
}, {} as ParsedOptions);
9192

9293
return result;

packages/eslint-plugin/src/rules/no-empty-function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export default createRule<Options, MessageIds>({
155155
isAllowedOverrideMethods &&
156156
isBodyEmpty(node) &&
157157
node.parent?.type === AST_NODE_TYPES.MethodDefinition &&
158-
node.parent.override === true
158+
node.parent.override
159159
);
160160
}
161161

packages/eslint-plugin/src/rules/no-namespace.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ export default createRule<Options, MessageIds>({
5252
const filename = context.getFilename();
5353

5454
function isDeclaration(node: TSESTree.Node): boolean {
55-
if (
56-
node.type === AST_NODE_TYPES.TSModuleDeclaration &&
57-
node.declare === true
58-
) {
55+
if (node.type === AST_NODE_TYPES.TSModuleDeclaration && node.declare) {
5956
return true;
6057
}
6158

packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ function isDefinitionWithAssignment(definition: Definition): boolean {
2626
}
2727

2828
const variableDeclarator = definition.node;
29-
return (
30-
variableDeclarator.definite === true || variableDeclarator.init != null
31-
);
29+
return variableDeclarator.definite || variableDeclarator.init != null;
3230
}
3331

3432
export default createRule({

packages/eslint-plugin/src/rules/no-redeclare.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ export default createRule<Options, MessageIds>({
7171
node?: TSESTree.Comment | TSESTree.Identifier;
7272
loc?: TSESTree.SourceLocation;
7373
},
74-
void,
75-
unknown
74+
void
7675
> {
7776
if (
7877
options?.builtinGlobals &&

0 commit comments

Comments
 (0)