From 17f941c1ba17674032711ebe0135d3ebf37f93bd Mon Sep 17 00:00:00 2001 From: Tom Milewski Date: Wed, 18 Oct 2023 13:43:27 -0400 Subject: [PATCH] chore(repo): Update rules to be more in-line with current expectations --- package-lock.json | 9 +++++---- packages/eslint-config-custom/jest.js | 3 +++ packages/eslint-config-custom/qunit.js | 5 +++++ packages/eslint-config-custom/react.js | 9 +++++++-- packages/eslint-config-custom/rules/variables.js | 4 ++-- packages/eslint-config-custom/typescript.js | 11 +++++++++-- packages/shared/src/globs.ts | 4 ++-- 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index fce4b5dcb35..4492905e2fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8422,9 +8422,10 @@ "license": "MIT" }, "node_modules/@types/qunit": { - "version": "2.19.5", - "dev": true, - "license": "MIT" + "version": "2.19.7", + "resolved": "https://registry.npmjs.org/@types/qunit/-/qunit-2.19.7.tgz", + "integrity": "sha512-Vf1+zHCOhMyDqZqM6zlB++6n5mkMe1+pWH1l3fzbzakQ2VImMNeAKSQD++RAjpGTqPUio8Tre2a6kmq6O1tK/A==", + "dev": true }, "node_modules/@types/range-parser": { "version": "1.2.4", @@ -32826,7 +32827,7 @@ "@cloudflare/workers-types": "^3.18.0", "@types/chai": "^4.3.3", "@types/cookie": "^0.5.1", - "@types/qunit": "^2.19.3", + "@types/qunit": "^2.19.7", "@types/sinon": "^10.0.13", "chai": "^4.3.6", "edge-runtime": "^2.0.0", diff --git a/packages/eslint-config-custom/jest.js b/packages/eslint-config-custom/jest.js index 3623e0b8877..1467056d4ec 100644 --- a/packages/eslint-config-custom/jest.js +++ b/packages/eslint-config-custom/jest.js @@ -5,7 +5,10 @@ const disabledRules = { // TODO: All rules below should be set to their defaults // when we're able to make the appropriate changes. + 'jest/expect-expect': 'off', 'jest/no-alias-methods': 'off', + 'jest/no-commented-out-tests': 'off', + 'jest/no-disabled-tests': 'off', 'jest/no-conditional-expect': 'off', 'jest/no-duplicate-hooks': 'off', 'jest/no-export': 'off', diff --git a/packages/eslint-config-custom/qunit.js b/packages/eslint-config-custom/qunit.js index 70a4658b29c..f8155984517 100644 --- a/packages/eslint-config-custom/qunit.js +++ b/packages/eslint-config-custom/qunit.js @@ -1,3 +1,7 @@ +const disabledRules = { + 'qunit/no-assert-equal': 'off', +}; + module.exports = { extends: ['plugin:qunit/recommended'], env: { @@ -8,5 +12,6 @@ module.exports = { 'qunit/no-assert-equal': 'warn', 'qunit/no-conditional-assertions': 'warn', 'qunit/no-early-return': 'warn', + ...disabledRules, }, }; diff --git a/packages/eslint-config-custom/react.js b/packages/eslint-config-custom/react.js index be5f895c8ed..8fd56d220c4 100644 --- a/packages/eslint-config-custom/react.js +++ b/packages/eslint-config-custom/react.js @@ -8,7 +8,12 @@ const disabledRules = { 'jsx-a11y/alt-text': 'warn', 'jsx-a11y/html-has-lang': 'warn', 'jsx-a11y/no-autofocus': 'warn', - 'react/display-name': 'warn', + 'react/button-has-type': 'warn', + 'react/display-name': 'off', + 'react/jsx-curly-brace-presence': 'off', + 'react/jsx-no-leaked-render': 'off', + 'react/jsx-no-useless-fragment': 'warn', + 'react/jsx-sort-props': 'off', 'react-hooks/rules-of-hooks': 'warn', }; @@ -34,7 +39,7 @@ module.exports = { }, ], 'react/button-has-type': 'warn', - 'react/function-component-definition': 'warn', + 'react/function-component-definition': 'off', 'react/hook-use-state': 'warn', 'react/jsx-boolean-value': 'warn', 'react/jsx-curly-brace-presence': 'warn', diff --git a/packages/eslint-config-custom/rules/variables.js b/packages/eslint-config-custom/rules/variables.js index 5fd34a2afa8..fe2fe47ed00 100644 --- a/packages/eslint-config-custom/rules/variables.js +++ b/packages/eslint-config-custom/rules/variables.js @@ -3,11 +3,11 @@ module.exports = { 'no-label-var': 'error', 'no-undef-init': 'warn', 'no-unused-vars': [ - 'error', + 'warn', { args: 'after-used', argsIgnorePattern: '^_', - ignoreRestSiblings: false, + ignoreRestSiblings: true, vars: 'all', varsIgnorePattern: '^_', }, diff --git a/packages/eslint-config-custom/typescript.js b/packages/eslint-config-custom/typescript.js index 0737c6bdda7..7437f04cfed 100644 --- a/packages/eslint-config-custom/typescript.js +++ b/packages/eslint-config-custom/typescript.js @@ -25,6 +25,7 @@ const disabledRules = { // TODO: All rules below should be set to their defaults // when we're able to make the appropriate changes. + '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/await-thenable': 'warn', '@typescript-eslint/no-misused-promises': 'warn', '@typescript-eslint/no-floating-promises': [ @@ -33,7 +34,6 @@ const disabledRules = { ignoreVoid: true, }, ], - '@typescript-eslint/no-unused-vars': 'warn', '@typescript-eslint/require-await': 'warn', }; @@ -58,7 +58,14 @@ module.exports = { 'prettier', ], rules: { - '@typescript-eslint/ban-ts-comment': [`warn`, { 'ts-ignore': `allow-with-description` }], + '@typescript-eslint/ban-ts-comment': [ + `warn`, + { + 'ts-ignore': 'allow-with-description', + 'ts-expect-error': 'allow-with-description', + 'ts-check': 'allow-with-description', + }, + ], '@typescript-eslint/consistent-type-imports': [ 'error', { diff --git a/packages/shared/src/globs.ts b/packages/shared/src/globs.ts index 674daf026a2..59ad17af59e 100644 --- a/packages/shared/src/globs.ts +++ b/packages/shared/src/globs.ts @@ -1,9 +1,9 @@ import globToRegexp from 'glob-to-regexp'; export const globs = { - toRegexp: (pattern: string) => { + toRegexp: (pattern: string): RegExp => { try { - return globToRegexp(pattern) as RegExp; + return globToRegexp(pattern); } catch (e: any) { throw new Error( `Invalid pattern: ${pattern}.\nConsult the documentation of glob-to-regexp here: https://www.npmjs.com/package/glob-to-regexp.\n${e.message}`,