33 */
44module . exports = {
55 extends : [
6+ 'plugin:@typescript-eslint/eslint-recommended' ,
67 'airbnb' ,
78 'plugin:jsx-a11y/recommended' ,
8- 'prettier' ,
99 'plugin:cypress/recommended' ,
1010 'plugin:storybook/recommended' ,
11- 'plugin:@typescript-eslint/eslint-recommended' ,
11+ 'plugin:prettier/recommended' ,
12+ 'prettier' ,
1213 ] ,
1314 env : {
1415 browser : true ,
@@ -19,7 +20,6 @@ module.exports = {
1920 } ,
2021 parser : '@babel/eslint-parser' ,
2122 plugins : [
22- 'prettier' ,
2323 'unicorn' ,
2424 'cypress' ,
2525 '@operation_code/custom-rules' ,
@@ -31,107 +31,19 @@ module.exports = {
3131 cy : true ,
3232 Cypress : true ,
3333 } ,
34- overrides : [
35- {
36- files : [ './**/*.test.js' , './**/*.test.jsx' , './**/*.test.ts' , './**/*.test.tsx' ] ,
37- plugins : [ 'vitest' ] ,
38- extends : [ 'plugin:vitest-globals/recommended' , 'plugin:vitest/recommended' ] ,
39- env : {
40- 'vitest-globals/env' : true ,
41- } ,
42- rules : {
43- 'vitest/consistent-test-it' : [ 'error' , { fn : 'it' , withinDescribe : 'it' } ] ,
44- 'vitest/expect-expect' : [
45- 'error' ,
46- { assertFunctionNames : [ 'expect' , 'createShallowSnapshotTest' , 'createSnapshotTest' ] } ,
47- ] ,
48- 'vitest/prefer-lowercase-title' : [ 'error' , { ignore : [ 'describe' ] } ] ,
49- 'vitest/no-test-prefixes' : 'error' ,
50- 'vitest/no-test-return-statement' : 'error' ,
51- 'vitest/prefer-strict-equal' : 'error' ,
52- 'vitest/valid-describe-callback' : 'error' ,
53- } ,
54- } ,
55- {
56- files : [ './**/*.ts' , './**/*.tsx' ] ,
57- parser : '@typescript-eslint/parser' ,
58- parserOptions : {
59- project : true ,
60- } ,
61- extends : [ 'plugin:@typescript-eslint/strict' , 'plugin:@typescript-eslint/stylistic' ] ,
62- rules : {
63- 'react/no-array-index-key' : 'off' ,
64- 'react/require-default-props' : 'off' ,
65-
66- // Typescript Rules
67- // custom rules for typescript-eslint: https://github.com/OperationCode/front-end/pull/1792#pullrequestreview-1874516174
68- '@typescript-eslint/consistent-type-imports' : [ 'error' , { prefer : 'no-type-imports' } ] ,
69- '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
70- '@typescript-eslint/naming-convention' : [
71- 'error' ,
72- {
73- selector : 'variable' ,
74- types : [ 'boolean' ] ,
75- format : [ 'PascalCase' , 'UPPER_CASE' ] ,
76- prefix : [
77- 'is' ,
78- 'was' ,
79- 'should' ,
80- 'has' ,
81- 'can' ,
82- 'did' ,
83- 'will' ,
84- 'IS_' ,
85- 'WAS_' ,
86- 'SHOULD_' ,
87- 'HAS_' ,
88- 'CAN_' ,
89- 'DID_' ,
90- 'WILL_' ,
91- ] ,
92- } ,
93- ] ,
94- '@typescript-eslint/no-empty-interface' : [ 'error' , { allowSingleExtends : true } ] ,
95- '@typescript-eslint/no-explicit-any' : 'error' ,
96- '@typescript-eslint/no-unused-vars' : [ 'error' , { vars : 'all' , varsIgnorePattern : '_' } ] ,
97- '@typescript-eslint/unbound-method' : 'off' , // gives false negatives in arrow funcs
98- } ,
99- } ,
100- {
101- files : [ 'cypress/**/*.js' ] ,
102- rules : {
103- 'func-names' : 'off' ,
104- 'vitest/expect-expect' : 'off' ,
105- 'vitest/valid-expect' : 'off' ,
106- 'no-unused-expressions' : [ 'off' ] ,
107- } ,
108- } ,
109- {
110- files : [
111- 'pages/**.js' ,
112- 'components/head.js' ,
113- 'components/nav.js' ,
114- 'components/Timeline/historyData.js' ,
115- ] ,
116- rules : {
117- 'react/react-in-jsx-scope' : 'off' ,
118- } ,
119- } ,
120- {
121- files : [ 'components/nav.js' , 'components/Footer/Footer.js' ] ,
122- rules : { 'jsx-a11y/anchor-is-valid' : 'off' } ,
123- } ,
124- {
125- files : [ 'components/UpdateProfileForm/**/*.js' ] ,
126- rules : { 'react/sort-comp' : 'off' } ,
127- } ,
128- ] ,
12934 rules : {
13035 // Import Rules
13136 'import/extensions' : [
13237 'error' ,
13338 'never' ,
134- { css : 'always' , jpg : 'always' , json : 'always' , png : 'always' , svg : 'always' } ,
39+ {
40+ css : 'always' ,
41+ jpg : 'always' ,
42+ json : 'always' ,
43+ png : 'always' ,
44+ svg : 'always' ,
45+ stories : 'always' ,
46+ } ,
13547 ] ,
13648 'import/no-unresolved' : 'off' ,
13749 'import/no-extraneous-dependencies' : [ 'error' , { devDependencies : true } ] ,
@@ -165,9 +77,6 @@ module.exports = {
16577 // Lodash Plugin Rules
16678 'lodash/import-scope' : [ 'error' , 'method' ] ,
16779
168- // Prettier Plugin Rules
169- 'prettier/prettier' : 'error' ,
170-
17180 // React Plugin Rules
17281 'react/function-component-definition' : [
17382 'error' ,
@@ -247,5 +156,135 @@ module.exports = {
247156 ] ,
248157 'no-use-before-define' : 'off' ,
249158 } ,
159+ overrides : [
160+ {
161+ files : [ './**/*.test.js' , './**/*.test.jsx' , './**/*.test.ts' , './**/*.test.tsx' ] ,
162+ plugins : [ 'vitest' ] ,
163+ extends : [ 'plugin:vitest-globals/recommended' , 'plugin:vitest/recommended' ] ,
164+ env : {
165+ 'vitest-globals/env' : true ,
166+ } ,
167+ rules : {
168+ 'vitest/consistent-test-it' : [ 'error' , { fn : 'it' , withinDescribe : 'it' } ] ,
169+ 'vitest/expect-expect' : [
170+ 'error' ,
171+ { assertFunctionNames : [ 'expect' , 'createShallowSnapshotTest' , 'createSnapshotTest' ] } ,
172+ ] ,
173+ 'vitest/prefer-lowercase-title' : [ 'error' , { ignore : [ 'describe' ] } ] ,
174+ 'vitest/no-test-prefixes' : 'error' ,
175+ 'vitest/no-test-return-statement' : 'error' ,
176+ 'vitest/prefer-strict-equal' : 'error' ,
177+ 'vitest/valid-describe-callback' : 'error' ,
178+ } ,
179+ } ,
180+ {
181+ files : [ './**/*.ts' , './**/*.tsx' ] ,
182+ parser : '@typescript-eslint/parser' ,
183+ parserOptions : {
184+ project : true ,
185+ } ,
186+ extends : [ 'plugin:@typescript-eslint/strict' , 'plugin:@typescript-eslint/stylistic' ] ,
187+ rules : {
188+ // Deactivate rules not meant for TS
189+ 'no-restricted-imports' : 'off' ,
190+
191+ // React Plugin Rules
192+ 'react/prop-types' : 'off' , // https://github.com/jsx-eslint/eslint-plugin-react/issues/3651
193+ 'react/no-array-index-key' : 'off' ,
194+ 'react/require-default-props' : 'off' ,
195+
196+ // Typescript Rules
197+ '@typescript-eslint/consistent-type-imports' : [ 'error' ] ,
198+ '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
199+ '@typescript-eslint/naming-convention' : [
200+ 'error' ,
201+ {
202+ selector : 'variable' ,
203+ types : [ 'boolean' ] ,
204+ format : [ 'PascalCase' , 'UPPER_CASE' ] ,
205+ prefix : [
206+ 'is' ,
207+ 'are' ,
208+ 'was' ,
209+ 'should' ,
210+ 'has' ,
211+ 'can' ,
212+ 'did' ,
213+ 'will' ,
214+ 'IS_' ,
215+ 'ARE_' ,
216+ 'WAS_' ,
217+ 'SHOULD_' ,
218+ 'HAS_' ,
219+ 'CAN_' ,
220+ 'DID_' ,
221+ 'WILL_' ,
222+ ] ,
223+ } ,
224+ ] ,
225+ '@typescript-eslint/no-empty-interface' : [ 'error' , { allowSingleExtends : true } ] ,
226+ '@typescript-eslint/no-explicit-any' : 'error' ,
227+ '@typescript-eslint/no-restricted-imports' : [
228+ 'error' ,
229+ {
230+ paths : [
231+ {
232+ name : 'react-select' ,
233+ message : 'Please use `components/Form/Select/ThemedReactSelect` instead.' ,
234+ } ,
235+ {
236+ name : 'formik' ,
237+ importNames : [ 'Form' ] ,
238+ message : `Please use our Form component to have good defaults defined.\n "import Form from 'components/Form/Form';"` ,
239+ } ,
240+ {
241+ name : 'react' ,
242+ importNames : [ 'default' ] ,
243+ message : 'React is globally availble for all page files.' ,
244+ } ,
245+ ] ,
246+ } ,
247+ ] ,
248+ '@typescript-eslint/no-unused-vars' : [ 'error' , { vars : 'all' , varsIgnorePattern : '_' } ] ,
249+ '@typescript-eslint/unbound-method' : 'off' , // gives false negatives in arrow funcs
250+ } ,
251+ } ,
252+ {
253+ files : [ './**/*.test.ts' , './**/*.test.tsx' ] ,
254+ rules : {
255+ '@typescript-eslint/no-non-null-assertion' : 'off' ,
256+ } ,
257+ } ,
258+ {
259+ files : [ './pages/api/**/*.ts' ] ,
260+ rules : {
261+ 'no-console' : 'off' ,
262+ } ,
263+ } ,
264+ {
265+ files : [ 'cypress/**/*.js' ] ,
266+ rules : {
267+ 'func-names' : 'off' ,
268+ 'vitest/expect-expect' : 'off' ,
269+ 'vitest/valid-expect' : 'off' ,
270+ 'no-unused-expressions' : [ 'off' ] ,
271+ } ,
272+ } ,
273+ {
274+ files : [
275+ 'pages/**.js' ,
276+ 'components/head.js' ,
277+ 'components/nav.js' ,
278+ 'components/Timeline/historyData.js' ,
279+ ] ,
280+ rules : {
281+ 'react/react-in-jsx-scope' : 'off' ,
282+ } ,
283+ } ,
284+ {
285+ files : [ 'components/nav.js' , 'components/Footer/Footer.js' ] ,
286+ rules : { 'jsx-a11y/anchor-is-valid' : 'off' } ,
287+ } ,
288+ ] ,
250289 root : true ,
251290} ;
0 commit comments