Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
282 lines (268 loc) · 6.47 KB
/
Copy patheslint.config.js
File metadata and controls
282 lines (268 loc) · 6.47 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
import js from "@eslint/js";
import vue from "eslint-plugin-vue";
import ts from "typescript-eslint";
import globals from "globals";
// app code never imports test fixtures; repeated in every block below that
// sets no-restricted-imports for src/ files (a later block replaces the rule)
const noTestData = {
group: ["@prunplanner/test-data", "@prunplanner/test-data/*"],
message: "@prunplanner/test-data is for tests only.",
};
export default [
{
ignores: [
"**/dist/*",
"**/dist-mcp/**",
"**/coverage/**",
"tsconfig.json",
"tailwind.config.js",
],
},
{
languageOptions: {
ecmaVersion: "latest",
globals: {
__APP_VERSION__: "readonly",
__BUILD_ID__: "readonly",
...globals.browser,
...globals.node,
},
},
},
// js
js.configs.recommended,
// ts
...ts.configs.recommended,
{
rules: {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-expressions": [
"error",
{ allowTernary: true },
],
"no-async-promise-executor": "off",
// ensure underscore-prefixed names are ignored for unused-vars
"no-unused-vars": "off", // disable base rule
"@typescript-eslint/no-unused-vars": [
"warn",
{
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
// types: `interface` for object shapes, `import type` for types
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/consistent-type-definitions": [
"error",
"interface",
],
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
fixStyle: "inline-type-imports",
// vitest mocks use `importOriginal<typeof import("…")>()`
disallowTypeAnnotations: false,
},
],
},
},
// schemas are the source of truth: derive types from them, never
// annotate them as `z.ZodType<…>` (only recursive schemas may, with a
// disable comment saying why)
{
files: [
"src/features/api/schemas/**",
"src/**/*.schemas.ts",
"packages/engine/src/schemas/**",
],
rules: {
"no-restricted-syntax": [
"error",
{
selector:
"TSTypeReference[typeName.name='ZodType'], TSTypeReference[typeName.right.name='ZodType']",
message:
"Don't annotate schemas as z.ZodType<…>; derive the type with z.infer.",
},
],
},
},
// tests: loose typing on mock data is fine, dead assertions are not
{
files: ["src/tests/**", "packages/engine/tests/**"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": [
"error",
{ "ts-expect-error": false },
],
},
},
// the engine package (@prunplanner/engine) runs anywhere: it imports only
// its own files (never above packages/engine/src) and zod
{
files: ["packages/engine/src/**"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
regex: "^(?!\\.\\.?/|zod$)",
message:
"The engine package only imports itself and zod.",
},
{
// src/ is at most one folder deep, so ../../ leaves it
regex: "^\\.\\./\\.\\./",
message:
"The engine package only imports itself and zod.",
},
],
},
],
},
},
// the engine's tests and scripts stay inside the package too: its own
// files, zod, vitest, node: builtins and the fixtures package
{
files: ["packages/engine/tests/**", "packages/engine/scripts/**"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
regex: "^(?!\\.\\.?/|zod$|vitest$|node:|@prunplanner/test-data(/|$))",
message:
"Engine tests import the package, zod, vitest, node: and @prunplanner/test-data.",
},
{
// tests/ is at most one folder deep: ../../../ leaves the
// package, and so does ../../ unless it goes into src/
regex: "^\\.\\./\\.\\./(\\.\\./|(?!src/))",
message:
"Engine tests import the package, zod, vitest, node: and @prunplanner/test-data.",
},
],
},
],
},
},
// fixtures (@prunplanner/test-data) are for tests only, never app code
{
files: ["src/**"],
ignores: ["src/tests/**"],
rules: {
"no-restricted-imports": ["error", { patterns: [noTestData] }],
},
},
// production chain engine: plain TypeScript, no Vue, stores or data layer
{
files: ["src/features/production_chain/engine/**"],
rules: {
"no-restricted-imports": [
"error",
{
paths: ["vue", "pinia"].map((name) => ({
name,
message: "The planning engine must not import Vue.",
})),
patterns: [
{
group: ["@vue/*", "vue-*"],
message: "The planning engine must not import Vue.",
},
{
group: [
"@/stores/*",
"!@/stores/*.types",
"@/database/*",
],
message:
"The planning engine gets its data through IPlanContext.",
},
noTestData,
],
},
],
},
},
// MCP server: Node only, no Vue, i18n, stores, data layer or UI
// (docs/mcp.md)
{
files: ["src/mcp/**"],
rules: {
"no-restricted-imports": [
"error",
{
paths: ["vue", "pinia", "vue-i18n", "axios"].map(
(name) => ({
name,
message:
"The MCP server runs in Node without the app.",
})
),
patterns: [
{
group: [
"@vue/*",
"vue-*",
"@/lib/*",
"@/ui/*",
"@/util/numbers",
"**/*.vue",
],
message:
"The MCP server runs in Node without the app.",
},
{
// stores and the data layer, their *.types files allowed
regex: "^@/(stores|database)/(?!.*\\.types$)",
message:
"The MCP server runs in Node without the app.",
},
noTestData,
],
},
],
},
},
// vue
...vue.configs["flat/recommended"],
{
files: ["*.vue", "**/*.vue"],
languageOptions: {
parserOptions: {
parser: ts.parser,
},
},
},
{
rules: {
"vue/no-unused-vars": ["error", { ignorePattern: "^_" }],
"vue/max-attributes-per-line": "off",
"vue/multiline-html-element-content-newline": "off",
"vue/html-indent": "off",
"vue/singleline-html-element-content-newline": "off",
"vue/html-closing-bracket-newline": "off",
"vue/html-self-closing": "off",
"vue/no-unused-components": [
"error",
{
ignoreWhenBindingPresent: true,
},
],
"vue/no-unused-properties": [
"warn",
{
groups: ["props", "setup"],
deepData: false,
},
],
},
},
];