|
| 1 | +// @ts-check |
| 2 | + |
| 3 | +import eslint from '@eslint/js'; |
| 4 | +import nodePlugin from 'eslint-plugin-n'; |
| 5 | +import simpleImportSort from 'eslint-plugin-simple-import-sort'; |
| 6 | +import tsEslint from 'typescript-eslint'; |
| 7 | + |
| 8 | +export default tsEslint.config( |
| 9 | + eslint.configs.recommended, |
| 10 | + nodePlugin.configs['flat/recommended'], |
| 11 | + ...tsEslint.configs.recommended, |
| 12 | + ...tsEslint.configs.strict, |
| 13 | + ...tsEslint.configs.stylistic, |
| 14 | + { |
| 15 | + ignores: [ |
| 16 | + '**/[Ss]amples/**', // cspell:disable-line |
| 17 | + '**/[Tt]emp/**', |
| 18 | + '**/*.d.mts', |
| 19 | + '**/*.d.ts', |
| 20 | + '**/*.json', |
| 21 | + '**/*.map', |
| 22 | + '**/*.snap', |
| 23 | + '**/*.yaml', |
| 24 | + '**/*.yml', |
| 25 | + '**/coverage/**', |
| 26 | + '**/dist/**', |
| 27 | + '**/node_modules/**', |
| 28 | + 'fixtures/*/lib*/**', |
| 29 | + 'fixtures/*/out/**', |
| 30 | + ], |
| 31 | + }, |
| 32 | + { |
| 33 | + plugins: { |
| 34 | + 'simple-import-sort': simpleImportSort, |
| 35 | + }, |
| 36 | + rules: { |
| 37 | + 'simple-import-sort/imports': 'error', |
| 38 | + 'simple-import-sort/exports': 'error', |
| 39 | + }, |
| 40 | + }, |
| 41 | + { |
| 42 | + files: ['**/*.{ts,cts,mts,tsx}'], |
| 43 | + rules: { |
| 44 | + // Note: you must disable the base rule as it can report incorrect errors |
| 45 | + 'no-unused-vars': 'off', |
| 46 | + '@typescript-eslint/consistent-type-imports': ['error'], |
| 47 | + '@typescript-eslint/explicit-function-return-type': 'error', |
| 48 | + '@typescript-eslint/no-empty-function': 'off', |
| 49 | + '@typescript-eslint/no-empty-interface': 'error', |
| 50 | + '@typescript-eslint/no-inferrable-types': 'off', // This is useful for type annotations in function parameters and return types. |
| 51 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 52 | + '@typescript-eslint/prefer-literal-enum-member': 'off', |
| 53 | + '@typescript-eslint/unified-signatures': 'off', // The signatures come from VS Code, it is better to have them match the source. |
| 54 | + '@typescript-eslint/no-unused-vars': [ |
| 55 | + 'error', |
| 56 | + { |
| 57 | + args: 'all', |
| 58 | + argsIgnorePattern: '^_', |
| 59 | + caughtErrors: 'all', |
| 60 | + caughtErrorsIgnorePattern: '^_', |
| 61 | + destructuredArrayIgnorePattern: '^_', |
| 62 | + varsIgnorePattern: '^_', |
| 63 | + ignoreRestSiblings: true, |
| 64 | + }, |
| 65 | + ], |
| 66 | + 'n/no-missing-import': [ |
| 67 | + 'off', // disabled because it is not working correctly |
| 68 | + { |
| 69 | + tryExtensions: ['.d.ts', '.d.mts', '.d.cts', '.ts', '.cts', '.mts', '.js', '.cjs', '.mjs'], |
| 70 | + }, |
| 71 | + ], |
| 72 | + }, |
| 73 | + }, |
| 74 | + { |
| 75 | + files: ['**/*.test.*', '**/__mocks__/**', '**/test/**', '**/test.*', '**/rollup.config.mjs', '**/build.mjs'], |
| 76 | + rules: { |
| 77 | + 'n/no-extraneous-require': 'off', // Mostly for __mocks__ and test files |
| 78 | + 'n/no-extraneous-import': 'off', |
| 79 | + 'n/no-unpublished-import': 'off', |
| 80 | + '@typescript-eslint/no-explicit-any': 'off', // any is allowed in tests |
| 81 | + '@typescript-eslint/no-useless-constructor': 'off', // useful for tests |
| 82 | + '@typescript-eslint/no-dynamic-delete': 'off', // useful for tests |
| 83 | + }, |
| 84 | + }, |
| 85 | + { |
| 86 | + files: ['**/jest.config.*', '**/__mocks__/**'], |
| 87 | + rules: { |
| 88 | + 'n/no-extraneous-require': 'off', |
| 89 | + 'no-undef': 'off', |
| 90 | + }, |
| 91 | + }, |
| 92 | +); |
0 commit comments