@dloizides/frontend-devtools 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/eslint/index.d.mts +77 -0
  2. package/dist/eslint/index.d.ts +77 -0
  3. package/dist/eslint/index.js +2000 -0
  4. package/dist/eslint/index.js.map +1 -0
  5. package/dist/eslint/index.mjs +1990 -0
  6. package/dist/eslint/index.mjs.map +1 -0
  7. package/dist/index.d.mts +71 -0
  8. package/dist/index.d.ts +71 -0
  9. package/dist/index.js +2029 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/index.mjs +2017 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/package.json +6 -1
  14. package/.eslintrc.js +0 -34
  15. package/jest.config.js +0 -24
  16. package/publish.ps1 +0 -107
  17. package/src/eslint/index.ts +0 -16
  18. package/src/eslint/legacy.ts +0 -44
  19. package/src/eslint/plugin.test.ts +0 -60
  20. package/src/eslint/plugin.ts +0 -87
  21. package/src/eslint/rules.behaviour.test.ts +0 -86
  22. package/src/eslint/rules.d.ts +0 -16
  23. package/src/eslint/types.ts +0 -27
  24. package/src/i18n/initI18n.test.ts +0 -101
  25. package/src/i18n/initI18n.ts +0 -109
  26. package/src/index.ts +0 -31
  27. package/src/rules/enforce-function-style.js +0 -278
  28. package/src/rules/enforce-module-structure.js +0 -323
  29. package/src/rules/enforce-route-preload.js +0 -288
  30. package/src/rules/enforce-test-colocation.js +0 -82
  31. package/src/rules/enum-file-isolation.js +0 -149
  32. package/src/rules/i18n-interpolation.js +0 -185
  33. package/src/rules/i18n-param-names.js +0 -119
  34. package/src/rules/no-barrel-companion-file.js +0 -142
  35. package/src/rules/no-duplicate-nav-prefix.js +0 -107
  36. package/src/rules/no-duplicate-shared-patterns.js +0 -166
  37. package/src/rules/no-generated-models-barrel-value-import.js +0 -70
  38. package/src/rules/no-null-check.js +0 -171
  39. package/src/rules/no-optional-undefined.js +0 -99
  40. package/src/rules/no-product-imports-in-shared.js +0 -164
  41. package/src/rules/prefer-const-enum.js +0 -127
  42. package/src/rules/require-stable-hook-args.js +0 -372
  43. package/src/rules/smart-max-lines.js +0 -344
  44. package/tsconfig.json +0 -25
  45. package/tsconfig.test.json +0 -11
  46. package/tsup.config.ts +0 -14
