-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.ts
More file actions
103 lines (91 loc) · 3.5 KB
/
eslint.config.ts
File metadata and controls
103 lines (91 loc) · 3.5 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier/flat";
import unicorn from "eslint-plugin-unicorn";
// eslint-disable-next-line @typescript-eslint/no-deprecated -- defineConfig() unavailable in this version
export default tseslint.config(
// Global ignores
{
ignores: [
"dist/",
"node_modules/",
"coverage/",
"opencode_analysis/",
"pi-mono-main/",
"scripts/**/*.mjs",
"**/*.cjs",
],
},
// Base recommended rules
eslint.configs.recommended,
// TypeScript strict + stylistic (type-checked)
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// TypeScript parser config
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ["eslint.config.ts", "vitest.config.ts"],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
// Modern JavaScript/TypeScript patterns (replaces eslint-plugin-security + eslint-plugin-sonarjs)
unicorn.configs.recommended,
// Custom rules
{
rules: {
// CLI tool uses console as primary output
"no-console": ["warn", { allow: ["warn", "error", "info", "log"] }],
// Unused vars: match Ruff F841 with underscore ignore
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
// Allow numbers/booleans in template literals (common CLI pattern)
"@typescript-eslint/restrict-template-expressions": [
"error",
{ allowNumber: true, allowBoolean: true },
],
// Unicorn: disable opinionated rules that conflict with CLI patterns
"unicorn/prevent-abbreviations": "off",
"unicorn/no-null": "off",
"unicorn/no-process-exit": "off",
"unicorn/prefer-top-level-await": "off",
// CLI uses named imports from node: modules extensively
"unicorn/import-style": "off",
// Hooks require inline arrow functions
"unicorn/consistent-function-scoping": "off",
// Node.js CLI uses EventEmitter, not DOM EventTarget
"unicorn/prefer-event-target": "off",
// .map(fn) is idiomatic; wrapping in arrow is noise
"unicorn/no-array-callback-reference": "off",
// pi-tui Component uses removeChild(), not DOM .remove()
"unicorn/prefer-dom-node-remove": "off",
// Noop stubs and fire-and-forget .catch(() => {}) are idiomatic
"@typescript-eslint/no-empty-function": "off",
// Resolve strictTypeChecked vs stylisticTypeChecked conflict:
// no-non-null-assertion (strict) forbids `x!`, non-nullable-type-assertion-style (stylistic) requires it.
// Prioritize type-safety: keep the forbid rule, disable the stylistic one that demands `!`.
"@typescript-eslint/non-nullable-type-assertion-style": "off",
},
},
// Test files: disable type-checked rules (tests excluded from tsconfig)
{
files: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "tests/**/*.ts"],
...tseslint.configs.disableTypeChecked,
rules: {
...tseslint.configs.disableTypeChecked.rules,
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"no-console": "off",
},
},
// Prettier last (disables formatting rules)
eslintConfigPrettier
);