2026-09-11 21:57:38 +08:00
|
|
|
|
import tseslint from 'typescript-eslint';
|
|
|
|
|
|
import pluginVue from 'eslint-plugin-vue';
|
|
|
|
|
|
import vueParser from 'vue-eslint-parser';
|
|
|
|
|
|
|
|
|
|
|
|
const sharedGlobals = {
|
|
|
|
|
|
console: 'readonly',
|
|
|
|
|
|
process: 'readonly',
|
|
|
|
|
|
Buffer: 'readonly',
|
|
|
|
|
|
__dirname: 'readonly',
|
|
|
|
|
|
__filename: 'readonly',
|
|
|
|
|
|
setTimeout: 'readonly',
|
|
|
|
|
|
clearTimeout: 'readonly',
|
|
|
|
|
|
setInterval: 'readonly',
|
|
|
|
|
|
clearInterval: 'readonly',
|
|
|
|
|
|
URL: 'readonly',
|
|
|
|
|
|
URLSearchParams: 'readonly',
|
|
|
|
|
|
fetch: 'readonly',
|
|
|
|
|
|
global: 'readonly',
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default tseslint.config(
|
|
|
|
|
|
{
|
|
|
|
|
|
ignores: [
|
|
|
|
|
|
'**/node_modules/**',
|
|
|
|
|
|
'**/dist/**',
|
|
|
|
|
|
'**/dist-electron/**',
|
|
|
|
|
|
'**/release/**',
|
2026-09-12 00:20:21 +08:00
|
|
|
|
'**/release-server/**',
|
2026-09-27 14:59:12 +08:00
|
|
|
|
// 交付产物归集目录(pnpm dist:* 的输出,见 AGENTS.md §4):里面是构建后的压缩 JS,不该进 lint
|
|
|
|
|
|
'**/releases/**',
|
2026-09-12 00:20:21 +08:00
|
|
|
|
'**/build/**',
|
2026-09-11 21:57:38 +08:00
|
|
|
|
'**/coverage/**',
|
|
|
|
|
|
'**/src/generated/**',
|
|
|
|
|
|
'**/.cache/**',
|
|
|
|
|
|
'**/.pnpm-store/**',
|
|
|
|
|
|
'**/.probe/**',
|
|
|
|
|
|
'**/*.d.ts',
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
...tseslint.configs.recommended,
|
|
|
|
|
|
...pluginVue.configs['flat/recommended'],
|
2026-09-12 00:20:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
// Electron 主进程脚本(图标渲染、UI 冒烟)必须是 CommonJS,允许 require
|
|
|
|
|
|
files: ['**/*.cjs'],
|
|
|
|
|
|
languageOptions: {
|
|
|
|
|
|
ecmaVersion: 'latest',
|
|
|
|
|
|
sourceType: 'commonjs',
|
|
|
|
|
|
globals: sharedGlobals,
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
'@typescript-eslint/no-require-imports': 'off',
|
|
|
|
|
|
'@typescript-eslint/no-var-requires': 'off',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2026-09-11 21:57:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
files: ['**/*.vue'],
|
|
|
|
|
|
languageOptions: {
|
|
|
|
|
|
parser: vueParser,
|
|
|
|
|
|
parserOptions: {
|
|
|
|
|
|
parser: tseslint.parser,
|
|
|
|
|
|
ecmaVersion: 'latest',
|
|
|
|
|
|
sourceType: 'module',
|
|
|
|
|
|
extraFileExtensions: ['.vue'],
|
|
|
|
|
|
},
|
|
|
|
|
|
globals: sharedGlobals,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
files: ['**/*.{ts,mts,cts,js,mjs,cjs,vue}'],
|
|
|
|
|
|
languageOptions: {
|
|
|
|
|
|
ecmaVersion: 'latest',
|
|
|
|
|
|
sourceType: 'module',
|
|
|
|
|
|
globals: sharedGlobals,
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
'no-console': 'off',
|
|
|
|
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
|
|
|
|
'@typescript-eslint/no-unused-vars': [
|
|
|
|
|
|
'warn',
|
|
|
|
|
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
|
|
|
|
|
|
],
|
|
|
|
|
|
'@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports' }],
|
|
|
|
|
|
// Vue 组件名使用多单词(Element Plus 视图文件均为 XxxView.vue)
|
|
|
|
|
|
'vue/multi-word-component-names': 'off',
|
|
|
|
|
|
'vue/max-attributes-per-line': 'off',
|
|
|
|
|
|
'vue/singleline-html-element-content-newline': 'off',
|
|
|
|
|
|
'vue/html-self-closing': 'off',
|
|
|
|
|
|
'vue/attributes-order': 'off',
|
|
|
|
|
|
'vue/html-indent': 'off',
|
|
|
|
|
|
'vue/html-closing-bracket-newline': 'off',
|
|
|
|
|
|
'vue/first-attribute-linebreak': 'off',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|