Files
ChatLab/eslint.config.mjs
T

90 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 pluginVue from 'eslint-plugin-vue'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import vuePrettierConfig from '@vue/eslint-config-prettier'
import globals from 'globals'
export default defineConfigWithVueTs(
{
ignores: ['node_modules', 'dist', 'out', '.gitignore'],
},
// ESLint 推荐规则
js.configs.recommended,
// Vue 3 推荐规则(flat config 格式)
...pluginVue.configs['flat/recommended'],
// Vue + TypeScript 推荐规则
vueTsConfigs.recommended,
// 全局环境变量(替代 @electron-toolkit 基础配置中的 env 设置)
{
languageOptions: {
ecmaVersion: 2021,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
...globals.commonjs,
...globals.es2021,
},
parserOptions: {
ecmaFeatures: { jsx: true },
},
},
},
// Prettier(@vue/eslint-config-prettier v10+ 已是 flat config 格式)
vuePrettierConfig,
// 自定义规则
{
rules: {
// Vue 规则放宽
'vue/require-default-prop': 'off',
'vue/multi-word-component-names': 'off',
// 项目中有受控的 HTML 渲染场景(如 Markdown/高亮结果),统一关闭该告警。
'vue/no-v-html': 'off',
// TypeScript 规则放宽(项目约定)
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
// 来自 @electron-toolkit/eslint-config-ts/eslint-recommended
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
},
// E2E Node helper/test 使用 CommonJS,允许 require
{
files: ['tests/e2e/**/*.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
// desktop 侧 better-sqlite3 必须显式携带 Electron-ABI nativeBinding,
// 否则 dev 环境会加载 node_modules 的 Node ABI 绑定并触发 NODE_MODULE_VERSION 报错。
// 新代码请优先走统一入口:worker 用 dbCore openRawDatabase()/openDatabase(),
// 主进程用 database/core 的 openDatabase()/createDatabase()。
{
files: ['apps/desktop/**/*.ts'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: "NewExpression[callee.name='Database']:not(:has(Property[key.name='nativeBinding']))",
message:
'Desktop new Database() must pass nativeBinding. Use dbCore openRawDatabase()/openDatabase() in workers, or database/core helpers (resolveDesktopNativeBinding()) in the main process.',
},
],
},
}
)