@gaia-react/lint 1.1.3 → 1.3.0
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.
- package/README.md +85 -48
- package/dist/configs/base.d.ts +1 -1
- package/dist/configs/base.d.ts.map +1 -1
- package/dist/configs/guardrails.d.ts +1 -1
- package/dist/configs/guardrails.d.ts.map +1 -1
- package/dist/configs/ignores.d.ts +10 -2
- package/dist/configs/ignores.d.ts.map +1 -1
- package/dist/configs/style-hygiene.d.ts +1 -1
- package/dist/configs/style-hygiene.d.ts.map +1 -1
- package/dist/index.d.ts +44 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +353 -303
- package/dist/index.js.map +1 -1
- package/dist/plugins/no-jsx-iife.d.ts +4 -0
- package/dist/plugins/no-jsx-iife.d.ts.map +1 -0
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -79,7 +79,7 @@ var typescriptConfig = [
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
];
|
|
82
|
-
var
|
|
82
|
+
var buildTsEslintConfig = (sourceDir) => [
|
|
83
83
|
{
|
|
84
84
|
files: ["**/*.ts?(x)"],
|
|
85
85
|
name: "typescript/config",
|
|
@@ -121,14 +121,22 @@ var tsEslintConfig = [
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
|
-
files: [
|
|
124
|
+
files: [
|
|
125
|
+
`${sourceDir}/hooks/**/*`,
|
|
126
|
+
`${sourceDir}/routes/**/*`,
|
|
127
|
+
`${sourceDir}/sessions.server/**/*`
|
|
128
|
+
],
|
|
125
129
|
name: "typescript/only-throw-error",
|
|
126
130
|
rules: {
|
|
127
131
|
"@typescript-eslint/only-throw-error": "off"
|
|
128
132
|
}
|
|
129
133
|
},
|
|
130
134
|
{
|
|
131
|
-
files: [
|
|
135
|
+
files: [
|
|
136
|
+
`${sourceDir}/utils/**`,
|
|
137
|
+
`${sourceDir}/services/**`,
|
|
138
|
+
`${sourceDir}/hooks/**`
|
|
139
|
+
],
|
|
132
140
|
name: "typescript/explicit-return-types",
|
|
133
141
|
rules: {
|
|
134
142
|
"@typescript-eslint/explicit-module-boundary-types": "error"
|
|
@@ -161,7 +169,7 @@ var tsEslintConfig = [
|
|
|
161
169
|
}
|
|
162
170
|
}
|
|
163
171
|
];
|
|
164
|
-
var
|
|
172
|
+
var buildImportXConfig = (sourceDir) => [
|
|
165
173
|
{
|
|
166
174
|
name: "import-x-all-files",
|
|
167
175
|
rules: {
|
|
@@ -200,14 +208,14 @@ var importXConfig = [
|
|
|
200
208
|
}
|
|
201
209
|
},
|
|
202
210
|
{
|
|
203
|
-
files: [
|
|
211
|
+
files: [`${sourceDir}/**/!(*.test|*.stories).ts?(x)`],
|
|
204
212
|
name: "import-x/app-test-files",
|
|
205
213
|
rules: {
|
|
206
214
|
"import-x/no-unresolved": "error"
|
|
207
215
|
}
|
|
208
216
|
},
|
|
209
217
|
{
|
|
210
|
-
files: [
|
|
218
|
+
files: [`${sourceDir}/**/hooks/*.ts?(x)`],
|
|
211
219
|
name: "import-x/hooks",
|
|
212
220
|
rules: {
|
|
213
221
|
"import-x/no-default-export": "error"
|
|
@@ -290,17 +298,311 @@ var lodashUnderscoreConfig = [
|
|
|
290
298
|
}
|
|
291
299
|
}
|
|
292
300
|
];
|
|
293
|
-
var
|
|
301
|
+
var buildBase = (sourceDir) => [
|
|
294
302
|
...jsConfig,
|
|
295
303
|
...jsCustomConfig,
|
|
296
304
|
...typescriptConfig,
|
|
297
|
-
...
|
|
298
|
-
...
|
|
305
|
+
...buildTsEslintConfig(sourceDir),
|
|
306
|
+
...buildImportXConfig(sourceDir),
|
|
299
307
|
...eslintCommentsConfig,
|
|
300
308
|
...preferArrowFunctionsConfig,
|
|
301
309
|
...lodashUnderscoreConfig
|
|
302
310
|
];
|
|
303
311
|
|
|
312
|
+
// src/configs/better-tailwind.ts
|
|
313
|
+
import betterTailwindPlugin from "eslint-plugin-better-tailwindcss";
|
|
314
|
+
var betterTailwind = (opts) => [
|
|
315
|
+
{
|
|
316
|
+
name: "better-tailwindcss",
|
|
317
|
+
plugins: {
|
|
318
|
+
"better-tailwindcss": betterTailwindPlugin
|
|
319
|
+
},
|
|
320
|
+
rules: {
|
|
321
|
+
"better-tailwindcss/enforce-canonical-classes": "error",
|
|
322
|
+
"better-tailwindcss/enforce-consistent-important-position": "error",
|
|
323
|
+
"better-tailwindcss/enforce-consistent-variable-syntax": "error",
|
|
324
|
+
"better-tailwindcss/enforce-shorthand-classes": "error",
|
|
325
|
+
"better-tailwindcss/no-conflicting-classes": "error",
|
|
326
|
+
"better-tailwindcss/no-deprecated-classes": "error",
|
|
327
|
+
"better-tailwindcss/no-unknown-classes": [
|
|
328
|
+
"error",
|
|
329
|
+
{ ignore: opts.ignore ?? [] }
|
|
330
|
+
]
|
|
331
|
+
},
|
|
332
|
+
settings: {
|
|
333
|
+
"better-tailwindcss": {
|
|
334
|
+
detectComponentClasses: true,
|
|
335
|
+
entryPoint: opts.entryPoint
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
];
|
|
340
|
+
|
|
341
|
+
// src/configs/guardrails.ts
|
|
342
|
+
import noRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
|
|
343
|
+
import sonarjs from "eslint-plugin-sonarjs";
|
|
344
|
+
|
|
345
|
+
// src/plugins/no-enum.ts
|
|
346
|
+
var noEnumRule = {
|
|
347
|
+
create: (context) => ({
|
|
348
|
+
TSEnumDeclaration: (node) => {
|
|
349
|
+
context.report({ messageId: "noEnum", node });
|
|
350
|
+
}
|
|
351
|
+
}),
|
|
352
|
+
meta: {
|
|
353
|
+
docs: { description: "Disallow TypeScript enums" },
|
|
354
|
+
messages: {
|
|
355
|
+
noEnum: "Do not use TypeScript enums. Use an object with `as const` instead."
|
|
356
|
+
},
|
|
357
|
+
schema: [],
|
|
358
|
+
type: "problem"
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
var plugin = {
|
|
362
|
+
meta: {
|
|
363
|
+
name: "no-enum",
|
|
364
|
+
version: "0.1.0"
|
|
365
|
+
},
|
|
366
|
+
rules: {
|
|
367
|
+
"no-enum": noEnumRule
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
var no_enum_default = plugin;
|
|
371
|
+
|
|
372
|
+
// src/plugins/no-jsx-iife.ts
|
|
373
|
+
var noJsxIifeRule = {
|
|
374
|
+
create: (context) => ({
|
|
375
|
+
"JSXExpressionContainer > CallExpression > ArrowFunctionExpression.callee": (node) => {
|
|
376
|
+
context.report({ messageId: "noJsxIife", node });
|
|
377
|
+
},
|
|
378
|
+
"JSXExpressionContainer > CallExpression > FunctionExpression.callee": (node) => {
|
|
379
|
+
context.report({ messageId: "noJsxIife", node });
|
|
380
|
+
}
|
|
381
|
+
}),
|
|
382
|
+
meta: {
|
|
383
|
+
docs: { description: "Disallow IIFEs in JSX expressions" },
|
|
384
|
+
messages: {
|
|
385
|
+
noJsxIife: "Do not use IIFEs in JSX. Use a computed variable before the return or extract a component instead."
|
|
386
|
+
},
|
|
387
|
+
schema: [],
|
|
388
|
+
type: "problem"
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
var plugin2 = {
|
|
392
|
+
meta: {
|
|
393
|
+
name: "no-jsx-iife",
|
|
394
|
+
version: "0.1.0"
|
|
395
|
+
},
|
|
396
|
+
rules: {
|
|
397
|
+
"no-jsx-iife": noJsxIifeRule
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
var no_jsx_iife_default = plugin2;
|
|
401
|
+
|
|
402
|
+
// src/plugins/no-switch.ts
|
|
403
|
+
var noSwitchRule = {
|
|
404
|
+
create: (context) => ({
|
|
405
|
+
SwitchStatement: (node) => {
|
|
406
|
+
context.report({ messageId: "noSwitch", node });
|
|
407
|
+
}
|
|
408
|
+
}),
|
|
409
|
+
meta: {
|
|
410
|
+
docs: { description: "Disallow switch statements" },
|
|
411
|
+
messages: {
|
|
412
|
+
noSwitch: "Do not use switch statements. Use an object map or if/else instead."
|
|
413
|
+
},
|
|
414
|
+
schema: [],
|
|
415
|
+
type: "problem"
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
var plugin3 = {
|
|
419
|
+
meta: {
|
|
420
|
+
name: "no-switch",
|
|
421
|
+
version: "0.1.0"
|
|
422
|
+
},
|
|
423
|
+
rules: {
|
|
424
|
+
"no-switch": noSwitchRule
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var no_switch_default = plugin3;
|
|
428
|
+
|
|
429
|
+
// src/configs/guardrails.ts
|
|
430
|
+
var buildSonarConfig = (sourceDir) => [
|
|
431
|
+
sonarjs.configs.recommended,
|
|
432
|
+
{
|
|
433
|
+
name: "sonarjs",
|
|
434
|
+
rules: {
|
|
435
|
+
"sonarjs/cognitive-complexity": "error",
|
|
436
|
+
"sonarjs/fixme-tag": "off",
|
|
437
|
+
"sonarjs/no-commented-code": "off",
|
|
438
|
+
"sonarjs/no-nested-conditional": "off",
|
|
439
|
+
"sonarjs/no-nested-functions": "off",
|
|
440
|
+
"sonarjs/no-selector-parameter": "off",
|
|
441
|
+
"sonarjs/regex-complexity": "off",
|
|
442
|
+
"sonarjs/todo-tag": "off"
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
files: ["**/*.tsx", "**/hooks/*.ts?(x)"],
|
|
447
|
+
name: "sonarjs/react-files",
|
|
448
|
+
rules: {
|
|
449
|
+
"sonarjs/cognitive-complexity": "off",
|
|
450
|
+
"sonarjs/function-return-type": "off"
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
files: ["**/*.test.ts?(x)", "**/*.stories.ts?(x)"],
|
|
455
|
+
name: "sonarjs/test-files",
|
|
456
|
+
rules: {
|
|
457
|
+
"sonarjs/no-duplicate-string": "off",
|
|
458
|
+
"sonarjs/no-identical-functions": "off"
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
files: [`${sourceDir}/languages/**/*.ts`, "eslint.config.mjs"],
|
|
463
|
+
name: "sonarjs/credential-checks",
|
|
464
|
+
rules: {
|
|
465
|
+
"sonarjs/no-hardcoded-credentials": "off",
|
|
466
|
+
"sonarjs/no-hardcoded-passwords": "off"
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
];
|
|
470
|
+
var noEnumConfig = [
|
|
471
|
+
{
|
|
472
|
+
files: ["**/*.ts?(x)"],
|
|
473
|
+
name: "no-enum",
|
|
474
|
+
plugins: { "no-enum": no_enum_default },
|
|
475
|
+
rules: {
|
|
476
|
+
"no-enum/no-enum": "error"
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
];
|
|
480
|
+
var noJsxIifeConfig = [
|
|
481
|
+
{
|
|
482
|
+
files: ["**/*.tsx", "**/*.jsx"],
|
|
483
|
+
name: "no-jsx-iife",
|
|
484
|
+
plugins: { "no-jsx-iife": no_jsx_iife_default },
|
|
485
|
+
rules: { "no-jsx-iife/no-jsx-iife": "error" }
|
|
486
|
+
}
|
|
487
|
+
];
|
|
488
|
+
var noSwitchConfig = [
|
|
489
|
+
{
|
|
490
|
+
files: ["**/*.ts?(x)", "**/*.js?(x)"],
|
|
491
|
+
name: "no-switch",
|
|
492
|
+
plugins: { "no-switch": no_switch_default },
|
|
493
|
+
rules: { "no-switch/no-switch": "error" }
|
|
494
|
+
}
|
|
495
|
+
];
|
|
496
|
+
var buildNoRelativeImportPathsConfig = (sourceDir) => [
|
|
497
|
+
{
|
|
498
|
+
name: "no-relative-import-paths",
|
|
499
|
+
plugins: {
|
|
500
|
+
"no-relative-import-paths": noRelativeImportPaths
|
|
501
|
+
},
|
|
502
|
+
rules: {
|
|
503
|
+
"no-relative-import-paths/no-relative-import-paths": [
|
|
504
|
+
"error",
|
|
505
|
+
{
|
|
506
|
+
allowedDepth: 2,
|
|
507
|
+
allowSameFolder: true,
|
|
508
|
+
prefix: "~",
|
|
509
|
+
rootDir: sourceDir
|
|
510
|
+
}
|
|
511
|
+
]
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
];
|
|
515
|
+
var buildGuardrails = (sourceDir) => [
|
|
516
|
+
...buildSonarConfig(sourceDir),
|
|
517
|
+
...noEnumConfig,
|
|
518
|
+
...noJsxIifeConfig,
|
|
519
|
+
...noSwitchConfig,
|
|
520
|
+
...buildNoRelativeImportPathsConfig(sourceDir)
|
|
521
|
+
];
|
|
522
|
+
|
|
523
|
+
// src/configs/ignores.ts
|
|
524
|
+
import { includeIgnoreFile } from "@eslint/config-helpers";
|
|
525
|
+
import fs from "fs";
|
|
526
|
+
import path from "path";
|
|
527
|
+
var defaultIgnores = [
|
|
528
|
+
".storybook",
|
|
529
|
+
".playwright",
|
|
530
|
+
"/.react-router/**",
|
|
531
|
+
".claude/**/*.js",
|
|
532
|
+
".claude/**/*.cjs",
|
|
533
|
+
"scripts",
|
|
534
|
+
"public/**",
|
|
535
|
+
"**/*.css",
|
|
536
|
+
"**/*.svg",
|
|
537
|
+
"**/*.md"
|
|
538
|
+
];
|
|
539
|
+
var ignores = (opts) => {
|
|
540
|
+
const out = [];
|
|
541
|
+
const gitignore = opts?.gitignore ?? ".gitignore";
|
|
542
|
+
if (gitignore !== false) {
|
|
543
|
+
const resolved = path.isAbsolute(gitignore) ? gitignore : path.resolve(process.cwd(), gitignore);
|
|
544
|
+
if (fs.existsSync(resolved)) {
|
|
545
|
+
out.push(includeIgnoreFile(resolved));
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
out.push({
|
|
549
|
+
ignores: [...defaultIgnores, ...opts?.extra ?? []],
|
|
550
|
+
name: "ignored-files"
|
|
551
|
+
});
|
|
552
|
+
return out;
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
// src/configs/playwright.ts
|
|
556
|
+
import playwrightPlugin from "eslint-plugin-playwright";
|
|
557
|
+
var playwright = [
|
|
558
|
+
{
|
|
559
|
+
name: "playwright",
|
|
560
|
+
...playwrightPlugin.configs["flat/recommended"],
|
|
561
|
+
files: [".playwright/**/*.ts?(x)"],
|
|
562
|
+
rules: {
|
|
563
|
+
...playwrightPlugin.configs["flat/recommended"].rules,
|
|
564
|
+
"playwright/expect-expect": [
|
|
565
|
+
"warn",
|
|
566
|
+
{ assertFunctionPatterns: ["^expect[A-Z]"] }
|
|
567
|
+
]
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
];
|
|
571
|
+
|
|
572
|
+
// src/configs/prettier.ts
|
|
573
|
+
import { rules as prettierConfigRules } from "eslint-config-prettier";
|
|
574
|
+
import prettierPlugin from "eslint-plugin-prettier";
|
|
575
|
+
var prettier = [
|
|
576
|
+
{
|
|
577
|
+
name: "prettier/plugin/config",
|
|
578
|
+
plugins: { prettier: prettierPlugin }
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
name: "prettier/config",
|
|
582
|
+
rules: {
|
|
583
|
+
...prettierConfigRules,
|
|
584
|
+
"@stylistic/padding-line-between-statements": [
|
|
585
|
+
"error",
|
|
586
|
+
{
|
|
587
|
+
blankLine: "always",
|
|
588
|
+
next: ["block-like", "export", "return", "throw"],
|
|
589
|
+
prev: "*"
|
|
590
|
+
}
|
|
591
|
+
],
|
|
592
|
+
"@stylistic/quotes": [
|
|
593
|
+
"error",
|
|
594
|
+
"single",
|
|
595
|
+
{
|
|
596
|
+
allowTemplateLiterals: "avoidEscape",
|
|
597
|
+
avoidEscape: true
|
|
598
|
+
}
|
|
599
|
+
],
|
|
600
|
+
"@stylistic/spaced-comment": "off",
|
|
601
|
+
"prettier/prettier": ["error", { endOfLine: "auto" }]
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
];
|
|
605
|
+
|
|
304
606
|
// src/configs/react.ts
|
|
305
607
|
import { configs as configs2, plugins as plugins2 } from "eslint-config-airbnb-extended";
|
|
306
608
|
var react = [
|
|
@@ -358,13 +660,19 @@ var react = [
|
|
|
358
660
|
}
|
|
359
661
|
];
|
|
360
662
|
|
|
663
|
+
// src/configs/storybook.ts
|
|
664
|
+
import storybookPlugin from "eslint-plugin-storybook";
|
|
665
|
+
var storybook = [
|
|
666
|
+
...storybookPlugin.configs["flat/recommended"]
|
|
667
|
+
];
|
|
668
|
+
|
|
361
669
|
// src/configs/style-hygiene.ts
|
|
362
670
|
import canonical from "eslint-plugin-canonical";
|
|
363
671
|
import checkFile from "eslint-plugin-check-file";
|
|
364
672
|
import perfectionist from "eslint-plugin-perfectionist";
|
|
365
673
|
import unicorn from "eslint-plugin-unicorn";
|
|
366
674
|
import unusedImports from "eslint-plugin-unused-imports";
|
|
367
|
-
var
|
|
675
|
+
var buildCanonicalConfig = (sourceDir) => [
|
|
368
676
|
canonical.configs["flat/recommended"],
|
|
369
677
|
{
|
|
370
678
|
name: "canonical",
|
|
@@ -384,9 +692,9 @@ var canonicalConfig = [
|
|
|
384
692
|
},
|
|
385
693
|
{
|
|
386
694
|
files: [
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
695
|
+
`${sourceDir}/root.tsx`,
|
|
696
|
+
`${sourceDir}/entry.server.tsx`,
|
|
697
|
+
`${sourceDir}/**/tests/*`,
|
|
390
698
|
"test/**/*.ts?(x)",
|
|
391
699
|
"**/*.stories.tsx",
|
|
392
700
|
"**/routes/**/*.tsx",
|
|
@@ -551,14 +859,14 @@ var unusedImportsConfig = [
|
|
|
551
859
|
}
|
|
552
860
|
}
|
|
553
861
|
];
|
|
554
|
-
var
|
|
862
|
+
var buildCheckFileConfig = (sourceDir) => [
|
|
555
863
|
{
|
|
556
864
|
plugins: {
|
|
557
865
|
"check-file": checkFile
|
|
558
866
|
}
|
|
559
867
|
},
|
|
560
868
|
{
|
|
561
|
-
files: [
|
|
869
|
+
files: [`${sourceDir}/**/*`],
|
|
562
870
|
name: "check-file",
|
|
563
871
|
rules: {
|
|
564
872
|
"check-file/filename-naming-convention": [
|
|
@@ -566,13 +874,13 @@ var checkFileConfig = [
|
|
|
566
874
|
{
|
|
567
875
|
// React hook files must be camelCase (to match the hook name)
|
|
568
876
|
"**/hooks/*.{ts,tsx}": "CAMEL_CASE",
|
|
569
|
-
|
|
877
|
+
[`${sourceDir}/state/*.tsx`]: "KEBAB_CASE",
|
|
570
878
|
// React component files must be named index.tsx
|
|
571
|
-
|
|
879
|
+
[`${sourceDir}/{components,pages}/**/!(assets|hooks|state|tests|utils)/*.tsx`]: "index+()",
|
|
572
880
|
// Generally, non-component files must be named kebab-case
|
|
573
|
-
|
|
881
|
+
[`${sourceDir}/{components,pages}/**/!(hooks)/*.ts`]: "KEBAB_CASE",
|
|
574
882
|
// Non-component files inside specific components folders must be kebab-case
|
|
575
|
-
|
|
883
|
+
[`${sourceDir}/{components,pages}/**/(assets|state|tests|utils)/*.{ts,tsx}`]: "KEBAB_CASE",
|
|
576
884
|
"test/**/*.ts?(x)": "KEBAB_CASE"
|
|
577
885
|
},
|
|
578
886
|
{
|
|
@@ -583,14 +891,14 @@ var checkFileConfig = [
|
|
|
583
891
|
"error",
|
|
584
892
|
{
|
|
585
893
|
// require stories and test files to be inside tests folders
|
|
586
|
-
"*.(stories|test).{ts,tsx}":
|
|
894
|
+
"*.(stories|test).{ts,tsx}": `${sourceDir}/**/tests/`
|
|
587
895
|
}
|
|
588
896
|
],
|
|
589
897
|
"check-file/folder-naming-convention": [
|
|
590
898
|
"error",
|
|
591
899
|
{
|
|
592
900
|
// enforce PascalCase component folders, and allow assets, hooks, tests, and utils subfolders
|
|
593
|
-
|
|
901
|
+
[`${sourceDir}/components/**/`]: "(assets|hooks|state|tests|utils|[A-Z][a-zA-Z0-9]*)"
|
|
594
902
|
}
|
|
595
903
|
]
|
|
596
904
|
}
|
|
@@ -611,155 +919,12 @@ var checkFileConfig = [
|
|
|
611
919
|
}
|
|
612
920
|
}
|
|
613
921
|
];
|
|
614
|
-
var
|
|
615
|
-
...
|
|
922
|
+
var buildStyleHygiene = (sourceDir) => [
|
|
923
|
+
...buildCanonicalConfig(sourceDir),
|
|
616
924
|
...perfectionistConfig,
|
|
617
925
|
...unicornConfig,
|
|
618
926
|
...unusedImportsConfig,
|
|
619
|
-
...
|
|
620
|
-
];
|
|
621
|
-
|
|
622
|
-
// src/configs/guardrails.ts
|
|
623
|
-
import noRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
|
|
624
|
-
import sonarjs from "eslint-plugin-sonarjs";
|
|
625
|
-
|
|
626
|
-
// src/plugins/no-enum.ts
|
|
627
|
-
var noEnumRule = {
|
|
628
|
-
create: (context) => ({
|
|
629
|
-
TSEnumDeclaration: (node) => {
|
|
630
|
-
context.report({ messageId: "noEnum", node });
|
|
631
|
-
}
|
|
632
|
-
}),
|
|
633
|
-
meta: {
|
|
634
|
-
docs: { description: "Disallow TypeScript enums" },
|
|
635
|
-
messages: {
|
|
636
|
-
noEnum: "Do not use TypeScript enums. Use an object with `as const` instead."
|
|
637
|
-
},
|
|
638
|
-
schema: [],
|
|
639
|
-
type: "problem"
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
var plugin = {
|
|
643
|
-
meta: {
|
|
644
|
-
name: "no-enum",
|
|
645
|
-
version: "0.1.0"
|
|
646
|
-
},
|
|
647
|
-
rules: {
|
|
648
|
-
"no-enum": noEnumRule
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
var no_enum_default = plugin;
|
|
652
|
-
|
|
653
|
-
// src/plugins/no-switch.ts
|
|
654
|
-
var noSwitchRule = {
|
|
655
|
-
create: (context) => ({
|
|
656
|
-
SwitchStatement: (node) => {
|
|
657
|
-
context.report({ messageId: "noSwitch", node });
|
|
658
|
-
}
|
|
659
|
-
}),
|
|
660
|
-
meta: {
|
|
661
|
-
docs: { description: "Disallow switch statements" },
|
|
662
|
-
messages: {
|
|
663
|
-
noSwitch: "Do not use switch statements. Use an object map or if/else instead."
|
|
664
|
-
},
|
|
665
|
-
schema: [],
|
|
666
|
-
type: "problem"
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
var plugin2 = {
|
|
670
|
-
meta: {
|
|
671
|
-
name: "no-switch",
|
|
672
|
-
version: "0.1.0"
|
|
673
|
-
},
|
|
674
|
-
rules: {
|
|
675
|
-
"no-switch": noSwitchRule
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
var no_switch_default = plugin2;
|
|
679
|
-
|
|
680
|
-
// src/configs/guardrails.ts
|
|
681
|
-
var sonarConfig = [
|
|
682
|
-
sonarjs.configs.recommended,
|
|
683
|
-
{
|
|
684
|
-
name: "sonarjs",
|
|
685
|
-
rules: {
|
|
686
|
-
"sonarjs/cognitive-complexity": "error",
|
|
687
|
-
"sonarjs/fixme-tag": "off",
|
|
688
|
-
"sonarjs/no-commented-code": "off",
|
|
689
|
-
"sonarjs/no-nested-conditional": "off",
|
|
690
|
-
"sonarjs/no-nested-functions": "off",
|
|
691
|
-
"sonarjs/no-selector-parameter": "off",
|
|
692
|
-
"sonarjs/regex-complexity": "off",
|
|
693
|
-
"sonarjs/todo-tag": "off"
|
|
694
|
-
}
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
files: ["**/*.tsx", "**/hooks/*.ts?(x)"],
|
|
698
|
-
name: "sonarjs/react-files",
|
|
699
|
-
rules: {
|
|
700
|
-
"sonarjs/cognitive-complexity": "off",
|
|
701
|
-
"sonarjs/function-return-type": "off"
|
|
702
|
-
}
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
files: ["**/*.test.ts?(x)", "**/*.stories.ts?(x)"],
|
|
706
|
-
name: "sonarjs/test-files",
|
|
707
|
-
rules: {
|
|
708
|
-
"sonarjs/no-duplicate-string": "off",
|
|
709
|
-
"sonarjs/no-identical-functions": "off"
|
|
710
|
-
}
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
files: ["app/languages/**/*.ts", "eslint.config.mjs"],
|
|
714
|
-
name: "sonarjs/credential-checks",
|
|
715
|
-
rules: {
|
|
716
|
-
"sonarjs/no-hardcoded-credentials": "off",
|
|
717
|
-
"sonarjs/no-hardcoded-passwords": "off"
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
];
|
|
721
|
-
var noEnumConfig = [
|
|
722
|
-
{
|
|
723
|
-
files: ["**/*.ts?(x)"],
|
|
724
|
-
name: "no-enum",
|
|
725
|
-
plugins: { "no-enum": no_enum_default },
|
|
726
|
-
rules: {
|
|
727
|
-
"no-enum/no-enum": "error"
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
];
|
|
731
|
-
var noSwitchConfig = [
|
|
732
|
-
{
|
|
733
|
-
files: ["**/*.ts?(x)", "**/*.js?(x)"],
|
|
734
|
-
name: "no-switch",
|
|
735
|
-
plugins: { "no-switch": no_switch_default },
|
|
736
|
-
rules: { "no-switch/no-switch": "error" }
|
|
737
|
-
}
|
|
738
|
-
];
|
|
739
|
-
var noRelativeImportPathsConfig = [
|
|
740
|
-
{
|
|
741
|
-
name: "no-relative-import-paths",
|
|
742
|
-
plugins: {
|
|
743
|
-
"no-relative-import-paths": noRelativeImportPaths
|
|
744
|
-
},
|
|
745
|
-
rules: {
|
|
746
|
-
"no-relative-import-paths/no-relative-import-paths": [
|
|
747
|
-
"error",
|
|
748
|
-
{
|
|
749
|
-
allowedDepth: 2,
|
|
750
|
-
allowSameFolder: true,
|
|
751
|
-
prefix: "~",
|
|
752
|
-
rootDir: "app"
|
|
753
|
-
}
|
|
754
|
-
]
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
];
|
|
758
|
-
var guardrails = [
|
|
759
|
-
...sonarConfig,
|
|
760
|
-
...noEnumConfig,
|
|
761
|
-
...noSwitchConfig,
|
|
762
|
-
...noRelativeImportPathsConfig
|
|
927
|
+
...buildCheckFileConfig(sourceDir)
|
|
763
928
|
];
|
|
764
929
|
|
|
765
930
|
// src/configs/testing.ts
|
|
@@ -798,145 +963,30 @@ var testing = [
|
|
|
798
963
|
}
|
|
799
964
|
];
|
|
800
965
|
|
|
801
|
-
// src/configs/storybook.ts
|
|
802
|
-
import storybookPlugin from "eslint-plugin-storybook";
|
|
803
|
-
var storybook = [
|
|
804
|
-
...storybookPlugin.configs["flat/recommended"]
|
|
805
|
-
];
|
|
806
|
-
|
|
807
|
-
// src/configs/playwright.ts
|
|
808
|
-
import playwrightPlugin from "eslint-plugin-playwright";
|
|
809
|
-
var playwright = [
|
|
810
|
-
{
|
|
811
|
-
name: "playwright",
|
|
812
|
-
...playwrightPlugin.configs["flat/recommended"],
|
|
813
|
-
files: [".playwright/**/*.ts?(x)"],
|
|
814
|
-
rules: {
|
|
815
|
-
...playwrightPlugin.configs["flat/recommended"].rules,
|
|
816
|
-
"playwright/expect-expect": [
|
|
817
|
-
"warn",
|
|
818
|
-
{ assertFunctionPatterns: ["^expect[A-Z]"] }
|
|
819
|
-
]
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
];
|
|
823
|
-
|
|
824
|
-
// src/configs/prettier.ts
|
|
825
|
-
import { rules as prettierConfigRules } from "eslint-config-prettier";
|
|
826
|
-
import prettierPlugin from "eslint-plugin-prettier";
|
|
827
|
-
var prettier = [
|
|
828
|
-
{
|
|
829
|
-
name: "prettier/plugin/config",
|
|
830
|
-
plugins: { prettier: prettierPlugin }
|
|
831
|
-
},
|
|
832
|
-
{
|
|
833
|
-
name: "prettier/config",
|
|
834
|
-
rules: {
|
|
835
|
-
...prettierConfigRules,
|
|
836
|
-
"@stylistic/padding-line-between-statements": [
|
|
837
|
-
"error",
|
|
838
|
-
{
|
|
839
|
-
blankLine: "always",
|
|
840
|
-
next: ["block-like", "export", "return", "throw"],
|
|
841
|
-
prev: "*"
|
|
842
|
-
}
|
|
843
|
-
],
|
|
844
|
-
"@stylistic/quotes": [
|
|
845
|
-
"error",
|
|
846
|
-
"single",
|
|
847
|
-
{
|
|
848
|
-
allowTemplateLiterals: "avoidEscape",
|
|
849
|
-
avoidEscape: true
|
|
850
|
-
}
|
|
851
|
-
],
|
|
852
|
-
"@stylistic/spaced-comment": "off",
|
|
853
|
-
"prettier/prettier": ["error", { endOfLine: "auto" }]
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
];
|
|
857
|
-
|
|
858
|
-
// src/configs/better-tailwind.ts
|
|
859
|
-
import betterTailwindPlugin from "eslint-plugin-better-tailwindcss";
|
|
860
|
-
var betterTailwind = (opts) => [
|
|
861
|
-
{
|
|
862
|
-
name: "better-tailwindcss",
|
|
863
|
-
plugins: {
|
|
864
|
-
"better-tailwindcss": betterTailwindPlugin
|
|
865
|
-
},
|
|
866
|
-
rules: {
|
|
867
|
-
"better-tailwindcss/enforce-canonical-classes": "error",
|
|
868
|
-
"better-tailwindcss/enforce-consistent-important-position": "error",
|
|
869
|
-
"better-tailwindcss/enforce-consistent-variable-syntax": "error",
|
|
870
|
-
"better-tailwindcss/enforce-shorthand-classes": "error",
|
|
871
|
-
"better-tailwindcss/no-conflicting-classes": "error",
|
|
872
|
-
"better-tailwindcss/no-deprecated-classes": "error",
|
|
873
|
-
"better-tailwindcss/no-unknown-classes": [
|
|
874
|
-
"error",
|
|
875
|
-
{ ignore: opts.ignore ?? [] }
|
|
876
|
-
]
|
|
877
|
-
},
|
|
878
|
-
settings: {
|
|
879
|
-
"better-tailwindcss": {
|
|
880
|
-
detectComponentClasses: true,
|
|
881
|
-
entryPoint: opts.entryPoint
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
];
|
|
886
|
-
|
|
887
|
-
// src/configs/ignores.ts
|
|
888
|
-
import { includeIgnoreFile } from "@eslint/compat";
|
|
889
|
-
import path from "path";
|
|
890
|
-
var defaultIgnores = [
|
|
891
|
-
".storybook",
|
|
892
|
-
".playwright",
|
|
893
|
-
"/.react-router/**",
|
|
894
|
-
".claude/**/*.js",
|
|
895
|
-
".claude/**/*.cjs",
|
|
896
|
-
"scripts",
|
|
897
|
-
"public/**",
|
|
898
|
-
"**/*.css",
|
|
899
|
-
"**/*.svg",
|
|
900
|
-
"**/*.md"
|
|
901
|
-
];
|
|
902
|
-
var ignores = (opts) => {
|
|
903
|
-
const out = [];
|
|
904
|
-
if (opts?.gitignore) {
|
|
905
|
-
const resolved = path.isAbsolute(opts.gitignore) ? opts.gitignore : path.resolve(process.cwd(), opts.gitignore);
|
|
906
|
-
out.push(includeIgnoreFile(resolved));
|
|
907
|
-
}
|
|
908
|
-
out.push({
|
|
909
|
-
ignores: [...defaultIgnores, ...opts?.extra ?? []],
|
|
910
|
-
name: "ignored-files"
|
|
911
|
-
});
|
|
912
|
-
return out;
|
|
913
|
-
};
|
|
914
|
-
|
|
915
966
|
// src/index.ts
|
|
916
|
-
var
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
967
|
+
var buildIgnoresAccessor = () => {
|
|
968
|
+
const defaults = ignores();
|
|
969
|
+
const accessor = ((opts) => ignores(opts));
|
|
970
|
+
accessor[Symbol.iterator] = () => defaults[Symbol.iterator]();
|
|
971
|
+
return accessor;
|
|
972
|
+
};
|
|
973
|
+
var gaiaLint = (opts) => {
|
|
974
|
+
const sourceDir = opts?.sourceDir ?? "app";
|
|
975
|
+
return {
|
|
976
|
+
base: buildBase(sourceDir),
|
|
977
|
+
betterTailwind,
|
|
978
|
+
guardrails: buildGuardrails(sourceDir),
|
|
979
|
+
ignores: buildIgnoresAccessor(),
|
|
980
|
+
playwright,
|
|
981
|
+
prettier,
|
|
982
|
+
react,
|
|
983
|
+
storybook,
|
|
984
|
+
styleHygiene: buildStyleHygiene(sourceDir),
|
|
985
|
+
testing
|
|
986
|
+
};
|
|
927
987
|
};
|
|
928
988
|
var index_default = gaiaLint;
|
|
929
989
|
export {
|
|
930
|
-
|
|
931
|
-
betterTailwind,
|
|
932
|
-
index_default as default,
|
|
933
|
-
guardrails,
|
|
934
|
-
ignores,
|
|
935
|
-
playwright,
|
|
936
|
-
prettier,
|
|
937
|
-
react,
|
|
938
|
-
storybook,
|
|
939
|
-
styleHygiene,
|
|
940
|
-
testing
|
|
990
|
+
index_default as default
|
|
941
991
|
};
|
|
942
992
|
//# sourceMappingURL=index.js.map
|