forked from Lichtblick-Suite/lichtblick
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.yaml
181 lines (146 loc) · 6.16 KB
/
.eslintrc.yaml
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
env:
browser: true
es6: true
node: true
ignorePatterns:
- dist
- out
- template
- "packages/**/wasm/*.js"
- "!.storybook"
- storybook-static
plugins:
- file-progress
- tss-unused-classes
- "@foxglove/eslint-plugin-studio"
extends:
- plugin:@foxglove/base
- plugin:@foxglove/react
- plugin:@foxglove/jest
- plugin:storybook/recommended
- plugin:@foxglove/studio/all
settings:
import/internal-regex: "^@foxglove"
rules:
"@foxglove/license-header": error
"@foxglove/prefer-hash-private": error
tss-unused-classes/unused-classes: error
# show progress while linting
file-progress/activate: warn
# enabled in .eslintrc.ci.yaml
prettier/prettier: off
import/no-self-import: off
import/no-duplicates: off
id-denylist:
- error
- useEffectOnce
- window # don't allow redefining window
no-console: off # configured in no-restricted-syntax
react/jsx-uses-react: off
react/prop-types: off # Unnecessary with typescript validation
react-hooks/exhaustive-deps:
- error
- additionalHooks: "(useAsync(?!AppConfigurationValue))|useCallbackWithToast"
react/jsx-curly-brace-presence: [error, never]
# The _sx_ property is slow
# https://stackoverflow.com/questions/68383046/is-there-a-performance-difference-between-the-sx-prop-and-the-makestyles-function
react/forbid-component-props:
- error
- forbid:
- propName: "sx"
message: "Use of the sx prop is not advised due to performance issues. Consider using alternative styling methods instead."
no-warning-comments:
- error
- terms: ["fixme", "xxx", "todo"]
location: anywhere
no-restricted-imports:
- error
- paths:
- name: "@emotion/styled"
importNames: [styled]
message: "@emotion/styled has performance implications. Use tss-react/mui instead."
- name: "@mui/material"
importNames: [styled]
message: "@mui/styled has performance implications. Use tss-react/mui instead."
- name: "@mui/system"
importNames: [styled]
message: "@mui/styled has performance implications. Use tss-react/mui instead."
- name: "@mui/material/styles/styled"
message: "@mui/styled has performance implications. Use tss-react/mui instead."
- name: "@mui/material"
importNames: [Box]
message: "@mui/Box has performance implications. Use tss-react/mui instead."
- name: "@mui/system"
importNames: [Box]
message: "@mui/Box has performance implications. Use tss-react/mui instead."
no-restricted-syntax:
- error
- selector: "MethodDefinition[kind='get'], Property[kind='get']"
message: "Property getters are not allowed; prefer function syntax instead."
- selector: "MethodDefinition[kind='set'], Property[kind='set']"
message: "Property setters are not allowed; prefer function syntax instead."
# We disable console methods here rather than using no-console so that it doesn't prohibit overrides such as "console.info = ..."
- selector: "CallExpression[callee.object.name='console'][callee.property.name!=/^(warn|error|debug|assert)$/]"
message: "Unexpected property on console object was called"
- selector: "TSNullKeyword, Literal[raw=null]"
message: >
Prefer undefined instead of null. When required for React refs/components, use
the `ReactNull` alias. Otherwise, if strictly necessary, disable this error with
`// eslint-disable-next-line no-restricted-syntax`. For rationale, see:
https://github.com/sindresorhus/meta/discussions/7"
- selector: "CallExpression[callee.name='setTimeout'][arguments.length<2]"
message: "`setTimeout()` must be invoked with at least two arguments."
- selector: "CallExpression[callee.name='setInterval'][arguments.length<2]"
message: "`setInterval()` must be invoked with at least two arguments."
- selector: "CallExpression[callee.object.name='Promise'][callee.property.name='race']"
message: >
Promise.race is banned
use `import { race } from "@foxglove/den/async"` instead
See:
https://github.com/nodejs/node/issues/17469#issuecomment-685216777
https://bugs.chromium.org/p/v8/issues/detail?id=9858"
jest/expect-expect:
[error, { assertFunctionNames: [expect*, sendNotification.expectCalledDuringTest] }]
overrides:
- files: ["*.ts", "*.tsx"]
extends:
- plugin:@foxglove/typescript
parserOptions:
project: ./tsconfig.eslint.json
rules:
"@typescript-eslint/ban-ts-comment":
- error
- ts-expect-error: allow-with-description
"@typescript-eslint/explicit-member-accessibility": error
"@typescript-eslint/no-inferrable-types": off # It's sometimes useful to explicitly name to guard against future changes
"@typescript-eslint/no-empty-function": off
# These are related to `any` types, which we generally don't have except from imports
"@typescript-eslint/no-unsafe-member-access": off
"@typescript-eslint/no-unsafe-return": off
"@typescript-eslint/no-unsafe-assignment": off
"@typescript-eslint/no-unsafe-call": off
# These could theoretically be turned on (or merit investigation) but are currently noisy
"@typescript-eslint/no-misused-promises": off # Often used with e.g. useCallback(async () => {})
"@typescript-eslint/restrict-template-expressions": off
"@typescript-eslint/prefer-regexp-exec": off
"@typescript-eslint/no-unnecessary-condition": error
"@typescript-eslint/unbound-method": [error, { ignoreStatic: true }]
# https://eslint.org/docs/latest/rules/no-loop-func
"no-loop-func": error
# unused vars must have `_` prefix, but `_` alone is not ignored (see @foxglove/studio/lodash-imports)
"@typescript-eslint/no-unused-vars":
- error
- vars: all
args: after-used
varsIgnorePattern: "^_."
argsIgnorePattern: "^_."
- rules:
"@typescript-eslint/no-explicit-any": off
files:
- "**/*.stories.tsx"
- "**/*.test.tsx"
- "**/*.test.ts"
- rules:
react/forbid-component-props: off
files:
- "**/*.stories.tsx"