|
| 1 | +// @ts-check |
| 2 | +const { defineConfig } = require('eslint-define-config') |
| 3 | + |
| 4 | +module.exports = defineConfig({ |
| 5 | + root: true, |
| 6 | + extends: [ |
| 7 | + 'eslint:recommended', |
| 8 | + 'plugin:node/recommended', |
| 9 | + 'plugin:@typescript-eslint/recommended' |
| 10 | + ], |
| 11 | + parser: '@typescript-eslint/parser', |
| 12 | + parserOptions: { |
| 13 | + sourceType: 'module', |
| 14 | + ecmaVersion: 2021 |
| 15 | + }, |
| 16 | + rules: { |
| 17 | + eqeqeq: ['warn', 'always', { null: 'never' }], |
| 18 | + 'no-debugger': ['error'], |
| 19 | + 'no-empty': ['warn', { allowEmptyCatch: true }], |
| 20 | + 'no-process-exit': 'off', |
| 21 | + 'no-useless-escape': 'off', |
| 22 | + 'prefer-const': [ |
| 23 | + 'warn', |
| 24 | + { |
| 25 | + destructuring: 'all' |
| 26 | + } |
| 27 | + ], |
| 28 | + |
| 29 | + 'node/no-missing-import': [ |
| 30 | + 'error', |
| 31 | + { |
| 32 | + allowModules: [ |
| 33 | + 'types', |
| 34 | + 'estree', |
| 35 | + 'testUtils', |
| 36 | + 'less', |
| 37 | + 'sass', |
| 38 | + 'stylus' |
| 39 | + ], |
| 40 | + tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'] |
| 41 | + } |
| 42 | + ], |
| 43 | + 'node/no-missing-require': [ |
| 44 | + 'error', |
| 45 | + { |
| 46 | + // for try-catching yarn pnp |
| 47 | + allowModules: ['pnpapi', 'vite'], |
| 48 | + tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'] |
| 49 | + } |
| 50 | + ], |
| 51 | + 'node/no-restricted-require': [ |
| 52 | + 'error', |
| 53 | + Object.keys(require('./packages/vite/package.json').devDependencies).map( |
| 54 | + (d) => ({ |
| 55 | + name: d, |
| 56 | + message: |
| 57 | + `devDependencies can only be imported using ESM syntax so ` + |
| 58 | + `that they are included in the rollup bundle. If you are trying to ` + |
| 59 | + `lazy load a dependency, use (await import('dependency')).default instead.` |
| 60 | + }) |
| 61 | + ) |
| 62 | + ], |
| 63 | + 'node/no-extraneous-import': [ |
| 64 | + 'error', |
| 65 | + { |
| 66 | + allowModules: ['vite', 'less', 'sass'] |
| 67 | + } |
| 68 | + ], |
| 69 | + 'node/no-extraneous-require': [ |
| 70 | + 'error', |
| 71 | + { |
| 72 | + allowModules: ['vite'] |
| 73 | + } |
| 74 | + ], |
| 75 | + 'node/no-deprecated-api': 'off', |
| 76 | + 'node/no-unpublished-import': 'off', |
| 77 | + 'node/no-unpublished-require': 'off', |
| 78 | + 'node/no-unsupported-features/es-syntax': 'off', |
| 79 | + |
| 80 | + '@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR |
| 81 | + '@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR |
| 82 | + '@typescript-eslint/no-empty-function': [ |
| 83 | + 'error', |
| 84 | + { allow: ['arrowFunctions'] } |
| 85 | + ], |
| 86 | + '@typescript-eslint/no-empty-interface': 'off', |
| 87 | + '@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR |
| 88 | + '@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier |
| 89 | + '@typescript-eslint/no-inferrable-types': 'off', |
| 90 | + '@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR |
| 91 | + '@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR |
| 92 | + '@typescript-eslint/no-var-requires': 'off' |
| 93 | + }, |
| 94 | + overrides: [ |
| 95 | + { |
| 96 | + files: ['packages/vite/src/node/**'], |
| 97 | + rules: { |
| 98 | + 'no-console': ['error'] |
| 99 | + } |
| 100 | + }, |
| 101 | + { |
| 102 | + files: ['packages/vite/types/**'], |
| 103 | + rules: { |
| 104 | + 'node/no-extraneous-import': 'off' |
| 105 | + } |
| 106 | + }, |
| 107 | + { |
| 108 | + files: ['packages/playground/**'], |
| 109 | + rules: { |
| 110 | + 'node/no-extraneous-import': 'off', |
| 111 | + 'node/no-extraneous-require': 'off' |
| 112 | + } |
| 113 | + }, |
| 114 | + { |
| 115 | + files: ['packages/create-vite/template-*/**'], |
| 116 | + rules: { |
| 117 | + 'node/no-missing-import': 'off' |
| 118 | + } |
| 119 | + }, |
| 120 | + { |
| 121 | + files: ['*.js'], |
| 122 | + rules: { |
| 123 | + '@typescript-eslint/explicit-module-boundary-types': 'off' |
| 124 | + } |
| 125 | + }, |
| 126 | + { |
| 127 | + files: ['*.d.ts'], |
| 128 | + rules: { |
| 129 | + '@typescript-eslint/triple-slash-reference': 'off' |
| 130 | + } |
| 131 | + } |
| 132 | + ] |
| 133 | +}) |
0 commit comments