diff --git a/web/eslint.config.mjs b/web/eslint.config.mjs index e8ab0fd8b3..2ff4d704fd 100644 --- a/web/eslint.config.mjs +++ b/web/eslint.config.mjs @@ -1,7 +1,7 @@ import { - GLOB_JSX, GLOB_TESTS, GLOB_TSX, combine, javascript, node, - stylistic, typescript, unicorn - } from '@antfu/eslint-config' + GLOB_TESTS, combine, javascript, node, + stylistic, typescript, unicorn, +} from '@antfu/eslint-config' import path from 'node:path' import { fileURLToPath } from 'node:url' import js from '@eslint/js' @@ -21,27 +21,27 @@ 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', - } + 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', - } - } + rules: { + 'storybook/no-uninstalled-addons': 'error', + }, + }, ] export default combine( @@ -49,27 +49,41 @@ export default combine( lessOpinionated: true, // original @antfu/eslint-config does not support jsx jsx: false, + semi: false, + quotes: 'single', overrides: { // original config - "style/indent": ["error", 2], + 'style/indent': ['error', 2], + 'style/quotes': ['error', 'single'], + 'curly': ['error', 'multi-line'], + 'style/comma-spacing': ['error', { before: false, after: true }], + 'style/quote-props': ['warn', 'consistent-as-needed'], // these options does not exist in old version // maybe useless - "style/indent-binary-ops": "off", - "style/multiline-ternary": "off", + 'style/indent-binary-ops': 'off', + 'style/multiline-ternary': 'off', + 'antfu/top-level-function': 'off', + 'antfu/curly': 'off', + 'antfu/consistent-chaining': 'off', + + // copy from eslint-config-antfu 0.36.0 + 'style/brace-style': ['error', 'stroustrup', { allowSingleLine: true }], + 'style/dot-location': ['error', 'property'], + 'style/object-curly-newline': ['error', { consistent: true, multiline: true }], + 'style/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }], + 'style/template-curly-spacing': ['error', 'never'], + 'style/keyword-spacing': 'off', // not exist in old version, and big change - "style/quote-props": "off", - "style/member-delimiter-style": "off", - "style/quotes": "off", - "style/comma-dangle": "off", - } + 'style/member-delimiter-style': 'off', + }, }), typescript({ overrides: { // useful, but big change - "ts/no-empty-object-type": "off", - } + 'ts/no-empty-object-type': 'off', + }, }), javascript({ overrides: { @@ -77,8 +91,8 @@ export default combine( 'no-unused-vars': 'off', // useless - 'no-use-before-define': 'warn' - } + 'no-use-before-define': 'warn', + }, }), unicorn(), node(), @@ -96,30 +110,36 @@ export default combine( '**/.next/', '**/public/*', '**/*.json', - ] + ], }, { // 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", + 'no-undef': 'off', 'ts/consistent-type-definitions': ['error', 'type'], // orignal ts/no-var-requires 'ts/no-require-imports': 'off', - "no-console": 'off', - "react-hooks/exhaustive-deps": "warn", - "react/display-name": "off", + 'no-console': 'off', + 'react-hooks/exhaustive-deps': 'warn', + 'react/display-name': 'off', + 'array-callback-return': ['error', { + allowImplicit: false, + checkForEach: false, + }], - // orignal config, but removed in new version antfu/eslint-config - // big change - "curly": "off", + // 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 - "sort-imports": [ + // will cause big change, so keep the original sort-imports + 'sort-imports': [ 'error', { ignoreCase: false, @@ -131,8 +151,8 @@ export default combine( ], // antfu migrate to eslint-plugin-unused-imports - "unused-imports/no-unused-vars": "warn", - "unused-imports/no-unused-imports": "warn", + 'unused-imports/no-unused-vars': 'warn', + 'unused-imports/no-unused-imports': 'warn', }, languageOptions: { @@ -140,25 +160,25 @@ export default combine( ...globals.browser, ...globals.es2025, ...globals.node, - 'React': 'readable', - 'JSX': 'readable', - } - } + React: 'readable', + JSX: 'readable', + }, + }, }, storybook, // need futher research { rules: { // not exist in old version - "antfu/consistent-list-newline": "off", + 'antfu/consistent-list-newline': 'off', 'node/prefer-global/process': 'off', 'node/prefer-global/buffer': 'off', 'node/no-callback-literal': 'off', // useful, but big change - "unicorn/prefer-number-properties": "warn", - "unicorn/no-new-array": "warn" - } + 'unicorn/prefer-number-properties': 'warn', + 'unicorn/no-new-array': 'warn', + }, }, // suppress error for `no-undef` rule {