From 9c2bdc25462362f1e2a426e44cde1cddeeb04a8a Mon Sep 17 00:00:00 2001 From: Aman Mahajan Date: Tue, 23 Jul 2024 12:41:09 -0500 Subject: [PATCH] Update eslint plugins (#3552) * bump `@typescript-eslint` * Remove deprecated rules * Add new rules * sort * Update `eslint-plugin-jest` * Update `eslint-plugin-react` * Address comments * Update .eslintrc.cjs * Update .eslintrc.cjs Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com> --------- Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com> --- .eslintrc.cjs | 39 +++++++++++++++----------------------- package.json | 8 ++++---- test/column/frozen.test.ts | 4 ++-- tsconfig.base.json | 3 ++- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 23e1b5b864..f2e5235530 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -201,7 +201,7 @@ const rules = { 'prefer-numeric-literals': 1, 'prefer-object-has-own': 1, 'prefer-object-spread': 1, - 'prefer-promise-reject-errors': [1, { allowEmptyReject: true }], + 'prefer-promise-reject-errors': 0, // replaced by @typescript-eslint/prefer-promise-reject-errors 'prefer-regex-literals': [1, { disallowRedundantWrapping: true }], 'prefer-rest-params': 1, 'prefer-spread': 1, @@ -289,6 +289,7 @@ const rules = { // https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules 'react/boolean-prop-naming': 0, 'react/button-has-type': 0, + 'react/checked-requires-onchange-or-readonly': 1, 'react/default-props-match-prop-types': 0, 'react/destructuring-assignment': 0, 'react/display-name': 0, @@ -344,10 +345,9 @@ const rules = { 'react/jsx-one-expression-per-line': 0, 'react/jsx-pascal-case': 1, 'react/jsx-props-no-multi-spaces': 1, + 'react/jsx-props-no-spread-multi': 1, 'react/jsx-props-no-spreading': 0, - 'react/jsx-sort-default-props': 0, 'react/jsx-sort-props': 0, - 'react/jsx-space-before-closing': 0, 'react/jsx-tag-spacing': [ 1, { @@ -434,6 +434,7 @@ const rules = { 'jest/no-commented-out-tests': 1, 'jest/no-conditional-expect': 1, 'jest/no-conditional-in-test': 0, + 'jest/no-confusing-set-timeout': 0, 'jest/no-deprecated-functions': 0, 'jest/no-disabled-tests': 0, 'jest/no-done-callback': 0, @@ -465,9 +466,11 @@ const rules = { 'jest/prefer-each': 1, 'jest/prefer-equality-matcher': 1, 'jest/prefer-expect-assertions': 0, - 'jest/prefer-expect-resolves': 0, + 'jest/prefer-expect-resolves': 1, 'jest/prefer-hooks-in-order': 1, 'jest/prefer-hooks-on-top': 1, + 'jest/prefer-importing-jest-globals': 0, + 'jest/prefer-jest-mocked': 0, 'jest/prefer-lowercase-title': 0, 'jest/prefer-mock-promise-shorthand': 1, 'jest/prefer-snapshot-hint': 0, @@ -554,10 +557,10 @@ const rules = { '@typescript-eslint/explicit-function-return-type': 0, '@typescript-eslint/explicit-member-accessibility': 0, '@typescript-eslint/explicit-module-boundary-types': 0, - '@typescript-eslint/member-delimiter-style': 0, '@typescript-eslint/member-ordering': 0, '@typescript-eslint/method-signature-style': 1, '@typescript-eslint/naming-convention': 0, + '@typescript-eslint/no-array-delete': 1, '@typescript-eslint/no-base-to-string': 0, '@typescript-eslint/no-confusing-non-null-assertion': 0, '@typescript-eslint/no-confusing-void-expression': [1, { ignoreArrowShorthand: true }], @@ -565,6 +568,7 @@ const rules = { '@typescript-eslint/no-duplicate-type-constituents': 1, '@typescript-eslint/no-dynamic-delete': 0, '@typescript-eslint/no-empty-interface': 1, + '@typescript-eslint/no-empty-object-type': 1, '@typescript-eslint/no-explicit-any': [1, { fixToUnknown: true }], '@typescript-eslint/no-extra-non-null-assertion': 1, '@typescript-eslint/no-extraneous-class': 1, @@ -587,7 +591,9 @@ const rules = { '@typescript-eslint/no-type-alias': 0, '@typescript-eslint/no-unnecessary-boolean-literal-compare': 1, '@typescript-eslint/no-unnecessary-condition': 1, + '@typescript-eslint/no-unnecessary-parameter-property-assignment': 1, '@typescript-eslint/no-unnecessary-qualifier': 0, + '@typescript-eslint/no-unnecessary-template-expression': 1, '@typescript-eslint/no-unnecessary-type-arguments': 1, '@typescript-eslint/no-unnecessary-type-assertion': 1, '@typescript-eslint/no-unnecessary-type-constraint': 1, @@ -604,6 +610,7 @@ const rules = { '@typescript-eslint/parameter-properties': 1, '@typescript-eslint/prefer-as-const': 1, '@typescript-eslint/prefer-enum-initializers': 0, + '@typescript-eslint/prefer-find': 1, '@typescript-eslint/prefer-for-of': 1, '@typescript-eslint/prefer-function-type': 1, '@typescript-eslint/prefer-includes': 1, @@ -614,13 +621,13 @@ const rules = { { ignorePrimitives: { boolean: true, string: true } } ], '@typescript-eslint/prefer-optional-chain': 1, + '@typescript-eslint/prefer-promise-reject-errors': [1, { allowEmptyReject: true }], '@typescript-eslint/prefer-readonly': 1, '@typescript-eslint/prefer-readonly-parameter-types': 0, '@typescript-eslint/prefer-reduce-type-parameter': 1, '@typescript-eslint/prefer-regexp-exec': 1, '@typescript-eslint/prefer-return-this-type': 0, '@typescript-eslint/prefer-string-starts-ends-with': 1, - '@typescript-eslint/prefer-ts-expect-error': 1, '@typescript-eslint/promise-function-async': 0, '@typescript-eslint/require-array-sort-compare': 1, '@typescript-eslint/restrict-plus-operands': 0, @@ -629,31 +636,18 @@ const rules = { '@typescript-eslint/strict-boolean-expressions': 0, '@typescript-eslint/switch-exhaustiveness-check': 1, '@typescript-eslint/triple-slash-reference': [1, { path: 'never', types: 'never', lib: 'never' }], - '@typescript-eslint/type-annotation-spacing': 0, '@typescript-eslint/typedef': 0, '@typescript-eslint/unbound-method': 0, '@typescript-eslint/unified-signatures': 0, // @typescript-eslint/eslint-plugin Extension Rules // https://typescript-eslint.io/rules/#extension-rules - '@typescript-eslint/block-spacing': 0, - '@typescript-eslint/brace-style': 0, - '@typescript-eslint/comma-dangle': 0, - '@typescript-eslint/comma-spacing': 0, '@typescript-eslint/default-param-last': 0, '@typescript-eslint/dot-notation': 1, - '@typescript-eslint/func-call-spacing': 0, - '@typescript-eslint/indent': 0, '@typescript-eslint/init-declarations': 0, - '@typescript-eslint/key-spacing': 0, - '@typescript-eslint/keyword-spacing': 0, - '@typescript-eslint/lines-around-comment': 0, - '@typescript-eslint/lines-between-class-members': 0, '@typescript-eslint/no-array-constructor': 1, '@typescript-eslint/no-dupe-class-members': 0, '@typescript-eslint/no-empty-function': 0, - '@typescript-eslint/no-extra-parens': 0, - '@typescript-eslint/no-extra-semi': 0, '@typescript-eslint/no-implied-eval': 1, '@typescript-eslint/no-invalid-this': 0, '@typescript-eslint/no-loop-func': 0, @@ -696,6 +690,7 @@ const rules = { '@typescript-eslint/no-use-before-define': 0, '@typescript-eslint/no-useless-constructor': 1, '@typescript-eslint/object-curly-spacing': 0, + // TODO: deprecated '@typescript-eslint/padding-line-between-statements': [ 1, { @@ -709,13 +704,9 @@ const rules = { next: '*' } ], - '@typescript-eslint/quotes': 0, '@typescript-eslint/require-await': 1, '@typescript-eslint/return-await': 1, - '@typescript-eslint/semi': 0, - '@typescript-eslint/space-before-blocks': 0, - '@typescript-eslint/space-before-function-paren': 0, - '@typescript-eslint/space-infix-ops': 0, + '@typescript-eslint/use-unknown-in-catch-callback-variable': 1, // eslint-plugin-testing-library Rules // https://github.com/testing-library/eslint-plugin-testing-library#supported-rules diff --git a/package.json b/package.json index 402e625c33..f943b3c54b 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "@types/node": "^20.10.3", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "@typescript-eslint/eslint-plugin": "^7.0.1", - "@typescript-eslint/parser": "^7.0.1", + "@typescript-eslint/eslint-plugin": "^7.16.1", + "@typescript-eslint/parser": "^7.16.1", "@vitejs/plugin-react": "^4.3.1", "@vitest/browser": "^2.0.3", "@vitest/coverage-istanbul": "^2.0.3", @@ -85,10 +85,10 @@ "babel-plugin-optimize-clsx": "^2.6.2", "eslint": "^8.43.0", "eslint-config-prettier": "^9.0.0", - "eslint-plugin-jest": "^28.2.0", + "eslint-plugin-jest": "^28.6.0", "eslint-plugin-jest-dom": "^5.0.1", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-react": "^7.32.2", + "eslint-plugin-react": "^7.35.0", "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-sonarjs": "^1.0.3", "eslint-plugin-testing-library": "^6.2.0", diff --git a/test/column/frozen.test.ts b/test/column/frozen.test.ts index a55972ee79..981d29826a 100644 --- a/test/column/frozen.test.ts +++ b/test/column/frozen.test.ts @@ -30,8 +30,8 @@ test('frozen column have a specific class, and are stable-sorted before non-froz expect(cell1).toHaveClass(`${cellClassname} ${cellFrozenClassname}`, { exact: true }); expect(cell2).toHaveClass(`${cellClassname} ${cellFrozenClassname}`, { exact: true }); - expect(cell3).toHaveClass(`${cellClassname}`, { exact: true }); - expect(cell4).toHaveClass(`${cellClassname}`, { exact: true }); + expect(cell3).toHaveClass(cellClassname, { exact: true }); + expect(cell4).toHaveClass(cellClassname, { exact: true }); expect(cell1).toHaveTextContent('col1'); expect(cell2).toHaveTextContent('col3'); diff --git a/tsconfig.base.json b/tsconfig.base.json index ac6b99a37e..4f5eb6f72a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -11,6 +11,7 @@ "pretty": true, "strict": true, "target": "esnext", - "skipLibCheck": true + "skipLibCheck": true, + "useUnknownInCatchVariables": true } }