- 最终完成16个组件的搭建,覆盖常用组件和布局 - 通过tsc eslint完成测试,vitest测试因未知问题放弃(但保留测试文件) BREAKING CHANGE: 新镜像分支
105 lines
2.9 KiB
JavaScript
105 lines
2.9 KiB
JavaScript
import js from '@eslint/js';
|
||
import typescript from '@typescript-eslint/eslint-plugin';
|
||
import typescriptParser from '@typescript-eslint/parser';
|
||
import vueEslintPlugin from 'eslint-plugin-vue';
|
||
|
||
export default [
|
||
js.configs.recommended,
|
||
...vueEslintPlugin.configs['flat/recommended'],
|
||
{
|
||
ignores: [
|
||
'**/*.test.ts',
|
||
'**/*.spec.ts',
|
||
'test/**',
|
||
'dist/**',
|
||
'node_modules/**',
|
||
'coverage/**',
|
||
'*.config.js',
|
||
'*.config.ts',
|
||
],
|
||
},
|
||
// Vue文件规则
|
||
{
|
||
files: ['**/*.vue'],
|
||
languageOptions: {
|
||
parser: vueEslintPlugin.parser,
|
||
parserOptions: {
|
||
ecmaVersion: 'latest',
|
||
sourceType: 'module',
|
||
parser: typescriptParser,
|
||
projectService: false, // 用tsc检查过了
|
||
extraFileExtensions: ['.vue'], // 添加.vue作为额外文件扩展名
|
||
},
|
||
},
|
||
plugins: {
|
||
'@typescript-eslint': typescript,
|
||
vue: vueEslintPlugin,
|
||
},
|
||
rules: {
|
||
// Vue特定规则
|
||
'vue/multi-word-component-names': 'off',
|
||
'vue/no-v-model-argument': 'error',
|
||
'vue/script-setup-uses-vars': 'error',
|
||
|
||
// TypeScript规则
|
||
'@typescript-eslint/no-unused-vars': ['error', {
|
||
argsIgnorePattern: '^_',
|
||
varsIgnorePattern: '^[A-Z_]+$'
|
||
}],
|
||
|
||
// 通用规则
|
||
'no-unused-vars': 'off',
|
||
'no-console': 'warn',
|
||
'no-debugger': 'error',
|
||
'no-var': 'error',
|
||
'prefer-const': 'error',
|
||
|
||
// 代码风格
|
||
'indent': ['error', 2, { SwitchCase: 1 }],
|
||
'quotes': ['error', 'single', { avoidEscape: true }],
|
||
'semi': ['error', 'always'],
|
||
'comma-dangle': ['error', 'never'],
|
||
'eol-last': ['warn', 'always'],
|
||
'no-trailing-spaces': 'warn',
|
||
},
|
||
},
|
||
// TypeScript文件规则(排除测试文件)
|
||
{
|
||
files: ['**/*.ts', '**/*.tsx'],
|
||
ignores: ['**/*.test.ts', '**/*.spec.ts', 'test/**/*.ts'],
|
||
languageOptions: {
|
||
parser: typescriptParser,
|
||
parserOptions: {
|
||
ecmaVersion: 'latest',
|
||
sourceType: 'module',
|
||
projectService: false, // 禁用projectService以提高性能
|
||
},
|
||
},
|
||
plugins: {
|
||
'@typescript-eslint': typescript,
|
||
},
|
||
rules: {
|
||
'no-unused-vars': 'off',
|
||
'@typescript-eslint/no-unused-vars': ['error', {
|
||
argsIgnorePattern: '^_',
|
||
varsIgnorePattern: '^[A-Z_]+$'
|
||
}],
|
||
'@typescript-eslint/no-explicit-any': 'warn',
|
||
'@typescript-eslint/no-non-null-assertion': 'warn',
|
||
|
||
// 通用规则
|
||
'no-console': 'warn',
|
||
'no-debugger': 'error',
|
||
'no-var': 'error',
|
||
'prefer-const': 'error',
|
||
|
||
// 代码风格
|
||
'indent': ['error', 2, { SwitchCase: 1 }],
|
||
'quotes': ['error', 'single', { avoidEscape: true }],
|
||
'semi': ['error', 'always'],
|
||
'comma-dangle': ['error', 'never'],
|
||
'eol-last': ['warn', 'always'],
|
||
'no-trailing-spaces': 'warn',
|
||
},
|
||
},
|
||
]; |