Files
knowai/eslint.config.js
tobegold574 b74c01340c feat(image): 新建knowai-ui:1.0.0镜像并完成推送
- 最终完成16个组件的搭建,覆盖常用组件和布局
- 通过tsc eslint完成测试,vitest测试因未知问题放弃(但保留测试文件)

BREAKING CHANGE: 新镜像分支
2025-11-14 14:48:18 +08:00

105 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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',
},
},
];