eslint.config.js
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* ESLint flat config(根)—— 装配本地架构红线 plugin + 基础 JS 规则。
*
* 声明式:判定逻辑全在 `tools/eslint-rules/*.js`,红线装配(白名单 / 规则集 / globals)
* 单源于 `tools/eslint-rules/config.js`,本文件与 `packages/config/eslint` 都从那里 import,
* 不各自再抄一份。根配置只 import 相对路径的 `tools/eslint-rules/*`,不 import 任何 workspace 包
* (避免把 config 的依赖拖进 lint 链)。
*
* composition-root / vite 配置白名单在单源 `config.js` 里维护,新增豁免点先改任务文档再改那里。
*/
import js from '@eslint/js'
import { dramaPlugin } from './tools/eslint-rules/index.js'
import {
buildArchRules,
BASE_GLOBALS,
BROWSER_GLOBALS,
COMMONJS_GLOBALS,
} from './tools/eslint-rules/config.js'
const ARCH_RULES = buildArchRules()
export default [
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/coverage/**',
'tmp/**',
],
},
js.configs.recommended,
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
ecmaVersion: 2023,
sourceType: 'module',
globals: {
...BASE_GLOBALS,
...BROWSER_GLOBALS,
},
},
plugins: { drama: dramaPlugin },
rules: { ...ARCH_RULES },
},
{
files: ['**/*.cjs'],
languageOptions: {
ecmaVersion: 2023,
sourceType: 'commonjs',
globals: { ...COMMONJS_GLOBALS },
},
plugins: { drama: dramaPlugin },
rules: { ...ARCH_RULES },
},
{
// 规则/预设单测 fixture 含故意违规代码与故意的 env 操作,不参与全仓 lint。
ignores: ['tools/eslint-rules/test/**', 'packages/config/test/**'],
},
]