-
Notifications
You must be signed in to change notification settings - Fork 194
Expand file tree
/
Copy path.eslintrc.js
More file actions
255 lines (243 loc) · 7.46 KB
/
.eslintrc.js
File metadata and controls
255 lines (243 loc) · 7.46 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
'use strict'
module.exports = {
root: true,
parserOptions: {
project: require('path').join(__dirname, 'tsconfig-eslint.json'),
},
extends: [
'standard-with-typescript',
'plugin:react/recommended',
'prettier',
'plugin:json/recommended',
'plugin:storybook/recommended',
'plugin:react/jsx-runtime',
],
plugins: [
'react',
'react-hooks',
'json',
'testing-library',
'opentrons',
'@eslint-react',
'jsx-a11y',
],
reportUnusedDisableDirectives: true,
rules: {
camelcase: 'off',
'no-var': 'error',
'prefer-const': 'error',
'react/display-name': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': [
'error',
{
additionalHooks: '(useDrag|useDrop)',
},
],
'no-extra-boolean-cast': 'off',
'import/no-default-export': 'error',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/default-param-last': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
// TODO(mc, 2021-01-29): fix these and remove warning overrides
'lines-between-class-members': 'warn',
'array-callback-return': 'warn',
'no-prototype-builtins': 'warn',
'no-import-assign': 'warn',
'default-case-last': 'warn',
'no-case-declarations': 'warn',
'prefer-regex-literals': 'warn',
'react/prop-types': 'warn',
'react/jsx-curly-brace-presence': 'warn',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
// Enforce notification hooks
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@opentrons/react-api-client',
importNames: [
'useAllRunsQuery',
'useRunQuery',
'useAllCommandsQuery',
'useCurrentMaintenanceRun',
'useDeckConfigurationQuery',
'useAllCommandsAsPreSerializedList',
'useSearchLabwareOffsets',
'useImageFileQuery',
'useCamera',
],
message:
'HTTP hook deprecated. Use the equivalent notification wrapper (useNotifyXYZ).',
},
{
name: 'lodash',
message:
'Use a granular import, like `import isEqual from "lodash/isEqual"`, instead of like `import { isEqual } from "lodash"`',
},
],
},
],
},
globals: {},
env: {
node: true,
browser: true,
},
settings: {
react: {
version: '17.0.1',
},
},
overrides: [
{
files: ['**/*.js'],
extends: ['plugin:@typescript-eslint/disable-type-checked'],
parserOptions: {
project: require('path').join(__dirname, 'tsconfig-eslint.json'),
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
},
},
{
// TODO(mc, 2021-03-18): remove to default these rules back to errors
files: ['**/*.@(ts|tsx)'],
rules: {
'@typescript-eslint/strict-boolean-expressions': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
'@typescript-eslint/naming-convention': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/unbound-method': 'warn',
'@typescript-eslint/consistent-generic-constructors': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
// need this to be able to pass in css prop into raw elements (babel adds this at build time for styled-components)
'react/no-unknown-property': [
'error',
{ ignore: ['css', 'indeterminate'] },
],
},
},
{
files: [
'./app/src/**/*.@(ts|tsx)',
'./opentrons-ai-client/src/**/*.@(ts|tsx)',
'./protocol-designer/src/**/*.@(ts|tsx)',
],
rules: {
'import/no-absolute-path': 'off',
'@eslint-react/no-nested-component-definitions': 'error',
'jsx-a11y/alt-text': 'error',
},
},
{
files: [
'**/test/**.js',
'**/__tests__/**.@(js|ts|tsx)',
'**/__mocks__/**.@(js|ts|tsx)',
'**/__utils__/**.@(js|ts|tsx)',
'**/__fixtures__/**.@(js|ts|tsx)',
'**/fixtures/**.@(js|ts|tsx)',
'scripts/*.@(js|ts|tsx)',
'**/**test.@(js|ts|tsx)',
],
rules: {
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-confusing-void-expression': 'warn',
'node/handle-callback-err': 'off',
},
},
{
files: ['**/__tests__/**test.tsx'],
extends: ['plugin:testing-library/react'],
},
{
files: ['**/*.stories.tsx'],
rules: {
'import/no-default-export': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
},
},
// Allow HTTP hooks in notification wrappers and tests
{
files: ['app/src/resources/**', '**/__tests__/**test**'],
rules: {
'no-restricted-imports': 'off',
},
},
// Apply tree-of-life import requirements to app as errors
{
files: ['./app/src/**/*.@(ts|tsx)'],
rules: {
'opentrons/no-imports-up-the-tree-of-life': 'error',
},
},
{
files: ['./protocol-designer/src/**/*.@(ts|tsx)'],
rules: {
'opentrons/no-imports-up-the-tree-of-life': 'warn',
'opentrons/no-margins-in-css': 'warn',
'opentrons/no-margins-inline': 'warn',
'@eslint-react/no-nested-component-definitions': 'error',
},
},
// apply application structure import requirements to app
{
files: ['./app/src/**/*.@(ts|tsx)'],
rules: {
'opentrons/no-imports-across-applications': 'error',
'opentrons/no-margins-in-css': 'warn',
'opentrons/no-margins-inline': 'warn',
},
},
{
files: ['./opentrons-ai-client/src/**/*.@(ts|tsx)'],
rules: {
'opentrons/no-imports-up-the-tree-of-life': 'warn',
'opentrons/no-margins-in-css': 'warn',
'opentrons/no-margins-inline': 'warn',
},
},
{
files: ['./components/src/**/*.@(ts|tsx)'],
rules: {
'opentrons/no-margins-in-css': 'warn',
'opentrons/no-margins-inline': 'warn',
},
},
{
files: ['**/*.tsx'],
excludedFiles: ['**/*.stories.tsx'],
rules: {
// TODO: Switch this rule to 'error' once the CSS modules migration is complete.
'react/forbid-dom-props': [
'warn',
{
forbid: [
{
propName: 'style',
message:
'Inline styles are not allowed. Use CSS modules instead.',
},
],
},
],
},
},
],
}