|
| 1 | +// eslint.config.mjs |
| 2 | + |
| 3 | +import tsParser from '@typescript-eslint/parser' |
| 4 | +import tseslint from '@typescript-eslint/eslint-plugin' |
| 5 | +import eslintPluginPrettier from 'eslint-plugin-prettier' |
| 6 | + |
| 7 | +export default [ |
| 8 | + // |
| 9 | + // 1. `.mjs` — use default JS parser |
| 10 | + // |
| 11 | + { |
| 12 | + files: ['**/*.mjs'], |
| 13 | + ignores: ['.source/**/*'], // ignore generated files |
| 14 | + languageOptions: { |
| 15 | + // no parser → espree (default JS parser) |
| 16 | + parserOptions: { |
| 17 | + ecmaVersion: 'latest', |
| 18 | + sourceType: 'module', |
| 19 | + // ensure TS projects don’t apply: |
| 20 | + project: undefined, |
| 21 | + tsconfigRootDir: undefined, |
| 22 | + }, |
| 23 | + }, |
| 24 | + plugins: { |
| 25 | + prettier: eslintPluginPrettier, |
| 26 | + }, |
| 27 | + rules: { |
| 28 | + semi: ['error', 'never'], |
| 29 | + quotes: ['error', 'single', { avoidEscape: true }], |
| 30 | + 'jsx-quotes': ['error', 'prefer-single'], |
| 31 | + 'comma-dangle': ['error', 'always-multiline'], |
| 32 | + 'prettier/prettier': ['error'], |
| 33 | + }, |
| 34 | + }, |
| 35 | + |
| 36 | + // |
| 37 | + // 2. NON-type-aware TS for .source/* |
| 38 | + // |
| 39 | + { |
| 40 | + files: ['.source/**/*.{ts,tsx}'], |
| 41 | + languageOptions: { |
| 42 | + parser: tsParser, |
| 43 | + parserOptions: { |
| 44 | + ecmaVersion: 'latest', |
| 45 | + sourceType: 'module', |
| 46 | + project: undefined, |
| 47 | + tsconfigRootDir: undefined, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }, |
| 51 | + |
| 52 | + // |
| 53 | + // 3. REAL type-aware TS for everything else |
| 54 | + // |
| 55 | + { |
| 56 | + files: ['**/*.{ts,tsx}'], |
| 57 | + ignores: ['.source/**/*'], |
| 58 | + languageOptions: { |
| 59 | + parser: tsParser, |
| 60 | + parserOptions: { |
| 61 | + ecmaFeatures: { jsx: true }, |
| 62 | + ecmaVersion: 'latest', |
| 63 | + sourceType: 'module', |
| 64 | + project: ['./tsconfig.json'], |
| 65 | + tsconfigRootDir: process.cwd(), |
| 66 | + }, |
| 67 | + }, |
| 68 | + plugins: { |
| 69 | + '@typescript-eslint': tseslint, |
| 70 | + prettier: eslintPluginPrettier, |
| 71 | + }, |
| 72 | + rules: { |
| 73 | + semi: ['error', 'never'], |
| 74 | + quotes: ['error', 'single', { avoidEscape: true }], |
| 75 | + 'jsx-quotes': ['error', 'prefer-single'], |
| 76 | + 'comma-dangle': ['error', 'always-multiline'], |
| 77 | + 'prettier/prettier': ['error'], |
| 78 | + }, |
| 79 | + }, |
| 80 | + |
| 81 | + // |
| 82 | + // 4. JS rules |
| 83 | + // |
| 84 | + { |
| 85 | + files: ['**/*.{js,jsx}'], |
| 86 | + ignores: ['**/*.mjs'], |
| 87 | + plugins: { |
| 88 | + prettier: eslintPluginPrettier, |
| 89 | + }, |
| 90 | + rules: { |
| 91 | + semi: ['error', 'never'], |
| 92 | + quotes: ['error', 'single', { avoidEscape: true }], |
| 93 | + 'jsx-quotes': ['error', 'prefer-single'], |
| 94 | + 'comma-dangle': ['error', 'always-multiline'], |
| 95 | + 'prettier/prettier': ['error'], |
| 96 | + }, |
| 97 | + }, |
| 98 | +] |
0 commit comments