forked from opf/openproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
209 lines (179 loc) · 7.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
module.exports = {
extends: [
"eslint:recommended",
],
env: {
browser: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./src/tsconfig.app.json",
tsconfigRootDir: __dirname,
sourceType: "module",
createDefaultProgram: true,
},
plugins: [
"@typescript-eslint",
"change-detection-strategy",
"jasmine",
],
overrides: [
{
files: ["*.ts"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./src/tsconfig.app.json",
tsconfigRootDir: __dirname,
sourceType: "module",
createDefaultProgram: true,
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@angular-eslint/recommended",
// This is required if you use inline templates in Components
"plugin:@angular-eslint/template/process-inline-templates",
"airbnb-base",
"airbnb-typescript/base",
],
rules: {
/**
* Any TypeScript source code (NOT TEMPLATE) related rules you wish to use/reconfigure over and above the
* recommended set provided by the @angular-eslint project would go here.
*/
"@angular-eslint/directive-selector": [
"error",
{"type": "attribute", "prefix": ["op", "opce"], "style": "camelCase"},
],
"@angular-eslint/component-selector": [
"error",
{"type": "element", "prefix": ["op", "opce"], "style": "kebab-case"},
],
"@angular-eslint/component-class-suffix": ["error", {"suffixes": ["Component", "Example"]}],
// Warn when new components are being created without OnPush
"change-detection-strategy/on-push": "error",
"no-console": [
"error",
{
allow: [
"warn",
"error",
],
},
],
// Sometimes we need to shush the TypeScript compiler
"no-unused-vars": ["error", {"varsIgnorePattern": "^_", "argsIgnorePattern": "^_"}],
"@typescript-eslint/no-unused-vars": ["error", {"varsIgnorePattern": "^_", "argsIgnorePattern": "^_"}],
// Who cares about line length
"max-len": "off",
// Disable forcing newlines in braces to prevent empty objects and import errors
"object-curly-newline": "off",
// Allow short circuit evaluations
"@typescript-eslint/no-unused-expressions": ["error", {"allowShortCircuit": true}],
// Force single quotes to align with ruby
quotes: "off",
"@typescript-eslint/quotes": ["error", "single", {avoidEscape: true}],
// Disable webpack loader definitions
"import/no-webpack-loader-syntax": "off",
// Disable order style as it's not compatible with intellij import organization
"import/order": "off",
// It'd be good if we could error this for switch cases but allow it for for loops
"no-continue": "off",
// no param reassignment is a pain when trying to set props on elements
"no-param-reassign": "off",
// destructuring doesn't always look better, only when object/array destructuring
"prefer-destructuring": "off",
// Sometimes, arrow functions implicit return looks better below, so allow both
"implicit-arrow-linebreak": "off",
// Sometimes, arrow functions look better broken down
"arrow-body-style": "off",
// No void at all collides with `@typescript-eslint/no-floating-promises` which wants us to handle each promise.
// Until we do that, `void` is a good way to explicitly mark unhandled promises.
"no-void": ["error", {allowAsStatement: true}],
// Disable no-use for functions and classes
"no-use-before-define": ["error", {"functions": false, "classes": false}],
"@typescript-eslint/no-use-before-define": ["error", {"functions": false, "classes": false}],
// Allow subsequent single fields in typescript classes
"@typescript-eslint/lines-between-class-members": ["error", "always", {"exceptAfterSingleLine": true}],
// Disable indentation rule as it breaks in edge cases and is covered by editorconfig
"indent": "off",
"@typescript-eslint/indent": "off",
// Allow namespaces, they are generated into flat functions and we don't care about modules for helpers
"@typescript-eslint/no-namespace": "off",
/*
// Disable use before define, as irrelevant for TS interfaces
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off",
*/
// Whitespace configuration
"@typescript-eslint/type-annotation-spacing": [
"error",
{
before: false,
after: false,
overrides: {
arrow: {
before: true,
after: true,
},
},
},
],
// Allow writing type union and type intersections without space
"@typescript-eslint/space-infix-ops": "off",
// Allow empty interfaces for naming purposes (HAL resources)
"@typescript-eslint/no-empty-interface": "off",
"import/prefer-default-export": "off",
// HAL has a lot of dangling properties, so allow
// usage in properties but not in all other places
"no-underscore-dangle": [
"warn",
{
allow: [
"_links",
"_embedded",
"_meta",
"_type",
"_destroy",
],
allowAfterThis: true,
allowAfterSuper: false,
allowAfterThisConstructor: false,
enforceInMethodNames: true,
allowFunctionParams: true,
},
],
"no-return-assign": ["error", "except-parens"],
"no-plusplus": ["error", {"allowForLoopAfterthoughts": true}],
// https://typescript-eslint.io/rules/no-base-to-string/ Disable false positives due to missing types
"@typescript-eslint/no-base-to-string": ["error", {"ignoredTypeNames": ["URI", "Error", "RegExp", "URL", "URLSearchParams"]}],
//////////////////////////////////////////////////////////////////////
// Anything below this line should be turned on again at some point //
//////////////////////////////////////////////////////////////////////
// It's common in Angular to wrap even pure functions in classes for injection purposes
"class-methods-use-this": "off",
"spaced-comment": "off",
},
},
{
files: ["*.html"],
extends: ["plugin:@angular-eslint/template/recommended"],
rules: {},
},
{
files: ["*.spec.ts"],
extends: ["plugin:jasmine/recommended"],
rules: {
/**
* Any template/HTML related rules you wish to use/reconfigure over and above the
* recommended set provided by the @angular-eslint project would go here.
*/
// jasmine is unusable with unsafe member access, as expect(...) is always any
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
// Allow more than one class definitions per file (test components)
"max-classes-per-file": "off",
},
},
],
};