forked from Cloud-Pipelines/pipeline-editor
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patheslint.config.js
More file actions
215 lines (211 loc) · 6.82 KB
/
eslint.config.js
File metadata and controls
215 lines (211 loc) · 6.82 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
import pluginJs from "@eslint/js";
import noRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
import pluginPlaywright from "eslint-plugin-playwright";
import pluginReact from "eslint-plugin-react";
import reactCompiler from "eslint-plugin-react-compiler";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import globals from "globals";
import tseslint from "typescript-eslint";
import { REACT_COMPILER_ENABLED_GLOBS } from "./react-compiler.config.js";
const baseRestrictedImportPaths = [
{
name: "@/components/ui",
message:
"Use absolute imports for '@/components/ui' instead of relative imports.",
},
];
const baseRestrictedImportPatterns = [
{
group: ["**/ui/*", "!@/components/ui/*", "!**/argo-workflows/ui/*"],
message:
"Only '@/components/ui/*' is allowed for importing from the ui folder.",
},
];
/** @type {import('eslint').Linter.Config[]} */
export default [
{ files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
{
rules: {
"@typescript-eslint/no-explicit-any": "off",
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
vars: "all",
args: "after-used",
ignoreRestSiblings: true,
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"react-compiler/react-compiler": "error",
"no-restricted-imports": [
"error",
{
paths: baseRestrictedImportPaths,
patterns: baseRestrictedImportPatterns,
},
],
},
plugins: {
"simple-import-sort": simpleImportSort,
"react-compiler": reactCompiler,
},
},
// React Compiler enabled directories: warn about unnecessary useCallback/useMemo
{
files: REACT_COMPILER_ENABLED_GLOBS,
rules: {
"no-restricted-syntax": [
"warn",
{
selector: "CallExpression[callee.name='useCallback']",
message:
"useCallback is unnecessary with React Compiler. The compiler auto-memoizes functions.",
},
{
selector: "CallExpression[callee.name='useMemo']",
message:
"useMemo may be unnecessary with React Compiler. The compiler auto-memoizes values.",
},
],
},
},
{
files: ["src/routes/v2/**/*.{ts,tsx}"],
plugins: {
"no-relative-import-paths": noRelativeImportPaths,
},
rules: {
"no-relative-import-paths/no-relative-import-paths": [
"error",
{
allowSameFolder: true,
rootDir: "src",
prefix: "@",
},
],
},
},
// v2 Architecture boundary: shared/ must not import from any page
{
files: ["src/routes/v2/shared/**/*.{ts,tsx}"],
rules: {
"no-restricted-imports": [
"error",
{
paths: baseRestrictedImportPaths,
patterns: [
...baseRestrictedImportPatterns,
{
group: ["@/routes/v2/pages/**"],
message:
"shared/ must not import from pages/. Dependency direction: pages → shared, never the reverse. See src/routes/v2/ARCHITECTURE.md.",
},
],
},
],
},
},
// v2 Architecture boundary: Editor must not import from other pages
{
files: ["src/routes/v2/pages/Editor/**/*.{ts,tsx}"],
rules: {
"no-restricted-imports": [
"error",
{
paths: baseRestrictedImportPaths,
patterns: [
...baseRestrictedImportPatterns,
{
group: ["@/routes/v2/pages/RunView/**"],
message:
"Editor must not import from RunView. Pages cannot depend on each other. See src/routes/v2/ARCHITECTURE.md.",
},
{
group: ["@/routes/v2/pages/PipelineFolders/**"],
message:
"Editor must not import from PipelineFolders. Pages cannot depend on each other. See src/routes/v2/ARCHITECTURE.md.",
},
],
},
],
},
},
// v2 Architecture boundary: RunView must not import from other pages
{
files: ["src/routes/v2/pages/RunView/**/*.{ts,tsx}"],
rules: {
"no-restricted-imports": [
"error",
{
paths: baseRestrictedImportPaths,
patterns: [
...baseRestrictedImportPatterns,
{
group: ["@/routes/v2/pages/Editor/**"],
message:
"RunView must not import from Editor. Pages cannot depend on each other. See src/routes/v2/ARCHITECTURE.md.",
},
{
group: ["@/routes/v2/pages/PipelineFolders/**"],
message:
"RunView must not import from PipelineFolders. Pages cannot depend on each other. See src/routes/v2/ARCHITECTURE.md.",
},
],
},
],
},
},
// v2 Architecture boundary: PipelineFolders must not import from other pages
{
files: ["src/routes/v2/pages/PipelineFolders/**/*.{ts,tsx}"],
rules: {
"no-restricted-imports": [
"error",
{
paths: baseRestrictedImportPaths,
patterns: [
...baseRestrictedImportPatterns,
{
group: ["@/routes/v2/pages/Editor/**"],
message:
"PipelineFolders must not import from Editor. Pages cannot depend on each other. See src/routes/v2/ARCHITECTURE.md.",
},
{
group: ["@/routes/v2/pages/RunView/**"],
message:
"PipelineFolders must not import from RunView. Pages cannot depend on each other. See src/routes/v2/ARCHITECTURE.md.",
},
],
},
],
},
},
{
ignores: ["src/api/**/*"],
},
// Playwright E2E test rules
{
files: ["tests/e2e/**/*.ts"],
...pluginPlaywright.configs["flat/recommended"],
rules: {
...pluginPlaywright.configs["flat/recommended"].rules,
// Enforce Playwright best practices
"playwright/no-wait-for-timeout": "error", // Prevent page.waitForTimeout()
"playwright/prefer-web-first-assertions": "error", // Use await expect(element).toBeVisible()
"playwright/no-conditional-in-test": "warn", // Avoid if/else based on element state
"playwright/no-standalone-expect": "error", // Ensure expects are awaited
"playwright/expect-expect": "warn", // Ensure tests have assertions
"playwright/no-skipped-test": "warn", // Warn about test.skip()
"@typescript-eslint/no-non-null-assertion": "error", // Prevent non-null assertions (!)
},
},
];