|
| 1 | +const defaultRules = { |
| 2 | + // No console statements in production |
| 3 | + 'no-console': process.env.NODE_ENV !== 'development' ? 'error' : 'off', |
| 4 | + // No debugger statements in production |
| 5 | + 'no-debugger': process.env.NODE_ENV !== 'development' ? 'error' : 'off', |
| 6 | + // Enforce prettier formatting |
| 7 | + 'prettier/prettier': 'error', |
| 8 | + 'padding-line-between-statements': [ |
| 9 | + 'error', |
| 10 | + { |
| 11 | + blankLine: 'always', |
| 12 | + prev: [ |
| 13 | + 'block', |
| 14 | + 'block-like', |
| 15 | + 'cjs-export', |
| 16 | + 'class', |
| 17 | + 'export', |
| 18 | + 'import', |
| 19 | + 'multiline-block-like', |
| 20 | + 'multiline-const', |
| 21 | + 'multiline-expression', |
| 22 | + 'multiline-let', |
| 23 | + 'multiline-var', |
| 24 | + ], |
| 25 | + next: '*', |
| 26 | + }, |
| 27 | + { |
| 28 | + blankLine: 'always', |
| 29 | + prev: ['const', 'let'], |
| 30 | + next: ['block', 'block-like', 'cjs-export', 'class', 'export', 'import'], |
| 31 | + }, |
| 32 | + { |
| 33 | + blankLine: 'always', |
| 34 | + prev: '*', |
| 35 | + next: ['multiline-block-like', 'multiline-const', 'multiline-expression', 'multiline-let', 'multiline-var'], |
| 36 | + }, |
| 37 | + { blankLine: 'any', prev: ['export', 'import'], next: ['export', 'import'] }, |
| 38 | + ], |
| 39 | + 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }], |
| 40 | + 'no-nested-ternary': 'error', |
| 41 | + curly: ['error', 'multi-line'], |
| 42 | +}; |
| 43 | + |
| 44 | +module.exports = { |
| 45 | + // Stop looking for ESLint configurations in parent folders |
| 46 | + root: true, |
| 47 | + // Global variables: Browser and Node.js |
| 48 | + env: { |
| 49 | + browser: true, |
| 50 | + node: true, |
| 51 | + }, |
| 52 | + // Basic configuration for js files |
| 53 | + plugins: ['@typescript-eslint', 'prettier'], |
| 54 | + extends: ['eslint:recommended', 'prettier'], |
| 55 | + rules: defaultRules, |
| 56 | + parserOptions: { |
| 57 | + ecmaVersion: 2022, |
| 58 | + sourceType: 'module', |
| 59 | + }, |
| 60 | + overrides: [ |
| 61 | + // Configuration for ts/vue files |
| 62 | + { |
| 63 | + files: ['*.ts', '*.vue'], |
| 64 | + parser: 'vue-eslint-parser', |
| 65 | + parserOptions: { |
| 66 | + parser: '@typescript-eslint/parser', |
| 67 | + }, |
| 68 | + extends: [ |
| 69 | + 'plugin:vue/vue3-recommended', |
| 70 | + 'eslint:recommended', |
| 71 | + 'plugin:@typescript-eslint/recommended', |
| 72 | + 'prettier', |
| 73 | + ], |
| 74 | + rules: { |
| 75 | + ...defaultRules, |
| 76 | + 'vue/multi-word-component-names': 'off', |
| 77 | + 'vue/require-default-prop': 'off', |
| 78 | + // It's recommended to turn off this rule on TypeScript projects |
| 79 | + 'no-undef': 'off', |
| 80 | + // Allow ts-directive comments (used to suppress TypeScript compiler errors) |
| 81 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 82 | + // Allow usage of the any type (consider to enable this rule later on) |
| 83 | + '@typescript-eslint/no-explicit-any': 'off', |
| 84 | + // Allow usage of require statements (consider to enable this rule later on) |
| 85 | + '@typescript-eslint/no-var-requires': 'off', |
| 86 | + // Allow non-null assertions for now (consider to enable this rule later on) |
| 87 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 88 | + // Allow unused arguments and variables when they begin with an underscore |
| 89 | + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], |
| 90 | + }, |
| 91 | + }, |
| 92 | + ], |
| 93 | +}; |
0 commit comments