Repository navigation
Expand file tree
/
Copy patheslint.config.cjs
More file actions
359 lines (353 loc) · 10.1 KB
/
Copy patheslint.config.cjs
File metadata and controls
359 lines (353 loc) · 10.1 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/**
* ESLint Flat Configuration (CommonJS format)
*
* Converted from ESM to CommonJS for compatibility.
* Load environment variables from .env file
* Enables configuration customization via environment variables
*/
require("dotenv").config();
const js = require("@eslint/js");
const tsPlugin = require("@typescript-eslint/eslint-plugin");
const tsParser = require("@typescript-eslint/parser");
const prettierConfig = require("eslint-config-prettier");
/**
* Generate ignore patterns for ESLint
*
* Supports environment variable override via ESLINT_IGNORE (comma-separated list)
* Default patterns exclude build artifacts, dependencies, and template files
*
* @type {string[]} Array of glob patterns to ignore
*/
const ignoreFolders = process.env.ESLINT_IGNORE
? process.env.ESLINT_IGNORE.split(",")
: [
"node_modules/**", // Third-party dependencies
"build/**", // Build output
"dist/**", // Distribution files
"website/dist/**", // Website build output
"coverage/**", // Test coverage reports
"test-results/**", // Test artifacts
"vendor/**", // Vendor libraries
".next/**", // Next.js build cache
"logs/**", // Application logs
"tmp/**", // Temporary files
".cache/**", // Cache directories
".husky/**", // Git hooks
".vercel/**", // Vercel deployment
".netlify/**", // Netlify deployment
".storybook/**", // Storybook build
".astro/**", // Astro build cache and generated types
"website/**/.astro/**", // Website Astro generated files
"docs/mustache-repo-templates/**", // Template files
"scripts/utility/__tests__/**", // Test files
"scripts/utility/__fixtures__/**", // Test fixtures
"skills/design-md-agent/figma-use/references/plugin-api-standalone.d.ts", // Imported Figma API typings
"**/figma-use/references/plugin-api-standalone.d.ts", // Same vendored typings, copied under agents/*
"skills/webmcpify/templates/**", // Vendored MCP-SDK templates (types not installed here)
];
/**
* Globals shared by every Node-executed file in this repository.
*
* Declared once here rather than repeated per block. The `**` + `/*.cjs` block
* previously carried no `globals` at all, which is why every `.cjs` test file
* reported `describe`, `it`, `expect`, `console` and `process` as undefined -
* roughly 1,700 `no-undef` errors that were configuration, not code.
*
* @type {Record<string, "readonly">}
*/
const nodeGlobals = {
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
clearImmediate: "readonly",
clearInterval: "readonly",
clearTimeout: "readonly",
console: "readonly",
global: "readonly",
process: "readonly",
setImmediate: "readonly",
setInterval: "readonly",
setTimeout: "readonly",
TextDecoder: "readonly",
TextEncoder: "readonly",
// Web-standard globals Node has exposed since v18; the agent scripts use
// these for HTTP and URL handling.
AbortController: "readonly",
URL: "readonly",
URLSearchParams: "readonly",
fetch: "readonly",
};
/**
* CommonJS module globals, for files loaded by `require` rather than `import`.
*
* @type {Record<string, "readonly">}
*/
const commonjsGlobals = {
exports: "readonly",
module: "readonly",
require: "readonly",
};
/**
* Jest test-environment globals.
*
* @type {Record<string, "readonly">}
*/
const jestGlobals = {
afterAll: "readonly",
afterEach: "readonly",
beforeAll: "readonly",
beforeEach: "readonly",
describe: "readonly",
expect: "readonly",
it: "readonly",
jest: "readonly",
test: "readonly",
};
/**
* ESLint Flat Configuration
*
* Uses the flat config format (ESLint 8.23+, default in 9.0+) with:
* - JavaScript recommended rules
* - TypeScript recommended rules
* - eslint-config-prettier to disable formatting rules (Prettier runs separately)
* - Performance-optimized ignore patterns
*
* @type {import('eslint').Linter.FlatConfig[]}
*/
module.exports = [
// Global ignores apply to all configurations
{
ignores: ignoreFolders,
},
// Base JavaScript recommended rules
js.configs.recommended,
// TypeScript specific configuration
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
globals: {
// Node.js globals
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
clearImmediate: "readonly",
clearInterval: "readonly",
clearTimeout: "readonly",
global: "readonly",
process: "readonly",
setImmediate: "readonly",
setInterval: "readonly",
setTimeout: "readonly",
// Jest test environment globals
describe: "readonly",
it: "readonly",
test: "readonly",
expect: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
jest: "readonly",
TextDecoder: "readonly",
TextEncoder: "readonly",
},
},
plugins: {
"@typescript-eslint": tsPlugin,
},
// Merge recommended TypeScript rules
rules: {
...tsPlugin.configs.recommended.rules,
},
},
// CommonJS files (.cjs)
{
files: ["**/*.cjs"],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "commonjs",
},
globals: {
...nodeGlobals,
...commonjsGlobals,
...jestGlobals,
},
},
rules: {
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-console": "off",
},
},
// ES Modules (.mjs and scripts that use import/export)
{
files: [
"**/*.mjs",
"scripts/**/*.js",
".github/agents/**/*.js",
".github/metrics/**/*.js",
".github/scripts/**/*.js",
"docs/ai/**/*.js",
],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
globals: {
...nodeGlobals,
...jestGlobals,
},
},
rules: {
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-console": "off",
},
},
// Standard JavaScript files and test utilities (.js)
{
files: ["**/*.js"],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "commonjs",
},
globals: {
...nodeGlobals,
...commonjsGlobals,
...jestGlobals,
},
},
rules: {
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-console": "off",
},
},
// Browser-based JavaScript files (website scripts)
{
// scripts/dashboard is a browser bundle too, not a Node script.
files: [
"website/src/scripts/**/*.js",
"scripts/dashboard/**/*.js",
],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
globals: {
// Browser globals
document: "readonly",
window: "readonly",
localStorage: "readonly",
CustomEvent: "readonly",
IntersectionObserver: "readonly",
requestAnimationFrame: "readonly",
navigator: "readonly",
// Used by the dashboard's import/export controls
alert: "readonly",
Blob: "readonly",
FileReader: "readonly",
URL: "readonly",
fetch: "readonly",
// Console is available in browser
console: "readonly",
},
},
rules: {
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
},
},
// Skills - may use browser and special API globals
{
files: [
"skills/**/*.{js,ts,jsx,tsx}",
".github/skills/**/*.{js,ts,jsx,tsx}",
],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
globals: {
// Browser globals that skills may use
document: "readonly",
window: "readonly",
Node: "readonly",
fetch: "readonly",
URL: "readonly",
URLSearchParams: "readonly",
TextEncoder: "readonly",
TextDecoder: "readonly",
// Figma API (figma plugin skills)
figma: "readonly",
// Node.js globals
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
clearImmediate: "readonly",
clearInterval: "readonly",
clearTimeout: "readonly",
global: "readonly",
process: "readonly",
require: "readonly",
module: "readonly",
exports: "readonly",
setImmediate: "readonly",
setInterval: "readonly",
setTimeout: "readonly",
console: "readonly",
},
},
rules: {
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-console": "off",
},
},
// Agent skill scripts - may use Figma and browser APIs
{
// `**` before plugin-provided so the `skills/local/plugin-provided/...`
// layout is matched too; the previous `skills/plugin-provided` glob missed
// it, leaving `figma` undefined across those scripts.
// Also cover the figma-generate-library scripts under agents/*/skills/figma
// and plugins/figma, which use the same `figma` global.
files: [
"agents/**/plugin-provided/figma/**/scripts/**/*.js",
"agents/**/skills/figma/**/scripts/**/*.js",
"plugins/figma/**/scripts/**/*.js",
],
languageOptions: {
parserOptions: {
ecmaVersion: 2024,
sourceType: "module",
},
globals: {
// Figma API
figma: "readonly",
// Browser globals
fetch: "readonly",
URL: "readonly",
// Node.js
console: "readonly",
__dirname: "readonly",
__filename: "readonly",
process: "readonly",
Buffer: "readonly",
},
},
rules: {
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"no-console": "off",
},
},
// Disable ESLint rules that conflict with Prettier. Prettier runs as a
// standalone formatter (see the format:* scripts); it must not also run as an
// ESLint rule. eslint-config-prettier turns the formatting rules off so the
// two tools do not fight over the same code.
prettierConfig,
];