forked from Lichtblick-Suite/lichtblick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.yaml
128 lines (105 loc) · 4.31 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
env:
browser: true
es6: true
node: true
ignorePatterns:
- dist
- out
- template
- "packages/**/wasm/*.js"
- "!.storybook"
- storybook-static
plugins:
- file-progress
extends:
- plugin:@foxglove/base
- plugin:@foxglove/react
- plugin:@foxglove/jest
settings:
import/internal-regex: "^@foxglove"
rules:
"@foxglove/license-header": 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"
# 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:
- warn
- 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"]
location: anywhere
no-restricted-imports:
- error
- paths:
- name: lodash
importNames: [get]
message: "Use optional chaining instead of lodash.get."
- name: lodash/get
message: "Use optional chaining instead of lodash.get."
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"
jest/no-done-callback: off # Can be a useful alternative to promises
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/no-inferrable-types": off # It's sometimes useful to explicitly name to guard against future changes
"@typescript-eslint/no-empty-function": off
"@typescript-eslint/no-implied-eval": off # We need to use `new Function()`
# 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
"@typescript-eslint/require-await": off # Async functions without await are used to satisfy interface requirements
# 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 }]
- rules:
"@typescript-eslint/no-explicit-any": off
files:
- "**/*.stories.tsx"
- "**/*.test.tsx"
- "**/*.test.ts"