vite/.eslintrc.js

134 lines
3.5 KiB
JavaScript
Raw Permalink Normal View History

// @ts-check
const { defineConfig } = require('eslint-define-config')
module.exports = defineConfig({
2020-12-08 10:55:12 +00:00
root: true,
2021-04-25 11:34:25 +00:00
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended'
],
2020-12-08 10:55:12 +00:00
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021
2020-12-08 10:55:12 +00:00
},
rules: {
2021-07-13 15:05:08 +00:00
eqeqeq: ['warn', 'always', { null: 'never' }],
'no-debugger': ['error'],
2021-04-25 11:34:25 +00:00
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-process-exit': 'off',
'no-useless-escape': 'off',
'prefer-const': [
'warn',
{
destructuring: 'all'
}
],
2020-12-08 10:55:12 +00:00
'node/no-missing-import': [
'error',
{
2021-09-24 20:21:04 +00:00
allowModules: [
'types',
'estree',
'testUtils',
'less',
'sass',
'stylus'
],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
2020-12-08 10:55:12 +00:00
}
],
'node/no-missing-require': [
'error',
{
// for try-catching yarn pnp
2021-09-24 20:21:04 +00:00
allowModules: ['pnpapi', 'vite'],
tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts']
2020-12-08 10:55:12 +00:00
}
],
'node/no-restricted-require': [
'error',
Object.keys(require('./packages/vite/package.json').devDependencies).map(
(d) => ({
name: d,
message:
`devDependencies can only be imported using ESM syntax so ` +
`that they are included in the rollup bundle. If you are trying to ` +
2021-03-27 06:31:18 +00:00
`lazy load a dependency, use (await import('dependency')).default instead.`
2020-12-08 10:55:12 +00:00
})
)
],
2020-12-09 09:54:10 +00:00
'node/no-extraneous-import': [
2020-12-09 08:26:05 +00:00
'error',
{
allowModules: ['vite', 'less', 'sass']
2020-12-09 08:26:05 +00:00
}
],
2020-12-09 20:41:13 +00:00
'node/no-extraneous-require': [
'error',
{
allowModules: ['vite']
}
],
2020-12-08 10:55:12 +00:00
'node/no-deprecated-api': 'off',
2020-12-10 04:40:34 +00:00
'node/no-unpublished-import': 'off',
2020-12-24 20:30:07 +00:00
'node/no-unpublished-require': 'off',
2020-12-08 10:55:12 +00:00
'node/no-unsupported-features/es-syntax': 'off',
2021-04-25 11:34:25 +00:00
'@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR
'@typescript-eslint/no-empty-function': [
'error',
{ allow: ['arrowFunctions'] }
],
'@typescript-eslint/no-empty-interface': 'off',
2021-04-25 11:34:25 +00:00
'@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR
'@typescript-eslint/no-var-requires': 'off'
2020-12-18 22:13:18 +00:00
},
overrides: [
{
files: ['packages/vite/src/node/**'],
rules: {
'no-console': ['error']
}
},
2021-09-24 20:21:04 +00:00
{
files: ['packages/vite/types/**'],
rules: {
'node/no-extraneous-import': 'off'
}
},
{
2020-12-20 03:33:13 +00:00
files: ['packages/playground/**'],
rules: {
2020-12-20 03:33:13 +00:00
'node/no-extraneous-import': 'off',
'node/no-extraneous-require': 'off'
}
2021-01-05 06:04:20 +00:00
},
{
files: ['packages/create-vite/template-*/**'],
2021-01-05 06:04:20 +00:00
rules: {
'node/no-missing-import': 'off'
}
},
{
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/triple-slash-reference': 'off'
}
2020-12-18 22:13:18 +00:00
}
]
})