Files

96 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

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/**',
'**/release-server/**',
// 交付产物归集目录(pnpm dist:* 的输出,见 AGENTS.md 的现行工程约定):里面是构建后的压缩 JS,不该进 lint
'**/releases/**',
'**/build/**',
'**/coverage/**',
'**/src/generated/**',
'**/.cache/**',
'**/.pnpm-store/**',
'**/.probe/**',
// 文档站(docfx)的构建产物:里面是 docfx 模板自带的压缩 JS 与生成的 HTML
'**/docs/_site/**',
'**/*.d.ts',
],
},
...tseslint.configs.recommended,
...pluginVue.configs['flat/recommended'],
{
// 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',
},
},
{
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',
},
},
);