-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eslintrc.js
116 lines (107 loc) · 3.12 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
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/typescript",
"prettier",
],
plugins: ["tsdoc", "simple-import-sort", "import"],
env: {
node: true,
es6: true,
},
rules: {
// We need this for our `GraphileEngine` namespace
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/consistent-type-imports": "error",
"no-confusing-arrow": "off",
"no-else-return": "off",
"no-underscore-dangle": "off",
"no-restricted-syntax": "off",
"no-await-in-loop": "off",
"tsdoc/syntax": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
args: "after-used",
ignoreRestSiblings: true,
},
],
/*
* simple-import-sort seems to be the most stable import sorting currently,
* disable others
*/
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"sort-imports": "off",
"import/order": "off",
"import/extensions": ["error", "ignorePackages"],
"import/no-deprecated": "warn",
// Apply has been more optimised than spread, use whatever feels right.
"prefer-spread": "off",
// note you must disable the base rule as it can report incorrect errors
"no-duplicate-imports": "off",
"import/no-duplicates": "error",
},
overrides: [
// Rules for interfaces.ts files
{
files: ["**/interfaces.ts"],
rules: {
"no-restricted-syntax": [
"error",
{
selector: "TSModuleDeclaration[kind='global']",
message:
"No `declare global` allowed in `interface.ts` files since these type-only files may not be imported by dependents, recommend adding to `index.ts` instead.",
},
],
},
},
// Rules for TypeScript only
{
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
rules: {
"no-dupe-class-members": "off",
"no-undef": "off",
// This rule doesn't understand import of './js'
"import/no-unresolved": "off",
},
},
// Rules for JavaScript only
{
files: ["*.js", "*.jsx", "*.mjs", "*.cjs"],
rules: {
"tsdoc/syntax": "off",
"import/extensions": "off",
},
},
// Stricter rules for source code
{
files: ["*/*/src/**/*.ts", "*/*/src/**/*.tsx"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
rules: {},
},
// Rules for tests only
{
files: ["**/__tests__/**/*.{ts,js,mts,mjs}"],
rules: {
// Disable these to enable faster test writing
"prefer-const": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-function-return-type": "off",
// We don't normally care about race conditions in tests
"require-atomic-updates": "off",
},
},
],
};