-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.json
120 lines (113 loc) · 3.96 KB
/
.eslintrc.json
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
{
// Prevent ESLint from looking for other configurations in parent directories
"root": true,
// Enable the use of global variables
"env": {
// From every ECMAScript release until ES2021
"es2021": true,
// From Node.js environment
"node": true
},
// Extend existing configurations
// Order matters, each extension overrides the previous one
"extends": [
// Airbnb base config uses import plugin
"airbnb-base",
// Airbnb typescript base config uses @typescript-eslint plugin and overrides airbnb base config
"airbnb-typescript/base"
],
"overrides": [
{
// Run testing rules only against test files
"files": ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
"extends": ["plugin:jest/recommended"],
"env": {
"jest/globals": true
},
"rules": {
// Allow nesting describe/test callbacks in Jest tests
"max-nested-callbacks": "off",
// Allow magic numbers in tests
"no-magic-numbers": "off"
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
// Link the typescript parser to the local typescript configuration
"project": "./tsconfig.json",
// Enable the use of syntax from latest ECMAScript releases
"ecmaVersion": "latest",
// Enable the use of syntax from ECMAScript modules
"sourceType": "module"
},
"ignorePatterns": ["swagger-static"],
"rules": {
// Force all functions have explicit return type
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
// Enforce consistent use of double quotes instead of single quotes to define strings
// IMHO having to escape single quotes is more annoying than escaping double quotes because
// single quotes are mandatory for contractions though double quotes never are mandatory
// See http://stackoverflow.com/a/18041188/1480391
// https://typescript-eslint.io/rules/quotes/
"quotes": "off",
"@typescript-eslint/quotes": [
"error",
"double",
{
"avoidEscape": true
}
],
// Enforce a convention in module import order
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
"import/order": [
"error",
{
"newlines-between": "never",
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"alphabetize": {
"order": "asc",
"caseInsensitive": false
}
}
],
// Enforce the export default when there is a single export from a module
// Disabled to follow Nest guidelines
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
"import/prefer-default-export": "off",
// Enforce the maximum depth callbacks that can be nested
// https://eslint.org/docs/latest/rules/max-nested-callbacks
"max-nested-callbacks" : ["error", 4],
// Disallow the use of console
// Disabled because that's a good practice in frontend only
// https://eslint.org/docs/latest/rules/no-console
"no-console": "off",
// Enforce the use of explicit constants instead of meaningless numbers
// https://eslint.org/docs/rules/no-magic-numbers
"no-magic-numbers": [
"error",
{
"ignore": [
-1,
0,
1,
2,
3,
10,
100,
1000
],
"ignoreArrayIndexes": true,
"enforceConst": true,
"detectObjects": false
}
]
}
}