|
| 1 | +// eslint.config.js |
| 2 | +import { fixupPluginRules } from '@eslint/compat' |
| 3 | +import pluginTs from '@typescript-eslint/eslint-plugin' |
| 4 | +import parserTs from '@typescript-eslint/parser' |
| 5 | +import pluginImport from 'eslint-plugin-import' |
| 6 | +import pluginUnused from 'eslint-plugin-unused-imports' |
| 7 | +import pluginPrettier from 'eslint-plugin-prettier' |
| 8 | +import globals from 'globals' |
| 9 | +import { defineConfig, globalIgnores } from 'eslint/config' |
| 10 | + |
| 11 | +export default defineConfig([ |
| 12 | + globalIgnores([ |
| 13 | + '.history', |
| 14 | + '.vscode', |
| 15 | + 'build/*', |
| 16 | + 'dist/*', |
| 17 | + 'coverage/*', |
| 18 | + 'node_modules/*', |
| 19 | + 'vendors/*', |
| 20 | + 'src/generated-schema.ts', |
| 21 | + ]), |
| 22 | + { |
| 23 | + files: ['**/*.ts'], |
| 24 | + languageOptions: { |
| 25 | + parser: parserTs, |
| 26 | + ecmaVersion: 2021, |
| 27 | + sourceType: 'module', |
| 28 | + parserOptions: { |
| 29 | + project: ['./tsconfig.json'], |
| 30 | + }, |
| 31 | + globals: { |
| 32 | + ...globals.node, |
| 33 | + ...globals.jest, |
| 34 | + }, |
| 35 | + }, |
| 36 | + plugins: { |
| 37 | + '@typescript-eslint': fixupPluginRules(pluginTs), |
| 38 | + import: fixupPluginRules(pluginImport), |
| 39 | + 'unused-imports': fixupPluginRules(pluginUnused), |
| 40 | + prettier: fixupPluginRules(pluginPrettier), |
| 41 | + }, |
| 42 | + settings: { |
| 43 | + 'import/resolver': { |
| 44 | + node: { |
| 45 | + extensions: ['.ts'], |
| 46 | + paths: ['src'], |
| 47 | + }, |
| 48 | + typescript: {}, |
| 49 | + }, |
| 50 | + }, |
| 51 | + rules: { |
| 52 | + // TS rules |
| 53 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 54 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 55 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 56 | + '@typescript-eslint/member-delimiter-style': 'off', |
| 57 | + '@typescript-eslint/no-explicit-any': 'off', |
| 58 | + '@typescript-eslint/no-floating-promises': 'off', |
| 59 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 60 | + '@typescript-eslint/no-shadow': [ |
| 61 | + 'error', |
| 62 | + { |
| 63 | + allow: ['deps', 'secrets', 'values'], |
| 64 | + }, |
| 65 | + ], |
| 66 | + '@typescript-eslint/no-unsafe-argument': 'warn', |
| 67 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 68 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 69 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 70 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 71 | + '@typescript-eslint/no-unused-vars': [ |
| 72 | + 'warn', |
| 73 | + { |
| 74 | + argsIgnorePattern: '^(_|next)', |
| 75 | + varsIgnorePattern: '^_', |
| 76 | + }, |
| 77 | + ], |
| 78 | + '@typescript-eslint/no-use-before-define': ['error'], |
| 79 | + '@typescript-eslint/restrict-template-expressions': 'off', |
| 80 | + '@typescript-eslint/naming-convention': [ |
| 81 | + 'error', |
| 82 | + { |
| 83 | + selector: 'function', |
| 84 | + format: ['camelCase'], |
| 85 | + leadingUnderscore: 'allow', |
| 86 | + }, |
| 87 | + ], |
| 88 | + |
| 89 | + // Base rules |
| 90 | + 'comma-dangle': ['error', 'only-multiline'], |
| 91 | + 'eol-last': ['error', 'always'], |
| 92 | + 'func-names': 'off', |
| 93 | + 'import/extensions': 'off', |
| 94 | + 'import/no-extraneous-dependencies': 'off', |
| 95 | + 'no-console': 'off', |
| 96 | + 'no-debugger': 'warn', |
| 97 | + 'no-fallthrough': 'warn', |
| 98 | + 'no-param-reassign': [ |
| 99 | + 'error', |
| 100 | + { |
| 101 | + props: true, |
| 102 | + ignorePropertyModificationsFor: ['memo'], |
| 103 | + }, |
| 104 | + ], |
| 105 | + 'no-shadow': 'off', |
| 106 | + 'no-unused-vars': 'off', |
| 107 | + 'no-use-before-define': 'off', |
| 108 | + 'object-shorthand': 'error', |
| 109 | + 'prefer-destructuring': 'warn', |
| 110 | + 'prefer-template': 'error', |
| 111 | + |
| 112 | + // Plugins |
| 113 | + 'prettier/prettier': 'error', |
| 114 | + }, |
| 115 | + }, |
| 116 | +]) |
0 commit comments