-
Notifications
You must be signed in to change notification settings - Fork 179
/
.eslintrc.js
192 lines (181 loc) · 5.68 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
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
'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'],
rules: {
camelcase: 'off',
'no-var': 'error',
'prefer-const': 'error',
'react/display-name': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'no-extra-boolean-cast': 'off',
'import/no-default-export': 'error',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/default-param-last': 'off',
// 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',
// Enforce notification hooks
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@opentrons/react-api-client',
importNames: [
'useAllRunsQuery',
'useRunQuery',
'useAllCommandsQuery',
'useCurrentMaintenanceRun',
'useDeckConfigurationQuery',
'useAllCommandsAsPreSerializedList',
],
message:
'HTTP hook deprecated. Use the equivalent notification wrapper (useNotifyXYZ).',
},
],
},
],
},
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/consistent-indexed-object-style': 'warn',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/non-nullable-type-assertion-style': '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)'],
rules: {
'import/no-absolute-path': 'off',
},
},
{
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',
},
},
{
files: ['**/cypress/**'],
extends: ['plugin:cypress/recommended'],
rules: {
'cypress/unsafe-to-chain-command': 'warn',
},
},
// 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',
},
},
// apply application structure import requirements to app
{
files: ['./app/src/**/*.@(ts|tsx)'],
rules: {
'opentrons/no-imports-across-applications': 'error',
},
},
],
}