@fabdeh/eslint-config 0.1.3 → 0.2.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 +2 -3
- package/dist/index.d.mts +5 -62
- package/dist/index.mjs +117 -159
- package/package.json +69 -38
- package/dist/index.cjs +0 -1988
- package/dist/index.d.cts +0 -790
- package/dist/index.d.ts +0 -790
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import { isPackageExists } from 'local-pkg';
|
|
1
2
|
import tseslint from 'typescript-eslint';
|
|
2
3
|
import { statSync } from 'node:fs';
|
|
3
4
|
import { readFile } from 'node:fs/promises';
|
|
4
5
|
import { resolve, dirname, join } from 'node:path';
|
|
5
6
|
import process from 'node:process';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { isPackageExists } from 'local-pkg';
|
|
8
|
-
import eslintComments from '@eslint-community/eslint-plugin-eslint-comments';
|
|
9
|
-
import * as importX from 'eslint-plugin-import-x';
|
|
10
8
|
import eslint from '@eslint/js';
|
|
11
9
|
import preferArrowFunctions from 'eslint-plugin-prefer-arrow-functions';
|
|
12
10
|
import unusedImports from 'eslint-plugin-unused-imports';
|
|
13
11
|
import globals from 'globals';
|
|
12
|
+
import eslintComments from '@eslint-community/eslint-plugin-eslint-comments';
|
|
13
|
+
import * as importX from 'eslint-plugin-import-x';
|
|
14
14
|
import jsdocPlugin from 'eslint-plugin-jsdoc';
|
|
15
|
-
import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
|
|
16
15
|
import perfectionistPlugin from 'eslint-plugin-perfectionist';
|
|
17
16
|
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
17
|
+
import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
|
|
18
18
|
|
|
19
19
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
20
20
|
const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
@@ -76,24 +76,6 @@ const GLOB_EXCLUDE = [
|
|
|
76
76
|
|
|
77
77
|
const SCOPE_URL = fileURLToPath(new URL(".", import.meta.url));
|
|
78
78
|
const IS_CWD_IN_SCOPE = isPackageExists("@fabdeh/eslint-config");
|
|
79
|
-
function isInEditorEnv() {
|
|
80
|
-
if (process.env.CI) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
const envKeys = Object.keys(process.env);
|
|
84
|
-
if (envKeys.some((k) => /^GIT_/i.test(k))) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
const isVsCode = envKeys.some((k) => /^VSCODE_/i.test(k));
|
|
88
|
-
const isIntelliJ = envKeys.some((k) => /^INTELLIJ_/i.test(k));
|
|
89
|
-
const isJetbrains = envKeys.some((k) => /^JETBRAINS_/i.test(k));
|
|
90
|
-
const isVim = envKeys.some((k) => /^VIM$/i.test(k));
|
|
91
|
-
const isNeoVim = envKeys.some((k) => /^NVIM$/i.test(k));
|
|
92
|
-
return isVsCode || isIntelliJ || isJetbrains || isVim || isNeoVim;
|
|
93
|
-
}
|
|
94
|
-
function toArray(value) {
|
|
95
|
-
return Array.isArray(value) ? value : [value];
|
|
96
|
-
}
|
|
97
79
|
async function interopDefault(m) {
|
|
98
80
|
const resolved = await m;
|
|
99
81
|
return resolved.default ?? resolved;
|
|
@@ -165,10 +147,36 @@ async function angular(options = {}) {
|
|
|
165
147
|
},
|
|
166
148
|
processor: angularEslint.processInlineTemplates,
|
|
167
149
|
files: [GLOB_TS],
|
|
168
|
-
extends: [angularEslint.configs.tsRecommended],
|
|
169
150
|
rules: {
|
|
170
151
|
"max-classes-per-file": ["error", 1],
|
|
171
152
|
"max-lines": ["error", 400],
|
|
153
|
+
"new-cap": [
|
|
154
|
+
"error",
|
|
155
|
+
{
|
|
156
|
+
capIsNewExceptions: [
|
|
157
|
+
"Attribute",
|
|
158
|
+
"Component",
|
|
159
|
+
"ContentChild",
|
|
160
|
+
"ContentChildren",
|
|
161
|
+
"Directive",
|
|
162
|
+
"Host",
|
|
163
|
+
"HostBinding",
|
|
164
|
+
"HostListener",
|
|
165
|
+
"Inject",
|
|
166
|
+
"Injectable",
|
|
167
|
+
"Input",
|
|
168
|
+
"NgModule",
|
|
169
|
+
"Optional",
|
|
170
|
+
"Output",
|
|
171
|
+
"Pipe",
|
|
172
|
+
"Self",
|
|
173
|
+
"SkipSelf",
|
|
174
|
+
"ViewChild",
|
|
175
|
+
"ViewChildren"
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
...angularEslint.configs.tsRecommended.find((c) => c.name === "angular-eslint/ts-recommended")?.rules,
|
|
172
180
|
"@angular-eslint/component-max-inline-declarations": "error",
|
|
173
181
|
"@angular-eslint/component-selector": [
|
|
174
182
|
"error",
|
|
@@ -208,14 +216,14 @@ async function angular(options = {}) {
|
|
|
208
216
|
{
|
|
209
217
|
name: "fabdeh/angular-template/rules",
|
|
210
218
|
plugins: {
|
|
211
|
-
"@angular-eslint": angularEslint.
|
|
219
|
+
"@angular-eslint/template": angularEslint.templatePlugin
|
|
220
|
+
},
|
|
221
|
+
languageOptions: {
|
|
222
|
+
parser: angularEslint.templateParser
|
|
212
223
|
},
|
|
213
224
|
files: [GLOB_HTML],
|
|
214
|
-
extends: [
|
|
215
|
-
...angularEslint.configs.templateRecommended,
|
|
216
|
-
...enableAccessibilityRules ? angularEslint.configs.templateAccessibility : []
|
|
217
|
-
],
|
|
218
225
|
rules: {
|
|
226
|
+
...angularEslint.configs.templateRecommended.find((c) => c.name === "angular-eslint/template-recommended")?.rules,
|
|
219
227
|
"@angular-eslint/template/attributes-order": ["error", { alphabetical: true }],
|
|
220
228
|
"@angular-eslint/template/button-has-type": "error",
|
|
221
229
|
"@angular-eslint/template/conditional-complexity": "error",
|
|
@@ -227,6 +235,8 @@ async function angular(options = {}) {
|
|
|
227
235
|
"@angular-eslint/template/prefer-control-flow": "error",
|
|
228
236
|
"@angular-eslint/template/prefer-ngsrc": "error",
|
|
229
237
|
"@angular-eslint/template/prefer-self-closing-tags": "error",
|
|
238
|
+
"@angular-eslint/template/prefer-static-string-properties": "error",
|
|
239
|
+
...enableAccessibilityRules ? angularEslint.configs.templateAccessibility.find((c) => c.name === "angular-eslint/template-accessibility")?.rules : {},
|
|
230
240
|
...htmlOverrides
|
|
231
241
|
}
|
|
232
242
|
}
|
|
@@ -308,7 +318,7 @@ function imports(options = {}) {
|
|
|
308
318
|
}
|
|
309
319
|
|
|
310
320
|
function javascript(options = {}) {
|
|
311
|
-
const {
|
|
321
|
+
const { overrides = {} } = options;
|
|
312
322
|
return tseslint.config(
|
|
313
323
|
{
|
|
314
324
|
name: "fabdeh/javascript/setup",
|
|
@@ -344,8 +354,8 @@ function javascript(options = {}) {
|
|
|
344
354
|
"prefer-arrow-functions": preferArrowFunctions,
|
|
345
355
|
"unused-imports": unusedImports
|
|
346
356
|
},
|
|
347
|
-
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
|
|
348
357
|
rules: {
|
|
358
|
+
...eslint.configs.recommended.rules,
|
|
349
359
|
"accessor-pairs": "error",
|
|
350
360
|
"array-callback-return": "error",
|
|
351
361
|
"block-scoped-var": "error",
|
|
@@ -364,32 +374,7 @@ function javascript(options = {}) {
|
|
|
364
374
|
"Undefined",
|
|
365
375
|
"undefined"
|
|
366
376
|
],
|
|
367
|
-
"new-cap":
|
|
368
|
-
"error",
|
|
369
|
-
{
|
|
370
|
-
capIsNewExceptions: [
|
|
371
|
-
"Attribute",
|
|
372
|
-
"Component",
|
|
373
|
-
"ContentChild",
|
|
374
|
-
"ContentChildren",
|
|
375
|
-
"Directive",
|
|
376
|
-
"Host",
|
|
377
|
-
"HostBinding",
|
|
378
|
-
"HostListener",
|
|
379
|
-
"Inject",
|
|
380
|
-
"Injectable",
|
|
381
|
-
"Input",
|
|
382
|
-
"NgModule",
|
|
383
|
-
"Optional",
|
|
384
|
-
"Output",
|
|
385
|
-
"Pipe",
|
|
386
|
-
"Self",
|
|
387
|
-
"SkipSelf",
|
|
388
|
-
"ViewChild",
|
|
389
|
-
"ViewChildren"
|
|
390
|
-
]
|
|
391
|
-
}
|
|
392
|
-
] : "error",
|
|
377
|
+
"new-cap": "error",
|
|
393
378
|
"no-alert": "error",
|
|
394
379
|
"no-caller": "error",
|
|
395
380
|
"no-cond-assign": ["error", "always"],
|
|
@@ -433,6 +418,7 @@ function javascript(options = {}) {
|
|
|
433
418
|
"no-useless-constructor": "error",
|
|
434
419
|
"no-useless-rename": "error",
|
|
435
420
|
"no-useless-return": "error",
|
|
421
|
+
"no-var": "error",
|
|
436
422
|
"object-shorthand": [
|
|
437
423
|
"error",
|
|
438
424
|
"always",
|
|
@@ -446,14 +432,18 @@ function javascript(options = {}) {
|
|
|
446
432
|
"error",
|
|
447
433
|
{ singleReturnOnly: true, allowNamedFunctions: true }
|
|
448
434
|
],
|
|
435
|
+
"prefer-const": "error",
|
|
449
436
|
"prefer-exponentiation-operator": "error",
|
|
450
437
|
"prefer-object-spread": "error",
|
|
451
438
|
"prefer-promise-reject-errors": "error",
|
|
452
439
|
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
440
|
+
"prefer-rest-params": "error",
|
|
441
|
+
"prefer-spread": "error",
|
|
453
442
|
"prefer-template": "error",
|
|
454
443
|
"symbol-description": "error",
|
|
455
444
|
"unicode-bom": ["error", "never"],
|
|
456
|
-
"unused-imports/no-unused-imports":
|
|
445
|
+
"unused-imports/no-unused-imports": "error",
|
|
446
|
+
"no-unused-vars": "off",
|
|
457
447
|
"unused-imports/no-unused-vars": [
|
|
458
448
|
"error",
|
|
459
449
|
{
|
|
@@ -468,64 +458,18 @@ function javascript(options = {}) {
|
|
|
468
458
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
469
459
|
"vars-on-top": "error",
|
|
470
460
|
yoda: ["error", "never", { exceptRange: true }],
|
|
471
|
-
"@typescript-eslint/
|
|
472
|
-
|
|
473
|
-
|
|
461
|
+
"@typescript-eslint/ban-ts-comment": "error",
|
|
462
|
+
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
463
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
464
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
465
|
+
"@typescript-eslint/no-require-imports": ["error", { allowAsImport: true }],
|
|
466
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
474
467
|
...overrides
|
|
475
468
|
}
|
|
476
469
|
}
|
|
477
470
|
);
|
|
478
471
|
}
|
|
479
472
|
|
|
480
|
-
async function jest(options = {}) {
|
|
481
|
-
const {
|
|
482
|
-
overrides = {},
|
|
483
|
-
useJestDom = isPackageExists("@testing-library/jest-dom"),
|
|
484
|
-
useTestingLibrary = isPackageExists("@testing-library/angular"),
|
|
485
|
-
stylistic = true
|
|
486
|
-
} = options;
|
|
487
|
-
const [jestPlugin, jestDomPlugin, testingLibraryPlugin] = await Promise.all([
|
|
488
|
-
interopDefault(import('eslint-plugin-jest')),
|
|
489
|
-
useJestDom ? interopDefault(import('eslint-plugin-jest-dom')) : Promise.resolve(undefined),
|
|
490
|
-
useTestingLibrary ? interopDefault(import('eslint-plugin-testing-library')) : Promise.resolve(undefined)
|
|
491
|
-
]);
|
|
492
|
-
return tseslint.config({
|
|
493
|
-
name: "fabdeh/jest/rules",
|
|
494
|
-
plugins: {
|
|
495
|
-
jest: jestPlugin
|
|
496
|
-
},
|
|
497
|
-
languageOptions: {
|
|
498
|
-
globals: {
|
|
499
|
-
...globals.node,
|
|
500
|
-
...globals.jest
|
|
501
|
-
}
|
|
502
|
-
},
|
|
503
|
-
files: [...GLOB_TESTS, `** /jest.config.${GLOB_SRC_EXT}`],
|
|
504
|
-
extends: [
|
|
505
|
-
jestPlugin.configs["flat/recommended"],
|
|
506
|
-
...stylistic ? [jestPlugin.configs["flat/style"]] : [],
|
|
507
|
-
...jestDomPlugin ? [jestDomPlugin.configs["flat/recommended"]] : [],
|
|
508
|
-
...testingLibraryPlugin ? [testingLibraryPlugin.configs["flat/angular"]] : []
|
|
509
|
-
],
|
|
510
|
-
rules: {
|
|
511
|
-
"max-classes-per-file": "off",
|
|
512
|
-
"max-lines": "off",
|
|
513
|
-
"@typescript-eslint/consistent-type-assertions": "off",
|
|
514
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
515
|
-
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
516
|
-
"@typescript-eslint/no-unsafe-call": "off",
|
|
517
|
-
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
518
|
-
"@typescript-eslint/unbound-method": "off",
|
|
519
|
-
"jest/consistent-test-it": ["error", { fn: "test" }],
|
|
520
|
-
"jest/prefer-spy-on": "error",
|
|
521
|
-
"jest/require-top-level-describe": "error",
|
|
522
|
-
"jest/unbound-method": "error",
|
|
523
|
-
"unicorn/no-null": "off",
|
|
524
|
-
...overrides
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
|
|
529
473
|
function jsdoc(options = {}) {
|
|
530
474
|
const { stylistic = true } = options;
|
|
531
475
|
return tseslint.config(
|
|
@@ -672,11 +616,16 @@ async function markdown(options = {}) {
|
|
|
672
616
|
processor: mergeProcessors([
|
|
673
617
|
markdownPlugin.processors.markdown,
|
|
674
618
|
processorPassThrough
|
|
675
|
-
])
|
|
619
|
+
]),
|
|
620
|
+
rules: {
|
|
621
|
+
...markdownPlugin.configs.recommended.at(0)?.rules,
|
|
622
|
+
"markdown/no-duplicate-headings": "error"
|
|
623
|
+
}
|
|
676
624
|
},
|
|
677
625
|
{
|
|
678
626
|
name: "fabdeh/markdown/disables",
|
|
679
627
|
languageOptions: {
|
|
628
|
+
parser: tseslint.parser,
|
|
680
629
|
parserOptions: {
|
|
681
630
|
ecmaFeatures: {
|
|
682
631
|
impliedStrict: true
|
|
@@ -684,8 +633,8 @@ async function markdown(options = {}) {
|
|
|
684
633
|
}
|
|
685
634
|
},
|
|
686
635
|
files: [GLOB_MARKDOWN_CODE],
|
|
687
|
-
extends: [tseslint.configs.disableTypeChecked],
|
|
688
636
|
rules: {
|
|
637
|
+
...tseslint.configs.disableTypeChecked.rules,
|
|
689
638
|
"import-x/newline-after-import": "off",
|
|
690
639
|
"no-alert": "off",
|
|
691
640
|
"no-console": "off",
|
|
@@ -746,17 +695,22 @@ async function ngrx(options = {}) {
|
|
|
746
695
|
signals = isPackageExists("@ngrx/signals")
|
|
747
696
|
} = options;
|
|
748
697
|
const configs = [];
|
|
698
|
+
let addOperatorsRules = false;
|
|
699
|
+
const ngrxOperatorsFiles = [];
|
|
749
700
|
if (store) {
|
|
750
701
|
const {
|
|
751
702
|
files = DEFAULT_STORE_GLOB,
|
|
752
703
|
enforceOperatorsRules = isPackageExists("@ngrx/operators"),
|
|
753
704
|
overrides = {}
|
|
754
705
|
} = typeof store === "object" ? store : {};
|
|
706
|
+
addOperatorsRules ||= enforceOperatorsRules;
|
|
707
|
+
ngrxOperatorsFiles.push(files);
|
|
755
708
|
configs.push({
|
|
756
709
|
name: "fabdeh/ngrx-store/rules",
|
|
757
710
|
files,
|
|
758
|
-
|
|
711
|
+
plugins: { "@ngrx": ngrxPlugin },
|
|
759
712
|
rules: {
|
|
713
|
+
...ngrxPlugin.configs.store.find((c) => c.name === "ngrx/store")?.rules,
|
|
760
714
|
"@typescript-eslint/naming-convention": [
|
|
761
715
|
"error",
|
|
762
716
|
...namingConvention,
|
|
@@ -787,11 +741,14 @@ async function ngrx(options = {}) {
|
|
|
787
741
|
enforceOperatorsRules = isPackageExists("@ngrx/operators"),
|
|
788
742
|
overrides = {}
|
|
789
743
|
} = typeof effects === "object" ? effects : {};
|
|
744
|
+
addOperatorsRules ||= enforceOperatorsRules;
|
|
745
|
+
ngrxOperatorsFiles.push(files);
|
|
790
746
|
configs.push({
|
|
791
747
|
name: "fabdeh/ngrx-effects/rules",
|
|
792
748
|
files,
|
|
793
|
-
|
|
749
|
+
plugins: { "@ngrx": ngrxPlugin },
|
|
794
750
|
rules: {
|
|
751
|
+
...ngrxPlugin.configs.effects.find((c) => c.name === "ngrx/effects")?.rules,
|
|
795
752
|
"@typescript-eslint/naming-convention": [
|
|
796
753
|
"error",
|
|
797
754
|
...namingConvention,
|
|
@@ -819,11 +776,14 @@ async function ngrx(options = {}) {
|
|
|
819
776
|
{ selector: "variableLike", format: ["camelCase"] },
|
|
820
777
|
{ selector: "memberLike", format: ["camelCase"], leadingUnderscore: "allow" }
|
|
821
778
|
];
|
|
779
|
+
addOperatorsRules ||= enforceOperatorsRules;
|
|
780
|
+
ngrxOperatorsFiles.push(files);
|
|
822
781
|
configs.push({
|
|
823
782
|
name: "fabdeh/ngrx-signals/rules",
|
|
824
783
|
files,
|
|
825
|
-
|
|
784
|
+
plugins: { "@ngrx": ngrxPlugin },
|
|
826
785
|
rules: {
|
|
786
|
+
...ngrxPlugin.configs.signals.find((c) => c.name === "ngrx/signals")?.rules,
|
|
827
787
|
"@typescript-eslint/naming-convention": [
|
|
828
788
|
"error",
|
|
829
789
|
...allowLeadingUnderscoreOnMemberLike(namingConvention),
|
|
@@ -839,6 +799,16 @@ async function ngrx(options = {}) {
|
|
|
839
799
|
}
|
|
840
800
|
});
|
|
841
801
|
}
|
|
802
|
+
if (addOperatorsRules) {
|
|
803
|
+
configs.push({
|
|
804
|
+
name: "fabdeh/ngrx-operators/rules",
|
|
805
|
+
files: [...ngrxOperatorsFiles],
|
|
806
|
+
plugins: { "@ngrx": ngrxPlugin },
|
|
807
|
+
rules: {
|
|
808
|
+
...ngrxPlugin.configs.operators.find((c) => c.name === "ngrx/operators")?.rules
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
}
|
|
842
812
|
return tseslint.config(configs);
|
|
843
813
|
}
|
|
844
814
|
|
|
@@ -892,9 +862,10 @@ const SORT_UNION_OR_INTERSECTION_GROUPS = [
|
|
|
892
862
|
];
|
|
893
863
|
|
|
894
864
|
async function perfectionist() {
|
|
895
|
-
const tsconfigRootDir = await findNearestPackageJsonName() === "@fabdeh/eslint-config" ?
|
|
865
|
+
const tsconfigRootDir = await findNearestPackageJsonName() === "@fabdeh/eslint-config" ? void 0 : getWorkspaceRoot(process.cwd(), process.cwd());
|
|
896
866
|
return tseslint.config({
|
|
897
867
|
name: "fabdeh/perfectionist/rules",
|
|
868
|
+
files: [GLOB_SRC],
|
|
898
869
|
plugins: {
|
|
899
870
|
perfectionist: perfectionistPlugin
|
|
900
871
|
},
|
|
@@ -1293,14 +1264,13 @@ function typescript(options = {}) {
|
|
|
1293
1264
|
name: "fabdeh/typescript/rules",
|
|
1294
1265
|
files: [GLOB_TS],
|
|
1295
1266
|
plugins: {
|
|
1296
|
-
"@typescript-eslint": tseslint.plugin
|
|
1267
|
+
"@typescript-eslint": tseslint.plugin,
|
|
1268
|
+
"unused-imports": unusedImports
|
|
1297
1269
|
},
|
|
1298
|
-
extends: [
|
|
1299
|
-
eslint.configs.recommended,
|
|
1300
|
-
...tseslint.configs.strictTypeChecked,
|
|
1301
|
-
...stylistic ? tseslint.configs.stylisticTypeChecked : []
|
|
1302
|
-
],
|
|
1303
1270
|
rules: {
|
|
1271
|
+
...tseslint.configs.stylisticTypeChecked.find((c) => c.name === "typescript-eslint/eslint-recommended")?.rules,
|
|
1272
|
+
...tseslint.configs.stylisticTypeChecked.find((c) => c.name === "typescript-eslint/strict-type-checked")?.rules,
|
|
1273
|
+
...stylistic ? tseslint.configs.stylisticTypeChecked.find((c) => c.name === "typescript-eslint/stylistic-type-checked")?.rules : {},
|
|
1304
1274
|
"@typescript-eslint/array-type": ["error", { default: "array" }],
|
|
1305
1275
|
"@typescript-eslint/consistent-indexed-object-style": "error",
|
|
1306
1276
|
"@typescript-eslint/consistent-type-assertions": [
|
|
@@ -1308,7 +1278,14 @@ function typescript(options = {}) {
|
|
|
1308
1278
|
{ assertionStyle: "as", objectLiteralTypeAssertions: "never" }
|
|
1309
1279
|
],
|
|
1310
1280
|
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
|
1281
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
1282
|
+
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
1283
|
+
disallowTypeAnnotations: false,
|
|
1284
|
+
fixStyle: "separate-type-imports",
|
|
1285
|
+
prefer: "type-imports"
|
|
1286
|
+
}],
|
|
1311
1287
|
"@typescript-eslint/dot-notation": "error",
|
|
1288
|
+
"@typescript-eslint/explicit-module-boundary-types": "error",
|
|
1312
1289
|
"@typescript-eslint/explicit-function-return-type": [
|
|
1313
1290
|
"error",
|
|
1314
1291
|
{
|
|
@@ -1332,12 +1309,11 @@ function typescript(options = {}) {
|
|
|
1332
1309
|
"@typescript-eslint/no-extraneous-class": ["error", { allowStaticOnly: true, allowWithDecorator: true }],
|
|
1333
1310
|
"@typescript-eslint/no-invalid-void-type": "error",
|
|
1334
1311
|
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
1335
|
-
"@typescript-eslint/no-require-imports": "error",
|
|
1336
1312
|
"@typescript-eslint/only-throw-error": "error",
|
|
1337
1313
|
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
1338
1314
|
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
1339
1315
|
"@typescript-eslint/no-unsafe-unary-minus": "error",
|
|
1340
|
-
"@typescript-eslint/parameter-properties":
|
|
1316
|
+
"@typescript-eslint/parameter-properties": "error",
|
|
1341
1317
|
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
1342
1318
|
"@typescript-eslint/prefer-for-of": "error",
|
|
1343
1319
|
"@typescript-eslint/prefer-function-type": "error",
|
|
@@ -1355,6 +1331,7 @@ function typescript(options = {}) {
|
|
|
1355
1331
|
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
1356
1332
|
"@typescript-eslint/unbound-method": ["error", { ignoreStatic: true }],
|
|
1357
1333
|
"@typescript-eslint/unified-signatures": "error",
|
|
1334
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
1358
1335
|
...overrides
|
|
1359
1336
|
}
|
|
1360
1337
|
}
|
|
@@ -1367,8 +1344,9 @@ function unicorn(options = {}) {
|
|
|
1367
1344
|
plugins: { unicorn: unicornPlugin },
|
|
1368
1345
|
files: [GLOB_SRC],
|
|
1369
1346
|
rules: {
|
|
1370
|
-
...options.allRecommended ? unicornPlugin.configs
|
|
1347
|
+
...options.allRecommended ? unicornPlugin.configs.recommended.rules : {
|
|
1371
1348
|
"unicorn/catch-error-name": "error",
|
|
1349
|
+
"unicorn/consistent-date-clone": "error",
|
|
1372
1350
|
"unicorn/consistent-empty-array-spread": "error",
|
|
1373
1351
|
"unicorn/consistent-existence-index-check": "error",
|
|
1374
1352
|
"unicorn/consistent-function-scoping": ["error", { checkArrowFunctions: false }],
|
|
@@ -1390,7 +1368,7 @@ function unicorn(options = {}) {
|
|
|
1390
1368
|
"unicorn/no-empty-file": "error",
|
|
1391
1369
|
"unicorn/no-for-loop": "error",
|
|
1392
1370
|
"unicorn/no-hex-escape": "error",
|
|
1393
|
-
"unicorn/no-instanceof-
|
|
1371
|
+
"unicorn/no-instanceof-builtins": "error",
|
|
1394
1372
|
"unicorn/no-invalid-fetch-options": "error",
|
|
1395
1373
|
"unicorn/no-invalid-remove-event-listener": "error",
|
|
1396
1374
|
"unicorn/no-length-as-slice-end": "error",
|
|
@@ -1469,12 +1447,16 @@ async function vitest(options = {}) {
|
|
|
1469
1447
|
} = options;
|
|
1470
1448
|
const [vitestPlugin, jestDomPlugin, testingLibraryPlugin] = await Promise.all([
|
|
1471
1449
|
interopDefault(import('@vitest/eslint-plugin')),
|
|
1472
|
-
useJestDom ? interopDefault(import('eslint-plugin-jest-dom')) : Promise.resolve(
|
|
1473
|
-
useTestingLibrary ? interopDefault(import('eslint-plugin-testing-library')) : Promise.resolve(
|
|
1450
|
+
useJestDom ? interopDefault(import('eslint-plugin-jest-dom')) : Promise.resolve(void 0),
|
|
1451
|
+
useTestingLibrary ? interopDefault(import('eslint-plugin-testing-library')) : Promise.resolve(void 0)
|
|
1474
1452
|
]);
|
|
1475
1453
|
return tseslint.config({
|
|
1476
1454
|
name: "fabdeh/vitest/rules",
|
|
1477
|
-
plugins: {
|
|
1455
|
+
plugins: {
|
|
1456
|
+
vitest: vitestPlugin,
|
|
1457
|
+
...jestDomPlugin ? { "jest-dom": jestDomPlugin } : {},
|
|
1458
|
+
...testingLibraryPlugin ? { "testing-library": testingLibraryPlugin } : {}
|
|
1459
|
+
},
|
|
1478
1460
|
languageOptions: {
|
|
1479
1461
|
globals: {
|
|
1480
1462
|
...globals.node,
|
|
@@ -1488,12 +1470,10 @@ async function vitest(options = {}) {
|
|
|
1488
1470
|
}
|
|
1489
1471
|
},
|
|
1490
1472
|
files: [...GLOB_TESTS],
|
|
1491
|
-
extends: [
|
|
1492
|
-
vitestPlugin.configs.recommended,
|
|
1493
|
-
...jestDomPlugin ? [jestDomPlugin.configs["flat/recommended"]] : [],
|
|
1494
|
-
...testingLibraryPlugin ? [testingLibraryPlugin.configs["flat/angular"]] : []
|
|
1495
|
-
],
|
|
1496
1473
|
rules: {
|
|
1474
|
+
...vitestPlugin.configs.recommended.rules,
|
|
1475
|
+
...jestDomPlugin?.configs["flat/recommended"].rules,
|
|
1476
|
+
...testingLibraryPlugin?.configs["flat/angular"].rules,
|
|
1497
1477
|
"max-classes-per-file": "off",
|
|
1498
1478
|
"max-lines": "off",
|
|
1499
1479
|
"@typescript-eslint/consistent-type-assertions": "off",
|
|
@@ -1584,9 +1564,7 @@ function mergePrettierOptions(options, overrides = {}) {
|
|
|
1584
1564
|
...options,
|
|
1585
1565
|
...overrides,
|
|
1586
1566
|
plugins: [
|
|
1587
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1588
1567
|
...overrides.plugins ?? [],
|
|
1589
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1590
1568
|
...options.plugins ?? []
|
|
1591
1569
|
]
|
|
1592
1570
|
};
|
|
@@ -1606,8 +1584,8 @@ async function formatters(options = {}, stylistic = {}) {
|
|
|
1606
1584
|
}
|
|
1607
1585
|
await ensurePackages([
|
|
1608
1586
|
"eslint-plugin-format",
|
|
1609
|
-
options.markdown && options.slidev ? "prettier-plugin-slidev" :
|
|
1610
|
-
options.xml || options.svg ? "@prettier/plugin-xml" :
|
|
1587
|
+
options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
|
|
1588
|
+
options.xml || options.svg ? "@prettier/plugin-xml" : void 0
|
|
1611
1589
|
]);
|
|
1612
1590
|
const {
|
|
1613
1591
|
indent,
|
|
@@ -1808,23 +1786,11 @@ async function createConfig(options = {}, ...userConfigs) {
|
|
|
1808
1786
|
const {
|
|
1809
1787
|
angular: enableAngular = isPackageExists("@angular/core"),
|
|
1810
1788
|
gitignore: enableGitignore = true,
|
|
1811
|
-
isInEditor = isInEditorEnv(),
|
|
1812
|
-
jest: enableJest = isPackageExists("jest"),
|
|
1813
1789
|
ngrx: enableNgrx = NGRX_PACKAGES.some((p) => isPackageExists(p)),
|
|
1814
1790
|
tailwindcss: enableTailwind = isPackageExists("tailwindcss"),
|
|
1815
1791
|
unicorn: enableUnicorn = true,
|
|
1816
1792
|
vitest: enableVitest = isPackageExists("vitest")
|
|
1817
1793
|
} = options;
|
|
1818
|
-
if (isInEditor) {
|
|
1819
|
-
console.log(
|
|
1820
|
-
"[@fabdeh/eslint-config] Detected running in editor, some rules are configured as warn or completely turned off."
|
|
1821
|
-
);
|
|
1822
|
-
}
|
|
1823
|
-
if (enableJest && enableVitest) {
|
|
1824
|
-
throw new Error(
|
|
1825
|
-
'[@fabdeh/eslint-config] Detected that both "jest" and "vitest" are enabled which is not supported. Manually disable or uninstall one of them.'
|
|
1826
|
-
);
|
|
1827
|
-
}
|
|
1828
1794
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
1829
1795
|
const configs = [];
|
|
1830
1796
|
if (enableGitignore) {
|
|
@@ -1842,10 +1808,9 @@ async function createConfig(options = {}, ...userConfigs) {
|
|
|
1842
1808
|
);
|
|
1843
1809
|
}
|
|
1844
1810
|
}
|
|
1845
|
-
const allowAngularDecorator = options.angular !== false;
|
|
1846
1811
|
configs.push(
|
|
1847
1812
|
ignores(options.ignores),
|
|
1848
|
-
javascript({
|
|
1813
|
+
javascript({ overrides: options.javascript?.overrides }),
|
|
1849
1814
|
typescript({
|
|
1850
1815
|
stylistic: stylisticOptions,
|
|
1851
1816
|
parserOptions: options.typescript?.parserOptions,
|
|
@@ -1868,13 +1833,6 @@ async function createConfig(options = {}, ...userConfigs) {
|
|
|
1868
1833
|
if (enableNgrx) {
|
|
1869
1834
|
configs.push(ngrx(typeof enableNgrx === "object" ? enableNgrx : {}));
|
|
1870
1835
|
}
|
|
1871
|
-
if (enableJest) {
|
|
1872
|
-
configs.push(
|
|
1873
|
-
jest(
|
|
1874
|
-
typeof enableJest === "object" ? { ...enableJest, stylistic: stylisticOptions } : { stylistic: stylisticOptions }
|
|
1875
|
-
)
|
|
1876
|
-
);
|
|
1877
|
-
}
|
|
1878
1836
|
if (enableVitest) {
|
|
1879
1837
|
configs.push(vitest(typeof enableVitest === "object" ? enableVitest : {}));
|
|
1880
1838
|
}
|
|
@@ -1923,4 +1881,4 @@ async function createConfig(options = {}, ...userConfigs) {
|
|
|
1923
1881
|
return tseslint.config(...await Promise.all(configs), ...await Promise.all(userConfigs));
|
|
1924
1882
|
}
|
|
1925
1883
|
|
|
1926
|
-
export { GLOB_HTML, GLOB_JS, GLOB_SRC, GLOB_TESTS, GLOB_TS, STYLISTIC_CONFIG_DEFAULT, angular, comments, createConfig, ensurePackages, findNearestPackageJsonName, getWorkspaceRoot, ignores, imports, interopDefault,
|
|
1884
|
+
export { GLOB_HTML, GLOB_JS, GLOB_SRC, GLOB_TESTS, GLOB_TS, STYLISTIC_CONFIG_DEFAULT, angular, comments, createConfig, ensurePackages, findNearestPackageJsonName, getWorkspaceRoot, ignores, imports, interopDefault, isPackageInScope, javascript, jsdoc, jsonc, markdown, ngrx, perfectionist, sortPackageJson, sortTsConfig, stylistic, tailwindcss, toml, typescript, unicorn, vitest, yaml };
|