-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy path.eslintrc.js
301 lines (289 loc) · 10.2 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
'use strict';
const ImportSortGroups = [
// Side effect imports.
// eslint-disable-next-line no-useless-escape
[`^\u0000`],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
// But not our packages, ember/glimmer/ember-data packages, or potential addons (things starting with ember- or @ember-)
[
// eslint-disable-next-line no-useless-escape
`^(?!@ember\-data)(?!ember)(?!@ember\-)(?!@glimmer)(?!@craftable/)(?!frontend/)(?!craftable\-web)(@?\\w)`,
],
// Glimmer & Ember & EmberData Dependencies
// eslint-disable-next-line no-useless-escape
[`^(@ember/|@glimmer|ember|@ember\-data/$)`],
// Potential Addons (Packages starting with ember-)
// eslint-disable-next-line no-useless-escape
[`^(ember\-|@ember\-)`],
// Our sub packages (engines / addons)
[`@html-next/`],
// Our Main Package.
// eslint-disable-next-line no-useless-escape
[`^flexi/`],
// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything that does not start with a dot.
['^[^.]'],
// Relative imports.
// Anything that starts with a dot.
// eslint-disable-next-line no-useless-escape
[`^\.`],
];
module.exports = {
root: true,
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
babelOptions: {
plugins: [[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }]],
},
requireConfigFile: false,
},
plugins: ['ember', 'qunit', 'simple-import-sort', 'import', 'unused-imports', 'unicorn', 'no-useless-assign'],
extends: [
'eslint:recommended',
'prettier/prettier',
'plugin:ember/recommended',
'plugin:qunit/recommended',
'plugin:unicorn/recommended',
],
env: {
browser: true,
},
rules: {
eqeqeq: 'error',
'no-eq-null': 'error',
'prefer-rest-params': 'error',
'no-shadow': 'error',
'no-loop-func': 'error',
'no-lonely-if': 'error',
'no-labels': 'error',
'no-dupe-keys': 'error',
'no-dupe-else-if': 'error',
'no-var': 'error',
'no-prototype-builtins': 'error',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
// these are a nice proxy measurement of where there is complexity to pay down
'max-params': ['error', { max: 4 }],
'max-depth': ['error', { max: 4 }],
/* TODO this rule doesn't play well with tests, make this 15-20 but exclude tests */
'max-statements': ['error', { max: 35 }],
/* TODO this rule doesn't play well with tests
'max-lines-per-function': [
'error',
{ max: 80, skipBlankLines: true, skipComments: true },
],
*/
complexity: ['error', { max: 20 }],
'no-magic-numbers': ['error', { ignore: [0, 1, -1], ignoreArrayIndexes: true }],
'object-shorthand': ['error', 'always'],
'no-restricted-imports': [
'error',
{
paths: ['@ember/runloop'],
},
],
'no-restricted-properties': ['error'],
'one-var': ['error', 'never'],
'prefer-const': 'error',
'require-await': 'error',
'prefer-spread': 'error',
'no-unreachable-loop': 'error',
'no-lone-blocks': 'error',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-rename': 'error',
'no-useless-computed-key': 'error',
'prefer-destructuring': [
'error',
{
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: false,
object: false,
},
},
{ enforceForRenamedProperties: false },
],
'no-implicit-globals': 'error',
'dot-notation': 'error',
'no-redeclare': 'error',
'no-cond-assign': ['error', 'except-parens'],
'no-unmodified-loop-condition': 'error',
'no-use-before-define': 'error',
'no-console': 'error',
'no-eval': 'error',
'no-else-return': 'error',
'no-self-assign': 'error',
'no-self-compare': 'error',
'new-cap': ['error', { capIsNewExceptions: ['A'], newIsCapExceptions: [] }],
'no-caller': 'error',
'no-useless-assign/no-useless-assign': 'error',
'ember/no-incorrect-calls-with-inline-anonymous-functions': 'error',
'ember/no-deeply-nested-dependent-keys-with-each': 'error',
'ember/jquery-ember-run': 'error',
'qunit/no-assert-equal-boolean': 'error',
'qunit/require-expect': 'off',
'qunit/no-compare-relation-boolean': 'error',
'no-restricted-globals': [
'error',
{
name: 'window',
message: 'Use a Fastboot safe service instead',
},
{
name: 'document',
message: 'Use a Fastboot safe service instead',
},
{
name: 'global',
message: 'Use a Fastboot safe service instead',
},
],
// Too many false positives
// See https://github.com/eslint/eslint/issues/11899 and similar
'require-atomic-updates': 'off',
'simple-import-sort/imports': ['error', { groups: ImportSortGroups }],
'sort-imports': 'off',
'import/order': 'off',
'import/first': 'error',
'import/newline-after-import': 'error',
// this rule doesn't work properly with --fix
// https://github.com/benmosher/eslint-plugin-import/issues/1504
'import/no-duplicates': 'warn',
'ember/routes-segments-snake-case': 'off', // We should leave this off permanently
'ember/use-brace-expansion': 'off', // has bugs and is annoying + only applies to computeds we are getting rid of
'ember/no-classic-classes': 'error',
'ember/no-get': 'error',
'ember/no-jquery': 'error',
'ember/require-return-from-computed': 'error',
'ember/no-actions-hash': 'error',
'ember/avoid-leaking-state-in-ember-objects': 'error',
'ember/no-mixins': 'error',
'ember/no-new-mixins': 'error',
'ember/no-controller-access-in-routes': 'error',
'ember/closure-actions': 'error',
'ember/no-component-lifecycle-hooks': 'error',
'ember/no-observers': 'error',
'ember/require-tagless-components': 'error',
'ember/no-classic-components': 'error',
'ember/no-side-effects': ['error', { checkPlainGetters: false }],
// unicorn
'unicorn/prefer-module': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-negated-condition': 'off',
'unicorn/prefer-structured-clone': 'off',
'unicorn/switch-case-braces': 'off',
'unicorn/no-array-for-each': 'off', // this might be nice someday? better if it would do regular for loops for arrays
'unicorn/number-literal-case': 'off', // conflicts with prettier
'unicorn/no-nested-ternary': 'off', // conflicts with prettier
'unicorn/no-null': 'off',
'unicorn/consistent-destructuring': 'off', // nice in some ways but heavy handed
'unicorn/prefer-spread': 'off', // possibly nice if we had native arrays
'unicorn/no-for-loop': 'off', // if for...of was good maybe we'd use this
'unicorn/better-regex': 'off', // would be awesome but has bugs https://github.com/sindresorhus/eslint-plugin-unicorn/issues?q=is%3Aissue+is%3Aopen+better-regex
'unicorn/no-anonymous-default-export': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/prefer-add-event-listener': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-default-parameters': 'error',
'unicorn/prefer-number-properties': 'error', // Number.isNaN and Number.isFinite usage differs from global
'unicorn/numeric-separators-style': 'error',
'unicorn/prefer-optional-catch-binding': 'error',
'unicorn/catch-error-name': 'error',
'unicorn/prefer-ternary': 'error',
'unicorn/no-lonely-if': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-array-find': 'error',
'unicorn/prefer-string-replace-all': 'error',
'unicorn/explicit-length-check': 'error',
'unicorn/no-unsafe-regex': 'error',
// to consider activating
'unicorn/prefer-array-some': 'off', // note: this is great, but if we use ember arrays we must polyfill this
'unicorn/prefer-negative-index': 'off',
'unicorn/prefer-dom-node-append': 'off',
'unicorn/prefer-dom-node-remove': 'off',
'unicorn/prefer-query-selector': 'off',
'unicorn/prefer-switch': 'off',
'unicorn/prefer-string-slice': 'off',
'unicorn/no-array-push-push': 'off',
'unicorn/no-zero-fractions': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/no-array-reduce': 'off',
'unicorn/new-for-builtins': 'off',
'unicorn/escape-case': 'off',
'unicorn/no-this-assignment': 'off',
'unicorn/prefer-set-has': 'off',
'unicorn/prefer-export-from': 'off',
'unicorn/prefer-code-point': 'off',
'unicorn/require-array-join-separator': 'off',
'unicorn/error-message': 'off',
'unicorn/no-array-callback-reference': 'off', // we may never want this
'unicorn/prevent-abbreviations': [
'off',
{
checkFilenames: false,
checkDefaultAndNamespaceImports: false,
extendDefaultReplacements: false,
replacements: {
e: {
error: true,
event: true,
},
},
},
],
},
overrides: [
// node files
{
files: [
'bin/**/*.js',
'.eslintrc.js',
'.lint-todorc.js',
'.prettierrc.js',
'.template-lintrc.js',
'packages/*/ember-cli-build.js',
'packages/*/testem.js',
'packages/*/blueprints/*/index.js',
'packages/flexi-config/lib/**/*.js',
'packages/flexi-layouts/lib/**/*.js',
'packages/flexi-default-styles/lib/**/*.js',
'packages/*/dsl/**/*.js',
'packages/*/blueprints/@html-next/*/index.js',
'packages/*/config/**/*.js',
'packages/*/tests/dummy/config/**/*.js',
'packages/*/index.js',
'packages/*/lib/*/index.js',
'packages/*/server/**/*.js',
],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
plugins: ['n'],
extends: ['plugin:n/recommended'],
rules: {
// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'n/no-unpublished-require': 'off',
},
},
],
};