|
| 1 | +import globals from 'globals'; |
| 2 | +import pluginJs from '@eslint/js'; |
| 3 | +import tseslint from 'typescript-eslint'; |
| 4 | +import pluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; |
| 5 | +import nodePlugin from 'eslint-plugin-n'; |
| 6 | + |
| 7 | +/** @type {import('eslint').Linter.Config[]} */ |
| 8 | +export default [ |
| 9 | + { |
| 10 | + name: 'ignore files', |
| 11 | + ignores: ['dist/', 'build/', 'reports/', 'node_modules/'] |
| 12 | + }, |
| 13 | + { |
| 14 | + name: 'include files', |
| 15 | + files: ['**/*.{js,mjs,cjs,ts}'] |
| 16 | + }, |
| 17 | + { |
| 18 | + name: 'globals for node', |
| 19 | + files: ['**/*.{mjs,cjs,ts}'], |
| 20 | + languageOptions: { globals: globals.node } |
| 21 | + }, |
| 22 | + { |
| 23 | + ...pluginJs.configs.recommended, |
| 24 | + name: 'plugin-js recommended' |
| 25 | + }, |
| 26 | + { |
| 27 | + ...nodePlugin.configs['flat/recommended-module'], |
| 28 | + name: 'custom eslint-plugin-n plugin config', |
| 29 | + files: ['**/*.ts'], |
| 30 | + rules: { |
| 31 | + 'n/no-process-env': 'error', |
| 32 | + 'n/no-missing-import': [ |
| 33 | + 'off', // eslint-plugin-n fails to resolve index.ts files |
| 34 | + { |
| 35 | + tryExtensions: ['.ts', '.d.ts'] |
| 36 | + } |
| 37 | + ] |
| 38 | + }, |
| 39 | + languageOptions: { |
| 40 | + globals: { |
| 41 | + ...globals.node, |
| 42 | + NodeJS: true |
| 43 | + } |
| 44 | + } |
| 45 | + }, |
| 46 | + { |
| 47 | + ...nodePlugin.configs['flat/recommended-module'], |
| 48 | + name: 'custom eslint-plugin-n plugin config for tests', |
| 49 | + files: ['tests*/**/*.ts'], |
| 50 | + // eslint-plugin-n rules |
| 51 | + rules: { |
| 52 | + 'n/no-process-env': 'off' |
| 53 | + }, |
| 54 | + languageOptions: { |
| 55 | + globals: { |
| 56 | + ...globals.jest |
| 57 | + } |
| 58 | + } |
| 59 | + }, |
| 60 | + ...tseslint.configs.recommended.map(config => ({ |
| 61 | + ...config, |
| 62 | + files: ['**/*.ts'], |
| 63 | + rules: { |
| 64 | + 'no-unused-vars': 'off', |
| 65 | + 'no-redeclare': 'off', |
| 66 | + '@typescript-eslint/no-redeclare': 'error', |
| 67 | + '@typescript-eslint/no-unused-vars': [ |
| 68 | + 'error', |
| 69 | + { |
| 70 | + argsIgnorePattern: '^_', |
| 71 | + caughtErrorsIgnorePattern: '^_' |
| 72 | + } |
| 73 | + ] |
| 74 | + } |
| 75 | + })), |
| 76 | + { |
| 77 | + // eslint core rules |
| 78 | + rules: { |
| 79 | + complexity: ['error', 10], |
| 80 | + 'no-console': 'error', |
| 81 | + eqeqeq: ['error', 'smart'] |
| 82 | + } |
| 83 | + }, |
| 84 | + pluginPrettierRecommended |
| 85 | +]; |
0 commit comments