-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
94 lines (94 loc) · 3.24 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
module.exports = {
env: {
browser: true,
es2021: true,
},
parser: '@babel/eslint-parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
},
plugins: ['babel', 'react', 'prettier', 'react-hooks', 'jsx-a11y'],
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:prettier/recommended',
'plugin:import/warnings',
'prettier/react',
'plugin:jsx-a11y/strict',
],
rules: {
'no-var': 'error',
'prefer-destructuring': 'warn',
'react/prop-types': 'off',
'react/destructuring-assignment': 'off',
'react/jsx-key': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'import/no-duplicates': 'warn',
'import/no-cycle': 'warn',
},
globals: {
/** Global environment variables */
WITH_SSR: 'readonly',
WITH_PWA: 'readonly',
IS_SERVER: 'readonly',
IS_CLIENT: 'readonly',
/** Tests variables */
jest: 'readonly',
describe: 'readonly',
xdescribe: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
it: 'readonly',
expect: 'readonly',
cy: 'readonly',
before: 'readonly',
after: 'readonly',
/** Webpack Provide plugin variables */
React: 'readonly',
/** Other variables */
process: 'readonly',
module: 'readonly',
global: 'readonly',
},
settings: {
react: {
version: 'detect',
},
},
/**
* Note: TSLint became deprecated from 2019 due to high code duplication with ESLint. Nowadays ESLint is used to format TypeScript files.
* More details: https://blog.palantir.com/tslint-in-2019-1a144c2317a9
* As Project intends to support both JS and TS, special override configuration used for TypeScript files.
*/
overrides: [
// TS overrides
{
files: ['*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
/**
* Note: 'typescript-eslint' disables some rules from 'eslint:recommended' as they are checked by TypeScript itself (e.g. constant reassign, object keys duplication)
* More details: https://github.com/typescript-eslint/typescript-eslint/blob/v2.23.0/packages/eslint-plugin/src/configs/eslint-recommended.ts
* Therefore it is required to handle TypeScript checking every time after ESlint checking (e.g. using 'tsc' command) as described cases will NOT be detected by ESLint.
*/
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'@typescript-eslint/consistent-type-definitions': 'warn',
},
},
{
// RTL (tests) overrides
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec).[jt]s?(x)'],
extends: ['plugin:testing-library/react', 'plugin:jest-dom/recommended'],
},
],
};