|
| 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 | +}; |
| 9 | + |
| 10 | +module.exports = { |
| 11 | +// Stop looking for ESLint configurations in parent folders |
| 12 | +root: true, |
| 13 | +// Global variables: Browser and Node.js |
| 14 | +env: { |
| 15 | +browser: true, |
| 16 | +node: true, |
| 17 | +}, |
| 18 | +// Basic configuration for js files |
| 19 | +plugins: ['@typescript-eslint', 'prettier'], |
| 20 | +extends: ['eslint:recommended', 'prettier'], |
| 21 | +rules: defaultRules, |
| 22 | +parserOptions: { |
| 23 | +ecmaVersion: 2020, |
| 24 | +}, |
| 25 | +overrides: [ |
| 26 | +// Parse rollup configration as module |
| 27 | +{ |
| 28 | +files: ['rollup.config.js', 'vite.config.js'], |
| 29 | +parserOptions: { |
| 30 | +sourceType: 'module', |
| 31 | +}, |
| 32 | +}, |
| 33 | +// Configuration for ts/vue files |
| 34 | +{ |
| 35 | +files: ['*.ts', '*.vue'], |
| 36 | +parser: 'vue-eslint-parser', |
| 37 | +parserOptions: { |
| 38 | +parser: '@typescript-eslint/parser', |
| 39 | +}, |
| 40 | +extends: [ |
| 41 | +'plugin:vue/vue3-recommended', |
| 42 | +'eslint:recommended', |
| 43 | +'plugin:@typescript-eslint/recommended', |
| 44 | +'prettier', |
| 45 | +], |
| 46 | +rules: { |
| 47 | +...defaultRules, |
| 48 | +// It's recommended to turn off this rule on TypeScript projects |
| 49 | +'no-undef': 'off', |
| 50 | +// Allow ts-directive comments (used to suppress TypeScript compiler errors) |
| 51 | +'@typescript-eslint/ban-ts-comment': 'off', |
| 52 | +// Allow usage of the any type (consider to enable this rule later on) |
| 53 | +'@typescript-eslint/no-explicit-any': 'off', |
| 54 | +// Allow usage of require statements (consider to enable this rule later on) |
| 55 | +'@typescript-eslint/no-var-requires': 'off', |
| 56 | +// Allow non-null assertions for now (consider to enable this rule later on) |
| 57 | +'@typescript-eslint/no-non-null-assertion': 'off', |
| 58 | +// Allow unused arguments and variables when they begin with an underscore |
| 59 | +'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], |
| 60 | +}, |
| 61 | +}, |
| 62 | +], |
| 63 | +}; |
0 commit comments