-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
109 lines (92 loc) · 3.32 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
const rules = {
// This is a useless warning, as mount hooks require empty arrays
// and sometimes you just don't need to track all dependencies.
"react-hooks/exhaustive-deps": 0,
// Disabled in favor of TS definitions.
"react/prop-types": 0,
"react/no-unescaped-entities": 0,
"no-empty": [
2,
{
allowEmptyCatch: true,
},
],
// Turn this off in favor of unused-imports plugin.
"no-unused-vars": 0,
// Warn on unused imports.
// Note that this is upgraded to an error during git commits.
"unused-imports/no-unused-imports": 1,
// Turn this off in favor of simple-import-sort rule.
"sort-imports": 0,
"simple-import-sort/sort": [
1,
{
// Custom groupings based on documentation from
// https://www.npmjs.com/package/eslint-plugin-simple-import-sort#custom-grouping
groups: [
// Side effect imports
["^\\u0000"],
// External packages: things that start with a letter, digit, underscore, or @
["^@?\\w"],
// Local packages: things that start with @client
["^@client", "^@shared", "^@server"],
// Absolute/other imports: anything that does not start with a dot
["^[^.]"],
// Relative imports: anything that starts with a dot
["^\\."],
],
},
],
// 'debugger' statements are only warnings because we want to allow them during local development
// Note that this is upgraded to an error during git commits.
"no-debugger": 1,
/** We warn about this to make you aware that require() is not recommended, but sometimes
* needed. You should eslint-ignore any valid usages. */
"@typescript-eslint/no-var-requires": 1,
// The TS compiler will already error if it can't detect the return type from the code.
// Forcing the return type is just too noisy sometimes.
"@typescript-eslint/explicit-function-return-type": 0,
// This is up for debate. We currently use a lot of I-prefixes so it's disabled for now.
// https://github.com/microsoft/TypeScript-Handbook/issues/121
"@typescript-eslint/interface-name-prefix": 0,
// Many of our API endpoints use snake_case.
"@typescript-eslint/camelcase": 0,
// This rule is too restrictive. Try not to use `any` if it's avoidable, but sometimes it's
// necessary.
"@typescript-eslint/no-explicit-any": 0,
// Unused vars are warnings during local development.
// Disables eslint rule in favor of typescript-specific rule below.
// Note that this is upgraded to an error during git commits.
"unused-imports/no-unused-vars": 0,
"@typescript-eslint/no-unused-vars": 1,
"@typescript-eslint/no-use-before-define": 0,
"prettier/prettier": 1,
};
module.exports = {
extends: ["eslint:recommended", "plugin:react/recommended", "plugin:prettier/recommended"],
env: {
es6: true,
browser: true,
node: true,
},
parserOptions: {
ecmaVersion: 9,
},
rules,
plugins: ["simple-import-sort", "unused-imports"],
overrides: [
{
files: "{client,server}/src/**/*.{ts,tsx}",
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
rules,
},
],
};