eslint-config-decent 2.0.3 → 2.1.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/dist/index.cjs +155 -55
- package/dist/index.d.cts +22 -2
- package/dist/index.d.mts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.mjs +143 -49
- package/package.json +22 -20
- package/src/index.ts +52 -10
- package/src/jest.ts +58 -0
- package/src/react.ts +10 -5
- package/src/testingLibrary.ts +25 -0
- package/src/types/eslint-plugin-jest-dom.d.ts +10 -0
- package/src/types/eslint-plugin-jest.d.ts +11 -0
- package/src/types/eslint-plugin-react.d.ts +2 -0
- package/src/types/eslint-plugin-testing-library.d.ts +4 -1
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,8 @@ const fs = require('fs');
|
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const utils = require('@typescript-eslint/utils');
|
|
10
10
|
const importPlugin = require('eslint-plugin-import-x');
|
|
11
|
+
const jest = require('eslint-plugin-jest');
|
|
12
|
+
const jestDom = require('eslint-plugin-jest-dom');
|
|
11
13
|
const jsdoc = require('eslint-plugin-jsdoc');
|
|
12
14
|
const mocha = require('eslint-plugin-mocha');
|
|
13
15
|
const promise = require('eslint-plugin-promise');
|
|
@@ -15,8 +17,8 @@ const compat = require('@eslint/compat');
|
|
|
15
17
|
const a11y = require('eslint-plugin-jsx-a11y');
|
|
16
18
|
const react = require('eslint-plugin-react');
|
|
17
19
|
const reactHooks = require('eslint-plugin-react-hooks');
|
|
18
|
-
const testingLibrary = require('eslint-plugin-testing-library');
|
|
19
20
|
const security = require('eslint-plugin-security');
|
|
21
|
+
const testingLibrary = require('eslint-plugin-testing-library');
|
|
20
22
|
const unicorn = require('eslint-plugin-unicorn');
|
|
21
23
|
|
|
22
24
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -26,17 +28,19 @@ const prettier__default = /*#__PURE__*/_interopDefaultCompat(prettier);
|
|
|
26
28
|
const globals__default = /*#__PURE__*/_interopDefaultCompat(globals);
|
|
27
29
|
const tsEslint__default = /*#__PURE__*/_interopDefaultCompat(tsEslint);
|
|
28
30
|
const importPlugin__default = /*#__PURE__*/_interopDefaultCompat(importPlugin);
|
|
31
|
+
const jest__default = /*#__PURE__*/_interopDefaultCompat(jest);
|
|
32
|
+
const jestDom__default = /*#__PURE__*/_interopDefaultCompat(jestDom);
|
|
29
33
|
const jsdoc__default = /*#__PURE__*/_interopDefaultCompat(jsdoc);
|
|
30
34
|
const mocha__default = /*#__PURE__*/_interopDefaultCompat(mocha);
|
|
31
35
|
const promise__default = /*#__PURE__*/_interopDefaultCompat(promise);
|
|
32
36
|
const a11y__default = /*#__PURE__*/_interopDefaultCompat(a11y);
|
|
33
37
|
const react__default = /*#__PURE__*/_interopDefaultCompat(react);
|
|
34
38
|
const reactHooks__default = /*#__PURE__*/_interopDefaultCompat(reactHooks);
|
|
35
|
-
const testingLibrary__default = /*#__PURE__*/_interopDefaultCompat(testingLibrary);
|
|
36
39
|
const security__default = /*#__PURE__*/_interopDefaultCompat(security);
|
|
40
|
+
const testingLibrary__default = /*#__PURE__*/_interopDefaultCompat(testingLibrary);
|
|
37
41
|
const unicorn__default = /*#__PURE__*/_interopDefaultCompat(unicorn);
|
|
38
42
|
|
|
39
|
-
const base$
|
|
43
|
+
const base$b = {
|
|
40
44
|
rules: {
|
|
41
45
|
"array-callback-return": ["error", { allowImplicit: true }],
|
|
42
46
|
"block-scoped-var": "error",
|
|
@@ -286,8 +290,8 @@ const cjs = {
|
|
|
286
290
|
strict: ["error", "global"]
|
|
287
291
|
}
|
|
288
292
|
};
|
|
289
|
-
const configs$
|
|
290
|
-
base: base$
|
|
293
|
+
const configs$b = {
|
|
294
|
+
base: base$b,
|
|
291
295
|
cjsAndEsm,
|
|
292
296
|
cjs
|
|
293
297
|
};
|
|
@@ -386,7 +390,7 @@ const requireIndexRule = utils.ESLintUtils.RuleCreator(() => "https://github.com
|
|
|
386
390
|
}
|
|
387
391
|
});
|
|
388
392
|
|
|
389
|
-
const base$
|
|
393
|
+
const base$a = {
|
|
390
394
|
plugins: {
|
|
391
395
|
"decent-extension": {
|
|
392
396
|
meta: {
|
|
@@ -404,11 +408,11 @@ const base$8 = {
|
|
|
404
408
|
"decent-extension/require-index": "error"
|
|
405
409
|
}
|
|
406
410
|
};
|
|
407
|
-
const configs$
|
|
408
|
-
base: base$
|
|
411
|
+
const configs$a = {
|
|
412
|
+
base: base$a
|
|
409
413
|
};
|
|
410
414
|
|
|
411
|
-
const base$
|
|
415
|
+
const base$9 = {
|
|
412
416
|
plugins: {
|
|
413
417
|
import: importPlugin__default
|
|
414
418
|
},
|
|
@@ -423,11 +427,58 @@ const base$7 = {
|
|
|
423
427
|
]
|
|
424
428
|
}
|
|
425
429
|
};
|
|
426
|
-
const configs$
|
|
427
|
-
base: base$
|
|
430
|
+
const configs$9 = {
|
|
431
|
+
base: base$9
|
|
428
432
|
};
|
|
429
433
|
|
|
430
|
-
const base$
|
|
434
|
+
const base$8 = {
|
|
435
|
+
plugins: {
|
|
436
|
+
jest: jest__default,
|
|
437
|
+
"jest-dom": jestDom__default
|
|
438
|
+
},
|
|
439
|
+
languageOptions: {
|
|
440
|
+
...jest__default.configs["flat/recommended"].languageOptions
|
|
441
|
+
},
|
|
442
|
+
rules: {
|
|
443
|
+
...jest__default.configs["flat/recommended"].rules,
|
|
444
|
+
"jest/max-nested-describe": "error",
|
|
445
|
+
"jest/no-conditional-in-test": "error",
|
|
446
|
+
"jest/no-confusing-set-timeout": "error",
|
|
447
|
+
"jest/no-test-prefixes": "error",
|
|
448
|
+
"jest/prefer-called-with": "error",
|
|
449
|
+
"jest/prefer-comparison-matcher": "error",
|
|
450
|
+
"jest/prefer-equality-matcher": "error",
|
|
451
|
+
"jest/prefer-hooks-in-order": "error",
|
|
452
|
+
"jest/prefer-hooks-on-top": "error",
|
|
453
|
+
"jest/prefer-mock-promise-shorthand": "error",
|
|
454
|
+
"jest/prefer-snapshot-hint": "error",
|
|
455
|
+
...jestDom__default.configs["flat/recommended"].rules,
|
|
456
|
+
"jest-dom/prefer-checked": "error",
|
|
457
|
+
"jest-dom/prefer-empty": "error",
|
|
458
|
+
"jest-dom/prefer-enabled-disabled": "error",
|
|
459
|
+
"jest-dom/prefer-focus": "error",
|
|
460
|
+
"jest-dom/prefer-in-document": "error",
|
|
461
|
+
"jest-dom/prefer-required": "error",
|
|
462
|
+
"jest-dom/prefer-to-have-attribute": "error",
|
|
463
|
+
"jest-dom/prefer-to-have-class": "error",
|
|
464
|
+
"jest-dom/prefer-to-have-style": "error",
|
|
465
|
+
"jest-dom/prefer-to-have-text-content": "error",
|
|
466
|
+
"jest-dom/prefer-to-have-value": "error",
|
|
467
|
+
"max-classes-per-file": "off",
|
|
468
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
469
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
470
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
471
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
472
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
473
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
474
|
+
"@typescript-eslint/unbound-method": "off"
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
const configs$8 = {
|
|
478
|
+
base: base$8
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
const base$7 = {
|
|
431
482
|
settings: {
|
|
432
483
|
jsdoc: {
|
|
433
484
|
preferredTypes: {
|
|
@@ -453,11 +504,11 @@ const base$6 = {
|
|
|
453
504
|
"unicorn/prefer-set-has": "error"
|
|
454
505
|
}
|
|
455
506
|
};
|
|
456
|
-
const configs$
|
|
457
|
-
base: base$
|
|
507
|
+
const configs$7 = {
|
|
508
|
+
base: base$7
|
|
458
509
|
};
|
|
459
510
|
|
|
460
|
-
const base$
|
|
511
|
+
const base$6 = {
|
|
461
512
|
plugins: {
|
|
462
513
|
mocha: mocha__default
|
|
463
514
|
},
|
|
@@ -476,11 +527,11 @@ const base$5 = {
|
|
|
476
527
|
"mocha/no-mocha-arrows": "off"
|
|
477
528
|
}
|
|
478
529
|
};
|
|
479
|
-
const configs$
|
|
480
|
-
base: base$
|
|
530
|
+
const configs$6 = {
|
|
531
|
+
base: base$6
|
|
481
532
|
};
|
|
482
533
|
|
|
483
|
-
const base$
|
|
534
|
+
const base$5 = {
|
|
484
535
|
plugins: {
|
|
485
536
|
promise: promise__default
|
|
486
537
|
},
|
|
@@ -497,16 +548,23 @@ const base$4 = {
|
|
|
497
548
|
"promise/param-names": "error"
|
|
498
549
|
}
|
|
499
550
|
};
|
|
500
|
-
const configs$
|
|
501
|
-
base: base$
|
|
551
|
+
const configs$5 = {
|
|
552
|
+
base: base$5
|
|
502
553
|
};
|
|
503
554
|
|
|
504
|
-
const base$
|
|
555
|
+
const base$4 = {
|
|
556
|
+
settings: {
|
|
557
|
+
react: {
|
|
558
|
+
version: "detect"
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
languageOptions: {
|
|
562
|
+
...react__default.configs["jsx-runtime"].languageOptions
|
|
563
|
+
},
|
|
505
564
|
plugins: {
|
|
506
565
|
"jsx-a11y": a11y__default,
|
|
507
566
|
react: react__default,
|
|
508
|
-
"react-hooks": reactHooks__default
|
|
509
|
-
"testing-library": compat.fixupPluginRules(testingLibrary__default)
|
|
567
|
+
"react-hooks": compat.fixupPluginRules(reactHooks__default)
|
|
510
568
|
},
|
|
511
569
|
rules: {
|
|
512
570
|
...a11y__default.configs.recommended.rules,
|
|
@@ -515,6 +573,7 @@ const base$3 = {
|
|
|
515
573
|
"jsx-a11y/aria-unsupported-elements": "error",
|
|
516
574
|
"jsx-a11y/role-has-required-aria-props": "error",
|
|
517
575
|
...react__default.configs.recommended.rules,
|
|
576
|
+
...react__default.configs["jsx-runtime"].rules,
|
|
518
577
|
"react/default-props-match-prop-types": "error",
|
|
519
578
|
"react/display-name": ["error", { ignoreTranspilerName: false }],
|
|
520
579
|
"react/forbid-foreign-prop-types": ["error", { allowInPropTypes: true }],
|
|
@@ -557,15 +616,14 @@ const base$3 = {
|
|
|
557
616
|
"react/self-closing-comp": "error",
|
|
558
617
|
"react/style-prop-object": "error",
|
|
559
618
|
"react-hooks/rules-of-hooks": "error",
|
|
560
|
-
"react-hooks/exhaustive-deps": "error"
|
|
561
|
-
...testingLibrary__default.configs.react.rules
|
|
619
|
+
"react-hooks/exhaustive-deps": "error"
|
|
562
620
|
}
|
|
563
621
|
};
|
|
564
|
-
const configs$
|
|
565
|
-
base: base$
|
|
622
|
+
const configs$4 = {
|
|
623
|
+
base: base$4
|
|
566
624
|
};
|
|
567
625
|
|
|
568
|
-
const base$
|
|
626
|
+
const base$3 = {
|
|
569
627
|
plugins: {
|
|
570
628
|
security: security__default
|
|
571
629
|
},
|
|
@@ -585,6 +643,22 @@ const base$2 = {
|
|
|
585
643
|
"security/detect-unsafe-regex": "error"
|
|
586
644
|
}
|
|
587
645
|
};
|
|
646
|
+
const configs$3 = {
|
|
647
|
+
base: base$3
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
const base$2 = {
|
|
651
|
+
plugins: {
|
|
652
|
+
"testing-library": compat.fixupPluginRules(testingLibrary__default)
|
|
653
|
+
},
|
|
654
|
+
rules: {
|
|
655
|
+
...testingLibrary__default.configs["flat/react"].rules,
|
|
656
|
+
"testing-library/no-debugging-utils": "error",
|
|
657
|
+
"testing-library/prefer-explicit-assert": "warn",
|
|
658
|
+
"testing-library/prefer-implicit-assert": "error",
|
|
659
|
+
"testing-library/prefer-query-matchers": "off"
|
|
660
|
+
}
|
|
661
|
+
};
|
|
588
662
|
const configs$2 = {
|
|
589
663
|
base: base$2
|
|
590
664
|
};
|
|
@@ -675,6 +749,10 @@ const configs = {
|
|
|
675
749
|
const defaultConfig = tsEslintConfig;
|
|
676
750
|
function tsEslintConfig(options) {
|
|
677
751
|
const enableRequireExtensionRule = options?.enableRequireExtensionRule ?? true;
|
|
752
|
+
const enableJest = options?.enableJest ?? true;
|
|
753
|
+
const enableMocha = options?.enableMocha ?? true;
|
|
754
|
+
const enableReact = options?.enableReact ?? true;
|
|
755
|
+
const enableTestingLibrary = options?.enableTestingLibrary ?? true;
|
|
678
756
|
const languageOptions = {
|
|
679
757
|
globals: {
|
|
680
758
|
...globals__default.node
|
|
@@ -704,27 +782,27 @@ function tsEslintConfig(options) {
|
|
|
704
782
|
{
|
|
705
783
|
languageOptions,
|
|
706
784
|
settings: {
|
|
707
|
-
...configs$
|
|
785
|
+
...configs$7.base.settings
|
|
708
786
|
}
|
|
709
787
|
},
|
|
710
788
|
{
|
|
711
789
|
name: "eslint-config-decent/base",
|
|
712
790
|
files: ["**/*.ts", "**/*.js", "**/*.cjs", "**/*.mjs", "**/*.tsx"],
|
|
713
791
|
plugins: {
|
|
714
|
-
...configs$
|
|
792
|
+
...configs$a.base.plugins,
|
|
793
|
+
...configs$9.base.plugins,
|
|
715
794
|
...configs$7.base.plugins,
|
|
716
|
-
...configs$
|
|
717
|
-
...configs$
|
|
718
|
-
...configs$2.base.plugins,
|
|
795
|
+
...configs$5.base.plugins,
|
|
796
|
+
...configs$3.base.plugins,
|
|
719
797
|
...configs.base.plugins
|
|
720
798
|
},
|
|
721
799
|
rules: {
|
|
800
|
+
...configs$b.base.rules,
|
|
801
|
+
...enableRequireExtensionRule ? configs$a.base.rules : {},
|
|
722
802
|
...configs$9.base.rules,
|
|
723
|
-
...enableRequireExtensionRule ? configs$8.base.rules : {},
|
|
724
803
|
...configs$7.base.rules,
|
|
725
|
-
...configs$
|
|
726
|
-
...configs$
|
|
727
|
-
...configs$2.base.rules,
|
|
804
|
+
...configs$5.base.rules,
|
|
805
|
+
...configs$3.base.rules,
|
|
728
806
|
...configs.base.rules
|
|
729
807
|
}
|
|
730
808
|
},
|
|
@@ -733,18 +811,20 @@ function tsEslintConfig(options) {
|
|
|
733
811
|
files: ["**/*.ts", "**/*.tsx"],
|
|
734
812
|
...configs$1.base
|
|
735
813
|
},
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
814
|
+
...enableReact ? [
|
|
815
|
+
{
|
|
816
|
+
name: "eslint-config-decent/tsx",
|
|
817
|
+
files: ["**/*.tsx"],
|
|
818
|
+
...configs$4.base
|
|
819
|
+
}
|
|
820
|
+
] : [],
|
|
741
821
|
{
|
|
742
822
|
name: "eslint-config-decent/cjs-and-esm",
|
|
743
823
|
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
|
|
744
824
|
languageOptions: {
|
|
745
825
|
sourceType: "script"
|
|
746
826
|
},
|
|
747
|
-
...configs$
|
|
827
|
+
...configs$b.cjsAndEsm
|
|
748
828
|
},
|
|
749
829
|
{
|
|
750
830
|
name: "eslint-config-decent/cjs",
|
|
@@ -752,13 +832,29 @@ function tsEslintConfig(options) {
|
|
|
752
832
|
languageOptions: {
|
|
753
833
|
sourceType: "script"
|
|
754
834
|
},
|
|
755
|
-
...configs$
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
name: "eslint-config-decent/tests",
|
|
759
|
-
files: ["**/*.tests.ts", "tests/tests.ts"],
|
|
760
|
-
...configs$5.base
|
|
835
|
+
...configs$b.cjs
|
|
761
836
|
},
|
|
837
|
+
...enableMocha ? [
|
|
838
|
+
{
|
|
839
|
+
name: "eslint-config-decent/mocha-tests",
|
|
840
|
+
files: ["**/*.tests.ts", "tests/tests.ts"],
|
|
841
|
+
...configs$6.base
|
|
842
|
+
}
|
|
843
|
+
] : [],
|
|
844
|
+
...enableJest ? [
|
|
845
|
+
{
|
|
846
|
+
name: "eslint-config-decent/jest-tests",
|
|
847
|
+
files: ["**/__tests__/**/*.ts?(x)", "**/*.{spec,test}.ts?(x)"],
|
|
848
|
+
...configs$8.base
|
|
849
|
+
}
|
|
850
|
+
] : [],
|
|
851
|
+
...enableTestingLibrary ? [
|
|
852
|
+
{
|
|
853
|
+
name: "eslint-config-decent/testing-library",
|
|
854
|
+
files: ["**/__tests__/**/*.ts?(x)", "**/*.{spec,test}.ts?(x)"],
|
|
855
|
+
...configs$2.base
|
|
856
|
+
}
|
|
857
|
+
] : [],
|
|
762
858
|
{
|
|
763
859
|
name: "eslint-config-decent/cjs-and-esm-disable-ts-rules",
|
|
764
860
|
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
|
|
@@ -773,12 +869,16 @@ function config(options) {
|
|
|
773
869
|
|
|
774
870
|
exports.config = config;
|
|
775
871
|
exports.defaultConfig = defaultConfig;
|
|
776
|
-
exports.eslintConfigs = configs$
|
|
777
|
-
exports.
|
|
778
|
-
exports.
|
|
779
|
-
exports.
|
|
780
|
-
exports.
|
|
781
|
-
exports.
|
|
872
|
+
exports.eslintConfigs = configs$b;
|
|
873
|
+
exports.extensionConfigs = configs$a;
|
|
874
|
+
exports.importConfigs = configs$9;
|
|
875
|
+
exports.jestConfigs = configs$8;
|
|
876
|
+
exports.jsdocConfigs = configs$7;
|
|
877
|
+
exports.mochaConfigs = configs$6;
|
|
878
|
+
exports.promiseConfigs = configs$5;
|
|
879
|
+
exports.reactConfigs = configs$4;
|
|
880
|
+
exports.securityConfigs = configs$3;
|
|
881
|
+
exports.testingLibraryConfigs = configs$2;
|
|
782
882
|
exports.tsEslintConfig = tsEslintConfig;
|
|
783
883
|
exports.typescriptEslintConfigs = configs$1;
|
|
784
884
|
exports.unicornConfigs = configs;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
2
|
import { ConfigWithExtends } from 'typescript-eslint';
|
|
3
3
|
|
|
4
|
-
declare const configs$
|
|
4
|
+
declare const configs$b: {
|
|
5
5
|
base: TSESLint.FlatConfig.Config;
|
|
6
6
|
cjsAndEsm: TSESLint.FlatConfig.Config;
|
|
7
7
|
cjs: TSESLint.FlatConfig.Config;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
declare const configs$a: {
|
|
11
|
+
base: TSESLint.FlatConfig.Config;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare const configs$9: {
|
|
15
|
+
base: TSESLint.FlatConfig.Config;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare const configs$8: {
|
|
19
|
+
base: TSESLint.FlatConfig.Config;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare const configs$7: {
|
|
23
|
+
base: TSESLint.FlatConfig.Config;
|
|
24
|
+
};
|
|
25
|
+
|
|
10
26
|
declare const configs$6: {
|
|
11
27
|
base: TSESLint.FlatConfig.Config;
|
|
12
28
|
};
|
|
@@ -38,6 +54,10 @@ declare const configs: {
|
|
|
38
54
|
interface DefaultConfigOptions {
|
|
39
55
|
parserOptions?: NonNullable<ConfigWithExtends['languageOptions']>['parserOptions'];
|
|
40
56
|
enableRequireExtensionRule?: boolean;
|
|
57
|
+
enableJest?: boolean;
|
|
58
|
+
enableMocha?: boolean;
|
|
59
|
+
enableReact?: boolean;
|
|
60
|
+
enableTestingLibrary?: boolean;
|
|
41
61
|
}
|
|
42
62
|
/**
|
|
43
63
|
* @deprecated Use `tsEslintConfig` instead
|
|
@@ -56,4 +76,4 @@ declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExten
|
|
|
56
76
|
*/
|
|
57
77
|
declare function config(options?: DefaultConfigOptions): TSESLint.FlatConfig.ConfigArray;
|
|
58
78
|
|
|
59
|
-
export { type DefaultConfigOptions, config, defaultConfig, configs$
|
|
79
|
+
export { type DefaultConfigOptions, config, defaultConfig, configs$b as eslintConfigs, configs$a as extensionConfigs, configs$9 as importConfigs, configs$8 as jestConfigs, configs$7 as jsdocConfigs, configs$6 as mochaConfigs, configs$5 as promiseConfigs, configs$4 as reactConfigs, configs$3 as securityConfigs, configs$2 as testingLibraryConfigs, tsEslintConfig, configs$1 as typescriptEslintConfigs, configs as unicornConfigs };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
2
|
import { ConfigWithExtends } from 'typescript-eslint';
|
|
3
3
|
|
|
4
|
-
declare const configs$
|
|
4
|
+
declare const configs$b: {
|
|
5
5
|
base: TSESLint.FlatConfig.Config;
|
|
6
6
|
cjsAndEsm: TSESLint.FlatConfig.Config;
|
|
7
7
|
cjs: TSESLint.FlatConfig.Config;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
declare const configs$a: {
|
|
11
|
+
base: TSESLint.FlatConfig.Config;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare const configs$9: {
|
|
15
|
+
base: TSESLint.FlatConfig.Config;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare const configs$8: {
|
|
19
|
+
base: TSESLint.FlatConfig.Config;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare const configs$7: {
|
|
23
|
+
base: TSESLint.FlatConfig.Config;
|
|
24
|
+
};
|
|
25
|
+
|
|
10
26
|
declare const configs$6: {
|
|
11
27
|
base: TSESLint.FlatConfig.Config;
|
|
12
28
|
};
|
|
@@ -38,6 +54,10 @@ declare const configs: {
|
|
|
38
54
|
interface DefaultConfigOptions {
|
|
39
55
|
parserOptions?: NonNullable<ConfigWithExtends['languageOptions']>['parserOptions'];
|
|
40
56
|
enableRequireExtensionRule?: boolean;
|
|
57
|
+
enableJest?: boolean;
|
|
58
|
+
enableMocha?: boolean;
|
|
59
|
+
enableReact?: boolean;
|
|
60
|
+
enableTestingLibrary?: boolean;
|
|
41
61
|
}
|
|
42
62
|
/**
|
|
43
63
|
* @deprecated Use `tsEslintConfig` instead
|
|
@@ -56,4 +76,4 @@ declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExten
|
|
|
56
76
|
*/
|
|
57
77
|
declare function config(options?: DefaultConfigOptions): TSESLint.FlatConfig.ConfigArray;
|
|
58
78
|
|
|
59
|
-
export { type DefaultConfigOptions, config, defaultConfig, configs$
|
|
79
|
+
export { type DefaultConfigOptions, config, defaultConfig, configs$b as eslintConfigs, configs$a as extensionConfigs, configs$9 as importConfigs, configs$8 as jestConfigs, configs$7 as jsdocConfigs, configs$6 as mochaConfigs, configs$5 as promiseConfigs, configs$4 as reactConfigs, configs$3 as securityConfigs, configs$2 as testingLibraryConfigs, tsEslintConfig, configs$1 as typescriptEslintConfigs, configs as unicornConfigs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
2
|
import { ConfigWithExtends } from 'typescript-eslint';
|
|
3
3
|
|
|
4
|
-
declare const configs$
|
|
4
|
+
declare const configs$b: {
|
|
5
5
|
base: TSESLint.FlatConfig.Config;
|
|
6
6
|
cjsAndEsm: TSESLint.FlatConfig.Config;
|
|
7
7
|
cjs: TSESLint.FlatConfig.Config;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
declare const configs$a: {
|
|
11
|
+
base: TSESLint.FlatConfig.Config;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare const configs$9: {
|
|
15
|
+
base: TSESLint.FlatConfig.Config;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare const configs$8: {
|
|
19
|
+
base: TSESLint.FlatConfig.Config;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare const configs$7: {
|
|
23
|
+
base: TSESLint.FlatConfig.Config;
|
|
24
|
+
};
|
|
25
|
+
|
|
10
26
|
declare const configs$6: {
|
|
11
27
|
base: TSESLint.FlatConfig.Config;
|
|
12
28
|
};
|
|
@@ -38,6 +54,10 @@ declare const configs: {
|
|
|
38
54
|
interface DefaultConfigOptions {
|
|
39
55
|
parserOptions?: NonNullable<ConfigWithExtends['languageOptions']>['parserOptions'];
|
|
40
56
|
enableRequireExtensionRule?: boolean;
|
|
57
|
+
enableJest?: boolean;
|
|
58
|
+
enableMocha?: boolean;
|
|
59
|
+
enableReact?: boolean;
|
|
60
|
+
enableTestingLibrary?: boolean;
|
|
41
61
|
}
|
|
42
62
|
/**
|
|
43
63
|
* @deprecated Use `tsEslintConfig` instead
|
|
@@ -56,4 +76,4 @@ declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExten
|
|
|
56
76
|
*/
|
|
57
77
|
declare function config(options?: DefaultConfigOptions): TSESLint.FlatConfig.ConfigArray;
|
|
58
78
|
|
|
59
|
-
export { type DefaultConfigOptions, config, defaultConfig, configs$
|
|
79
|
+
export { type DefaultConfigOptions, config, defaultConfig, configs$b as eslintConfigs, configs$a as extensionConfigs, configs$9 as importConfigs, configs$8 as jestConfigs, configs$7 as jsdocConfigs, configs$6 as mochaConfigs, configs$5 as promiseConfigs, configs$4 as reactConfigs, configs$3 as securityConfigs, configs$2 as testingLibraryConfigs, tsEslintConfig, configs$1 as typescriptEslintConfigs, configs as unicornConfigs };
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,8 @@ import { existsSync, lstatSync } from 'fs';
|
|
|
6
6
|
import { resolve, dirname } from 'path';
|
|
7
7
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
8
8
|
import importPlugin from 'eslint-plugin-import-x';
|
|
9
|
+
import jest from 'eslint-plugin-jest';
|
|
10
|
+
import jestDom from 'eslint-plugin-jest-dom';
|
|
9
11
|
import jsdoc from 'eslint-plugin-jsdoc';
|
|
10
12
|
import mocha from 'eslint-plugin-mocha';
|
|
11
13
|
import promise from 'eslint-plugin-promise';
|
|
@@ -13,11 +15,11 @@ import { fixupPluginRules } from '@eslint/compat';
|
|
|
13
15
|
import a11y from 'eslint-plugin-jsx-a11y';
|
|
14
16
|
import react from 'eslint-plugin-react';
|
|
15
17
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
16
|
-
import testingLibrary from 'eslint-plugin-testing-library';
|
|
17
18
|
import security from 'eslint-plugin-security';
|
|
19
|
+
import testingLibrary from 'eslint-plugin-testing-library';
|
|
18
20
|
import unicorn from 'eslint-plugin-unicorn';
|
|
19
21
|
|
|
20
|
-
const base$
|
|
22
|
+
const base$b = {
|
|
21
23
|
rules: {
|
|
22
24
|
"array-callback-return": ["error", { allowImplicit: true }],
|
|
23
25
|
"block-scoped-var": "error",
|
|
@@ -267,8 +269,8 @@ const cjs = {
|
|
|
267
269
|
strict: ["error", "global"]
|
|
268
270
|
}
|
|
269
271
|
};
|
|
270
|
-
const configs$
|
|
271
|
-
base: base$
|
|
272
|
+
const configs$b = {
|
|
273
|
+
base: base$b,
|
|
272
274
|
cjsAndEsm,
|
|
273
275
|
cjs
|
|
274
276
|
};
|
|
@@ -367,7 +369,7 @@ const requireIndexRule = ESLintUtils.RuleCreator(() => "https://github.com/jgeur
|
|
|
367
369
|
}
|
|
368
370
|
});
|
|
369
371
|
|
|
370
|
-
const base$
|
|
372
|
+
const base$a = {
|
|
371
373
|
plugins: {
|
|
372
374
|
"decent-extension": {
|
|
373
375
|
meta: {
|
|
@@ -385,11 +387,11 @@ const base$8 = {
|
|
|
385
387
|
"decent-extension/require-index": "error"
|
|
386
388
|
}
|
|
387
389
|
};
|
|
388
|
-
const configs$
|
|
389
|
-
base: base$
|
|
390
|
+
const configs$a = {
|
|
391
|
+
base: base$a
|
|
390
392
|
};
|
|
391
393
|
|
|
392
|
-
const base$
|
|
394
|
+
const base$9 = {
|
|
393
395
|
plugins: {
|
|
394
396
|
import: importPlugin
|
|
395
397
|
},
|
|
@@ -404,11 +406,58 @@ const base$7 = {
|
|
|
404
406
|
]
|
|
405
407
|
}
|
|
406
408
|
};
|
|
407
|
-
const configs$
|
|
408
|
-
base: base$
|
|
409
|
+
const configs$9 = {
|
|
410
|
+
base: base$9
|
|
409
411
|
};
|
|
410
412
|
|
|
411
|
-
const base$
|
|
413
|
+
const base$8 = {
|
|
414
|
+
plugins: {
|
|
415
|
+
jest,
|
|
416
|
+
"jest-dom": jestDom
|
|
417
|
+
},
|
|
418
|
+
languageOptions: {
|
|
419
|
+
...jest.configs["flat/recommended"].languageOptions
|
|
420
|
+
},
|
|
421
|
+
rules: {
|
|
422
|
+
...jest.configs["flat/recommended"].rules,
|
|
423
|
+
"jest/max-nested-describe": "error",
|
|
424
|
+
"jest/no-conditional-in-test": "error",
|
|
425
|
+
"jest/no-confusing-set-timeout": "error",
|
|
426
|
+
"jest/no-test-prefixes": "error",
|
|
427
|
+
"jest/prefer-called-with": "error",
|
|
428
|
+
"jest/prefer-comparison-matcher": "error",
|
|
429
|
+
"jest/prefer-equality-matcher": "error",
|
|
430
|
+
"jest/prefer-hooks-in-order": "error",
|
|
431
|
+
"jest/prefer-hooks-on-top": "error",
|
|
432
|
+
"jest/prefer-mock-promise-shorthand": "error",
|
|
433
|
+
"jest/prefer-snapshot-hint": "error",
|
|
434
|
+
...jestDom.configs["flat/recommended"].rules,
|
|
435
|
+
"jest-dom/prefer-checked": "error",
|
|
436
|
+
"jest-dom/prefer-empty": "error",
|
|
437
|
+
"jest-dom/prefer-enabled-disabled": "error",
|
|
438
|
+
"jest-dom/prefer-focus": "error",
|
|
439
|
+
"jest-dom/prefer-in-document": "error",
|
|
440
|
+
"jest-dom/prefer-required": "error",
|
|
441
|
+
"jest-dom/prefer-to-have-attribute": "error",
|
|
442
|
+
"jest-dom/prefer-to-have-class": "error",
|
|
443
|
+
"jest-dom/prefer-to-have-style": "error",
|
|
444
|
+
"jest-dom/prefer-to-have-text-content": "error",
|
|
445
|
+
"jest-dom/prefer-to-have-value": "error",
|
|
446
|
+
"max-classes-per-file": "off",
|
|
447
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
448
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
449
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
450
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
451
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
452
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
453
|
+
"@typescript-eslint/unbound-method": "off"
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
const configs$8 = {
|
|
457
|
+
base: base$8
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
const base$7 = {
|
|
412
461
|
settings: {
|
|
413
462
|
jsdoc: {
|
|
414
463
|
preferredTypes: {
|
|
@@ -434,11 +483,11 @@ const base$6 = {
|
|
|
434
483
|
"unicorn/prefer-set-has": "error"
|
|
435
484
|
}
|
|
436
485
|
};
|
|
437
|
-
const configs$
|
|
438
|
-
base: base$
|
|
486
|
+
const configs$7 = {
|
|
487
|
+
base: base$7
|
|
439
488
|
};
|
|
440
489
|
|
|
441
|
-
const base$
|
|
490
|
+
const base$6 = {
|
|
442
491
|
plugins: {
|
|
443
492
|
mocha
|
|
444
493
|
},
|
|
@@ -457,11 +506,11 @@ const base$5 = {
|
|
|
457
506
|
"mocha/no-mocha-arrows": "off"
|
|
458
507
|
}
|
|
459
508
|
};
|
|
460
|
-
const configs$
|
|
461
|
-
base: base$
|
|
509
|
+
const configs$6 = {
|
|
510
|
+
base: base$6
|
|
462
511
|
};
|
|
463
512
|
|
|
464
|
-
const base$
|
|
513
|
+
const base$5 = {
|
|
465
514
|
plugins: {
|
|
466
515
|
promise
|
|
467
516
|
},
|
|
@@ -478,16 +527,23 @@ const base$4 = {
|
|
|
478
527
|
"promise/param-names": "error"
|
|
479
528
|
}
|
|
480
529
|
};
|
|
481
|
-
const configs$
|
|
482
|
-
base: base$
|
|
530
|
+
const configs$5 = {
|
|
531
|
+
base: base$5
|
|
483
532
|
};
|
|
484
533
|
|
|
485
|
-
const base$
|
|
534
|
+
const base$4 = {
|
|
535
|
+
settings: {
|
|
536
|
+
react: {
|
|
537
|
+
version: "detect"
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
languageOptions: {
|
|
541
|
+
...react.configs["jsx-runtime"].languageOptions
|
|
542
|
+
},
|
|
486
543
|
plugins: {
|
|
487
544
|
"jsx-a11y": a11y,
|
|
488
545
|
react,
|
|
489
|
-
"react-hooks": reactHooks
|
|
490
|
-
"testing-library": fixupPluginRules(testingLibrary)
|
|
546
|
+
"react-hooks": fixupPluginRules(reactHooks)
|
|
491
547
|
},
|
|
492
548
|
rules: {
|
|
493
549
|
...a11y.configs.recommended.rules,
|
|
@@ -496,6 +552,7 @@ const base$3 = {
|
|
|
496
552
|
"jsx-a11y/aria-unsupported-elements": "error",
|
|
497
553
|
"jsx-a11y/role-has-required-aria-props": "error",
|
|
498
554
|
...react.configs.recommended.rules,
|
|
555
|
+
...react.configs["jsx-runtime"].rules,
|
|
499
556
|
"react/default-props-match-prop-types": "error",
|
|
500
557
|
"react/display-name": ["error", { ignoreTranspilerName: false }],
|
|
501
558
|
"react/forbid-foreign-prop-types": ["error", { allowInPropTypes: true }],
|
|
@@ -538,15 +595,14 @@ const base$3 = {
|
|
|
538
595
|
"react/self-closing-comp": "error",
|
|
539
596
|
"react/style-prop-object": "error",
|
|
540
597
|
"react-hooks/rules-of-hooks": "error",
|
|
541
|
-
"react-hooks/exhaustive-deps": "error"
|
|
542
|
-
...testingLibrary.configs.react.rules
|
|
598
|
+
"react-hooks/exhaustive-deps": "error"
|
|
543
599
|
}
|
|
544
600
|
};
|
|
545
|
-
const configs$
|
|
546
|
-
base: base$
|
|
601
|
+
const configs$4 = {
|
|
602
|
+
base: base$4
|
|
547
603
|
};
|
|
548
604
|
|
|
549
|
-
const base$
|
|
605
|
+
const base$3 = {
|
|
550
606
|
plugins: {
|
|
551
607
|
security
|
|
552
608
|
},
|
|
@@ -566,6 +622,22 @@ const base$2 = {
|
|
|
566
622
|
"security/detect-unsafe-regex": "error"
|
|
567
623
|
}
|
|
568
624
|
};
|
|
625
|
+
const configs$3 = {
|
|
626
|
+
base: base$3
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
const base$2 = {
|
|
630
|
+
plugins: {
|
|
631
|
+
"testing-library": fixupPluginRules(testingLibrary)
|
|
632
|
+
},
|
|
633
|
+
rules: {
|
|
634
|
+
...testingLibrary.configs["flat/react"].rules,
|
|
635
|
+
"testing-library/no-debugging-utils": "error",
|
|
636
|
+
"testing-library/prefer-explicit-assert": "warn",
|
|
637
|
+
"testing-library/prefer-implicit-assert": "error",
|
|
638
|
+
"testing-library/prefer-query-matchers": "off"
|
|
639
|
+
}
|
|
640
|
+
};
|
|
569
641
|
const configs$2 = {
|
|
570
642
|
base: base$2
|
|
571
643
|
};
|
|
@@ -656,6 +728,10 @@ const configs = {
|
|
|
656
728
|
const defaultConfig = tsEslintConfig;
|
|
657
729
|
function tsEslintConfig(options) {
|
|
658
730
|
const enableRequireExtensionRule = options?.enableRequireExtensionRule ?? true;
|
|
731
|
+
const enableJest = options?.enableJest ?? true;
|
|
732
|
+
const enableMocha = options?.enableMocha ?? true;
|
|
733
|
+
const enableReact = options?.enableReact ?? true;
|
|
734
|
+
const enableTestingLibrary = options?.enableTestingLibrary ?? true;
|
|
659
735
|
const languageOptions = {
|
|
660
736
|
globals: {
|
|
661
737
|
...globals.node
|
|
@@ -685,27 +761,27 @@ function tsEslintConfig(options) {
|
|
|
685
761
|
{
|
|
686
762
|
languageOptions,
|
|
687
763
|
settings: {
|
|
688
|
-
...configs$
|
|
764
|
+
...configs$7.base.settings
|
|
689
765
|
}
|
|
690
766
|
},
|
|
691
767
|
{
|
|
692
768
|
name: "eslint-config-decent/base",
|
|
693
769
|
files: ["**/*.ts", "**/*.js", "**/*.cjs", "**/*.mjs", "**/*.tsx"],
|
|
694
770
|
plugins: {
|
|
695
|
-
...configs$
|
|
771
|
+
...configs$a.base.plugins,
|
|
772
|
+
...configs$9.base.plugins,
|
|
696
773
|
...configs$7.base.plugins,
|
|
697
|
-
...configs$
|
|
698
|
-
...configs$
|
|
699
|
-
...configs$2.base.plugins,
|
|
774
|
+
...configs$5.base.plugins,
|
|
775
|
+
...configs$3.base.plugins,
|
|
700
776
|
...configs.base.plugins
|
|
701
777
|
},
|
|
702
778
|
rules: {
|
|
779
|
+
...configs$b.base.rules,
|
|
780
|
+
...enableRequireExtensionRule ? configs$a.base.rules : {},
|
|
703
781
|
...configs$9.base.rules,
|
|
704
|
-
...enableRequireExtensionRule ? configs$8.base.rules : {},
|
|
705
782
|
...configs$7.base.rules,
|
|
706
|
-
...configs$
|
|
707
|
-
...configs$
|
|
708
|
-
...configs$2.base.rules,
|
|
783
|
+
...configs$5.base.rules,
|
|
784
|
+
...configs$3.base.rules,
|
|
709
785
|
...configs.base.rules
|
|
710
786
|
}
|
|
711
787
|
},
|
|
@@ -714,18 +790,20 @@ function tsEslintConfig(options) {
|
|
|
714
790
|
files: ["**/*.ts", "**/*.tsx"],
|
|
715
791
|
...configs$1.base
|
|
716
792
|
},
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
793
|
+
...enableReact ? [
|
|
794
|
+
{
|
|
795
|
+
name: "eslint-config-decent/tsx",
|
|
796
|
+
files: ["**/*.tsx"],
|
|
797
|
+
...configs$4.base
|
|
798
|
+
}
|
|
799
|
+
] : [],
|
|
722
800
|
{
|
|
723
801
|
name: "eslint-config-decent/cjs-and-esm",
|
|
724
802
|
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
|
|
725
803
|
languageOptions: {
|
|
726
804
|
sourceType: "script"
|
|
727
805
|
},
|
|
728
|
-
...configs$
|
|
806
|
+
...configs$b.cjsAndEsm
|
|
729
807
|
},
|
|
730
808
|
{
|
|
731
809
|
name: "eslint-config-decent/cjs",
|
|
@@ -733,13 +811,29 @@ function tsEslintConfig(options) {
|
|
|
733
811
|
languageOptions: {
|
|
734
812
|
sourceType: "script"
|
|
735
813
|
},
|
|
736
|
-
...configs$
|
|
737
|
-
},
|
|
738
|
-
{
|
|
739
|
-
name: "eslint-config-decent/tests",
|
|
740
|
-
files: ["**/*.tests.ts", "tests/tests.ts"],
|
|
741
|
-
...configs$5.base
|
|
814
|
+
...configs$b.cjs
|
|
742
815
|
},
|
|
816
|
+
...enableMocha ? [
|
|
817
|
+
{
|
|
818
|
+
name: "eslint-config-decent/mocha-tests",
|
|
819
|
+
files: ["**/*.tests.ts", "tests/tests.ts"],
|
|
820
|
+
...configs$6.base
|
|
821
|
+
}
|
|
822
|
+
] : [],
|
|
823
|
+
...enableJest ? [
|
|
824
|
+
{
|
|
825
|
+
name: "eslint-config-decent/jest-tests",
|
|
826
|
+
files: ["**/__tests__/**/*.ts?(x)", "**/*.{spec,test}.ts?(x)"],
|
|
827
|
+
...configs$8.base
|
|
828
|
+
}
|
|
829
|
+
] : [],
|
|
830
|
+
...enableTestingLibrary ? [
|
|
831
|
+
{
|
|
832
|
+
name: "eslint-config-decent/testing-library",
|
|
833
|
+
files: ["**/__tests__/**/*.ts?(x)", "**/*.{spec,test}.ts?(x)"],
|
|
834
|
+
...configs$2.base
|
|
835
|
+
}
|
|
836
|
+
] : [],
|
|
743
837
|
{
|
|
744
838
|
name: "eslint-config-decent/cjs-and-esm-disable-ts-rules",
|
|
745
839
|
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
|
|
@@ -752,4 +846,4 @@ function config(options) {
|
|
|
752
846
|
return tsEslint.config(...tsEslintConfig(options));
|
|
753
847
|
}
|
|
754
848
|
|
|
755
|
-
export { config, defaultConfig, configs$
|
|
849
|
+
export { config, defaultConfig, configs$b as eslintConfigs, configs$a as extensionConfigs, configs$9 as importConfigs, configs$8 as jestConfigs, configs$7 as jsdocConfigs, configs$6 as mochaConfigs, configs$5 as promiseConfigs, configs$4 as reactConfigs, configs$3 as securityConfigs, configs$2 as testingLibraryConfigs, tsEslintConfig, configs$1 as typescriptEslintConfigs, configs as unicornConfigs };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-decent",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A decent ESLint configuration",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -73,29 +73,31 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@eslint/compat": "1.1.1",
|
|
76
|
-
"@eslint/js": "
|
|
77
|
-
"@typescript-eslint/utils": "8.
|
|
78
|
-
"eslint-config-prettier": "
|
|
79
|
-
"eslint-plugin-import-x": "
|
|
80
|
-
"eslint-plugin-
|
|
81
|
-
"eslint-plugin-
|
|
82
|
-
"eslint-plugin-
|
|
83
|
-
"eslint-plugin-
|
|
84
|
-
"eslint-plugin-
|
|
85
|
-
"eslint-plugin-
|
|
86
|
-
"eslint-plugin-
|
|
87
|
-
"eslint-plugin-
|
|
88
|
-
"eslint-plugin-
|
|
89
|
-
"eslint-plugin-
|
|
90
|
-
"
|
|
91
|
-
"
|
|
76
|
+
"@eslint/js": "9.9.0",
|
|
77
|
+
"@typescript-eslint/utils": "8.1.0",
|
|
78
|
+
"eslint-config-prettier": "9.1.0",
|
|
79
|
+
"eslint-plugin-import-x": "3.1.0",
|
|
80
|
+
"eslint-plugin-jest": "28.8.0",
|
|
81
|
+
"eslint-plugin-jest-dom": "5.4.0",
|
|
82
|
+
"eslint-plugin-jsdoc": "50.1.0",
|
|
83
|
+
"eslint-plugin-jsx-a11y": "6.9.0",
|
|
84
|
+
"eslint-plugin-mocha": "10.5.0",
|
|
85
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
86
|
+
"eslint-plugin-promise": "7.1.0",
|
|
87
|
+
"eslint-plugin-react": "7.35.0",
|
|
88
|
+
"eslint-plugin-react-hooks": "4.6.2",
|
|
89
|
+
"eslint-plugin-security": "3.0.1",
|
|
90
|
+
"eslint-plugin-testing-library": "6.3.0",
|
|
91
|
+
"eslint-plugin-unicorn": "55.0.0",
|
|
92
|
+
"globals": "15.9.0",
|
|
93
|
+
"typescript-eslint": "8.1.0"
|
|
92
94
|
},
|
|
93
95
|
"devDependencies": {
|
|
94
|
-
"@swc/core": "1.7.
|
|
96
|
+
"@swc/core": "^1.7.10",
|
|
95
97
|
"@types/node": ">=22",
|
|
96
|
-
"eslint": "^9.
|
|
98
|
+
"eslint": "^9.9.0",
|
|
97
99
|
"husky": "^9.1.4",
|
|
98
|
-
"lint-staged": "^15.2.
|
|
100
|
+
"lint-staged": "^15.2.9",
|
|
99
101
|
"markdownlint-cli": "^0.41.0",
|
|
100
102
|
"npm-run-all": "^4.1.5",
|
|
101
103
|
"pinst": "^3.0.0",
|
package/src/index.ts
CHANGED
|
@@ -7,21 +7,27 @@ import tsEslint, { type ConfigWithExtends } from 'typescript-eslint';
|
|
|
7
7
|
import { configs as eslintConfigs } from './eslint.js';
|
|
8
8
|
import { configs as extensionConfigs } from './extension.js';
|
|
9
9
|
import { configs as importConfigs } from './import.js';
|
|
10
|
+
import { configs as jestConfigs } from './jest.js';
|
|
10
11
|
import { configs as jsdocConfigs } from './jsdoc.js';
|
|
11
12
|
import { configs as mochaConfigs } from './mocha.js';
|
|
12
13
|
import { configs as promiseConfigs } from './promise.js';
|
|
13
14
|
import { configs as reactConfigs } from './react.js';
|
|
14
15
|
import { configs as securityConfigs } from './security.js';
|
|
16
|
+
import { configs as testingLibraryConfigs } from './testingLibrary.js';
|
|
15
17
|
import { configs as typescriptEslintConfigs } from './typescriptEslint.js';
|
|
16
18
|
import { configs as unicornConfigs } from './unicorn.js';
|
|
17
19
|
|
|
18
20
|
export {
|
|
19
21
|
eslintConfigs, //
|
|
22
|
+
extensionConfigs,
|
|
20
23
|
importConfigs,
|
|
24
|
+
jestConfigs,
|
|
21
25
|
jsdocConfigs,
|
|
26
|
+
mochaConfigs,
|
|
22
27
|
promiseConfigs,
|
|
23
28
|
reactConfigs,
|
|
24
29
|
securityConfigs,
|
|
30
|
+
testingLibraryConfigs,
|
|
25
31
|
typescriptEslintConfigs,
|
|
26
32
|
unicornConfigs,
|
|
27
33
|
};
|
|
@@ -29,6 +35,10 @@ export {
|
|
|
29
35
|
export interface DefaultConfigOptions {
|
|
30
36
|
parserOptions?: NonNullable<ConfigWithExtends['languageOptions']>['parserOptions'];
|
|
31
37
|
enableRequireExtensionRule?: boolean;
|
|
38
|
+
enableJest?: boolean;
|
|
39
|
+
enableMocha?: boolean;
|
|
40
|
+
enableReact?: boolean;
|
|
41
|
+
enableTestingLibrary?: boolean;
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
/**
|
|
@@ -43,6 +53,10 @@ export const defaultConfig = tsEslintConfig;
|
|
|
43
53
|
*/
|
|
44
54
|
export function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExtends[] {
|
|
45
55
|
const enableRequireExtensionRule = options?.enableRequireExtensionRule ?? true;
|
|
56
|
+
const enableJest = options?.enableJest ?? true;
|
|
57
|
+
const enableMocha = options?.enableMocha ?? true;
|
|
58
|
+
const enableReact = options?.enableReact ?? true;
|
|
59
|
+
const enableTestingLibrary = options?.enableTestingLibrary ?? true;
|
|
46
60
|
const languageOptions: ConfigWithExtends['languageOptions'] = {
|
|
47
61
|
globals: {
|
|
48
62
|
...globals.node,
|
|
@@ -103,11 +117,15 @@ export function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExtend
|
|
|
103
117
|
files: ['**/*.ts', '**/*.tsx'],
|
|
104
118
|
...typescriptEslintConfigs.base,
|
|
105
119
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
...(enableReact
|
|
121
|
+
? [
|
|
122
|
+
{
|
|
123
|
+
name: 'eslint-config-decent/tsx',
|
|
124
|
+
files: ['**/*.tsx'],
|
|
125
|
+
...reactConfigs.base,
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
: []),
|
|
111
129
|
{
|
|
112
130
|
name: 'eslint-config-decent/cjs-and-esm',
|
|
113
131
|
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
|
|
@@ -124,12 +142,36 @@ export function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExtend
|
|
|
124
142
|
},
|
|
125
143
|
...eslintConfigs.cjs,
|
|
126
144
|
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
145
|
+
...(enableMocha
|
|
146
|
+
? [
|
|
147
|
+
{
|
|
148
|
+
name: 'eslint-config-decent/mocha-tests',
|
|
149
|
+
files: ['**/*.tests.ts', 'tests/tests.ts'],
|
|
130
150
|
|
|
131
|
-
|
|
132
|
-
|
|
151
|
+
...mochaConfigs.base,
|
|
152
|
+
},
|
|
153
|
+
]
|
|
154
|
+
: []),
|
|
155
|
+
...(enableJest
|
|
156
|
+
? [
|
|
157
|
+
{
|
|
158
|
+
name: 'eslint-config-decent/jest-tests',
|
|
159
|
+
files: ['**/__tests__/**/*.ts?(x)', '**/*.{spec,test}.ts?(x)'],
|
|
160
|
+
|
|
161
|
+
...jestConfigs.base,
|
|
162
|
+
},
|
|
163
|
+
]
|
|
164
|
+
: []),
|
|
165
|
+
...(enableTestingLibrary
|
|
166
|
+
? [
|
|
167
|
+
{
|
|
168
|
+
name: 'eslint-config-decent/testing-library',
|
|
169
|
+
files: ['**/__tests__/**/*.ts?(x)', '**/*.{spec,test}.ts?(x)'],
|
|
170
|
+
|
|
171
|
+
...testingLibraryConfigs.base,
|
|
172
|
+
},
|
|
173
|
+
]
|
|
174
|
+
: []),
|
|
133
175
|
{
|
|
134
176
|
name: 'eslint-config-decent/cjs-and-esm-disable-ts-rules',
|
|
135
177
|
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
|
package/src/jest.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
import jest from 'eslint-plugin-jest';
|
|
3
|
+
import jestDom from 'eslint-plugin-jest-dom';
|
|
4
|
+
|
|
5
|
+
const base: TSESLint.FlatConfig.Config = {
|
|
6
|
+
plugins: {
|
|
7
|
+
jest,
|
|
8
|
+
'jest-dom': jestDom,
|
|
9
|
+
},
|
|
10
|
+
languageOptions: {
|
|
11
|
+
...jest.configs['flat/recommended'].languageOptions,
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
...jest.configs['flat/recommended'].rules,
|
|
15
|
+
'jest/max-nested-describe': 'error',
|
|
16
|
+
'jest/no-conditional-in-test': 'error',
|
|
17
|
+
'jest/no-confusing-set-timeout': 'error',
|
|
18
|
+
'jest/no-test-prefixes': 'error',
|
|
19
|
+
'jest/prefer-called-with': 'error',
|
|
20
|
+
'jest/prefer-comparison-matcher': 'error',
|
|
21
|
+
'jest/prefer-equality-matcher': 'error',
|
|
22
|
+
'jest/prefer-hooks-in-order': 'error',
|
|
23
|
+
'jest/prefer-hooks-on-top': 'error',
|
|
24
|
+
'jest/prefer-mock-promise-shorthand': 'error',
|
|
25
|
+
'jest/prefer-snapshot-hint': 'error',
|
|
26
|
+
|
|
27
|
+
...jestDom.configs['flat/recommended'].rules,
|
|
28
|
+
'jest-dom/prefer-checked': 'error',
|
|
29
|
+
'jest-dom/prefer-empty': 'error',
|
|
30
|
+
'jest-dom/prefer-enabled-disabled': 'error',
|
|
31
|
+
'jest-dom/prefer-focus': 'error',
|
|
32
|
+
'jest-dom/prefer-in-document': 'error',
|
|
33
|
+
'jest-dom/prefer-required': 'error',
|
|
34
|
+
'jest-dom/prefer-to-have-attribute': 'error',
|
|
35
|
+
'jest-dom/prefer-to-have-class': 'error',
|
|
36
|
+
'jest-dom/prefer-to-have-style': 'error',
|
|
37
|
+
'jest-dom/prefer-to-have-text-content': 'error',
|
|
38
|
+
'jest-dom/prefer-to-have-value': 'error',
|
|
39
|
+
|
|
40
|
+
'max-classes-per-file': 'off',
|
|
41
|
+
|
|
42
|
+
'@typescript-eslint/no-confusing-void-expression': 'off',
|
|
43
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
44
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
45
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
46
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
47
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
48
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const configs = {
|
|
53
|
+
base,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
configs,
|
|
58
|
+
};
|
package/src/react.ts
CHANGED
|
@@ -3,14 +3,20 @@ import type { TSESLint } from '@typescript-eslint/utils';
|
|
|
3
3
|
import a11y from 'eslint-plugin-jsx-a11y';
|
|
4
4
|
import react from 'eslint-plugin-react';
|
|
5
5
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
6
|
-
import testingLibrary from 'eslint-plugin-testing-library';
|
|
7
6
|
|
|
8
7
|
const base: TSESLint.FlatConfig.Config = {
|
|
8
|
+
settings: {
|
|
9
|
+
react: {
|
|
10
|
+
version: 'detect',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
languageOptions: {
|
|
14
|
+
...react.configs['jsx-runtime'].languageOptions,
|
|
15
|
+
},
|
|
9
16
|
plugins: {
|
|
10
17
|
'jsx-a11y': a11y,
|
|
11
18
|
react,
|
|
12
|
-
'react-hooks': reactHooks,
|
|
13
|
-
'testing-library': fixupPluginRules(testingLibrary) as typeof testingLibrary,
|
|
19
|
+
'react-hooks': fixupPluginRules(reactHooks) as typeof reactHooks,
|
|
14
20
|
},
|
|
15
21
|
rules: {
|
|
16
22
|
...a11y.configs.recommended.rules,
|
|
@@ -20,6 +26,7 @@ const base: TSESLint.FlatConfig.Config = {
|
|
|
20
26
|
'jsx-a11y/role-has-required-aria-props': 'error',
|
|
21
27
|
|
|
22
28
|
...react.configs.recommended.rules,
|
|
29
|
+
...react.configs['jsx-runtime'].rules,
|
|
23
30
|
'react/default-props-match-prop-types': 'error',
|
|
24
31
|
'react/display-name': ['error', { ignoreTranspilerName: false }],
|
|
25
32
|
'react/forbid-foreign-prop-types': ['error', { allowInPropTypes: true }],
|
|
@@ -64,8 +71,6 @@ const base: TSESLint.FlatConfig.Config = {
|
|
|
64
71
|
|
|
65
72
|
'react-hooks/rules-of-hooks': 'error',
|
|
66
73
|
'react-hooks/exhaustive-deps': 'error',
|
|
67
|
-
|
|
68
|
-
...testingLibrary.configs.react.rules,
|
|
69
74
|
},
|
|
70
75
|
};
|
|
71
76
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { fixupPluginRules } from '@eslint/compat';
|
|
2
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
3
|
+
import testingLibrary from 'eslint-plugin-testing-library';
|
|
4
|
+
|
|
5
|
+
const base: TSESLint.FlatConfig.Config = {
|
|
6
|
+
plugins: {
|
|
7
|
+
'testing-library': fixupPluginRules(testingLibrary) as typeof testingLibrary,
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
...testingLibrary.configs['flat/react'].rules,
|
|
11
|
+
|
|
12
|
+
'testing-library/no-debugging-utils': 'error',
|
|
13
|
+
'testing-library/prefer-explicit-assert': 'warn',
|
|
14
|
+
'testing-library/prefer-implicit-assert': 'error',
|
|
15
|
+
'testing-library/prefer-query-matchers': 'off',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const configs = {
|
|
20
|
+
base,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
configs,
|
|
25
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare module 'eslint-plugin-jest-dom' {
|
|
2
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
3
|
+
const value: TSESLint.FlatConfig.Plugin & {
|
|
4
|
+
configs: {
|
|
5
|
+
'flat/all': TSESLint.FlatConfig.Config;
|
|
6
|
+
'flat/recommended': TSESLint.FlatConfig.Config;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default value;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare module 'eslint-plugin-jest' {
|
|
2
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
3
|
+
const value: TSESLint.FlatConfig.Plugin & {
|
|
4
|
+
configs: {
|
|
5
|
+
'flat/all': TSESLint.FlatConfig.Config;
|
|
6
|
+
'flat/recommended': TSESLint.FlatConfig.Config;
|
|
7
|
+
'flat/style': TSESLint.FlatConfig.Config;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default value;
|
|
11
|
+
}
|
|
@@ -2,7 +2,9 @@ declare module 'eslint-plugin-react' {
|
|
|
2
2
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
3
3
|
const value: TSESLint.FlatConfig.Plugin & {
|
|
4
4
|
configs: {
|
|
5
|
+
all: TSESLint.FlatConfig.Config;
|
|
5
6
|
recommended: TSESLint.FlatConfig.Config;
|
|
7
|
+
'jsx-runtime': TSESLint.FlatConfig.Config;
|
|
6
8
|
};
|
|
7
9
|
};
|
|
8
10
|
export default value;
|
|
@@ -2,7 +2,10 @@ declare module 'eslint-plugin-testing-library' {
|
|
|
2
2
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
3
3
|
const value: TSESLint.FlatConfig.Plugin & {
|
|
4
4
|
configs: {
|
|
5
|
-
|
|
5
|
+
'flat/angular': TSESLint.FlatConfig.Config;
|
|
6
|
+
'flat/dom': TSESLint.FlatConfig.Config;
|
|
7
|
+
'flat/react': TSESLint.FlatConfig.Config;
|
|
8
|
+
'flat/vue': TSESLint.FlatConfig.Config;
|
|
6
9
|
};
|
|
7
10
|
};
|
|
8
11
|
export default value;
|