@pplancq/eslint-config 3.0.1 → 4.0.1
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/CHANGELOG.md +26 -0
- package/MIGRATION.md +52 -0
- package/README.md +32 -56
- package/bin/init.js +8 -3
- package/main.js +67 -0
- package/package.json +11 -16
- package/rules/base.js +18 -11
- package/rules/import.js +14 -6
- package/rules/jest.js +248 -243
- package/rules/prettier.js +10 -2
- package/rules/react-jsx-a11y.js +10 -2
- package/rules/react.js +186 -168
- package/rules/typescript.js +567 -538
- package/rules/vitest.js +181 -173
- package/jest.js +0 -3
- package/node.js +0 -3
- package/prettier.js +0 -3
- package/react.js +0 -3
- package/vitest.js +0 -3
package/rules/react.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const reactPlugin = require('eslint-plugin-react');
|
|
2
|
+
const reactHooksPlugin = require('eslint-plugin-react-hooks');
|
|
3
|
+
const testingLibraryPlugin = require('eslint-plugin-testing-library');
|
|
4
|
+
const jestDom = require('eslint-plugin-jest-dom');
|
|
5
|
+
|
|
6
|
+
const reactRules = {
|
|
7
|
+
plugins: {
|
|
8
|
+
react: reactPlugin,
|
|
9
|
+
'react-hooks': reactHooksPlugin,
|
|
10
|
+
},
|
|
11
|
+
languageOptions: {
|
|
12
|
+
parserOptions: {
|
|
13
|
+
ecmaFeatures: {
|
|
14
|
+
jsx: true,
|
|
15
|
+
},
|
|
7
16
|
},
|
|
8
17
|
},
|
|
9
18
|
rules: {
|
|
@@ -640,211 +649,220 @@ module.exports = {
|
|
|
640
649
|
'Object.freeze', // https://tc39.github.io/ecma262/#sec-object.freeze
|
|
641
650
|
],
|
|
642
651
|
},
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
const reactTypescriptRules = {
|
|
655
|
+
settings: {
|
|
656
|
+
'import/resolver': {
|
|
657
|
+
node: {
|
|
658
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
652
659
|
},
|
|
653
|
-
|
|
654
|
-
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
languageOptions: {
|
|
663
|
+
parserOptions: {
|
|
664
|
+
jsxPragma: null,
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
rules: {
|
|
668
|
+
// eslint-plugin-import https://github.com/import-js/eslint-plugin-import
|
|
669
|
+
|
|
670
|
+
// import/extensions
|
|
671
|
+
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md
|
|
672
|
+
'import/extensions': [
|
|
673
|
+
'error',
|
|
674
|
+
'ignorePackages',
|
|
675
|
+
{
|
|
676
|
+
js: 'never',
|
|
677
|
+
jsx: 'never',
|
|
678
|
+
ts: 'never',
|
|
679
|
+
tsx: 'never',
|
|
655
680
|
},
|
|
656
|
-
|
|
657
|
-
// eslint-plugin-import https://github.com/import-js/eslint-plugin-import
|
|
658
|
-
|
|
659
|
-
// import/extensions
|
|
660
|
-
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md
|
|
661
|
-
'import/extensions': [
|
|
662
|
-
'error',
|
|
663
|
-
'ignorePackages',
|
|
664
|
-
{
|
|
665
|
-
js: 'never',
|
|
666
|
-
jsx: 'never',
|
|
667
|
-
ts: 'never',
|
|
668
|
-
tsx: 'never',
|
|
669
|
-
},
|
|
670
|
-
],
|
|
681
|
+
],
|
|
671
682
|
|
|
672
|
-
|
|
683
|
+
// eslint-plugin-react https://github.com/jsx-eslint/eslint-plugin-react
|
|
673
684
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
685
|
+
// Enforce a defaultProps definition for every prop that is not a required prop
|
|
686
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
|
|
687
|
+
'react/require-default-props': 'off',
|
|
677
688
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
},
|
|
685
|
-
],
|
|
689
|
+
// Disallow file extensions that may contain JSX
|
|
690
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
691
|
+
'react/jsx-filename-extension': [
|
|
692
|
+
'error',
|
|
693
|
+
{
|
|
694
|
+
extensions: ['.jsx', '.tsx'],
|
|
686
695
|
},
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
plugins: ['testing-library', 'jest-dom'],
|
|
691
|
-
rules: {
|
|
692
|
-
// eslint-plugin-jest-dom https://github.com/testing-library/eslint-plugin-jest-dom
|
|
696
|
+
],
|
|
697
|
+
},
|
|
698
|
+
};
|
|
693
699
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
700
|
+
const reactTestRules = {
|
|
701
|
+
plugins: {
|
|
702
|
+
'testing-library': testingLibraryPlugin,
|
|
703
|
+
'jest-dom': jestDom,
|
|
704
|
+
},
|
|
705
|
+
rules: {
|
|
706
|
+
// eslint-plugin-jest-dom https://github.com/testing-library/eslint-plugin-jest-dom
|
|
697
707
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
708
|
+
// Prefer toBeChecked over checking attributes
|
|
709
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-checked.md
|
|
710
|
+
'jest-dom/prefer-checked': 'error',
|
|
701
711
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
712
|
+
// Prefer toBeEmpty over checking innerHTML
|
|
713
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-empty.md
|
|
714
|
+
'jest-dom/prefer-empty': 'error',
|
|
705
715
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
716
|
+
// Prefer toBeDisabled or toBeEnabled over checking attributes
|
|
717
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-enabled-disabled.md
|
|
718
|
+
'jest-dom/prefer-enabled-disabled': 'error',
|
|
709
719
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
720
|
+
// Prefer toHaveFocus over checking document.activeElement
|
|
721
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-focus.md
|
|
722
|
+
'jest-dom/prefer-focus': 'error',
|
|
713
723
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
724
|
+
// Prefer .toBeInTheDocument() for asserting the existence of a DOM node
|
|
725
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-in-document.md
|
|
726
|
+
'jest-dom/prefer-in-document': 'error',
|
|
717
727
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
728
|
+
// Prefer toBeRequired over checking properties
|
|
729
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-required.md
|
|
730
|
+
'jest-dom/prefer-required': 'error',
|
|
721
731
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
732
|
+
// Prefer toHaveAttribute over checking getAttribute/hasAttribute
|
|
733
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-attribute.md
|
|
734
|
+
'jest-dom/prefer-to-have-attribute': 'error',
|
|
725
735
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
736
|
+
// Prefer toHaveClass over checking element className
|
|
737
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-class.md
|
|
738
|
+
'jest-dom/prefer-to-have-class': 'error',
|
|
729
739
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
740
|
+
// Prefer toHaveStyle over checking element style
|
|
741
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-style.md
|
|
742
|
+
'jest-dom/prefer-to-have-style': 'error',
|
|
733
743
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
744
|
+
// Prefer toHaveTextContent over checking element.textContent
|
|
745
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-text-content.md
|
|
746
|
+
'jest-dom/prefer-to-have-text-content': 'error',
|
|
737
747
|
|
|
738
|
-
|
|
748
|
+
// Prefer toHaveValue over checking element.value
|
|
749
|
+
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-value.md
|
|
750
|
+
'jest-dom/prefer-to-have-value': 'error',
|
|
739
751
|
|
|
740
|
-
|
|
741
|
-
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-events.md
|
|
742
|
-
'testing-library/await-async-events': 'off',
|
|
752
|
+
// eslint-plugin-testing-library https://github.com/testing-library/eslint-plugin-testing-library
|
|
743
753
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
754
|
+
// Enforce promises from async event methods are handled
|
|
755
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-events.md
|
|
756
|
+
'testing-library/await-async-events': 'off',
|
|
747
757
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
758
|
+
// Enforce promises from async queries to be handled
|
|
759
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-queries.md
|
|
760
|
+
'testing-library/await-async-queries': 'error',
|
|
751
761
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
762
|
+
// Enforce promises from async utils to be awaited properly
|
|
763
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-utils.md
|
|
764
|
+
'testing-library/await-async-utils': 'error',
|
|
755
765
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
766
|
+
// Ensures consistent usage of data-testid
|
|
767
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/consistent-data-testid.md
|
|
768
|
+
'testing-library/consistent-data-testid': 'off',
|
|
759
769
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
770
|
+
// Disallow unnecessary await for sync events
|
|
771
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-events.md
|
|
772
|
+
'testing-library/no-await-sync-events': 'off',
|
|
763
773
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
774
|
+
// Disallow unnecessary await for sync queries
|
|
775
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-queries.md
|
|
776
|
+
'testing-library/no-await-sync-queries': 'error',
|
|
767
777
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
778
|
+
// Disallow the use of container methods
|
|
779
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-container.md
|
|
780
|
+
'testing-library/no-container': 'error',
|
|
771
781
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
782
|
+
// Disallow the use of debugging utilities like debug
|
|
783
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-debugging-utils.md
|
|
784
|
+
'testing-library/no-debugging-utils': 'error',
|
|
775
785
|
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
786
|
+
// Disallow importing from DOM Testing Library
|
|
787
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-dom-import.md
|
|
788
|
+
'testing-library/no-dom-import': ['error', 'react'],
|
|
779
789
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
790
|
+
// Disallow the use of the global RegExp flag (/g) in queries
|
|
791
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-global-regexp-flag-in-query.md
|
|
792
|
+
'testing-library/no-global-regexp-flag-in-query': 'off',
|
|
783
793
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
794
|
+
// Disallow the use of cleanup
|
|
795
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-manual-cleanup.md
|
|
796
|
+
'testing-library/no-manual-cleanup': 'off',
|
|
787
797
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
798
|
+
// Disallow direct Node access
|
|
799
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-node-access.md
|
|
800
|
+
'testing-library/no-node-access': 'error',
|
|
791
801
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
802
|
+
// Disallow the use of promises passed to a fireEvent method
|
|
803
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-promise-in-fire-event.md
|
|
804
|
+
'testing-library/no-promise-in-fire-event': 'error',
|
|
795
805
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
806
|
+
// Disallow the use of render in testing frameworks setup functions
|
|
807
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-render-in-lifecycle.md
|
|
808
|
+
'testing-library/no-render-in-lifecycle': 'error',
|
|
799
809
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
810
|
+
// Disallow wrapping Testing Library utils or empty callbacks in act
|
|
811
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-unnecessary-act.md
|
|
812
|
+
'testing-library/no-unnecessary-act': 'error',
|
|
803
813
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
814
|
+
// Disallow the use of multiple expect calls inside waitFor
|
|
815
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-multiple-assertions.md
|
|
816
|
+
'testing-library/no-wait-for-multiple-assertions': 'error',
|
|
807
817
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
818
|
+
// Disallow the use of side effects in waitFor
|
|
819
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-side-effects.md
|
|
820
|
+
'testing-library/no-wait-for-side-effects': 'error',
|
|
811
821
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
822
|
+
// Ensures no snapshot is generated inside of a waitFor call
|
|
823
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-snapshot.md
|
|
824
|
+
'testing-library/no-wait-for-snapshot': 'error',
|
|
815
825
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
826
|
+
// Suggest using explicit assertions rather than standalone queries
|
|
827
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-explicit-assert.md
|
|
828
|
+
'testing-library/prefer-explicit-assert': 'off',
|
|
819
829
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
830
|
+
// Suggest using find(All)By* query instead of waitFor + get(All)By* to wait for elements
|
|
831
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-find-by.md
|
|
832
|
+
'testing-library/prefer-find-by': 'error',
|
|
823
833
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
834
|
+
// Suggest using implicit assertions for getBy* & findBy* queries
|
|
835
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-implicit-assert.md
|
|
836
|
+
'testing-library/prefer-implicit-assert': 'off',
|
|
827
837
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
838
|
+
// Ensure appropriate get*/query* queries are used with their respective matchers
|
|
839
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-presence-queries.md
|
|
840
|
+
'testing-library/prefer-presence-queries': 'error',
|
|
831
841
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
842
|
+
// Suggest using queryBy* queries when waiting for disappearance
|
|
843
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-query-by-disappearance.md
|
|
844
|
+
'testing-library/prefer-query-by-disappearance': 'error',
|
|
835
845
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
846
|
+
// Ensure the configured get*/query* query is used with the corresponding matchers
|
|
847
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-query-matchers.md
|
|
848
|
+
'testing-library/prefer-query-matchers': 'error',
|
|
839
849
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
850
|
+
// Suggest using screen while querying
|
|
851
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md
|
|
852
|
+
'testing-library/prefer-screen-queries': 'error',
|
|
843
853
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
854
|
+
// Suggest using userEvent over fireEvent for simulating user interactions
|
|
855
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-user-event.md
|
|
856
|
+
'testing-library/prefer-user-event': 'off',
|
|
857
|
+
|
|
858
|
+
// Enforce a valid naming for return value from render
|
|
859
|
+
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/render-result-naming-convention.md
|
|
860
|
+
'testing-library/render-result-naming-convention': 'error',
|
|
861
|
+
},
|
|
862
|
+
};
|
|
863
|
+
|
|
864
|
+
module.exports = {
|
|
865
|
+
reactRules,
|
|
866
|
+
reactTypescriptRules,
|
|
867
|
+
reactTestRules,
|
|
850
868
|
};
|