|
| 1 | +const globals = require('globals') |
| 2 | +const js = require('@eslint/js') |
| 3 | +const tsPlugin = require('@typescript-eslint/eslint-plugin') |
| 4 | +const tsParser = require('@typescript-eslint/parser') |
| 5 | +const importPlugin = require('eslint-plugin-import') |
| 6 | +const promisePlugin = require('eslint-plugin-promise') |
| 7 | +const eslintConfigPrettier = require('eslint-config-prettier') |
| 8 | + |
| 9 | +const tsEslintRecommendedAdjustments = |
| 10 | + tsPlugin.configs['eslint-recommended'].overrides?.[0]?.rules ?? {} |
| 11 | + |
| 12 | +module.exports = [ |
| 13 | + { |
| 14 | + ignores: [ |
| 15 | + '**/dist/**', |
| 16 | + '**/node_modules/**', |
| 17 | + '**/*.d.ts', |
| 18 | + '.eslintrc.js', |
| 19 | + 'bin', |
| 20 | + 'scripts/**/*.js' |
| 21 | + ], |
| 22 | + linterOptions: { |
| 23 | + reportUnusedDisableDirectives: 'off' |
| 24 | + } |
| 25 | + }, |
| 26 | + { |
| 27 | + ...js.configs.recommended, |
| 28 | + files: ['**/*.js', '**/*.cjs', '**/*.mjs'], |
| 29 | + ignores: ['**/dist/**', '**/node_modules/**'], |
| 30 | + languageOptions: { |
| 31 | + sourceType: 'commonjs', |
| 32 | + globals: { |
| 33 | + ...globals.node, |
| 34 | + ...globals.es2022 |
| 35 | + } |
| 36 | + }, |
| 37 | + rules: { |
| 38 | + 'no-undef': 'off', |
| 39 | + semi: ['error', 'never'] |
| 40 | + } |
| 41 | + }, |
| 42 | + { |
| 43 | + files: ['**/*.d.ts'], |
| 44 | + ignores: ['**/dist/**', '**/node_modules/**'], |
| 45 | + languageOptions: { |
| 46 | + parser: tsParser, |
| 47 | + parserOptions: { |
| 48 | + project: './tsconfig.json', |
| 49 | + tsconfigRootDir: __dirname, |
| 50 | + sourceType: 'module' |
| 51 | + }, |
| 52 | + globals: { |
| 53 | + ...globals.node, |
| 54 | + ...globals.es2022 |
| 55 | + } |
| 56 | + }, |
| 57 | + plugins: { |
| 58 | + '@typescript-eslint': tsPlugin |
| 59 | + }, |
| 60 | + rules: { |
| 61 | + 'no-var': 'off', |
| 62 | + '@typescript-eslint/naming-convention': 'off' |
| 63 | + } |
| 64 | + }, |
| 65 | + { |
| 66 | + files: ['src/**/*.ts', 'scripts/**/*.ts', 'types/**/*.ts'], |
| 67 | + ignores: ['**/*.d.ts'], |
| 68 | + languageOptions: { |
| 69 | + parser: tsParser, |
| 70 | + parserOptions: { |
| 71 | + project: './tsconfig.json', |
| 72 | + tsconfigRootDir: __dirname, |
| 73 | + sourceType: 'module' |
| 74 | + }, |
| 75 | + globals: { |
| 76 | + ...globals.node, |
| 77 | + ...globals.es2022 |
| 78 | + } |
| 79 | + }, |
| 80 | + plugins: { |
| 81 | + '@typescript-eslint': tsPlugin, |
| 82 | + import: importPlugin, |
| 83 | + promise: promisePlugin |
| 84 | + }, |
| 85 | + rules: { |
| 86 | + ...tsEslintRecommendedAdjustments, |
| 87 | + ...tsPlugin.configs.recommended.rules, |
| 88 | + ...tsPlugin.configs['recommended-requiring-type-checking'].rules, |
| 89 | + ...promisePlugin.configs.recommended.rules, |
| 90 | + ...eslintConfigPrettier.rules, |
| 91 | + '@typescript-eslint/strict-boolean-expressions': 'off', |
| 92 | + '@typescript-eslint/prefer-nullish-coalescing': 'off', |
| 93 | + '@typescript-eslint/return-await': 'off', |
| 94 | + '@typescript-eslint/no-floating-promises': 'off', |
| 95 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 96 | + '@typescript-eslint/no-explicit-any': 'off', |
| 97 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 98 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 99 | + '@typescript-eslint/no-unsafe-argument': 'off', |
| 100 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 101 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 102 | + '@typescript-eslint/no-unsafe-function-type': 'off', |
| 103 | + '@typescript-eslint/no-redundant-type-constituents': 'off', |
| 104 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 105 | + '@typescript-eslint/require-await': 'off', |
| 106 | + '@typescript-eslint/no-require-imports': 'off', |
| 107 | + '@typescript-eslint/no-unused-vars': 'off', |
| 108 | + '@typescript-eslint/prefer-promise-reject-errors': 'off', |
| 109 | + '@typescript-eslint/naming-convention': [ |
| 110 | + 'error', |
| 111 | + { |
| 112 | + selector: 'interface', |
| 113 | + format: ['PascalCase'], |
| 114 | + custom: { regex: '^I[A-Z]', match: true } |
| 115 | + } |
| 116 | + ], |
| 117 | + 'import/no-unresolved': 'off', |
| 118 | + 'import/namespace': 'off', |
| 119 | + 'import/no-duplicates': 'off', |
| 120 | + 'import/default': 'off', |
| 121 | + 'import/no-named-as-default': 'off', |
| 122 | + 'import/no-named-as-default-member': 'off', |
| 123 | + 'promise/always-return': 'off', |
| 124 | + 'promise/no-promise-in-callback': 'off', |
| 125 | + semi: ['error', 'never'] |
| 126 | + }, |
| 127 | + settings: { |
| 128 | + 'import/resolver': { |
| 129 | + typescript: true, |
| 130 | + node: true |
| 131 | + } |
| 132 | + } |
| 133 | + } |
| 134 | +] |
0 commit comments