From e7597f9fc5e66bd6f4588de8c8615e24ebba0484 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 1 Jul 2023 15:24:22 -0700 Subject: [PATCH 1/5] feat(eslint-plugin): final final config changes for v6 --- .../eslint-plugin/src/rules/no-confusing-void-expression.ts | 2 +- packages/eslint-plugin/src/rules/no-explicit-any.ts | 2 +- packages/eslint-plugin/src/rules/sort-type-constituents.ts | 1 - packages/eslint-plugin/src/rules/strict-boolean-expressions.ts | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts b/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts index ab6f08c1bb55..66ac9e28c512 100644 --- a/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts +++ b/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts @@ -28,7 +28,7 @@ export default util.createRule({ docs: { description: 'Require expressions of type void to appear in statement position', - recommended: 'stylistic', + recommended: 'strict', requiresTypeChecking: true, }, messages: { diff --git a/packages/eslint-plugin/src/rules/no-explicit-any.ts b/packages/eslint-plugin/src/rules/no-explicit-any.ts index 3e92039827da..fd2ddeefbe2b 100644 --- a/packages/eslint-plugin/src/rules/no-explicit-any.ts +++ b/packages/eslint-plugin/src/rules/no-explicit-any.ts @@ -17,7 +17,7 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow the `any` type', - recommended: 'strict', + recommended: 'recommended', }, fixable: 'code', hasSuggestions: true, diff --git a/packages/eslint-plugin/src/rules/sort-type-constituents.ts b/packages/eslint-plugin/src/rules/sort-type-constituents.ts index ec54153e988d..fd975d42073c 100644 --- a/packages/eslint-plugin/src/rules/sort-type-constituents.ts +++ b/packages/eslint-plugin/src/rules/sort-type-constituents.ts @@ -112,7 +112,6 @@ export default util.createRule({ docs: { description: 'Enforce constituents of a type union/intersection to be sorted alphabetically', - recommended: 'stylistic', }, fixable: 'code', hasSuggestions: true, diff --git a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts index 3e0d60d48cea..6ea73c6e299f 100644 --- a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts +++ b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts @@ -145,7 +145,7 @@ export default util.createRule({ allowNullableBoolean: false, allowNullableString: false, allowNullableNumber: false, - allowNullableEnum: true, + allowNullableEnum: false, allowAny: false, allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false, }, From dfe7814947e2f81ff208383c92baeb43b74b7f8b Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 4 Jul 2023 07:56:11 -0700 Subject: [PATCH 2/5] yarn generate:configs --- packages/eslint-plugin/src/configs/recommended-type-checked.ts | 1 + packages/eslint-plugin/src/configs/recommended.ts | 1 + packages/eslint-plugin/src/configs/strict-type-checked.ts | 1 + packages/eslint-plugin/src/configs/stylistic-type-checked.ts | 2 -- packages/eslint-plugin/src/configs/stylistic.ts | 1 - 5 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin/src/configs/recommended-type-checked.ts b/packages/eslint-plugin/src/configs/recommended-type-checked.ts index 6be755c48e74..ab0f50394612 100644 --- a/packages/eslint-plugin/src/configs/recommended-type-checked.ts +++ b/packages/eslint-plugin/src/configs/recommended-type-checked.ts @@ -16,6 +16,7 @@ export = { '@typescript-eslint/no-base-to-string': 'error', '@typescript-eslint/no-duplicate-enum-values': 'error', '@typescript-eslint/no-duplicate-type-constituents': 'error', + '@typescript-eslint/no-explicit-any': 'error', '@typescript-eslint/no-extra-non-null-assertion': 'error', '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-for-in-array': 'error', diff --git a/packages/eslint-plugin/src/configs/recommended.ts b/packages/eslint-plugin/src/configs/recommended.ts index 0f817d7681b6..d8654cd45e07 100644 --- a/packages/eslint-plugin/src/configs/recommended.ts +++ b/packages/eslint-plugin/src/configs/recommended.ts @@ -13,6 +13,7 @@ export = { 'no-array-constructor': 'off', '@typescript-eslint/no-array-constructor': 'error', '@typescript-eslint/no-duplicate-enum-values': 'error', + '@typescript-eslint/no-explicit-any': 'error', '@typescript-eslint/no-extra-non-null-assertion': 'error', 'no-loss-of-precision': 'off', '@typescript-eslint/no-loss-of-precision': 'error', diff --git a/packages/eslint-plugin/src/configs/strict-type-checked.ts b/packages/eslint-plugin/src/configs/strict-type-checked.ts index b666e4f1cb6b..dfba0b81c7fa 100644 --- a/packages/eslint-plugin/src/configs/strict-type-checked.ts +++ b/packages/eslint-plugin/src/configs/strict-type-checked.ts @@ -14,6 +14,7 @@ export = { 'no-array-constructor': 'off', '@typescript-eslint/no-array-constructor': 'error', '@typescript-eslint/no-base-to-string': 'error', + '@typescript-eslint/no-confusing-void-expression': 'error', '@typescript-eslint/no-duplicate-enum-values': 'error', '@typescript-eslint/no-duplicate-type-constituents': 'error', '@typescript-eslint/no-dynamic-delete': 'error', diff --git a/packages/eslint-plugin/src/configs/stylistic-type-checked.ts b/packages/eslint-plugin/src/configs/stylistic-type-checked.ts index ed9e23dae4ac..5c73ae3845b6 100644 --- a/packages/eslint-plugin/src/configs/stylistic-type-checked.ts +++ b/packages/eslint-plugin/src/configs/stylistic-type-checked.ts @@ -19,7 +19,6 @@ export = { 'dot-notation': 'off', '@typescript-eslint/dot-notation': 'error', '@typescript-eslint/no-confusing-non-null-assertion': 'error', - '@typescript-eslint/no-confusing-void-expression': 'error', 'no-empty-function': 'off', '@typescript-eslint/no-empty-function': 'error', '@typescript-eslint/no-empty-interface': 'error', @@ -31,6 +30,5 @@ export = { '@typescript-eslint/prefer-nullish-coalescing': 'error', '@typescript-eslint/prefer-optional-chain': 'error', '@typescript-eslint/prefer-string-starts-ends-with': 'error', - '@typescript-eslint/sort-type-constituents': 'error', }, }; diff --git a/packages/eslint-plugin/src/configs/stylistic.ts b/packages/eslint-plugin/src/configs/stylistic.ts index ed5ce3ded8c9..fd95427bef4d 100644 --- a/packages/eslint-plugin/src/configs/stylistic.ts +++ b/packages/eslint-plugin/src/configs/stylistic.ts @@ -25,6 +25,5 @@ export = { '@typescript-eslint/prefer-function-type': 'error', '@typescript-eslint/prefer-namespace-keyword': 'error', '@typescript-eslint/prefer-optional-chain': 'error', - '@typescript-eslint/sort-type-constituents': 'error', }, }; From a76eb54828829f546e6e6f899de5475b75095254 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 4 Jul 2023 08:59:40 -0700 Subject: [PATCH 3/5] Fix unused lint suppression complaint and test snapshot --- packages/typescript-estree/src/ts-estree/ts-nodes.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/typescript-estree/src/ts-estree/ts-nodes.ts b/packages/typescript-estree/src/ts-estree/ts-nodes.ts index 27d89b0f4f66..ceb3ab17ed64 100644 --- a/packages/typescript-estree/src/ts-estree/ts-nodes.ts +++ b/packages/typescript-estree/src/ts-estree/ts-nodes.ts @@ -21,7 +21,6 @@ declare module 'typescript' { export type TSToken = ts.Token; -/* eslint-disable @typescript-eslint/sort-type-constituents */ export type TSNode = | ts.AssertClause | ts.AssertEntry @@ -216,4 +215,3 @@ export type TSNode = | ts.JSDocOptionalType | ts.JSDocVariadicType | ts.JSDocAuthorTag; -/* eslint-enable @typescript-eslint/sort-type-constituents */ From 7c462f42eb0b445509d1e0b652cb652656c5a694 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 4 Jul 2023 09:18:23 -0700 Subject: [PATCH 4/5] unknown, not any, in recommended-does-not-require-program --- .../fixtures/recommended-does-not-require-program/index.ts | 2 +- .../recommended-does-not-require-program.test.ts.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integration-tests/fixtures/recommended-does-not-require-program/index.ts b/packages/integration-tests/fixtures/recommended-does-not-require-program/index.ts index cf187492f176..5c59896bad34 100644 --- a/packages/integration-tests/fixtures/recommended-does-not-require-program/index.ts +++ b/packages/integration-tests/fixtures/recommended-does-not-require-program/index.ts @@ -1 +1 @@ -var foo: any = true; +var foo: unknown = true; diff --git a/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap b/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap index db6b4a806442..cb3d069e7b2f 100644 --- a/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap @@ -21,7 +21,7 @@ exports[`recommended-does-not-require-program should lint successfully 1`] = ` "severity": 2, }, ], - "output": "const foo: any = true; + "output": "const foo: unknown = true; ", "suppressedMessages": [], "usedDeprecatedRules": [], From 15c987c3553ba646212316568232b8eb84742d11 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 4 Jul 2023 09:30:08 -0700 Subject: [PATCH 5/5] Updated endColumn --- .../recommended-does-not-require-program.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap b/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap index cb3d069e7b2f..83a2f0129c90 100644 --- a/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap @@ -11,7 +11,7 @@ exports[`recommended-does-not-require-program should lint successfully 1`] = ` "messages": [ { "column": 7, - "endColumn": 15, + "endColumn": 19, "endLine": 1, "line": 1, "message": "'foo' is assigned a value but never used.",