-
Notifications
You must be signed in to change notification settings - Fork 59
/
.eslintrc.js
151 lines (144 loc) · 4.36 KB
/
.eslintrc.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/** @type {import('eslint').Linter.Config} */
module.exports = {
env: {
browser: true,
es2021: true,
jest: true,
},
root: true,
globals: {
// global variables, that should be assumed by eslint as defined
JSX: true,
RequiredNonNullable: true,
Dictionary: true,
NodeJS: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
extends: ['plugin:react/recommended', 'airbnb', 'prettier'],
plugins: ['custom-rules', 'react', '@typescript-eslint', 'import'],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
'import/core-modules': [
'@clients/locale',
'@clients/ui-atoms',
'@clients/primitives',
'@clients/theme',
'@clients/common',
'@clients/db',
],
},
rules: {
// "off" or 0 - turn the rule off; "warn" or 1; "error" or 2
'arrow-body-style': 'off',
'consistent-return': 'off',
'no-use-before-define': 'warn',
'no-shadow': 'off',
'no-nested-ternary': 'off',
'no-unused-vars': 'off',
'no-redeclare': 'off',
'prefer-destructuring': 'warn',
'prefer-promise-reject-errors': 'warn',
'no-restricted-syntax': 'warn',
'guard-for-in': 'warn',
'no-param-reassign': 'warn',
'no-unused-expressions': 'warn',
'no-continue': 'warn',
'no-restricted-globals': 'warn',
'default-case': 'warn',
'no-underscore-dangle': 'warn',
'no-return-assign': 'warn',
'no-throw-literal': 'warn',
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['@mui/styles', '@naterial/styles'],
importNames: ['makeStyles'],
message:
"MUIv5 styles are incompatible with JSS, use 'styled' pattern or 'sx' prop instead.",
},
],
},
],
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
// typescript specific
'@typescript-eslint/no-shadow': 'off',
// disabled to let "@typescript-eslint/*" rules do it's job
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-redeclare': ['warn', { ignoreDeclarationMerge: true }], // still will warn on exporting enums :(
// classic
'no-plusplus': 'off',
'array-callback-return': 'off',
// import
'import/extensions': 'off',
'import/prefer-default-export': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-cycle': 2,
'import/no-unresolved': 'off',
'import/no-unused-modules': [1, { unusedExports: true }],
// up for discussion
'react/function-component-definition': 'off',
eqeqeq: 'warn', // 12
// react
'react/destructuring-assignment': 'off',
'react/jsx-props-no-spreading': 'off',
'react/jsx-filename-extension': [
2,
{
extensions: ['.jsx', '.tsx'],
},
],
'react/button-has-type': 'off', // 5
'react/jsx-no-useless-fragment': 'off', // 15
'react/no-access-state-in-setstate': 'warn', // 2
'react/jsx-no-bind': 'warn', // 3
'react/prop-types': 'off', // 69
'react/self-closing-comp': 'off',
'react/jsx-no-constructed-context-values': 'off',
'react/no-unstable-nested-components': 'off',
'react/no-unescaped-entities': 'off',
'react/require-default-props': 'off',
'react/no-unused-prop-types': 'off', // 15
'react/no-array-index-key': 'warn', // 2
'react/static-property-placement': 'warn', // 1
'react/state-in-constructor': 'warn', // 2
'react/no-children-prop': 'warn', // 1
// jsx-a11y
'jsx-a11y/anchor-is-valid': 'off', // 4
'jsx-a11y/no-noninteractive-element-interactions': 'off', // 1
'jsx-a11y/click-events-have-key-events': 'off', // 7
'jsx-a11y/no-static-element-interactions': 'off', // 6
'jsx-a11y/control-has-associated-label': 'warn',
// custom-rules
'custom-rules/enforce-path': 'error',
},
overrides: [
{
// overrides for test files
files: ['*.spec.*', '*.test.*', 'scripts/*'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'import/no-extraneous-dependencies': 'off',
},
},
{
// overrides for test files
files: ['*.json'],
rules: {
bracketSpacing: 2,
},
},
],
};