|
| 1 | +import js from '@eslint/js'; |
| 2 | +import pluginVue from 'eslint-plugin-vue'; |
| 3 | +import vueParser from 'vue-eslint-parser'; |
| 4 | +import globals from 'globals'; |
| 5 | +import tsParser from '@typescript-eslint/parser'; |
| 6 | +import tsPlugin from '@typescript-eslint/eslint-plugin'; |
| 7 | +import prettierConfig from 'eslint-config-prettier'; |
| 8 | +import prettierPlugin from 'eslint-plugin-prettier'; |
| 9 | +import tseslint from 'typescript-eslint'; |
| 10 | + |
| 11 | +const sharedRules = { |
| 12 | + 'prettier/prettier': 'error', |
| 13 | + ...prettierConfig.rules, |
| 14 | + 'max-len': 'off', |
| 15 | + 'no-unused-vars': 'off', |
| 16 | + 'vue/no-unused-vars': 'off', |
| 17 | + 'no-plusplus': 'off', |
| 18 | + 'no-param-reassign': [ |
| 19 | + 'error', |
| 20 | + { |
| 21 | + props: true, |
| 22 | + ignorePropertyModificationsFor: ['state', 'acc', 'e'], |
| 23 | + }, |
| 24 | + ], |
| 25 | +}; |
| 26 | + |
| 27 | +const tsRules = { |
| 28 | + ...Object.assign({}, ...tseslint.configs.recommended.map((c) => c.rules ?? {})), |
| 29 | + '@typescript-eslint/no-explicit-any': 'off', |
| 30 | + '@typescript-eslint/no-unused-vars': 'off', |
| 31 | +}; |
| 32 | + |
| 33 | +const sharedGlobals = { |
| 34 | + ...globals.browser, |
| 35 | + ...globals.node, |
| 36 | + ...globals.es2021, |
| 37 | +}; |
| 38 | + |
| 39 | +export default [ |
| 40 | + { |
| 41 | + ignores: [ |
| 42 | + '**/node_modules/**', |
| 43 | + '**/dist/**', |
| 44 | + '../server/static/**', |
| 45 | + 'junit/**', |
| 46 | + '*.backup', |
| 47 | + ], |
| 48 | + }, |
| 49 | + js.configs.recommended, |
| 50 | + ...pluginVue.configs['flat/recommended'], |
| 51 | + // TypeScript source files |
| 52 | + { |
| 53 | + files: ['**/*.ts'], |
| 54 | + plugins: { |
| 55 | + '@typescript-eslint': tsPlugin, |
| 56 | + prettier: prettierPlugin, |
| 57 | + }, |
| 58 | + languageOptions: { |
| 59 | + parser: tsParser, |
| 60 | + parserOptions: { ecmaVersion: 2022, sourceType: 'module' }, |
| 61 | + globals: sharedGlobals, |
| 62 | + }, |
| 63 | + rules: { ...tsRules, ...sharedRules }, |
| 64 | + }, |
| 65 | + // Vue SFCs — all use <script lang="ts"> |
| 66 | + { |
| 67 | + files: ['**/*.vue'], |
| 68 | + plugins: { |
| 69 | + '@typescript-eslint': tsPlugin, |
| 70 | + prettier: prettierPlugin, |
| 71 | + }, |
| 72 | + languageOptions: { |
| 73 | + parser: vueParser, |
| 74 | + parserOptions: { |
| 75 | + parser: tsParser, |
| 76 | + ecmaVersion: 2022, |
| 77 | + sourceType: 'module', |
| 78 | + }, |
| 79 | + globals: sharedGlobals, |
| 80 | + }, |
| 81 | + rules: { ...tsRules, ...sharedRules }, |
| 82 | + }, |
| 83 | + // Test files — declare vitest globals |
| 84 | + { |
| 85 | + files: ['**/*.test.ts'], |
| 86 | + languageOptions: { |
| 87 | + globals: { |
| 88 | + describe: 'readonly', |
| 89 | + it: 'readonly', |
| 90 | + expect: 'readonly', |
| 91 | + vi: 'readonly', |
| 92 | + beforeEach: 'readonly', |
| 93 | + afterEach: 'readonly', |
| 94 | + }, |
| 95 | + }, |
| 96 | + }, |
| 97 | +]; |
0 commit comments