This repository has been archived by the owner on May 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc
175 lines (175 loc) · 5.87 KB
/
.eslintrc
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{
"root": true,
"overrides": [
{
"files": ["**/scripts/**/*.[jt]s?(x)"],
"rules": {
// Scripts are devDependencies, which often import devDependencies, so this rule would complain
"import/no-extraneous-dependencies": "off"
}
},
{
"extends": ["plugin:jest/recommended", "plugin:jest/style"],
"files": [
"**/test/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)",
"*.config.js"
],
"env": {
"jest": true
},
"rules": {
// In testing, devDependencies are often imported, and this rule would complain
"import/no-extraneous-dependencies": "off",
// In testing, dynamic requires are often required
"@typescript-eslint/no-var-requires": "off",
// Strict type safety can be more of a hindrance in tests sometimes
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
// Requiring in local scopes is useful in tests
"global-require": "off"
}
}
],
"env": {
"es6": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"airbnb-typescript/base"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
"project": "./tsconfig.json",
"sourceType": "module" // Allows for the use of imports
},
"plugins": ["@typescript-eslint"],
"rules": {
// Spacing in brackets is consistent and readable
"array-bracket-spacing": ["error", "always"],
// Spacing in brackets is consistent and readable
"computed-property-spacing": ["error", "always"],
// Spacing in brackets is consistent and readable
"space-in-parens": [
"error",
"always",
{
"exceptions": ["empty"]
}
],
// Doesn't really help to check if the module is on the filesystem, and can harm when using Docker etc: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
"import/no-unresolved": "off",
// Do not require .js/ts extensions, except for .json
"import/extensions": [
"error",
"never",
{
"json": "always"
}
],
// Preferable, but the author should know best for the situation
"import/prefer-default-export": "off",
// Windows users may checkout as CRLF, but check in as LF, which this rule breaks
"linebreak-style": "off",
// There's no need to have more than 1 empty line, ever
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
// No unused variables except when prepended with _, to indicate that they're not to be used, but require definition to be valid code
"no-unused-vars": [
"error",
{
"ignoreRestSiblings": true,
"argsIgnorePattern": "^_"
}
],
// https://eslint.org/docs/rules/no-shadow seems sensible to not have shadow variables, but can get annoying real quick, especially in the case of reducers
"no-shadow": "off",
"@typescript-eslint/no-shadow": "off",
// Be consistent about where the object braces go
"object-curly-newline": [
"error",
{
"consistent": true
}
],
// Object properties either on the same line, or all on separate, consistently
"object-property-newline": [
"error",
{
"allowAllPropertiesOnSameLine": true
}
],
// We always want a space after the colon when defining types
"@typescript-eslint/type-annotation-spacing": ["error"],
// Let Typescript infer the return types
"@typescript-eslint/explicit-module-boundary-types": "off",
// Sometimes you want to declare a function as async so that it returns a Promisified value
"@typescript-eslint/require-await": "off",
// Use types throughout, not interfaces
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
// Semi colons are visual garbage
"@typescript-eslint/semi": ["error", "never"],
// For the few semi-colons required (e.g. inline array operations), place them at the beginning of the statement
"semi-style": ["error", "first"],
// Typescript types should be delimeted by commas, not semi-colons
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "comma"
},
"singleline": {
"delimiter": "comma"
}
}
],
// Prefer passing in ES6 default values to function components (ideal solution resolve #113)
"react/require-default-props": "off",
// This plugin sorts alphabetically by default
"simple-import-sort/sort": "off",
// Add new line between imports
"import/order": [
"error",
{
"newlines-between": "always"
}
],
// This plugin enforces naming conventions
"@typescript-eslint/naming-convention": [
"error",
// For variables, properties, funtions, methods, etc.
{
"selector": ["variableLike", "memberLike"],
"format": ["strictCamelCase", "StrictPascalCase"],
"leadingUnderscore": "allow"
},
// For types, enums, etc.
{
"selector": ["typeLike"],
"format": ["StrictPascalCase"]
},
// Prefix camelCase booleans
{
"selector": "variable",
"types": ["boolean"],
"format": ["StrictPascalCase"],
"prefix": ["is", "should", "has", "can", "did", "will"]
},
// Allow "true constant" bool/str/num to be UPPER_CASE
// Don't require prefix for UPPER_CASE boolean
// E.g. hardcoded string or env variable
{
"selector": "variable",
"modifiers": ["const"],
"format": ["strictCamelCase", "StrictPascalCase", "UPPER_CASE"]
}
]
}
}