@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/rules/react.js CHANGED
@@ -1,9 +1,18 @@
1
- module.exports = {
2
- extends: ['./react-jsx-a11y.js', './base.js', './typescript.js'],
3
- plugins: ['react', 'react-hooks'],
4
- parserOptions: {
5
- ecmaFeatures: {
6
- jsx: true,
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
- overrides: [
644
- {
645
- files: ['**/*.ts?(x)'],
646
- settings: {
647
- 'import/resolver': {
648
- node: {
649
- extensions: ['.js', '.jsx', '.ts', '.tsx'],
650
- },
651
- },
652
+ };
653
+
654
+ const reactTypescriptRules = {
655
+ settings: {
656
+ 'import/resolver': {
657
+ node: {
658
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
652
659
  },
653
- parserOptions: {
654
- jsxPragma: null,
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
- rules: {
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
- // eslint-plugin-react https://github.com/jsx-eslint/eslint-plugin-react
683
+ // eslint-plugin-react https://github.com/jsx-eslint/eslint-plugin-react
673
684
 
674
- // Enforce a defaultProps definition for every prop that is not a required prop
675
- // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
676
- 'react/require-default-props': 'off',
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
- // Disallow file extensions that may contain JSX
679
- // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
680
- 'react/jsx-filename-extension': [
681
- 'error',
682
- {
683
- extensions: ['.jsx', '.tsx'],
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
- files: ['*.{test,spec,steps}.{js,jsx,ts,tsx}'],
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
- // Prefer toBeChecked over checking attributes
695
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-checked.md
696
- 'jest-dom/prefer-checked': 'error',
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
- // Prefer toBeEmpty over checking innerHTML
699
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-empty.md
700
- 'jest-dom/prefer-empty': 'error',
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
- // Prefer toBeDisabled or toBeEnabled over checking attributes
703
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-enabled-disabled.md
704
- 'jest-dom/prefer-enabled-disabled': 'error',
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
- // Prefer toHaveFocus over checking document.activeElement
707
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-focus.md
708
- 'jest-dom/prefer-focus': 'error',
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
- // Prefer .toBeInTheDocument() for asserting the existence of a DOM node
711
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-in-document.md
712
- 'jest-dom/prefer-in-document': 'error',
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
- // Prefer toBeRequired over checking properties
715
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-required.md
716
- 'jest-dom/prefer-required': 'error',
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
- // Prefer toHaveAttribute over checking getAttribute/hasAttribute
719
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-attribute.md
720
- 'jest-dom/prefer-to-have-attribute': 'error',
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
- // Prefer toHaveClass over checking element className
723
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-class.md
724
- 'jest-dom/prefer-to-have-class': 'error',
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
- // Prefer toHaveStyle over checking element style
727
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-style.md
728
- 'jest-dom/prefer-to-have-style': 'error',
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
- // Prefer toHaveTextContent over checking element.textContent
731
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-text-content.md
732
- 'jest-dom/prefer-to-have-text-content': 'error',
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
- // Prefer toHaveValue over checking element.value
735
- // https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-to-have-value.md
736
- 'jest-dom/prefer-to-have-value': 'error',
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
- // eslint-plugin-testing-library https://github.com/testing-library/eslint-plugin-testing-library
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
- // Enforce promises from async event methods are handled
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
- // Enforce promises from async queries to be handled
745
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-queries.md
746
- 'testing-library/await-async-queries': 'error',
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
- // Enforce promises from async utils to be awaited properly
749
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-utils.md
750
- 'testing-library/await-async-utils': 'error',
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
- // Ensures consistent usage of data-testid
753
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/consistent-data-testid.md
754
- 'testing-library/consistent-data-testid': 'off',
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
- // Disallow unnecessary await for sync events
757
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-events.md
758
- 'testing-library/no-await-sync-events': 'off',
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
- // Disallow unnecessary await for sync queries
761
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-await-sync-queries.md
762
- 'testing-library/no-await-sync-queries': 'error',
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
- // Disallow the use of container methods
765
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-container.md
766
- 'testing-library/no-container': 'error',
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
- // Disallow the use of debugging utilities like debug
769
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-debugging-utils.md
770
- 'testing-library/no-debugging-utils': 'error',
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
- // Disallow importing from DOM Testing Library
773
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-dom-import.md
774
- 'testing-library/no-dom-import': ['error', 'react'],
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
- // Disallow the use of the global RegExp flag (/g) in queries
777
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-global-regexp-flag-in-query.md
778
- 'testing-library/no-global-regexp-flag-in-query': 'off',
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
- // Disallow the use of cleanup
781
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-manual-cleanup.md
782
- 'testing-library/no-manual-cleanup': 'off',
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
- // Disallow direct Node access
785
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-node-access.md
786
- 'testing-library/no-node-access': 'error',
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
- // Disallow the use of promises passed to a fireEvent method
789
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-promise-in-fire-event.md
790
- 'testing-library/no-promise-in-fire-event': 'error',
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
- // Disallow the use of render in testing frameworks setup functions
793
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-render-in-lifecycle.md
794
- 'testing-library/no-render-in-lifecycle': 'error',
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
- // Disallow wrapping Testing Library utils or empty callbacks in act
797
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-unnecessary-act.md
798
- 'testing-library/no-unnecessary-act': 'error',
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
- // Disallow the use of multiple expect calls inside waitFor
801
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-multiple-assertions.md
802
- 'testing-library/no-wait-for-multiple-assertions': 'error',
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
- // Disallow the use of side effects in waitFor
805
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-side-effects.md
806
- 'testing-library/no-wait-for-side-effects': 'error',
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
- // Ensures no snapshot is generated inside of a waitFor call
809
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-snapshot.md
810
- 'testing-library/no-wait-for-snapshot': 'error',
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
- // Suggest using explicit assertions rather than standalone queries
813
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-explicit-assert.md
814
- 'testing-library/prefer-explicit-assert': 'off',
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
- // Suggest using find(All)By* query instead of waitFor + get(All)By* to wait for elements
817
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-find-by.md
818
- 'testing-library/prefer-find-by': 'error',
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
- // Suggest using implicit assertions for getBy* & findBy* queries
821
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-implicit-assert.md
822
- 'testing-library/prefer-implicit-assert': 'off',
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
- // Ensure appropriate get*/query* queries are used with their respective matchers
825
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-presence-queries.md
826
- 'testing-library/prefer-presence-queries': 'error',
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
- // Suggest using queryBy* queries when waiting for disappearance
829
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-query-by-disappearance.md
830
- 'testing-library/prefer-query-by-disappearance': 'error',
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
- // Ensure the configured get*/query* query is used with the corresponding matchers
833
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-query-matchers.md
834
- 'testing-library/prefer-query-matchers': 'error',
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
- // Suggest using screen while querying
837
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md
838
- 'testing-library/prefer-screen-queries': 'error',
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
- // Suggest using userEvent over fireEvent for simulating user interactions
841
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-user-event.md
842
- 'testing-library/prefer-user-event': 'off',
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
- // Enforce a valid naming for return value from render
845
- // https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/render-result-naming-convention.md
846
- 'testing-library/render-result-naming-convention': 'error',
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
  };