forked from get-convex/convex-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
86 lines (80 loc) · 2.58 KB
/
.eslintrc.cjs
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
module.exports = {
// means don't look to parent dir, so use `root: true` in descendant directories to ignore this config
// See https://eslint.org/docs/user-guide/configuring/configuration-files#cascading-and-hierarchy
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["./tsconfig.json"],
tsconfigRootDir: __dirname,
},
plugins: [
"@typescript-eslint",
"react-hooks",
"react",
"vitest",
"require-extensions",
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:require-extensions/recommended",
],
env: {
amd: true,
browser: true,
node: true,
},
rules: {
"no-debugger": "error",
// any is terrible but we use it a lot (even in our public code).
"@typescript-eslint/no-explicit-any": "off",
// asserting that values aren't null is risky but useful.
"@typescript-eslint/no-non-null-assertion": "off",
// Warn against interpolating objects
"@typescript-eslint/restrict-template-expressions": "error",
// allow (_arg: number) => {}
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
// Add React hooks rules so we don't misuse them.
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
// If you add rules here, make sure to add it to subdir eslintrc files as well!
"no-restricted-syntax": [
"error",
{
// From https://github.com/typescript-eslint/typescript-eslint/issues/1391#issuecomment-1124154589
// Prefer `private` ts keyword to `#private` private methods
selector:
":matches(PropertyDefinition, MethodDefinition) > PrivateIdentifier.key",
message: "Use `private` instead",
},
],
// Makes it harder to accidentally fire off a promise without waiting for it.
"@typescript-eslint/no-floating-promises": "error",
// Since `const x = <number>foo;` syntax is ambiguous with JSX syntax some tools don't support it.
// In particular we need this for depcheck https://github.com/depcheck/depcheck/issues/585
"@typescript-eslint/consistent-type-assertions": [
"error",
{
assertionStyle: "as",
},
],
eqeqeq: ["error", "always"],
// vitest (manually enabled until we can upgrade eslint)
"vitest/no-focused-tests": ["error", { fixable: false }],
},
ignorePatterns: [
"node_modules",
"dist",
"*.js",
"tmpDist*",
"tmpPackage*",
"custom-vitest-environment.ts",
],
};