diff --git a/web/eslint.config.mjs b/web/eslint.config.mjs index 2ff4d704fd..6416e3e9a1 100644 --- a/web/eslint.config.mjs +++ b/web/eslint.config.mjs @@ -7,6 +7,8 @@ import { fileURLToPath } from 'node:url' import js from '@eslint/js' import { FlatCompat } from '@eslint/eslintrc' import globals from 'globals' +import storybook from 'eslint-plugin-storybook' +import { fixupConfigRules } from '@eslint/compat' const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) @@ -16,34 +18,6 @@ const compat = new FlatCompat({ allConfig: js.configs.all, }) -// storybook plugin not support v9, so add its recommended rules here -const storybook = [ - { - plugins: ['storybook'], - files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'], - rules: { - 'react-hooks/rules-of-hooks': 'off', - 'import/no-anonymous-default-export': 'off', - 'storybook/await-interactions': 'error', - 'storybook/context-in-play-function': 'error', - 'storybook/default-exports': 'error', - 'storybook/hierarchy-separator': 'warn', - 'storybook/no-redundant-story-name': 'warn', - 'storybook/prefer-pascal-case': 'warn', - 'storybook/story-exports': 'error', - 'storybook/use-storybook-expect': 'error', - 'storybook/use-storybook-testing-library': 'error', - }, - }, - { - plugins: ['storybook'], - files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'], - rules: { - 'storybook/no-uninstalled-addons': 'error', - }, - }, -] - export default combine( stylistic({ lessOpinionated: true, @@ -55,7 +29,7 @@ export default combine( // original config 'style/indent': ['error', 2], 'style/quotes': ['error', 'single'], - 'curly': ['error', 'multi-line'], + 'curly': ['error', 'multi-or-nest', 'consistent'], 'style/comma-spacing': ['error', { before: false, after: true }], 'style/quote-props': ['warn', 'consistent-as-needed'], @@ -79,27 +53,26 @@ export default combine( 'style/member-delimiter-style': 'off', }, }), + javascript({ + overrides: { + // handled by unused-imports/no-unused-vars + 'no-unused-vars': 'off', + }, + }), typescript({ overrides: { // useful, but big change 'ts/no-empty-object-type': 'off', }, }), - javascript({ - overrides: { - // handled by unused-imports/no-unused-vars - 'no-unused-vars': 'off', - - // useless - 'no-use-before-define': 'warn', - }, - }), unicorn(), node(), + // use nextjs config will break @eslint/config-inspector + // use `ESLINT_CONFIG_INSPECTOR=true pnpx @eslint/config-inspector` to check the config ...process.env.ESLINT_CONFIG_INSPECTOR ? [] // TODO: remove this when upgrade to nextjs 15 - : [compat.extends('next')], + : fixupConfigRules(compat.extends('next')), { ignores: [ '**/node_modules/*', @@ -115,11 +88,6 @@ export default combine( { // orignal config rules: { - // from old version of antfu/eslint-config - // typescript will handle this, see https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors - 'no-undef': 'off', - - 'ts/consistent-type-definitions': ['error', 'type'], // orignal ts/no-var-requires 'ts/no-require-imports': 'off', 'no-console': 'off', @@ -132,10 +100,7 @@ export default combine( // copy from eslint-config-antfu 0.36.0 'camelcase': 'off', - 'curly': ['error', 'multi-or-nest', 'consistent'], 'default-case-last': 'error', - 'dot-notation': ['error', { allowKeywords: true }], - 'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }], // antfu use eslint-plugin-perfectionist to replace this // will cause big change, so keep the original sort-imports @@ -165,7 +130,7 @@ export default combine( }, }, }, - storybook, + storybook.configs['flat/recommended'], // need futher research { rules: { diff --git a/web/package.json b/web/package.json index 970b3f12b1..acfe4f4af7 100644 --- a/web/package.json +++ b/web/package.json @@ -150,11 +150,11 @@ "code-inspector-plugin": "^0.13.0", "cross-env": "^7.0.3", "eslint": "^9.13.0", - "eslint-config-next": "^15.0.0-canary.202", + "eslint-config-next": "^15.0.0", "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.12", - "eslint-plugin-storybook": "^0.9.0", "husky": "^8.0.3", + "eslint-plugin-react-refresh": "^0.4.13", + "eslint-plugin-storybook": "^0.10.1", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "lint-staged": "^13.2.2", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index cfc0b8887b..ee85a4179b 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -387,17 +387,17 @@ importers: specifier: ^9.13.0 version: 9.13.0(jiti@1.21.6) eslint-config-next: - specifier: ^15.0.0-canary.202 + specifier: ^15.0.0 version: 15.0.0(eslint-plugin-import-x@4.3.1(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5))(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5) eslint-plugin-react-hooks: specifier: ^5.0.0 version: 5.0.0(eslint@9.13.0(jiti@1.21.6)) eslint-plugin-react-refresh: - specifier: ^0.4.12 + specifier: ^0.4.13 version: 0.4.13(eslint@9.13.0(jiti@1.21.6)) eslint-plugin-storybook: - specifier: ^0.9.0 - version: 0.9.0(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5) + specifier: ^0.10.1 + version: 0.10.1(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5) husky: specifier: ^8.0.3 version: 8.0.3 @@ -2195,9 +2195,6 @@ packages: peerDependencies: storybook: ^8.3.6 - '@storybook/csf@0.0.1': - resolution: {integrity: sha512-USTLkZze5gkel8MYCujSRBVIrUQ3YPBrLOx7GNk/0wttvVtlzWXAq9eLbQ4p/NicGxP+3T7KPEMVV//g+yubpw==} - '@storybook/csf@0.1.11': resolution: {integrity: sha512-dHYFQH3mA+EtnCkHXzicbLgsvzYjcDJ1JWsogbItZogkPHgSJM/Wr71uMkcvw8v9mmCyP4NpXJuu6bPoVsOnzg==} @@ -2712,10 +2709,6 @@ packages: typescript: optional: true - '@typescript-eslint/scope-manager@5.62.0': - resolution: {integrity: sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@typescript-eslint/scope-manager@8.11.0': resolution: {integrity: sha512-Uholz7tWhXmA4r6epo+vaeV7yjdKy5QFCERMjs1kMVsLRKIrSdM6o21W2He9ftp5PP6aWOVpD5zvrvuHZC0bMQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2729,23 +2722,10 @@ packages: typescript: optional: true - '@typescript-eslint/types@5.62.0': - resolution: {integrity: sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@typescript-eslint/types@8.11.0': resolution: {integrity: sha512-tn6sNMHf6EBAYMvmPUaKaVeYvhUsrE6x+bXQTxjQRp360h1giATU0WvgeEys1spbvb5R+VpNOZ+XJmjD8wOUHw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@5.62.0': - resolution: {integrity: sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - '@typescript-eslint/typescript-estree@8.11.0': resolution: {integrity: sha512-yHC3s1z1RCHoCz5t06gf7jH24rr3vns08XXhfEqzYpd6Hll3z/3g23JRi0jM8A47UFKNc3u/y5KIMx8Ynbjohg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2755,22 +2735,12 @@ packages: typescript: optional: true - '@typescript-eslint/utils@5.62.0': - resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - '@typescript-eslint/utils@8.11.0': resolution: {integrity: sha512-CYiX6WZcbXNJV7UNB4PLDIBtSdRmRI/nb0FMyqHPTQD1rMjA0foPLaPUV39C/MxkTd/QKSeX+Gb34PPsDVC35g==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - '@typescript-eslint/visitor-keys@5.62.0': - resolution: {integrity: sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@typescript-eslint/visitor-keys@8.11.0': resolution: {integrity: sha512-EaewX6lxSjRJnc+99+dqzTeoDZUfyrA52d2/HRrkI830kgovWsmIiTfmr0NZorzqic7ga+1bS60lRBUgR3n/Bw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -3039,10 +3009,6 @@ packages: resolution: {integrity: sha512-itaWrbYbqpGXkGhZPGUulwnhVf5Hpy1xiCFsGqyIGglbBxmG5vSjxQen3/WGOjPpNEv1RtBLKxbmVXm8HpJStQ==} engines: {node: '>= 0.4'} - array-union@2.1.0: - resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} - engines: {node: '>=8'} - array.prototype.findlast@1.2.5: resolution: {integrity: sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==} engines: {node: '>= 0.4'} @@ -3964,10 +3930,6 @@ packages: diffie-hellman@5.0.3: resolution: {integrity: sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==} - dir-glob@3.0.1: - resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} - engines: {node: '>=8'} - dlv@1.1.3: resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==} @@ -4388,8 +4350,8 @@ packages: peerDependencies: eslint: '>=8.44.0' - eslint-plugin-storybook@0.9.0: - resolution: {integrity: sha512-qOT/2vQBo0VqrG/BhZv8IdSsKQiyzJw+2Wqq+WFCiblI/PfxLSrGkF/buiXF+HumwfsCyBdaC94UhqhmYFmAvA==} + eslint-plugin-storybook@0.10.1: + resolution: {integrity: sha512-YpxkdqyiKpMIrRquuvBaCinsqmZJ86JvXRX/gtRa4Qctpk0ipFt2cWqEjkB1HHWWG0DVRXlUBKHjRogC2Ig1fg==} engines: {node: '>= 18'} peerDependencies: eslint: '>=6' @@ -4780,10 +4742,6 @@ packages: resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} - globby@11.1.0: - resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} - engines: {node: '>=10'} - gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} @@ -7037,10 +6995,6 @@ packages: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} - requireindex@1.2.0: - resolution: {integrity: sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==} - engines: {node: '>=0.10.5'} - requires-port@1.0.0: resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} @@ -7674,21 +7628,12 @@ packages: resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} engines: {node: '>=6'} - tslib@1.14.1: - resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} - tslib@2.3.0: resolution: {integrity: sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==} tslib@2.8.0: resolution: {integrity: sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==} - tsutils@3.21.0: - resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} - engines: {node: '>= 6'} - peerDependencies: - typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' - tty-browserify@0.0.1: resolution: {integrity: sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==} @@ -10390,10 +10335,6 @@ snapshots: transitivePeerDependencies: - webpack-sources - '@storybook/csf@0.0.1': - dependencies: - lodash: 4.17.21 - '@storybook/csf@0.1.11': dependencies: type-fest: 2.19.0 @@ -11069,11 +11010,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@5.62.0': - dependencies: - '@typescript-eslint/types': 5.62.0 - '@typescript-eslint/visitor-keys': 5.62.0 - '@typescript-eslint/scope-manager@8.11.0': dependencies: '@typescript-eslint/types': 8.11.0 @@ -11091,24 +11027,8 @@ snapshots: - eslint - supports-color - '@typescript-eslint/types@5.62.0': {} - '@typescript-eslint/types@8.11.0': {} - '@typescript-eslint/typescript-estree@5.62.0(typescript@4.9.5)': - dependencies: - '@typescript-eslint/types': 5.62.0 - '@typescript-eslint/visitor-keys': 5.62.0 - debug: 4.3.7 - globby: 11.1.0 - is-glob: 4.0.3 - semver: 7.6.3 - tsutils: 3.21.0(typescript@4.9.5) - optionalDependencies: - typescript: 4.9.5 - transitivePeerDependencies: - - supports-color - '@typescript-eslint/typescript-estree@8.11.0(typescript@4.9.5)': dependencies: '@typescript-eslint/types': 8.11.0 @@ -11124,21 +11044,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@5.62.0(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5)': - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@9.13.0(jiti@1.21.6)) - '@types/json-schema': 7.0.15 - '@types/semver': 7.5.8 - '@typescript-eslint/scope-manager': 5.62.0 - '@typescript-eslint/types': 5.62.0 - '@typescript-eslint/typescript-estree': 5.62.0(typescript@4.9.5) - eslint: 9.13.0(jiti@1.21.6) - eslint-scope: 5.1.1 - semver: 7.6.3 - transitivePeerDependencies: - - supports-color - - typescript - '@typescript-eslint/utils@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.13.0(jiti@1.21.6)) @@ -11150,11 +11055,6 @@ snapshots: - supports-color - typescript - '@typescript-eslint/visitor-keys@5.62.0': - dependencies: - '@typescript-eslint/types': 5.62.0 - eslint-visitor-keys: 3.4.3 - '@typescript-eslint/visitor-keys@8.11.0': dependencies: '@typescript-eslint/types': 8.11.0 @@ -11471,8 +11371,6 @@ snapshots: get-intrinsic: 1.2.4 is-string: 1.0.7 - array-union@2.1.0: {} - array.prototype.findlast@1.2.5: dependencies: call-bind: 1.0.7 @@ -12481,10 +12379,6 @@ snapshots: miller-rabin: 4.0.1 randombytes: 2.1.0 - dir-glob@3.0.1: - dependencies: - path-type: 4.0.0 - dlv@1.1.3: {} doctrine@2.1.0: @@ -13130,12 +13024,11 @@ snapshots: regexp-ast-analysis: 0.7.1 scslre: 0.3.0 - eslint-plugin-storybook@0.9.0(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5): + eslint-plugin-storybook@0.10.1(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5): dependencies: - '@storybook/csf': 0.0.1 - '@typescript-eslint/utils': 5.62.0(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5) + '@storybook/csf': 0.1.11 + '@typescript-eslint/utils': 8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@4.9.5) eslint: 9.13.0(jiti@1.21.6) - requireindex: 1.2.0 ts-dedent: 2.2.0 transitivePeerDependencies: - supports-color @@ -13658,15 +13551,6 @@ snapshots: define-properties: 1.2.1 gopd: 1.0.1 - globby@11.1.0: - dependencies: - array-union: 2.1.0 - dir-glob: 3.0.1 - fast-glob: 3.3.2 - ignore: 5.3.2 - merge2: 1.4.1 - slash: 3.0.0 - gopd@1.0.1: dependencies: get-intrinsic: 1.2.4 @@ -16784,8 +16668,6 @@ snapshots: require-from-string@2.0.2: {} - requireindex@1.2.0: {} - requires-port@1.0.0: {} resize-observer-polyfill@1.5.1: {} @@ -17462,17 +17344,10 @@ snapshots: minimist: 1.2.8 strip-bom: 3.0.0 - tslib@1.14.1: {} - tslib@2.3.0: {} tslib@2.8.0: {} - tsutils@3.21.0(typescript@4.9.5): - dependencies: - tslib: 1.14.1 - typescript: 4.9.5 - tty-browserify@0.0.1: {} tween-functions@1.2.0: {}