86 lines
2.1 KiB
JavaScript
86 lines
2.1 KiB
JavaScript
/* eslint-env node */
|
|
require('@rushstack/eslint-patch/modern-module-resolution')
|
|
|
|
module.exports = {
|
|
root: true,
|
|
extends: [
|
|
'plugin:vue/vue3-essential',
|
|
'eslint:recommended',
|
|
'@vue/eslint-config-typescript',
|
|
'@vue/eslint-config-prettier/skip-formatting',
|
|
'./.eslintrc-auto-import.json'
|
|
],
|
|
parserOptions: {
|
|
ecmaVersion: 'latest'
|
|
},
|
|
env: {
|
|
node: true,
|
|
browser: true,
|
|
es2022: true
|
|
},
|
|
globals: {
|
|
defineEmits: 'readonly',
|
|
defineProps: 'readonly',
|
|
defineExpose: 'readonly',
|
|
withDefaults: 'readonly'
|
|
},
|
|
rules: {
|
|
// Vue规则
|
|
'vue/multi-word-component-names': 'off',
|
|
'vue/no-v-html': 'off',
|
|
'vue/require-default-prop': 'off',
|
|
'vue/require-explicit-emits': 'off',
|
|
'vue/html-self-closing': [
|
|
'error',
|
|
{
|
|
html: {
|
|
void: 'always',
|
|
normal: 'always',
|
|
component: 'always'
|
|
},
|
|
svg: 'always',
|
|
math: 'always'
|
|
}
|
|
],
|
|
|
|
// TypeScript规则
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_'
|
|
}
|
|
],
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
'@typescript-eslint/ban-ts-comment': 'off',
|
|
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
|
|
|
// 通用规则
|
|
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
'no-unused-vars': 'off', // 使用TypeScript版本
|
|
'prefer-const': 'error',
|
|
'no-var': 'error',
|
|
|
|
// 代码风格
|
|
'eqeqeq': ['error', 'always'],
|
|
'curly': ['error', 'all'],
|
|
'brace-style': ['error', '1tbs'],
|
|
'comma-dangle': ['error', 'never'],
|
|
'quotes': ['error', 'single', { avoidEscape: true }],
|
|
'semi': ['error', 'never']
|
|
},
|
|
overrides: [
|
|
{
|
|
files: ['cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'],
|
|
extends: ['plugin:cypress/recommended']
|
|
},
|
|
{
|
|
files: ['src/**/__tests__/**/*', 'src/**/*.{test,spec}.*'],
|
|
env: {
|
|
vitest: true
|
|
}
|
|
}
|
|
]
|
|
}
|