|
1 | 1 | import prettier from 'eslint-config-prettier/flat';
|
2 | 2 | import { flatConfigs as importFlatConfigs } from 'eslint-plugin-import';
|
3 | 3 | import mochaPlugin from 'eslint-plugin-mocha';
|
4 |
| -import reactCompilerPlugin from 'eslint-plugin-react-compiler'; |
| 4 | +// import reactCompilerPlugin from 'eslint-plugin-react-compiler'; |
5 | 5 | import { configs as reactHookConfigs } from 'eslint-plugin-react-hooks';
|
6 | 6 | import testingLibrary from 'eslint-plugin-testing-library';
|
7 | 7 | import globals from 'globals';
|
@@ -50,105 +50,101 @@ export const baseSpecRules = {
|
50 | 50 | * @param {boolean} [params.enableReactCompiler] - Whether the config is for spec files.
|
51 | 51 | * @returns {import('typescript-eslint').ConfigArray}
|
52 | 52 | */
|
53 |
| -export function createBaseConfig({ enableReactCompiler = false } = {}) { |
54 |
| - return tseslint.config( |
55 |
| - importFlatConfigs.recommended, |
56 |
| - importFlatConfigs.typescript, |
57 |
| - reactHookConfigs.recommended, |
58 |
| - enableReactCompiler ? reactCompilerPlugin.configs.recommended : {}, |
59 |
| - airbnbBase, |
60 |
| - airbnbReact, |
61 |
| - airbnbTs, |
62 |
| - prettier, |
63 |
| - { |
64 |
| - name: 'typescript-eslint-parser', |
65 |
| - languageOptions: { |
66 |
| - parser: tseslint.parser, |
67 |
| - ecmaVersion: 7, |
68 |
| - globals: { |
69 |
| - ...globals.es2020, |
70 |
| - ...globals.browser, |
71 |
| - ...globals.node, |
72 |
| - }, |
| 53 | +export const baseConfig = tseslint.config( |
| 54 | + importFlatConfigs.recommended, |
| 55 | + importFlatConfigs.typescript, |
| 56 | + reactHookConfigs.recommended, |
| 57 | + // enableReactCompiler ? reactCompilerPlugin.configs.recommended : {}, |
| 58 | + airbnbBase, |
| 59 | + airbnbReact, |
| 60 | + airbnbTs, |
| 61 | + prettier, |
| 62 | + { |
| 63 | + name: 'typescript-eslint-parser', |
| 64 | + languageOptions: { |
| 65 | + parser: tseslint.parser, |
| 66 | + ecmaVersion: 7, |
| 67 | + globals: { |
| 68 | + ...globals.es2020, |
| 69 | + ...globals.browser, |
| 70 | + ...globals.node, |
73 | 71 | },
|
74 |
| - plugins: { |
75 |
| - '@typescript-eslint': tseslint.plugin, |
76 |
| - 'material-ui': muiPlugin, |
| 72 | + }, |
| 73 | + plugins: { |
| 74 | + '@typescript-eslint': tseslint.plugin, |
| 75 | + 'material-ui': muiPlugin, |
| 76 | + }, |
| 77 | + settings: { |
| 78 | + 'import/parsers': { |
| 79 | + '@typescript-eslint/parser': ['.ts', '.tsx'], |
77 | 80 | },
|
78 |
| - settings: { |
79 |
| - 'import/parsers': { |
80 |
| - '@typescript-eslint/parser': ['.ts', '.tsx'], |
81 |
| - }, |
82 |
| - 'import/resolver': { |
83 |
| - typescript: { |
84 |
| - project: ['tsconfig.node.json', 'apps/*/tsconfig.json', 'packages/*/tsconfig.json'], |
85 |
| - }, |
| 81 | + 'import/resolver': { |
| 82 | + typescript: { |
| 83 | + project: ['tsconfig.node.json', 'apps/*/tsconfig.json', 'packages/*/tsconfig.json'], |
86 | 84 | },
|
87 | 85 | },
|
88 |
| - extends: createCoreConfig({ reactCompilerEnabled: enableReactCompiler }), |
89 | 86 | },
|
90 |
| - ); |
91 |
| -} |
| 87 | + extends: createCoreConfig({ reactCompilerEnabled: false }), |
| 88 | + }, |
| 89 | +); |
92 | 90 |
|
93 | 91 | /**
|
94 | 92 | * @returns {import('typescript-eslint').ConfigArray}
|
95 | 93 | */
|
96 |
| -export function createTestConfig() { |
97 |
| - return tseslint.config( |
98 |
| - mochaPlugin.configs.recommended, |
99 |
| - testingLibrary.configs['flat/dom'], |
100 |
| - testingLibrary.configs['flat/react'], |
101 |
| - { |
102 |
| - languageOptions: { |
103 |
| - parser: tseslint.parser, |
104 |
| - parserOptions: { |
105 |
| - ecmaVersion: 7, |
106 |
| - }, |
107 |
| - globals: globals.mocha, |
| 94 | +export const testConfig = tseslint.config( |
| 95 | + mochaPlugin.configs.recommended, |
| 96 | + testingLibrary.configs['flat/dom'], |
| 97 | + testingLibrary.configs['flat/react'], |
| 98 | + { |
| 99 | + languageOptions: { |
| 100 | + parser: tseslint.parser, |
| 101 | + parserOptions: { |
| 102 | + ecmaVersion: 7, |
108 | 103 | },
|
109 |
| - rules: { |
110 |
| - // does not work with wildcard imports. Mistakes will throw at runtime anyway |
111 |
| - 'import/named': 'off', |
112 |
| - 'material-ui/disallow-active-element-as-key-event-target': 'error', |
113 |
| - 'mocha/consistent-spacing-between-blocks': 'off', |
| 104 | + globals: globals.mocha, |
| 105 | + }, |
| 106 | + rules: { |
| 107 | + // does not work with wildcard imports. Mistakes will throw at runtime anyway |
| 108 | + 'import/named': 'off', |
| 109 | + 'material-ui/disallow-active-element-as-key-event-target': 'error', |
| 110 | + 'mocha/consistent-spacing-between-blocks': 'off', |
114 | 111 |
|
115 |
| - // upgraded level from recommended |
116 |
| - 'mocha/no-pending-tests': 'error', |
| 112 | + // upgraded level from recommended |
| 113 | + 'mocha/no-pending-tests': 'error', |
117 | 114 |
|
118 |
| - // no rationale provided in /recommended |
119 |
| - 'mocha/no-mocha-arrows': 'off', |
120 |
| - // definitely a useful rule but too many false positives |
121 |
| - // due to `describeConformance` |
122 |
| - // "If you're using dynamically generated tests, you should disable this rule."" |
123 |
| - 'mocha/no-setup-in-describe': 'off', |
124 |
| - // `beforeEach` for a single case is optimized for change |
125 |
| - // when we add a test we don't have to refactor the existing |
126 |
| - // test to `beforeEach`. |
127 |
| - // `beforeEach`+`afterEach` also means that the `beforeEach` |
128 |
| - // is cleaned up in `afterEach` if the test causes a crash |
129 |
| - 'mocha/no-hooks-for-single-case': 'off', |
| 115 | + // no rationale provided in /recommended |
| 116 | + 'mocha/no-mocha-arrows': 'off', |
| 117 | + // definitely a useful rule but too many false positives |
| 118 | + // due to `describeConformance` |
| 119 | + // "If you're using dynamically generated tests, you should disable this rule."" |
| 120 | + 'mocha/no-setup-in-describe': 'off', |
| 121 | + // `beforeEach` for a single case is optimized for change |
| 122 | + // when we add a test we don't have to refactor the existing |
| 123 | + // test to `beforeEach`. |
| 124 | + // `beforeEach`+`afterEach` also means that the `beforeEach` |
| 125 | + // is cleaned up in `afterEach` if the test causes a crash |
| 126 | + 'mocha/no-hooks-for-single-case': 'off', |
130 | 127 |
|
131 |
| - // disable eslint-plugin-jsx-a11y |
132 |
| - // tests are not driven by assistive technology |
133 |
| - // add `jsx-a11y` rules once you encounter them in tests |
134 |
| - 'jsx-a11y/click-events-have-key-events': 'off', |
135 |
| - 'jsx-a11y/control-has-associated-label': 'off', |
136 |
| - 'jsx-a11y/iframe-has-title': 'off', |
137 |
| - 'jsx-a11y/label-has-associated-control': 'off', |
138 |
| - 'jsx-a11y/mouse-events-have-key-events': 'off', |
139 |
| - 'jsx-a11y/no-noninteractive-tabindex': 'off', |
140 |
| - 'jsx-a11y/no-static-element-interactions': 'off', |
141 |
| - 'jsx-a11y/tabindex-no-positive': 'off', |
| 128 | + // disable eslint-plugin-jsx-a11y |
| 129 | + // tests are not driven by assistive technology |
| 130 | + // add `jsx-a11y` rules once you encounter them in tests |
| 131 | + 'jsx-a11y/click-events-have-key-events': 'off', |
| 132 | + 'jsx-a11y/control-has-associated-label': 'off', |
| 133 | + 'jsx-a11y/iframe-has-title': 'off', |
| 134 | + 'jsx-a11y/label-has-associated-control': 'off', |
| 135 | + 'jsx-a11y/mouse-events-have-key-events': 'off', |
| 136 | + 'jsx-a11y/no-noninteractive-tabindex': 'off', |
| 137 | + 'jsx-a11y/no-static-element-interactions': 'off', |
| 138 | + 'jsx-a11y/tabindex-no-positive': 'off', |
142 | 139 |
|
143 |
| - // In tests this is generally intended. |
144 |
| - 'react/button-has-type': 'off', |
145 |
| - // They are accessed to test custom validator implementation with PropTypes.checkPropTypes |
146 |
| - 'react/forbid-foreign-prop-types': 'off', |
147 |
| - // components that are defined in test are isolated enough |
148 |
| - // that they don't need type-checking |
149 |
| - 'react/prop-types': 'off', |
150 |
| - 'react/no-unused-prop-types': 'off', |
151 |
| - }, |
| 140 | + // In tests this is generally intended. |
| 141 | + 'react/button-has-type': 'off', |
| 142 | + // They are accessed to test custom validator implementation with PropTypes.checkPropTypes |
| 143 | + 'react/forbid-foreign-prop-types': 'off', |
| 144 | + // components that are defined in test are isolated enough |
| 145 | + // that they don't need type-checking |
| 146 | + 'react/prop-types': 'off', |
| 147 | + 'react/no-unused-prop-types': 'off', |
152 | 148 | },
|
153 |
| - ); |
154 |
| -} |
| 149 | + }, |
| 150 | +); |
0 commit comments