@@ -0,0 +1,1990 @@
1
+ import fs, { existsSync, readdirSync } from 'fs';
2
+ import path, { basename, dirname, sep, posix, join } from 'path';
3
+
4
+ // src/rules/enforce-function-style.js
5
+ function isJSX(node) {
6
+ return node && (node.type === "JSXElement" || node.type === "JSXFragment");
7
+ }
8
+ function expressionReturnsJSX(node) {
9
+ if (!node) return false;
10
+ if (isJSX(node)) return true;
11
+ if (node.type === "ConditionalExpression")
12
+ return expressionReturnsJSX(node.consequent) || expressionReturnsJSX(node.alternate);
13
+ if (node.type === "LogicalExpression")
14
+ return expressionReturnsJSX(node.left) || expressionReturnsJSX(node.right);
15
+ if (node.type === "ParenthesizedExpression")
16
+ return expressionReturnsJSX(node.expression);
17
+ return false;
18
+ }
19
+ function blockReturnsJSX(body) {
20
+ if (!Array.isArray(body)) return false;
21
+ for (const stmt of body) {
22
+ if (stmt.type === "ReturnStatement" && expressionReturnsJSX(stmt.argument))
23
+ return true;
24
+ if (stmt.type === "IfStatement") {
25
+ const check = (branch) => {
26
+ if (!branch) return false;
27
+ if (branch.type === "BlockStatement") return blockReturnsJSX(branch.body);
28
+ return branch.type === "ReturnStatement" && expressionReturnsJSX(branch.argument);
29
+ };
30
+ if (check(stmt.consequent) || check(stmt.alternate)) return true;
31
+ }
32
+ if (stmt.type === "SwitchStatement") {
33
+ for (const c of stmt.cases)
34
+ if (blockReturnsJSX(c.consequent)) return true;
35
+ }
36
+ }
37
+ return false;
38
+ }
39
+ function functionReturnsJSX(fnNode) {
40
+ if (fnNode.type === "ArrowFunctionExpression" && fnNode.body.type !== "BlockStatement")
41
+ return expressionReturnsJSX(fnNode.body);
42
+ if (fnNode.body && fnNode.body.type === "BlockStatement")
43
+ return blockReturnsJSX(fnNode.body.body);
44
+ return false;
45
+ }
46
+ function isExemptStatement(stmt) {
47
+ if (stmt.type === "ImportDeclaration") return true;
48
+ if (stmt.type === "TSTypeAliasDeclaration") return true;
49
+ if (stmt.type === "TSInterfaceDeclaration") return true;
50
+ if (stmt.type === "TSEnumDeclaration") return true;
51
+ if (stmt.type === "ExportAllDeclaration") return true;
52
+ if (stmt.type === "ExportNamedDeclaration" && stmt.exportKind === "type") return true;
53
+ if (stmt.type === "ExportNamedDeclaration" && stmt.source) return true;
54
+ if (stmt.type === "ExportNamedDeclaration" && !stmt.declaration && stmt.specifiers.length === 0)
55
+ return true;
56
+ return false;
57
+ }
58
+ function hasFunctionInit(varDecl) {
59
+ if (!varDecl.declarations || varDecl.declarations.length === 0) return false;
60
+ const init = varDecl.declarations[0].init;
61
+ if (!init) return false;
62
+ return init.type === "ArrowFunctionExpression" || init.type === "FunctionExpression";
63
+ }
64
+ function classifyZone(stmt) {
65
+ if (isExemptStatement(stmt)) return 0;
66
+ if (stmt.type === "ExportNamedDeclaration" || stmt.type === "ExportDefaultDeclaration")
67
+ return 2;
68
+ if (stmt.type === "FunctionDeclaration") return 2;
69
+ if (stmt.type === "VariableDeclaration") {
70
+ if (hasFunctionInit(stmt)) return 2;
71
+ return 1;
72
+ }
73
+ return 0;
74
+ }
75
+ function getStatementName(stmt) {
76
+ if (stmt.type === "ExportNamedDeclaration" && stmt.declaration) {
77
+ const decl = stmt.declaration;
78
+ if (decl.type === "FunctionDeclaration" && decl.id) return decl.id.name;
79
+ if (decl.type === "VariableDeclaration" && decl.declarations[0]?.id)
80
+ return decl.declarations[0].id.name;
81
+ }
82
+ if (stmt.type === "ExportDefaultDeclaration") return "default export";
83
+ if (stmt.type === "FunctionDeclaration" && stmt.id) return stmt.id.name;
84
+ if (stmt.type === "VariableDeclaration" && stmt.declarations[0]?.id)
85
+ return stmt.declarations[0].id.name;
86
+ return "(anonymous)";
87
+ }
88
+ function isTopLevel(node) {
89
+ const varDecl = node.parent;
90
+ if (!varDecl) return false;
91
+ const container = varDecl.parent;
92
+ if (!container) return false;
93
+ if (container.type === "Program") return true;
94
+ if (container.type === "ExportNamedDeclaration" && container.parent?.type === "Program")
95
+ return true;
96
+ return false;
97
+ }
98
+ var enforceFunctionStyleRule = {
99
+ meta: {
100
+ type: "suggestion",
101
+ docs: {
102
+ description: "Enforce function declarations for multi-statement functions and correct ordering of exports, private functions, and constants.",
103
+ category: "Best Practices",
104
+ recommended: true
105
+ },
106
+ schema: [
107
+ {
108
+ type: "object",
109
+ properties: {
110
+ checkStyle: {
111
+ type: "boolean",
112
+ description: "Flag const-assigned multi-statement functions (default true)"
113
+ },
114
+ checkOrdering: {
115
+ type: "boolean",
116
+ description: "Flag out-of-order module statements (default true)"
117
+ }
118
+ },
119
+ additionalProperties: false
120
+ }
121
+ ],
122
+ messages: {
123
+ useFunction: "Use a function declaration (`function {{name}}`) instead of a const-assigned arrow/function expression for multi-statement functions.",
124
+ constantAfterCode: "Module-level constant `{{name}}` should appear before functions and exports."
125
+ }
126
+ },
127
+ create(context) {
128
+ const options = context.options[0] || {};
129
+ const checkStyle = options.checkStyle !== false;
130
+ const checkOrdering = options.checkOrdering !== false;
131
+ return {
132
+ // -----------------------------------------------------------------
133
+ // Check 1: Declaration style
134
+ // -----------------------------------------------------------------
135
+ ...checkStyle ? {
136
+ VariableDeclarator(node) {
137
+ if (!isTopLevel(node)) return;
138
+ const init = node.init;
139
+ if (!init) return;
140
+ if (init.type !== "ArrowFunctionExpression" && init.type !== "FunctionExpression")
141
+ return;
142
+ if (init.type === "ArrowFunctionExpression" && init.body.type !== "BlockStatement")
143
+ return;
144
+ if (functionReturnsJSX(init)) return;
145
+ const name = node.id?.name ?? "(anonymous)";
146
+ if (/^[A-Z]/.test(name)) return;
147
+ context.report({
148
+ node,
149
+ messageId: "useFunction",
150
+ data: { name }
151
+ });
152
+ }
153
+ } : {},
154
+ // -----------------------------------------------------------------
155
+ // Check 2: Ordering
156
+ // -----------------------------------------------------------------
157
+ ...checkOrdering ? {
158
+ "Program:exit"(programNode) {
159
+ let maxZoneSeen = 0;
160
+ for (const stmt of programNode.body) {
161
+ const zone = classifyZone(stmt);
162
+ if (zone === 0) continue;
163
+ if (zone < maxZoneSeen) {
164
+ const name = getStatementName(stmt);
165
+ const messageId = "constantAfterCode";
166
+ context.report({
167
+ node: stmt,
168
+ messageId,
169
+ data: { name }
170
+ });
171
+ }
172
+ if (zone > maxZoneSeen) maxZoneSeen = zone;
173
+ }
174
+ }
175
+ } : {}
176
+ };
177
+ }
178
+ };
179
+ var enforce_function_style_default = {
180
+ rules: {
181
+ "enforce-function-style": enforceFunctionStyleRule
182
+ }
183
+ };
184
+ var FILE_THRESHOLD_DEFAULT = 4;
185
+ var ROOT_ALLOWED_BASENAMES = /* @__PURE__ */ new Set([
186
+ "index.tsx",
187
+ "index.ts",
188
+ "types.ts",
189
+ "constants.ts",
190
+ "schema.ts",
191
+ "columns.ts"
192
+ ]);
193
+ var ROOT_ALLOWED_PATTERNS = [
194
+ /^[a-zA-Z]+Types\.ts$/
195
+ // alertTypes.ts, buttonTypes.ts, etc.
196
+ ];
197
+ var COMPONENT_EXEMPT_DIRS = /* @__PURE__ */ new Set([
198
+ "sections",
199
+ "forms",
200
+ "Forms"
201
+ ]);
202
+ var FLAT_EXEMPT_DIRS = /* @__PURE__ */ new Set([
203
+ // Common (shared with SyncfusionThemeStudio)
204
+ "shared",
205
+ "presets",
206
+ "defaults",
207
+ "injectors",
208
+ "types",
209
+ "actions",
210
+ "icons",
211
+ "errors",
212
+ "interceptors",
213
+ "events",
214
+ "routes",
215
+ "utils",
216
+ "components",
217
+ "form-fields",
218
+ // BaseClient-specific
219
+ "enums",
220
+ "testIds",
221
+ "constants",
222
+ "slices",
223
+ "schemas",
224
+ "locales",
225
+ "mutators",
226
+ "customHooks",
227
+ "swagger",
228
+ "models",
229
+ "handlers",
230
+ "menuHandlers",
231
+ "userHandlers"
232
+ ]);
233
+ function countSourceFiles(dirPath) {
234
+ try {
235
+ const entries = readdirSync(dirPath, { withFileTypes: true });
236
+ return entries.filter((e) => {
237
+ if (!e.isFile()) return false;
238
+ const name = e.name;
239
+ if (!name.endsWith(".ts") && !name.endsWith(".tsx")) return false;
240
+ if (name.endsWith(".test.ts") || name.endsWith(".test.tsx")) return false;
241
+ if (name.endsWith(".d.ts")) return false;
242
+ return true;
243
+ }).length;
244
+ } catch {
245
+ return 0;
246
+ }
247
+ }
248
+ function isInsideSubdirectory(filePath, moduleRoot) {
249
+ const rel = filePath.split(sep).join(posix.sep).slice(moduleRoot.split(sep).join(posix.sep).length + 1);
250
+ return rel.includes("/");
251
+ }
252
+ function findModuleRoot(filePath) {
253
+ let dir = dirname(filePath);
254
+ const maxDepth = 10;
255
+ for (let i = 0; i < maxDepth; i++) {
256
+ try {
257
+ const entries = readdirSync(dir);
258
+ if (entries.includes("index.ts") || entries.includes("index.tsx"))
259
+ return dir;
260
+ } catch {
261
+ return null;
262
+ }
263
+ const parent = dirname(dir);
264
+ if (parent === dir) return null;
265
+ dir = parent;
266
+ }
267
+ return null;
268
+ }
269
+ var enforceModuleStructureRule = {
270
+ meta: {
271
+ type: "suggestion",
272
+ docs: {
273
+ description: "Enforce standard module structure: hooks in hooks/, sub-components in components/, utils in utils/, data in data/. Only applies when directory has 4+ source files.",
274
+ category: "Best Practices",
275
+ recommended: true
276
+ },
277
+ schema: [
278
+ {
279
+ type: "object",
280
+ properties: {
281
+ fileThreshold: {
282
+ type: "integer",
283
+ minimum: 2,
284
+ description: "Minimum number of non-test source files before structure is enforced"
285
+ }
286
+ },
287
+ additionalProperties: false
288
+ }
289
+ ],
290
+ messages: {
291
+ hookAtRoot: 'Hook "{{fileName}}" should be in a hooks/ subdirectory. Move to {{suggestedPath}}.',
292
+ componentAtRoot: 'Sub-component "{{fileName}}" should be in a components/ subdirectory. Move to {{suggestedPath}}.',
293
+ utilAtRoot: 'Utility file "{{fileName}}" should be in a utils/ subdirectory. Move to {{suggestedPath}}.',
294
+ dataInSections: 'Data file "{{fileName}}" should be in a data/ subdirectory, not mixed with section components. Move to {{suggestedPath}}.'
295
+ }
296
+ },
297
+ create(context) {
298
+ const options = context.options[0] || {};
299
+ const fileThreshold = options.fileThreshold ?? FILE_THRESHOLD_DEFAULT;
300
+ return {
301
+ Program() {
302
+ const filePath = context.filename || context.getFilename();
303
+ if (!filePath) return;
304
+ if (!filePath.endsWith(".ts") && !filePath.endsWith(".tsx")) return;
305
+ if (filePath.endsWith(".d.ts")) return;
306
+ const fileName = basename(filePath);
307
+ if (fileName.endsWith(".test.ts") || fileName.endsWith(".test.tsx"))
308
+ return;
309
+ if (ROOT_ALLOWED_BASENAMES.has(fileName)) return;
310
+ if (ROOT_ALLOWED_PATTERNS.some((p) => p.test(fileName))) return;
311
+ const dir = dirname(filePath);
312
+ const dirName = basename(dir);
313
+ if (FLAT_EXEMPT_DIRS.has(dirName)) return;
314
+ const moduleRoot = findModuleRoot(filePath);
315
+ if (!moduleRoot) return;
316
+ if (isInsideSubdirectory(filePath, moduleRoot)) return;
317
+ const sourceFileCount = countSourceFiles(moduleRoot);
318
+ if (sourceFileCount < fileThreshold) return;
319
+ const isHook = /^use[A-Z]/.test(fileName) && (fileName.endsWith(".ts") || fileName.endsWith(".tsx"));
320
+ const isComponent = fileName.endsWith(".tsx") && /^[A-Z]/.test(fileName);
321
+ const isDataFile = /[Dd]ata\.tsx?$/.test(fileName) || /\.data\.tsx?$/.test(fileName);
322
+ if (isDataFile && dirName === "sections") {
323
+ context.report({
324
+ loc: { line: 1, column: 0 },
325
+ messageId: "dataInSections",
326
+ data: {
327
+ fileName,
328
+ suggestedPath: `data/${fileName}`
329
+ }
330
+ });
331
+ return;
332
+ }
333
+ if (isHook) {
334
+ context.report({
335
+ loc: { line: 1, column: 0 },
336
+ messageId: "hookAtRoot",
337
+ data: {
338
+ fileName,
339
+ suggestedPath: `hooks/${fileName}`
340
+ }
341
+ });
342
+ return;
343
+ }
344
+ if (isComponent && !COMPONENT_EXEMPT_DIRS.has(dirName)) {
345
+ context.report({
346
+ loc: { line: 1, column: 0 },
347
+ messageId: "componentAtRoot",
348
+ data: {
349
+ fileName,
350
+ suggestedPath: `components/${fileName}`
351
+ }
352
+ });
353
+ return;
354
+ }
355
+ if (fileName.endsWith(".ts") && !isDataFile) {
356
+ context.report({
357
+ loc: { line: 1, column: 0 },
358
+ messageId: "utilAtRoot",
359
+ data: {
360
+ fileName,
361
+ suggestedPath: `utils/${fileName}`
362
+ }
363
+ });
364
+ }
365
+ }
366
+ };
367
+ }
368
+ };
369
+ var enforce_module_structure_default = {
370
+ rules: {
371
+ "enforce-module-structure": enforceModuleStructureRule
372
+ }
373
+ };
374
+ function discoverRoutePages(baseDir, options) {
375
+ const {
376
+ excludeFiles = ["_layout.tsx"],
377
+ excludeDirs = ["__tests__"],
378
+ rootIndexIsRedirect = true
379
+ } = options;
380
+ const routePages = [];
381
+ function walk(dir, relativePrefix) {
382
+ let entries;
383
+ try {
384
+ entries = fs.readdirSync(dir, { withFileTypes: true });
385
+ } catch {
386
+ return;
387
+ }
388
+ for (const entry of entries) {
389
+ const fullPath = path.join(dir, entry.name);
390
+ const relativePath = path.join(relativePrefix, entry.name);
391
+ if (entry.isDirectory()) {
392
+ if (excludeDirs.includes(entry.name)) continue;
393
+ walk(fullPath, relativePath);
394
+ continue;
395
+ }
396
+ if (!entry.name.endsWith(".tsx")) continue;
397
+ if (excludeFiles.includes(entry.name)) continue;
398
+ if (entry.name.startsWith("_")) continue;
399
+ const normalizedRelative = relativePath.replace(/\\/g, "/");
400
+ if (rootIndexIsRedirect && normalizedRelative === "index.tsx") continue;
401
+ const withoutExt = normalizedRelative.replace(/\.tsx$/, "");
402
+ routePages.push(withoutExt);
403
+ }
404
+ }
405
+ walk(baseDir, "");
406
+ return routePages;
407
+ }
408
+ function resolveImportToProjectRelative(importPath, fileDir, projectRoot) {
409
+ const absoluteResolved = path.resolve(fileDir, importPath);
410
+ const projectRelative = path.relative(projectRoot, absoluteResolved);
411
+ return projectRelative.replace(/\\/g, "/");
412
+ }
413
+ var enforceRoutePreloadRule = {
414
+ meta: {
415
+ type: "problem",
416
+ docs: {
417
+ description: "Ensure every route page in the configured directory has a matching dynamic import() in the preloader file",
418
+ category: "Best Practices",
419
+ recommended: true
420
+ },
421
+ schema: [
422
+ {
423
+ type: "object",
424
+ properties: {
425
+ routeDir: {
426
+ type: "string",
427
+ description: "Directory to scan for route pages, relative to project root",
428
+ default: "app/(protected)"
429
+ },
430
+ excludeFiles: {
431
+ type: "array",
432
+ items: { type: "string" },
433
+ description: "Filename patterns to skip",
434
+ default: ["_layout.tsx"]
435
+ },
436
+ excludeDirs: {
437
+ type: "array",
438
+ items: { type: "string" },
439
+ description: "Directory names to skip",
440
+ default: ["__tests__"]
441
+ },
442
+ rootIndexIsRedirect: {
443
+ type: "boolean",
444
+ description: "Whether the root index.tsx in routeDir is just a redirect and should be skipped",
445
+ default: true
446
+ }
447
+ },
448
+ additionalProperties: false
449
+ }
450
+ ],
451
+ messages: {
452
+ missingPreload: `Route page "{{routeFile}}" is not preloaded. Add: import('{{importPath}}').catch(() => undefined);`,
453
+ stalePreload: 'Preload import "{{importPath}}" does not match any route page in {{routeDir}}/. Remove it or add the corresponding route page.',
454
+ noImportsFound: "Preloader file has no dynamic import() expressions. Add imports for all route pages in {{routeDir}}/."
455
+ }
456
+ },
457
+ create(context) {
458
+ const options = context.options[0] ?? {};
459
+ const routeDir = options.routeDir ?? "app/(protected)";
460
+ const excludeFiles = options.excludeFiles ?? ["_layout.tsx"];
461
+ const excludeDirs = options.excludeDirs ?? ["__tests__"];
462
+ const rootIndexIsRedirect = options.rootIndexIsRedirect ?? true;
463
+ const cwd = context.cwd ?? context.getCwd?.() ?? process.cwd();
464
+ const projectRoot = cwd;
465
+ const filename = context.filename ?? context.getFilename?.();
466
+ const fileDir = path.dirname(filename);
467
+ const routeDirAbsolute = path.resolve(projectRoot, routeDir);
468
+ const routePages = discoverRoutePages(routeDirAbsolute, {
469
+ excludeFiles,
470
+ excludeDirs,
471
+ rootIndexIsRedirect
472
+ });
473
+ const expectedRouteSet = new Set(
474
+ routePages.map((rp) => `${routeDir}/${rp}`.replace(/\\/g, "/"))
475
+ );
476
+ const importExpressions = [];
477
+ return {
478
+ // Collect all dynamic import() expressions in the file
479
+ ImportExpression(node) {
480
+ if (node.source?.type !== "Literal") return;
481
+ const rawPath = node.source.value;
482
+ const resolvedPath = resolveImportToProjectRelative(
483
+ rawPath,
484
+ fileDir,
485
+ projectRoot
486
+ );
487
+ importExpressions.push({ resolvedPath, rawPath, node });
488
+ },
489
+ "Program:exit"(programNode) {
490
+ if (expectedRouteSet.size === 0) return;
491
+ if (importExpressions.length === 0) {
492
+ context.report({
493
+ node: programNode,
494
+ messageId: "noImportsFound",
495
+ data: { routeDir }
496
+ });
497
+ return;
498
+ }
499
+ const importedPaths = new Set(
500
+ importExpressions.map((i) => i.resolvedPath)
501
+ );
502
+ for (const routePath of expectedRouteSet) {
503
+ if (!importedPaths.has(routePath)) {
504
+ const routeAbsolute = path.resolve(projectRoot, `${routePath}.tsx`);
505
+ let relativePath = path.relative(fileDir, routeAbsolute);
506
+ relativePath = relativePath.replace(/\\/g, "/");
507
+ if (!relativePath.startsWith("."))
508
+ relativePath = `./${relativePath}`;
509
+ relativePath = relativePath.replace(/\.tsx$/, "");
510
+ context.report({
511
+ node: programNode,
512
+ messageId: "missingPreload",
513
+ data: {
514
+ routeFile: routePath,
515
+ importPath: relativePath
516
+ }
517
+ });
518
+ }
519
+ }
520
+ for (const { resolvedPath, rawPath, node } of importExpressions) {
521
+ const normalizedRouteDir = routeDir.replace(/\\/g, "/");
522
+ if (!resolvedPath.startsWith(normalizedRouteDir)) continue;
523
+ if (!expectedRouteSet.has(resolvedPath))
524
+ context.report({
525
+ node,
526
+ messageId: "stalePreload",
527
+ data: {
528
+ importPath: rawPath,
529
+ routeDir
530
+ }
531
+ });
532
+ }
533
+ }
534
+ };
535
+ }
536
+ };
537
+ var enforce_route_preload_default = {
538
+ rules: {
539
+ "enforce-route-preload": enforceRoutePreloadRule
540
+ }
541
+ };
542
+ var enforceTestColocationRule = {
543
+ meta: {
544
+ type: "suggestion",
545
+ docs: {
546
+ description: "Test files should be co-located next to their source file, not placed in a __tests__/ directory.",
547
+ category: "Best Practices",
548
+ recommended: true
549
+ },
550
+ schema: [],
551
+ messages: {
552
+ testInTestsDir: 'Test file "{{fileName}}" is inside a __tests__/ directory. Move it next to its source file for co-location. Suggested: {{suggestedPath}}'
553
+ }
554
+ },
555
+ create(context) {
556
+ return {
557
+ Program() {
558
+ const filePath = context.filename || context.getFilename();
559
+ if (!filePath) return;
560
+ const fileName = basename(filePath);
561
+ if (!fileName.endsWith(".test.ts") && !fileName.endsWith(".test.tsx"))
562
+ return;
563
+ const normalized = filePath.split(sep).join(posix.sep);
564
+ if (!normalized.includes("/__tests__/")) return;
565
+ const dir = dirname(filePath);
566
+ const parentDir = dirname(dir);
567
+ const parentDirName = basename(parentDir);
568
+ context.report({
569
+ loc: { line: 1, column: 0 },
570
+ messageId: "testInTestsDir",
571
+ data: {
572
+ fileName,
573
+ suggestedPath: `${parentDirName}/${fileName}`
574
+ }
575
+ });
576
+ }
577
+ };
578
+ }
579
+ };
580
+ var enforce_test_colocation_default = {
581
+ rules: {
582
+ "enforce-test-colocation": enforceTestColocationRule
583
+ }
584
+ };
585
+
586
+ // src/rules/enum-file-isolation.js
587
+ var enumFileIsolationRule = {
588
+ meta: {
589
+ type: "suggestion",
590
+ docs: {
591
+ description: "Exported enums should live in dedicated files. Only related helpers may share the file.",
592
+ category: "Best Practices",
593
+ recommended: true
594
+ },
595
+ schema: [],
596
+ messages: {
597
+ multipleEnums: "File contains multiple exported enums ({{enumNames}}). Each enum should have its own dedicated file.",
598
+ unrelatedExports: 'Exported enum "{{enumName}}" is in a file with unrelated exports. Move the enum to a dedicated file (e.g., {{suggestedFile}}) or move unrelated exports elsewhere.'
599
+ }
600
+ },
601
+ create(context) {
602
+ const exportedEnums = [];
603
+ const otherExportNodes = [];
604
+ function collectExportedEnum(node) {
605
+ if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "TSEnumDeclaration") {
606
+ exportedEnums.push({
607
+ name: node.declaration.id.name,
608
+ node: node.declaration.id
609
+ });
610
+ return true;
611
+ }
612
+ return false;
613
+ }
614
+ function collectOtherExport(node) {
615
+ if (node.type !== "ExportNamedDeclaration") return;
616
+ if (node.declaration && node.declaration.type === "TSEnumDeclaration")
617
+ return;
618
+ otherExportNodes.push(node);
619
+ }
620
+ function referencesEnum(sourceText, enumName) {
621
+ const regex = new RegExp(`\\b${enumName}\\b`);
622
+ return regex.test(sourceText);
623
+ }
624
+ return {
625
+ ExportNamedDeclaration(node) {
626
+ if (!collectExportedEnum(node)) collectOtherExport(node);
627
+ },
628
+ "Program:exit"() {
629
+ if (exportedEnums.length === 0) return;
630
+ const sourceCode = context.sourceCode || context.getSourceCode();
631
+ if (exportedEnums.length > 1) {
632
+ const enumNames = exportedEnums.map((e) => e.name).join(", ");
633
+ for (const enumInfo of exportedEnums) {
634
+ context.report({
635
+ node: enumInfo.node,
636
+ messageId: "multipleEnums",
637
+ data: { enumNames }
638
+ });
639
+ }
640
+ return;
641
+ }
642
+ const enumName = exportedEnums[0].name;
643
+ const enumNode = exportedEnums[0].node;
644
+ if (otherExportNodes.length === 0) return;
645
+ const unrelatedExports = otherExportNodes.filter((node) => {
646
+ const text = sourceCode.getText(node);
647
+ return !referencesEnum(text, enumName);
648
+ });
649
+ if (unrelatedExports.length > 0) {
650
+ const suggestedFile = enumName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase().concat(".ts");
651
+ context.report({
652
+ node: enumNode,
653
+ messageId: "unrelatedExports",
654
+ data: { enumName, suggestedFile }
655
+ });
656
+ }
657
+ }
658
+ };
659
+ }
660
+ };
661
+ var enum_file_isolation_default = {
662
+ rules: {
663
+ "enum-file-isolation": enumFileIsolationRule
664
+ }
665
+ };
666
+
667
+ // src/rules/i18n-interpolation.js
668
+ var DOUBLE_BRACE_REGEX = /\{\{(\w+)\}\}/g;
669
+ var SINGLE_BRACE_REGEX = /(?<!\{)\{(\w+)\}(?!\})/g;
670
+ var ALLOWED_NAMES = /* @__PURE__ */ new Set(["p1", "p2", "p3"]);
671
+ var MAX_POSITIONAL_PARAMS = 3;
672
+ var rule = {
673
+ meta: {
674
+ type: "problem",
675
+ docs: {
676
+ description: "Enforce {{p1}}/{{p2}}/{{p3}} interpolation placeholders in translation JSON files"
677
+ },
678
+ fixable: "code",
679
+ schema: [],
680
+ messages: {
681
+ nonStandardPlaceholder: 'Non-standard placeholder "{{placeholder}}" found. Use {{p1}}/{{p2}}/{{p3}} instead.',
682
+ singleBracePlaceholder: 'Single-brace placeholder "{{{placeholder}}}" found. Use double braces: {{{{{fixedName}}}}}.',
683
+ tooManyPlaceholders: "Translation has {{count}} unique placeholders but FM() only supports 3. Refactor the translation string."
684
+ }
685
+ },
686
+ create(context) {
687
+ return {
688
+ JSONLiteral(node) {
689
+ if (typeof node.value !== "string") return;
690
+ const raw = node.value;
691
+ const doubleBraceMatches = [];
692
+ let match;
693
+ while ((match = DOUBLE_BRACE_REGEX.exec(raw)) !== null) {
694
+ if (!ALLOWED_NAMES.has(match[1]))
695
+ doubleBraceMatches.push({ name: match[1], index: match.index });
696
+ }
697
+ const singleBraceMatches = [];
698
+ while ((match = SINGLE_BRACE_REGEX.exec(raw)) !== null)
699
+ singleBraceMatches.push({ name: match[1], index: match.index });
700
+ const hasDoubleBraceIssues = doubleBraceMatches.length > 0;
701
+ const hasSingleBraceIssues = singleBraceMatches.length > 0;
702
+ if (!hasDoubleBraceIssues && !hasSingleBraceIssues) return;
703
+ const seenNames = [];
704
+ const allMatches = [...doubleBraceMatches, ...singleBraceMatches].sort(
705
+ (a, b) => a.index - b.index
706
+ );
707
+ for (const m of allMatches) {
708
+ if (!seenNames.includes(m.name) && !ALLOWED_NAMES.has(m.name))
709
+ seenNames.push(m.name);
710
+ }
711
+ const existingValid = /* @__PURE__ */ new Set();
712
+ let m2;
713
+ const tempRegex = /\{\{(\w+)\}\}/g;
714
+ while ((m2 = tempRegex.exec(raw)) !== null) {
715
+ if (ALLOWED_NAMES.has(m2[1])) existingValid.add(m2[1]);
716
+ }
717
+ const tempSingleRegex = /(?<!\{)\{(\w+)\}(?!\})/g;
718
+ while ((m2 = tempSingleRegex.exec(raw)) !== null) {
719
+ if (ALLOWED_NAMES.has(m2[1])) existingValid.add(m2[1]);
720
+ }
721
+ const totalUnique = seenNames.length + existingValid.size;
722
+ if (totalUnique > MAX_POSITIONAL_PARAMS) {
723
+ context.report({
724
+ node,
725
+ messageId: "tooManyPlaceholders",
726
+ data: { count: String(totalUnique) }
727
+ });
728
+ return;
729
+ }
730
+ const usedPositional = new Set(existingValid);
731
+ const nameMap = {};
732
+ const positionalNames = ["p1", "p2", "p3"];
733
+ let nextIdx = 0;
734
+ for (const name of seenNames) {
735
+ while (nextIdx < positionalNames.length && usedPositional.has(positionalNames[nextIdx]))
736
+ nextIdx++;
737
+ if (nextIdx < positionalNames.length) {
738
+ nameMap[name] = positionalNames[nextIdx];
739
+ usedPositional.add(positionalNames[nextIdx]);
740
+ nextIdx++;
741
+ }
742
+ }
743
+ if (hasDoubleBraceIssues) {
744
+ const fixedValue = raw.replace(DOUBLE_BRACE_REGEX, (full, name) => {
745
+ if (ALLOWED_NAMES.has(name)) return full;
746
+ const replacement = nameMap[name];
747
+ return replacement !== void 0 ? `{{${replacement}}}` : full;
748
+ });
749
+ context.report({
750
+ node,
751
+ messageId: "nonStandardPlaceholder",
752
+ data: { placeholder: doubleBraceMatches[0].name },
753
+ fix(fixer) {
754
+ let finalValue = fixedValue;
755
+ if (hasSingleBraceIssues)
756
+ finalValue = finalValue.replace(
757
+ SINGLE_BRACE_REGEX,
758
+ (full, name) => {
759
+ if (ALLOWED_NAMES.has(name)) return `{{${name}}}`;
760
+ const replacement = nameMap[name];
761
+ return replacement !== void 0 ? `{{${replacement}}}` : `{{${name}}}`;
762
+ }
763
+ );
764
+ return fixer.replaceText(node, JSON.stringify(finalValue));
765
+ }
766
+ });
767
+ } else if (hasSingleBraceIssues) {
768
+ const fixedValue = raw.replace(SINGLE_BRACE_REGEX, (full, name) => {
769
+ if (ALLOWED_NAMES.has(name)) return `{{${name}}}`;
770
+ const replacement = nameMap[name];
771
+ return replacement !== void 0 ? `{{${replacement}}}` : `{{${name}}}`;
772
+ });
773
+ context.report({
774
+ node,
775
+ messageId: "singleBracePlaceholder",
776
+ data: {
777
+ placeholder: singleBraceMatches[0].name,
778
+ fixedName: ALLOWED_NAMES.has(singleBraceMatches[0].name) ? singleBraceMatches[0].name : nameMap[singleBraceMatches[0].name] ?? singleBraceMatches[0].name
779
+ },
780
+ fix(fixer) {
781
+ return fixer.replaceText(node, JSON.stringify(fixedValue));
782
+ }
783
+ });
784
+ }
785
+ }
786
+ };
787
+ }
788
+ };
789
+ var i18n_interpolation_default = {
790
+ rules: {
791
+ "i18n-interpolation": rule
792
+ }
793
+ };
794
+
795
+ // src/rules/i18n-param-names.js
796
+ var ALLOWED_PARAM_NAMES = /* @__PURE__ */ new Set(["p1", "p2", "p3"]);
797
+ var I18NEXT_CONFIG_KEYS = /* @__PURE__ */ new Set([
798
+ "defaultValue",
799
+ "ns",
800
+ "lng",
801
+ "context",
802
+ "returnObjects",
803
+ "keySeparator",
804
+ "nsSeparator",
805
+ "interpolation",
806
+ "joinArrays",
807
+ "postProcess",
808
+ "replace",
809
+ "ordinal",
810
+ "formatParams",
811
+ "missingInterpolationHandler"
812
+ ]);
813
+ var rule2 = {
814
+ meta: {
815
+ type: "problem",
816
+ docs: {
817
+ description: "Enforce p1/p2/p3 parameter names in t() interpolation calls. Translation JSON uses {{p1}}/{{p2}}/{{p3}} placeholders, so call sites must pass { p1: value } \u2014 not { count: value } or other names.",
818
+ category: "Possible Errors",
819
+ recommended: true
820
+ },
821
+ schema: [],
822
+ messages: {
823
+ nonStandardParam: 'Non-standard interpolation param "{{paramName}}" in t() call. Translation placeholders use {{p1}}/{{p2}}/{{p3}}. Use FM(key, value) or t(key, { p1: value }) instead.',
824
+ preferFM: "Prefer FM() over t() for parameterized translations. FM() enforces positional params (p1, p2, p3) by design."
825
+ }
826
+ },
827
+ create(context) {
828
+ return {
829
+ CallExpression(node) {
830
+ if (node.callee.type !== "Identifier" || node.callee.name !== "t")
831
+ return;
832
+ if (node.arguments.length < 2) return;
833
+ const optionsArg = node.arguments.length >= 3 ? node.arguments[2] : node.arguments[1];
834
+ if (!optionsArg || optionsArg.type !== "ObjectExpression") return;
835
+ const properties = optionsArg.properties;
836
+ for (const prop of properties) {
837
+ if (prop.type === "SpreadElement") continue;
838
+ const keyName = prop.key.type === "Identifier" ? prop.key.name : prop.key.type === "Literal" ? String(prop.key.value) : null;
839
+ if (keyName === null) continue;
840
+ if (I18NEXT_CONFIG_KEYS.has(keyName)) continue;
841
+ if (!ALLOWED_PARAM_NAMES.has(keyName))
842
+ context.report({
843
+ node: prop,
844
+ messageId: "nonStandardParam",
845
+ data: { paramName: keyName }
846
+ });
847
+ }
848
+ }
849
+ };
850
+ }
851
+ };
852
+ var i18n_param_names_default = {
853
+ rules: {
854
+ "i18n-param-names": rule2
855
+ }
856
+ };
857
+ function isPureReExportFile(programNode) {
858
+ const { body } = programNode;
859
+ if (body.length === 0) return false;
860
+ return body.every((stmt) => {
861
+ if (stmt.type === "ImportDeclaration") return true;
862
+ if (stmt.type === "ExportAllDeclaration") return true;
863
+ const isReExport = stmt.type === "ExportNamedDeclaration" && stmt.source !== null;
864
+ return isReExport;
865
+ });
866
+ }
867
+ var noBarrelCompanionFileRule = {
868
+ meta: {
869
+ type: "problem",
870
+ fixable: "code",
871
+ docs: {
872
+ description: "Disallow .ts/.tsx files that shadow a same-named directory barrel (index.ts). This causes TypeScript to resolve imports to the file instead of the barrel, leading to missing export errors.",
873
+ category: "Possible Errors",
874
+ recommended: true
875
+ },
876
+ schema: [],
877
+ messages: {
878
+ companionFileConflict: 'File "{{fileName}}" shadows the barrel "{{barrelPath}}". TypeScript resolves `import from \'./{{baseName}}\'` to this file, ignoring the barrel. Delete this file and update imports to use the barrel, or consolidate into one location.'
879
+ }
880
+ },
881
+ create(context) {
882
+ return {
883
+ Program(node) {
884
+ const filePath = context.filename || context.getFilename();
885
+ if (!filePath || !filePath.endsWith(".ts") && !filePath.endsWith(".tsx")) return;
886
+ if (filePath.endsWith(".d.ts")) return;
887
+ const fileBaseName = basename(filePath);
888
+ if (fileBaseName === "index.ts" || fileBaseName === "index.tsx") return;
889
+ const ext = fileBaseName.endsWith(".tsx") ? ".tsx" : ".ts";
890
+ const baseName = fileBaseName.slice(0, -ext.length);
891
+ const dir = dirname(filePath);
892
+ const siblingDir = join(dir, baseName);
893
+ const barrelTs = join(siblingDir, "index.ts");
894
+ const barrelTsx = join(siblingDir, "index.tsx");
895
+ const hasBarrelTs = existsSync(barrelTs);
896
+ const hasBarrelTsx = existsSync(barrelTsx);
897
+ if (hasBarrelTs || hasBarrelTsx) {
898
+ const sourceCode = context.sourceCode || context.getSourceCode();
899
+ const trimmed = sourceCode.text.trim();
900
+ const safePattern = `export * from './${baseName}/index';`;
901
+ if (trimmed === safePattern) return;
902
+ const barrelPath = hasBarrelTs ? `${baseName}/index.ts` : `${baseName}/index.tsx`;
903
+ const canAutoFix = isPureReExportFile(node);
904
+ context.report({
905
+ node,
906
+ messageId: "companionFileConflict",
907
+ data: {
908
+ fileName: fileBaseName,
909
+ barrelPath,
910
+ baseName
911
+ },
912
+ ...canAutoFix && {
913
+ fix(fixer) {
914
+ const fullRange = [0, sourceCode.text.length];
915
+ const replacement = `export * from './${baseName}/index';
916
+ `;
917
+ return fixer.replaceTextRange(fullRange, replacement);
918
+ }
919
+ }
920
+ });
921
+ }
922
+ }
923
+ };
924
+ }
925
+ };
926
+ var no_barrel_companion_file_default = {
927
+ rules: {
928
+ "no-barrel-companion-file": noBarrelCompanionFileRule
929
+ }
930
+ };
931
+
932
+ // src/rules/no-duplicate-nav-prefix.js
933
+ function createDuplicateChecker(propName, messageId) {
934
+ return {
935
+ /** @param {import('estree').ArrayExpression} node */
936
+ check(node, context) {
937
+ const objectsWithProp = node.elements.filter(
938
+ (el) => el && el.type === "ObjectExpression" && el.properties.some(
939
+ (p) => p.type === "Property" && p.key.type === "Identifier" && p.key.name === propName
940
+ )
941
+ );
942
+ if (objectsWithProp.length === 0) return;
943
+ const seen = /* @__PURE__ */ new Map();
944
+ for (const obj of objectsWithProp) {
945
+ const prop = obj.properties.find(
946
+ (p) => p.type === "Property" && p.key.type === "Identifier" && p.key.name === propName
947
+ );
948
+ if (!prop) continue;
949
+ let value;
950
+ if (prop.value.type === "Literal") {
951
+ value = String(prop.value.value);
952
+ } else if (prop.value.type === "MemberExpression") {
953
+ const src = context.sourceCode || context.getSourceCode();
954
+ value = src.getText(prop.value);
955
+ } else if (prop.value.type === "TemplateLiteral" && prop.value.quasis.length === 1) {
956
+ value = prop.value.quasis[0].value.cooked;
957
+ } else {
958
+ continue;
959
+ }
960
+ if (seen.has(value)) {
961
+ context.report({
962
+ node: prop.value,
963
+ messageId,
964
+ data: { value }
965
+ });
966
+ } else {
967
+ seen.set(value, prop);
968
+ }
969
+ }
970
+ }
971
+ };
972
+ }
973
+ var noDuplicateNavPrefixRule = {
974
+ meta: {
975
+ type: "problem",
976
+ docs: {
977
+ description: "Disallow duplicate route or key values in module sidebarItems. Duplicate routes cause navigation collisions; duplicate keys cause rendering issues.",
978
+ category: "Possible Errors",
979
+ recommended: true
980
+ },
981
+ schema: [],
982
+ messages: {
983
+ duplicateRoute: 'Duplicate route "{{value}}" - each sidebar item must have a unique route.',
984
+ duplicateKey: 'Duplicate key "{{value}}" - each sidebar item must have a unique key.'
985
+ }
986
+ },
987
+ create(context) {
988
+ const routeChecker = createDuplicateChecker("route", "duplicateRoute");
989
+ const keyChecker = createDuplicateChecker("key", "duplicateKey");
990
+ return {
991
+ ArrayExpression(node) {
992
+ routeChecker.check(node, context);
993
+ keyChecker.check(node, context);
994
+ }
995
+ };
996
+ }
997
+ };
998
+ var no_duplicate_nav_prefix_default = {
999
+ rules: {
1000
+ "no-duplicate-nav-prefix": noDuplicateNavPrefixRule
1001
+ }
1002
+ };
1003
+ function normalizePath(filePath) {
1004
+ return filePath.split(sep).join(posix.sep);
1005
+ }
1006
+ function collectComponentNames(dirPath) {
1007
+ const names = /* @__PURE__ */ new Set();
1008
+ if (!existsSync(dirPath)) return names;
1009
+ function walk(dir) {
1010
+ try {
1011
+ const entries = readdirSync(dir, { withFileTypes: true });
1012
+ for (const entry of entries) {
1013
+ if (entry.isDirectory()) {
1014
+ walk(join(dir, entry.name));
1015
+ continue;
1016
+ }
1017
+ const name = entry.name;
1018
+ if (!name.endsWith(".tsx")) continue;
1019
+ if (name.endsWith(".test.tsx")) continue;
1020
+ if (name === "index.tsx") continue;
1021
+ names.add(name);
1022
+ }
1023
+ } catch {
1024
+ }
1025
+ }
1026
+ walk(dirPath);
1027
+ return names;
1028
+ }
1029
+ function isInsideProductDirectory(filePath) {
1030
+ const normalized = normalizePath(filePath);
1031
+ return normalized.includes("/packages/") && normalized.includes("-module/src/") || normalized.includes("/src/features/");
1032
+ }
1033
+ function findSharedComponentsDir(filePath) {
1034
+ const normalized = normalizePath(filePath);
1035
+ const baseClientIdx = normalized.indexOf("/BaseClient/");
1036
+ if (baseClientIdx === -1) return null;
1037
+ const baseClientRoot = filePath.split(sep).join(posix.sep).slice(0, baseClientIdx + "/BaseClient".length);
1038
+ const osPath = baseClientRoot.split(posix.sep).join(sep);
1039
+ return join(osPath, "src", "components");
1040
+ }
1041
+ var sharedNamesCache = /* @__PURE__ */ new Map();
1042
+ var noDuplicateSharedPatternsRule = {
1043
+ meta: {
1044
+ type: "suggestion",
1045
+ docs: {
1046
+ description: "Warn when product modules create components that share names with existing shared components in src/components/.",
1047
+ category: "Best Practices",
1048
+ recommended: false
1049
+ },
1050
+ schema: [],
1051
+ messages: {
1052
+ duplicateSharedPattern: '"{{fileName}}" already exists as a shared component in src/components/. Consider reusing the shared version or renaming this component to clarify its purpose.'
1053
+ }
1054
+ },
1055
+ create(context) {
1056
+ const filePath = context.filename || context.getFilename();
1057
+ if (!filePath) return {};
1058
+ if (!filePath.endsWith(".tsx")) return {};
1059
+ const fileName = basename(filePath);
1060
+ if (fileName.endsWith(".test.tsx")) return {};
1061
+ if (fileName === "index.tsx") return {};
1062
+ if (!isInsideProductDirectory(filePath)) return {};
1063
+ return {
1064
+ Program() {
1065
+ const componentsDir = findSharedComponentsDir(filePath);
1066
+ if (!componentsDir) return;
1067
+ if (!sharedNamesCache.has(componentsDir))
1068
+ sharedNamesCache.set(
1069
+ componentsDir,
1070
+ collectComponentNames(componentsDir)
1071
+ );
1072
+ const sharedNames = sharedNamesCache.get(componentsDir);
1073
+ if (sharedNames.has(fileName))
1074
+ context.report({
1075
+ loc: { line: 1, column: 0 },
1076
+ messageId: "duplicateSharedPattern",
1077
+ data: { fileName }
1078
+ });
1079
+ }
1080
+ };
1081
+ }
1082
+ };
1083
+ var no_duplicate_shared_patterns_default = {
1084
+ rules: {
1085
+ "no-duplicate-shared-patterns": noDuplicateSharedPatternsRule
1086
+ }
1087
+ };
1088
+
1089
+ // src/rules/no-generated-models-barrel-value-import.js
1090
+ var BARREL_PATTERN = /autoGeneratedHooks\/[^/]+\/models(?:\/index)?$/;
1091
+ function isTypeOnlyImport(node) {
1092
+ if (node.importKind === "type") return true;
1093
+ const specifiers = node.specifiers ?? [];
1094
+ if (specifiers.length === 0) return false;
1095
+ return specifiers.every((s) => s.importKind === "type");
1096
+ }
1097
+ var noGeneratedModelsBarrelValueImportRule = {
1098
+ meta: {
1099
+ type: "problem",
1100
+ docs: {
1101
+ description: "Disallow runtime (value) imports from generated model barrels; use specific leaf modules or type-only imports.",
1102
+ category: "Best Practices",
1103
+ recommended: true
1104
+ },
1105
+ schema: [],
1106
+ messages: {
1107
+ noValueImport: 'Do not import runtime values from "{{module}}". Import from a specific leaf model module instead (e.g. \u2026/models/questionType). Type-only imports are allowed.'
1108
+ }
1109
+ },
1110
+ create(context) {
1111
+ return {
1112
+ ImportDeclaration(node) {
1113
+ const moduleName = node.source?.value;
1114
+ if (typeof moduleName !== "string") return;
1115
+ if (!BARREL_PATTERN.test(moduleName)) return;
1116
+ if (isTypeOnlyImport(node)) return;
1117
+ context.report({
1118
+ node,
1119
+ messageId: "noValueImport",
1120
+ data: { module: moduleName }
1121
+ });
1122
+ }
1123
+ };
1124
+ }
1125
+ };
1126
+ var no_generated_models_barrel_value_import_default = {
1127
+ rules: {
1128
+ "no-generated-models-barrel-value-import": noGeneratedModelsBarrelValueImportRule
1129
+ }
1130
+ };
1131
+
1132
+ // src/rules/no-null-check.js
1133
+ var noNullCheckRule = {
1134
+ meta: {
1135
+ type: "suggestion",
1136
+ docs: {
1137
+ description: "Disallow direct null/undefined checks. Use isValueDefined() or isNullOrUndefined() instead.",
1138
+ category: "Best Practices",
1139
+ recommended: true
1140
+ },
1141
+ fixable: "code",
1142
+ schema: [
1143
+ {
1144
+ type: "object",
1145
+ properties: {
1146
+ utilImportPath: {
1147
+ type: "string",
1148
+ description: "Import path for the utility functions",
1149
+ default: "@dloizides/utils"
1150
+ }
1151
+ },
1152
+ additionalProperties: false
1153
+ }
1154
+ ],
1155
+ messages: {
1156
+ noNotEqualsNull: 'Avoid "!== null" checks. Use isValueDefined({{identifier}}) instead, which handles both null and undefined.',
1157
+ noEqualsNull: 'Avoid "=== null" checks. Use !isValueDefined({{identifier}}) or isNullOrUndefined({{identifier}}) instead.',
1158
+ noNotEqualsNullComplex: 'Avoid "!== null" checks. Use isValueDefined() instead, which handles both null and undefined.',
1159
+ noEqualsNullComplex: 'Avoid "=== null" checks. Use !isValueDefined() or isNullOrUndefined() instead.',
1160
+ noNotEqualsUndefined: 'Avoid "!== undefined" checks. Use isValueDefined({{identifier}}) instead, which handles both null and undefined.',
1161
+ noEqualsUndefined: 'Avoid "=== undefined" checks. Use !isValueDefined({{identifier}}) or isNullOrUndefined({{identifier}}) instead.',
1162
+ noNotEqualsUndefinedComplex: 'Avoid "!== undefined" checks. Use isValueDefined() instead, which handles both null and undefined.',
1163
+ noEqualsUndefinedComplex: 'Avoid "=== undefined" checks. Use !isValueDefined() or isNullOrUndefined() instead.'
1164
+ }
1165
+ },
1166
+ create(context) {
1167
+ const sourceCode = context.sourceCode || context.getSourceCode();
1168
+ function isNullLiteral(node) {
1169
+ return node && node.type === "Literal" && node.value === null;
1170
+ }
1171
+ function isUndefinedIdentifier(node) {
1172
+ return node && node.type === "Identifier" && node.name === "undefined";
1173
+ }
1174
+ function getNodeText(node) {
1175
+ return sourceCode.getText(node);
1176
+ }
1177
+ function isSimpleIdentifier(node) {
1178
+ return node.type === "Identifier" || node.type === "MemberExpression" && !node.computed;
1179
+ }
1180
+ function checkBinaryExpression(node) {
1181
+ const { operator, left, right } = node;
1182
+ if (operator !== "===" && operator !== "!==") {
1183
+ return;
1184
+ }
1185
+ const leftIsNull = isNullLiteral(left);
1186
+ const rightIsNull = isNullLiteral(right);
1187
+ const leftIsUndefined = isUndefinedIdentifier(left);
1188
+ const rightIsUndefined = isUndefinedIdentifier(right);
1189
+ const isNullCheck = leftIsNull || rightIsNull;
1190
+ const isUndefinedCheck = leftIsUndefined || rightIsUndefined;
1191
+ if (!isNullCheck && !isUndefinedCheck) {
1192
+ return;
1193
+ }
1194
+ const valueNode = leftIsNull || leftIsUndefined ? right : left;
1195
+ const valueText = getNodeText(valueNode);
1196
+ const isSimple = isSimpleIdentifier(valueNode);
1197
+ if (operator === "!==") {
1198
+ const messageId = isNullCheck ? isSimple ? "noNotEqualsNull" : "noNotEqualsNullComplex" : isSimple ? "noNotEqualsUndefined" : "noNotEqualsUndefinedComplex";
1199
+ context.report({
1200
+ node,
1201
+ messageId,
1202
+ data: isSimple ? { identifier: valueText } : {},
1203
+ fix(fixer) {
1204
+ return fixer.replaceText(node, `isValueDefined(${valueText})`);
1205
+ }
1206
+ });
1207
+ } else {
1208
+ const messageId = isNullCheck ? isSimple ? "noEqualsNull" : "noEqualsNullComplex" : isSimple ? "noEqualsUndefined" : "noEqualsUndefinedComplex";
1209
+ context.report({
1210
+ node,
1211
+ messageId,
1212
+ data: isSimple ? { identifier: valueText } : {},
1213
+ fix(fixer) {
1214
+ return fixer.replaceText(node, `!isValueDefined(${valueText})`);
1215
+ }
1216
+ });
1217
+ }
1218
+ }
1219
+ return {
1220
+ BinaryExpression: checkBinaryExpression
1221
+ };
1222
+ }
1223
+ };
1224
+ var no_null_check_default = {
1225
+ rules: {
1226
+ "no-null-check": noNullCheckRule
1227
+ }
1228
+ };
1229
+
1230
+ // src/rules/no-optional-undefined.js
1231
+ var no_optional_undefined_default = {
1232
+ rules: {
1233
+ "no-optional-undefined": {
1234
+ meta: {
1235
+ type: "suggestion",
1236
+ docs: {
1237
+ description: "Disallow combining optional marker (?) with `| undefined` in type annotations"
1238
+ },
1239
+ messages: {
1240
+ noOptionalUndefined: "Do not combine optional (?) with `| undefined`. Use `?: {{type}}` and omit the key when the value is undefined."
1241
+ },
1242
+ schema: []
1243
+ },
1244
+ create(context) {
1245
+ function getTypeWithoutUndefined(typeAnnotation) {
1246
+ if (!typeAnnotation || typeAnnotation.type !== "TSUnionType") return null;
1247
+ const hasUndefined = typeAnnotation.types.some(
1248
+ (t) => t.type === "TSUndefinedKeyword"
1249
+ );
1250
+ if (!hasUndefined) return null;
1251
+ const nonUndefinedTypes = typeAnnotation.types.filter(
1252
+ (t) => t.type !== "TSUndefinedKeyword"
1253
+ );
1254
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
1255
+ if (nonUndefinedTypes.length === 1)
1256
+ return sourceCode.getText(nonUndefinedTypes[0]);
1257
+ return nonUndefinedTypes.map((t) => sourceCode.getText(t)).join(" | ");
1258
+ }
1259
+ function checkNode(node, typeAnnotationNode) {
1260
+ if (!node.optional) return;
1261
+ if (!typeAnnotationNode) return;
1262
+ const annotation = typeAnnotationNode.typeAnnotation ?? typeAnnotationNode;
1263
+ const cleanType = getTypeWithoutUndefined(annotation);
1264
+ if (cleanType === null) return;
1265
+ context.report({
1266
+ node: typeAnnotationNode,
1267
+ messageId: "noOptionalUndefined",
1268
+ data: { type: cleanType }
1269
+ });
1270
+ }
1271
+ return {
1272
+ // Interface / type alias properties: foo?: string | undefined
1273
+ TSPropertySignature(node) {
1274
+ checkNode(node, node.typeAnnotation?.typeAnnotation);
1275
+ },
1276
+ // Function parameters: function foo(bar?: string | undefined)
1277
+ // Arrow functions, methods, etc.
1278
+ Identifier(node) {
1279
+ if (!node.optional) return;
1280
+ const parent = node.parent;
1281
+ if (!parent) return;
1282
+ const isParam = (parent.type === "FunctionDeclaration" || parent.type === "FunctionExpression" || parent.type === "ArrowFunctionExpression") && parent.params.includes(node);
1283
+ if (!isParam) return;
1284
+ checkNode(node, node.typeAnnotation?.typeAnnotation);
1285
+ }
1286
+ };
1287
+ }
1288
+ }
1289
+ }
1290
+ };
1291
+ var ALLOWED_BASECLIENT_PACKAGES = /* @__PURE__ */ new Set([
1292
+ "@baseclient/core",
1293
+ "@baseclient/identity-client",
1294
+ "@baseclient/identity-module"
1295
+ ]);
1296
+ var PRODUCT_HOOK_DIRS = /* @__PURE__ */ new Set([
1297
+ "onlinemenu",
1298
+ "questioner",
1299
+ "content",
1300
+ "notification"
1301
+ ]);
1302
+ function normalizePath2(filePath) {
1303
+ return filePath.split(sep).join(posix.sep);
1304
+ }
1305
+ function isInsideSharedComponents(filePath) {
1306
+ const normalized = normalizePath2(filePath);
1307
+ return normalized.includes("/src/components/");
1308
+ }
1309
+ function isBannedBaseclientModule(source) {
1310
+ if (!source.startsWith("@baseclient/")) return false;
1311
+ if (ALLOWED_BASECLIENT_PACKAGES.has(source)) return false;
1312
+ return source.endsWith("-module");
1313
+ }
1314
+ function isBannedAutoGeneratedHook(source) {
1315
+ const normalized = normalizePath2(source);
1316
+ for (const dir of PRODUCT_HOOK_DIRS) {
1317
+ if (normalized.includes(`autoGeneratedHooks/${dir}`)) return true;
1318
+ if (normalized.includes(`autoGeneratedHooks/${dir}/`)) return true;
1319
+ }
1320
+ return false;
1321
+ }
1322
+ function isBannedFeatureOrModulePath(source) {
1323
+ const normalized = normalizePath2(source);
1324
+ return normalized.includes("/src/features/") || normalized.includes("/src/modules/") || normalized.includes("/features/") || normalized.includes("/modules/");
1325
+ }
1326
+ var noProductImportsInSharedRule = {
1327
+ meta: {
1328
+ type: "problem",
1329
+ docs: {
1330
+ description: "Disallow product-specific imports in src/components/. Shared components must not depend on product modules.",
1331
+ category: "Best Practices",
1332
+ recommended: true
1333
+ },
1334
+ schema: [],
1335
+ messages: {
1336
+ productImportInShared: "Shared components in src/components/ must not import from product-specific modules ({{source}}). Move product-specific logic to the feature module, or extract shared types to @baseclient/core."
1337
+ }
1338
+ },
1339
+ create(context) {
1340
+ const filePath = context.filename || context.getFilename();
1341
+ if (!filePath) return {};
1342
+ if (!isInsideSharedComponents(filePath)) return {};
1343
+ function checkImportSource(node) {
1344
+ const source = node.source;
1345
+ if (!source) return;
1346
+ const importPath = source.value;
1347
+ if (typeof importPath !== "string") return;
1348
+ const isBanned = isBannedBaseclientModule(importPath) || isBannedAutoGeneratedHook(importPath) || isBannedFeatureOrModulePath(importPath);
1349
+ if (isBanned)
1350
+ context.report({
1351
+ node,
1352
+ messageId: "productImportInShared",
1353
+ data: { source: importPath }
1354
+ });
1355
+ }
1356
+ return {
1357
+ ImportDeclaration: checkImportSource,
1358
+ ExportNamedDeclaration: checkImportSource,
1359
+ ExportAllDeclaration: checkImportSource
1360
+ };
1361
+ }
1362
+ };
1363
+ var no_product_imports_in_shared_default = {
1364
+ rules: {
1365
+ "no-product-imports-in-shared": noProductImportsInSharedRule
1366
+ }
1367
+ };
1368
+
1369
+ // src/rules/prefer-const-enum.js
1370
+ function toPascalCase(value) {
1371
+ const words = value.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[-_\s]+/).filter((w) => w.length > 0);
1372
+ const result = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
1373
+ if (/^\d/.test(result)) return `_${result}`;
1374
+ return result;
1375
+ }
1376
+ var preferConstEnumRule = {
1377
+ meta: {
1378
+ type: "suggestion",
1379
+ docs: {
1380
+ description: "Prefer const enum over string literal union types for better autocomplete, refactoring, and centralized definitions.",
1381
+ category: "Best Practices",
1382
+ recommended: true
1383
+ },
1384
+ hasSuggestions: true,
1385
+ schema: [],
1386
+ messages: {
1387
+ preferConstEnum: 'String literal union type "{{name}}" should be a const enum. Const enums provide autocomplete, refactoring support, and centralized definitions.',
1388
+ convertToConstEnum: 'Convert "{{name}}" to const enum'
1389
+ }
1390
+ },
1391
+ create(context) {
1392
+ return {
1393
+ TSTypeAliasDeclaration(node) {
1394
+ const { typeAnnotation } = node;
1395
+ if (typeAnnotation.type !== "TSUnionType") return;
1396
+ const { types } = typeAnnotation;
1397
+ if (types.length < 2) return;
1398
+ const allStringLiterals = types.every(
1399
+ (member) => member.type === "TSLiteralType" && member.literal.type === "Literal" && typeof member.literal.value === "string"
1400
+ );
1401
+ if (!allStringLiterals) return;
1402
+ const typeName = node.id.name;
1403
+ const isExported = node.parent.type === "ExportNamedDeclaration";
1404
+ const exportPrefix = isExported ? "export " : "";
1405
+ const enumMembers = types.map((member) => {
1406
+ const value = member.literal.value;
1407
+ const memberName = toPascalCase(value);
1408
+ return ` ${memberName} = '${value}',`;
1409
+ }).join("\n");
1410
+ const replacement = `${exportPrefix}const enum ${typeName} {
1411
+ ${enumMembers}
1412
+ }`;
1413
+ const targetNode = isExported ? node.parent : node;
1414
+ context.report({
1415
+ node: node.id,
1416
+ messageId: "preferConstEnum",
1417
+ data: { name: typeName },
1418
+ suggest: [
1419
+ {
1420
+ messageId: "convertToConstEnum",
1421
+ data: { name: typeName },
1422
+ fix(fixer) {
1423
+ return fixer.replaceText(targetNode, replacement);
1424
+ }
1425
+ }
1426
+ ]
1427
+ });
1428
+ }
1429
+ };
1430
+ }
1431
+ };
1432
+ var prefer_const_enum_default = {
1433
+ rules: {
1434
+ "prefer-const-enum": preferConstEnumRule
1435
+ }
1436
+ };
1437
+
1438
+ // src/rules/require-stable-hook-args.js
1439
+ var STABLE_INIT_CALLS = /* @__PURE__ */ new Set([
1440
+ "useCallback",
1441
+ "useMemo",
1442
+ "useRef",
1443
+ "useState",
1444
+ "useReducer",
1445
+ "useContext",
1446
+ "useId",
1447
+ "useDeferredValue",
1448
+ "useTransition",
1449
+ "useSyncExternalStore",
1450
+ "useActionState",
1451
+ "useFormStatus",
1452
+ "useOptimistic",
1453
+ "StyleSheet.create",
1454
+ "Object.freeze"
1455
+ ]);
1456
+ var IGNORED_HOOKS = /* @__PURE__ */ new Set([
1457
+ // React built-in
1458
+ "useState",
1459
+ "useEffect",
1460
+ "useLayoutEffect",
1461
+ "useCallback",
1462
+ "useMemo",
1463
+ "useRef",
1464
+ "useReducer",
1465
+ "useContext",
1466
+ "useImperativeHandle",
1467
+ "useDebugValue",
1468
+ "useId",
1469
+ "useDeferredValue",
1470
+ "useTransition",
1471
+ "useSyncExternalStore",
1472
+ "useInsertionEffect",
1473
+ "useActionState",
1474
+ "useFormStatus",
1475
+ "useOptimistic",
1476
+ "use",
1477
+ // Redux - selector runs on every render by design
1478
+ "useSelector",
1479
+ "useDispatch",
1480
+ "useStore",
1481
+ // React Query / TanStack Query - callbacks are not deps
1482
+ "useQuery",
1483
+ "useMutation",
1484
+ "useInfiniteQuery",
1485
+ "useQueryClient",
1486
+ "useSuspenseQuery",
1487
+ "useSuspenseInfiniteQuery",
1488
+ "useQueries",
1489
+ "usePrefetchQuery",
1490
+ "useIsFetching",
1491
+ "useIsMutating",
1492
+ // React Navigation / Expo Router
1493
+ "useNavigation",
1494
+ "useRoute",
1495
+ "useRouter",
1496
+ "usePathname",
1497
+ "useSegments",
1498
+ "useSearchParams",
1499
+ "useLocalSearchParams",
1500
+ "useGlobalSearchParams",
1501
+ "useFocusEffect",
1502
+ "useNavigationState",
1503
+ // i18next
1504
+ "useTranslation",
1505
+ // Zustand - selector runs on every render
1506
+ "useStoreWithEqualityFn",
1507
+ // React Spring / Animated
1508
+ "useSpring",
1509
+ "useSprings",
1510
+ "useTrail",
1511
+ "useChain",
1512
+ // Syncfusion
1513
+ "useDynamicFormStyles",
1514
+ // React Hook Form - options object is safely handled
1515
+ "useForm",
1516
+ "useFormContext",
1517
+ "useController",
1518
+ "useWatch",
1519
+ "useFieldArray"
1520
+ ]);
1521
+ function isUnstableInit(initNode) {
1522
+ if (!initNode) return null;
1523
+ if (initNode.type === "ArrowFunctionExpression" || initNode.type === "FunctionExpression")
1524
+ return "function";
1525
+ if (initNode.type === "ObjectExpression") return "object";
1526
+ if (initNode.type === "ArrayExpression") return "array";
1527
+ return null;
1528
+ }
1529
+ function isStableCall(initNode) {
1530
+ if (initNode.type !== "CallExpression") return false;
1531
+ const callee = initNode.callee;
1532
+ if (callee.type === "Identifier")
1533
+ return STABLE_INIT_CALLS.has(callee.name);
1534
+ if (callee.type === "MemberExpression" && callee.object.type === "Identifier" && callee.property.type === "Identifier")
1535
+ return STABLE_INIT_CALLS.has(`${callee.object.name}.${callee.property.name}`);
1536
+ return false;
1537
+ }
1538
+ function getCalleeName(callNode) {
1539
+ const callee = callNode.callee;
1540
+ if (callee.type === "Identifier") return callee.name;
1541
+ if (callee.type === "MemberExpression" && callee.object.type === "Identifier" && callee.property.type === "Identifier")
1542
+ return `${callee.object.name}.${callee.property.name}`;
1543
+ return null;
1544
+ }
1545
+ function isCustomHookName(name, extraIgnored, patterns) {
1546
+ if (!name || name.length <= 3 || !name.startsWith("use")) return false;
1547
+ const charAfterUse = name[3];
1548
+ const isUpperCase = charAfterUse === charAfterUse.toUpperCase() && charAfterUse !== charAfterUse.toLowerCase();
1549
+ if (!isUpperCase) return false;
1550
+ if (IGNORED_HOOKS.has(name)) return false;
1551
+ if (extraIgnored && extraIgnored.has(name)) return false;
1552
+ if (patterns && patterns.some((re) => re.test(name))) return false;
1553
+ return true;
1554
+ }
1555
+ function isInsideComponentOrHook(node) {
1556
+ let current = node.parent;
1557
+ while (current) {
1558
+ const isFunction = current.type === "FunctionDeclaration" || current.type === "FunctionExpression" || current.type === "ArrowFunctionExpression";
1559
+ if (isFunction) {
1560
+ const name = getFunctionName(current);
1561
+ if (!name) return false;
1562
+ const isPascalCase = name[0] === name[0].toUpperCase() && name[0] !== name[0].toLowerCase();
1563
+ const isHook = name.length > 3 && name.startsWith("use");
1564
+ return isPascalCase || isHook;
1565
+ }
1566
+ current = current.parent;
1567
+ }
1568
+ return false;
1569
+ }
1570
+ function getFunctionName(funcNode) {
1571
+ if (funcNode.id) return funcNode.id.name;
1572
+ if (funcNode.parent && funcNode.parent.type === "VariableDeclarator" && funcNode.parent.id && funcNode.parent.id.type === "Identifier")
1573
+ return funcNode.parent.id.name;
1574
+ return null;
1575
+ }
1576
+ var requireStableHookArgsRule = {
1577
+ meta: {
1578
+ type: "problem",
1579
+ docs: {
1580
+ description: "Disallow passing unstable functions/objects/arrays to custom hooks. Wrap in useCallback/useMemo to prevent infinite re-renders.",
1581
+ category: "Possible Errors",
1582
+ recommended: true
1583
+ },
1584
+ schema: [
1585
+ {
1586
+ type: "object",
1587
+ properties: {
1588
+ ignoreHooks: {
1589
+ type: "array",
1590
+ items: { type: "string" },
1591
+ description: 'Additional hook names to ignore (e.g., ["useMyLibraryHook"])'
1592
+ },
1593
+ ignoreHookPatterns: {
1594
+ type: "array",
1595
+ items: { type: "string" },
1596
+ description: 'Regex patterns for hook names to ignore (e.g., ["^useIdentityService", "^useQuestionerWeb"])'
1597
+ }
1598
+ },
1599
+ additionalProperties: false
1600
+ }
1601
+ ],
1602
+ messages: {
1603
+ unstableFunction: 'Unstable function "{{name}}" passed to hook "{{hook}}". Wrap in useCallback() to prevent infinite re-renders.',
1604
+ unstableObject: 'Unstable object "{{name}}" passed to hook "{{hook}}". Wrap in useMemo() to prevent infinite re-renders.',
1605
+ unstableArray: 'Unstable array "{{name}}" passed to hook "{{hook}}". Wrap in useMemo() to prevent infinite re-renders.',
1606
+ unstableInlineFunction: 'Inline function passed to hook "{{hook}}". Extract to a useCallback() variable to prevent infinite re-renders.',
1607
+ unstableInlineObject: 'Inline object passed to hook "{{hook}}". Extract to a useMemo() variable to prevent infinite re-renders.',
1608
+ unstableInlineArray: 'Inline array passed to hook "{{hook}}". Extract to a useMemo() variable to prevent infinite re-renders.'
1609
+ }
1610
+ },
1611
+ create(context) {
1612
+ const options = context.options[0] || {};
1613
+ const extraIgnored = options.ignoreHooks ? new Set(options.ignoreHooks) : null;
1614
+ const ignorePatterns = (options.ignoreHookPatterns || []).map((p) => new RegExp(p));
1615
+ const unstableVars = /* @__PURE__ */ new Map();
1616
+ return {
1617
+ /**
1618
+ * Track variable declarations with unstable initializers.
1619
+ * e.g., const t = (key) => i18nT(key);
1620
+ */
1621
+ VariableDeclarator(node) {
1622
+ if (!node.id || node.id.type !== "Identifier" || !node.init)
1623
+ return;
1624
+ if (isStableCall(node.init)) return;
1625
+ const unstableType = isUnstableInit(node.init);
1626
+ if (!unstableType) return;
1627
+ if (!isInsideComponentOrHook(node)) return;
1628
+ unstableVars.set(node.id.name, {
1629
+ type: unstableType,
1630
+ node
1631
+ });
1632
+ },
1633
+ /**
1634
+ * Check call expressions that look like custom hooks.
1635
+ * Flag any arguments that reference unstable variables or are inline literals.
1636
+ */
1637
+ CallExpression(node) {
1638
+ const hookName = getCalleeName(node);
1639
+ if (!isCustomHookName(hookName, extraIgnored, ignorePatterns)) return;
1640
+ if (!isInsideComponentOrHook(node)) return;
1641
+ for (const arg of node.arguments) {
1642
+ if (arg.type === "Identifier") {
1643
+ const tracked = unstableVars.get(arg.name);
1644
+ if (!tracked) continue;
1645
+ const messageMap = {
1646
+ function: "unstableFunction",
1647
+ object: "unstableObject",
1648
+ array: "unstableArray"
1649
+ };
1650
+ context.report({
1651
+ node: arg,
1652
+ messageId: messageMap[tracked.type],
1653
+ data: {
1654
+ name: arg.name,
1655
+ hook: hookName
1656
+ }
1657
+ });
1658
+ continue;
1659
+ }
1660
+ const inlineType = isUnstableInit(arg);
1661
+ if (inlineType) {
1662
+ const inlineMessageMap = {
1663
+ function: "unstableInlineFunction",
1664
+ object: "unstableInlineObject",
1665
+ array: "unstableInlineArray"
1666
+ };
1667
+ context.report({
1668
+ node: arg,
1669
+ messageId: inlineMessageMap[inlineType],
1670
+ data: { hook: hookName }
1671
+ });
1672
+ }
1673
+ }
1674
+ }
1675
+ };
1676
+ }
1677
+ };
1678
+ var require_stable_hook_args_default = {
1679
+ rules: {
1680
+ "require-stable-hook-args": requireStableHookArgsRule
1681
+ }
1682
+ };
1683
+
1684
+ // src/rules/smart-max-lines.js
1685
+ var COMPONENT_MAX_DEFAULT = 200;
1686
+ var FUNCTION_MAX_DEFAULT = 50;
1687
+ var FUNCTION_WARN_DEFAULT = 30;
1688
+ function isJSX2(node) {
1689
+ if (!node) {
1690
+ return false;
1691
+ }
1692
+ return node.type === "JSXElement" || node.type === "JSXFragment";
1693
+ }
1694
+ function expressionReturnsJSX2(node) {
1695
+ if (!node) {
1696
+ return false;
1697
+ }
1698
+ if (isJSX2(node)) {
1699
+ return true;
1700
+ }
1701
+ if (node.type === "ConditionalExpression") {
1702
+ return expressionReturnsJSX2(node.consequent) || expressionReturnsJSX2(node.alternate);
1703
+ }
1704
+ if (node.type === "LogicalExpression") {
1705
+ return expressionReturnsJSX2(node.left) || expressionReturnsJSX2(node.right);
1706
+ }
1707
+ if (node.type === "ParenthesizedExpression") {
1708
+ return expressionReturnsJSX2(node.expression);
1709
+ }
1710
+ if (node.type === "SequenceExpression") {
1711
+ const lastExpr = node.expressions[node.expressions.length - 1];
1712
+ return expressionReturnsJSX2(lastExpr);
1713
+ }
1714
+ return false;
1715
+ }
1716
+ function blockReturnsJSX2(blockBody) {
1717
+ if (!blockBody || !Array.isArray(blockBody)) {
1718
+ return false;
1719
+ }
1720
+ for (const statement of blockBody) {
1721
+ if (statementReturnsJSX(statement)) {
1722
+ return true;
1723
+ }
1724
+ }
1725
+ return false;
1726
+ }
1727
+ function statementReturnsJSX(statement) {
1728
+ if (!statement) {
1729
+ return false;
1730
+ }
1731
+ switch (statement.type) {
1732
+ case "ReturnStatement":
1733
+ return expressionReturnsJSX2(statement.argument);
1734
+ case "IfStatement":
1735
+ if (statement.consequent) {
1736
+ if (statement.consequent.type === "BlockStatement") {
1737
+ if (blockReturnsJSX2(statement.consequent.body)) {
1738
+ return true;
1739
+ }
1740
+ } else if (statementReturnsJSX(statement.consequent)) {
1741
+ return true;
1742
+ }
1743
+ }
1744
+ if (statement.alternate) {
1745
+ if (statement.alternate.type === "BlockStatement") {
1746
+ if (blockReturnsJSX2(statement.alternate.body)) {
1747
+ return true;
1748
+ }
1749
+ } else if (statementReturnsJSX(statement.alternate)) {
1750
+ return true;
1751
+ }
1752
+ }
1753
+ return false;
1754
+ case "SwitchStatement":
1755
+ for (const switchCase of statement.cases) {
1756
+ if (blockReturnsJSX2(switchCase.consequent)) {
1757
+ return true;
1758
+ }
1759
+ }
1760
+ return false;
1761
+ case "TryStatement":
1762
+ if (statement.block && blockReturnsJSX2(statement.block.body)) {
1763
+ return true;
1764
+ }
1765
+ if (statement.handler && statement.handler.body && blockReturnsJSX2(statement.handler.body.body)) {
1766
+ return true;
1767
+ }
1768
+ if (statement.finalizer && blockReturnsJSX2(statement.finalizer.body)) {
1769
+ return true;
1770
+ }
1771
+ return false;
1772
+ case "BlockStatement":
1773
+ return blockReturnsJSX2(statement.body);
1774
+ default:
1775
+ return false;
1776
+ }
1777
+ }
1778
+ function isReactComponent(node) {
1779
+ if (node.type === "ArrowFunctionExpression") {
1780
+ if (node.body.type !== "BlockStatement") {
1781
+ return expressionReturnsJSX2(node.body);
1782
+ }
1783
+ }
1784
+ const body = node.body;
1785
+ if (body && body.type === "BlockStatement") {
1786
+ return blockReturnsJSX2(body.body);
1787
+ }
1788
+ return false;
1789
+ }
1790
+ function countLines(node, sourceCode, skipBlankLines, skipComments) {
1791
+ const startLine = node.loc.start.line;
1792
+ const endLine = node.loc.end.line;
1793
+ if (!skipBlankLines && !skipComments) {
1794
+ return endLine - startLine + 1;
1795
+ }
1796
+ const lines = sourceCode.lines.slice(startLine - 1, endLine);
1797
+ let count = 0;
1798
+ const allComments = sourceCode.getAllComments();
1799
+ const functionComments = allComments.filter(
1800
+ (comment) => comment.loc.start.line >= startLine && comment.loc.end.line <= endLine
1801
+ );
1802
+ const commentOnlyLines = /* @__PURE__ */ new Set();
1803
+ if (skipComments) {
1804
+ for (const comment of functionComments) {
1805
+ for (let line = comment.loc.start.line; line <= comment.loc.end.line; line++) {
1806
+ const lineContent = sourceCode.lines[line - 1];
1807
+ if (lineContent) {
1808
+ const trimmed = lineContent.trim();
1809
+ const isOnlyComment = trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*") || trimmed.endsWith("*/") || trimmed === "";
1810
+ if (isOnlyComment) {
1811
+ commentOnlyLines.add(line);
1812
+ }
1813
+ }
1814
+ }
1815
+ }
1816
+ }
1817
+ for (let i = 0; i < lines.length; i++) {
1818
+ const lineNumber = startLine + i;
1819
+ const lineContent = lines[i];
1820
+ if (skipBlankLines && lineContent.trim() === "") {
1821
+ continue;
1822
+ }
1823
+ if (skipComments && commentOnlyLines.has(lineNumber)) {
1824
+ continue;
1825
+ }
1826
+ count++;
1827
+ }
1828
+ return count;
1829
+ }
1830
+ var smartMaxLinesRule = {
1831
+ meta: {
1832
+ type: "suggestion",
1833
+ docs: {
1834
+ description: "Enforce different line limits for React components vs regular functions",
1835
+ category: "Best Practices",
1836
+ recommended: true
1837
+ },
1838
+ schema: [
1839
+ {
1840
+ type: "object",
1841
+ properties: {
1842
+ componentMax: {
1843
+ type: "integer",
1844
+ minimum: 1,
1845
+ description: "Maximum lines for React components"
1846
+ },
1847
+ functionMax: {
1848
+ type: "integer",
1849
+ minimum: 1,
1850
+ description: "Maximum lines for regular functions (error threshold)"
1851
+ },
1852
+ functionWarn: {
1853
+ type: "integer",
1854
+ minimum: 1,
1855
+ description: "Warning threshold for regular functions"
1856
+ },
1857
+ skipBlankLines: {
1858
+ type: "boolean",
1859
+ description: "Skip blank lines when counting"
1860
+ },
1861
+ skipComments: {
1862
+ type: "boolean",
1863
+ description: "Skip comment lines when counting"
1864
+ }
1865
+ },
1866
+ additionalProperties: false
1867
+ }
1868
+ ],
1869
+ messages: {
1870
+ componentTooLong: "React component has too many lines ({{count}}). Maximum allowed is {{max}}.",
1871
+ functionTooLong: "Function has too many lines ({{count}}). Maximum allowed is {{max}}.",
1872
+ functionWarning: "Function has {{count}} lines which exceeds recommended limit of {{warn}}. Consider refactoring."
1873
+ }
1874
+ },
1875
+ create(context) {
1876
+ const options = context.options[0] || {};
1877
+ const componentMax = options.componentMax ?? COMPONENT_MAX_DEFAULT;
1878
+ const functionMax = options.functionMax ?? FUNCTION_MAX_DEFAULT;
1879
+ const functionWarn = options.functionWarn ?? FUNCTION_WARN_DEFAULT;
1880
+ const skipBlankLines = options.skipBlankLines ?? true;
1881
+ const skipComments = options.skipComments ?? true;
1882
+ const sourceCode = context.sourceCode || context.getSourceCode();
1883
+ function checkFunction(node) {
1884
+ const lineCount = countLines(node, sourceCode, skipBlankLines, skipComments);
1885
+ const isComponent = isReactComponent(node);
1886
+ if (isComponent) {
1887
+ if (lineCount > componentMax) {
1888
+ context.report({
1889
+ node,
1890
+ messageId: "componentTooLong",
1891
+ data: {
1892
+ count: String(lineCount),
1893
+ max: String(componentMax)
1894
+ }
1895
+ });
1896
+ }
1897
+ } else {
1898
+ if (lineCount > functionMax) {
1899
+ context.report({
1900
+ node,
1901
+ messageId: "functionTooLong",
1902
+ data: {
1903
+ count: String(lineCount),
1904
+ max: String(functionMax)
1905
+ }
1906
+ });
1907
+ } else if (lineCount > functionWarn) {
1908
+ context.report({
1909
+ node,
1910
+ messageId: "functionWarning",
1911
+ data: {
1912
+ count: String(lineCount),
1913
+ warn: String(functionWarn)
1914
+ }
1915
+ });
1916
+ }
1917
+ }
1918
+ }
1919
+ return {
1920
+ FunctionDeclaration: checkFunction,
1921
+ FunctionExpression: checkFunction,
1922
+ ArrowFunctionExpression: checkFunction
1923
+ };
1924
+ }
1925
+ };
1926
+ var smart_max_lines_default = {
1927
+ rules: {
1928
+ "smart-max-lines": smartMaxLinesRule
1929
+ }
1930
+ };
1931
+
1932
+ // src/eslint/plugin.ts
1933
+ var PLUGIN_VERSION = "1.0.0";
1934
+ var ruleModules = [
1935
+ enforce_function_style_default,
1936
+ enforce_module_structure_default,
1937
+ enforce_route_preload_default,
1938
+ enforce_test_colocation_default,
1939
+ enum_file_isolation_default,
1940
+ i18n_interpolation_default,
1941
+ i18n_param_names_default,
1942
+ no_barrel_companion_file_default,
1943
+ no_duplicate_nav_prefix_default,
1944
+ no_duplicate_shared_patterns_default,
1945
+ no_generated_models_barrel_value_import_default,
1946
+ no_null_check_default,
1947
+ no_optional_undefined_default,
1948
+ no_product_imports_in_shared_default,
1949
+ prefer_const_enum_default,
1950
+ require_stable_hook_args_default,
1951
+ smart_max_lines_default
1952
+ ];
1953
+ function mergeRules(modules) {
1954
+ const merged = {};
1955
+ for (const mod of modules) {
1956
+ for (const [name, rule3] of Object.entries(mod.rules)) {
1957
+ if (merged[name] !== void 0) {
1958
+ throw new Error(`Duplicate ESLint rule name: "${name}"`);
1959
+ }
1960
+ merged[name] = rule3;
1961
+ }
1962
+ }
1963
+ return merged;
1964
+ }
1965
+ var plugin = {
1966
+ meta: { name: "@dloizides/frontend-devtools", version: PLUGIN_VERSION },
1967
+ rules: mergeRules(ruleModules)
1968
+ };
1969
+ var rules = plugin.rules;
1970
+ var ruleNames = Object.keys(plugin.rules).sort();
1971
+
1972
+ // src/eslint/legacy.ts
1973
+ var legacyPlugins = buildLegacyPlugins();
1974
+ function buildLegacyPlugins() {
1975
+ const out = {};
1976
+ for (const [name, rule3] of Object.entries(rules)) {
1977
+ out[name] = oneRulePlugin(name, rule3);
1978
+ }
1979
+ return out;
1980
+ }
1981
+ function oneRulePlugin(name, rule3) {
1982
+ return {
1983
+ meta: { name, version: "1.0.0" },
1984
+ rules: { [name]: rule3 }
1985
+ };
1986
+ }
1987
+
1988
+ export { legacyPlugins, plugin, ruleNames, rules };
1989
+ //# sourceMappingURL=index.mjs.map
1990
+ //# sourceMappingURL=index.mjs.map