-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eslintrc.js
263 lines (254 loc) · 8.19 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
// See https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping
const ImportSortGroups = [
// Side effect imports.
// eslint-disable-next-line no-useless-escape
[`^\u0000`],
// Glimmer & Ember Dependencies
[`^(@ember/|@glimmer|ember$)`],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
// But not our packages or packages starting with ember-
// eslint-disable-next-line no-useless-escape
[`^(?!@ember\-data)(?!ember-)(@?\\w)`],
// Packages starting with ember-
// eslint-disable-next-line no-useless-escape
[`^ember\-`],
// Our Packages.
// Things that start with @ember-data
// eslint-disable-next-line no-useless-escape
[`^@skyrocketjs`],
// 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 = {
parser: 'babel-eslint',
root: true,
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['prettier', 'qunit', 'simple-import-sort', 'import'],
extends: ['eslint:recommended', 'prettier', 'plugin:qunit/recommended'],
rules: {
'prettier/prettier': 'error',
'no-unused-vars': ['error', { args: 'none' }],
'no-cond-assign': ['error', 'except-parens'],
eqeqeq: 'error',
'no-eval': 'error',
'new-cap': ['error', { capIsNew: false }],
'no-caller': 'error',
'no-eq-null': 'error',
'no-console': 'error', // no longer recommended in eslint v6, this restores it
'simple-import-sort/sort': ['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',
// Too many false positives
// See https://github.com/eslint/eslint/issues/11899 and similar
'require-atomic-updates': 'off',
// eslint-plugin-qunit
'qunit/assert-args': 'off',
'qunit/literal-compare-order': 'off',
'qunit/no-identical-names': 'off',
'qunit/no-ok-equality': 'off',
'qunit/require-expect': 'off',
'qunit/resolve-async': 'off',
},
globals: {
Map: true,
WeakMap: true,
Set: true,
Promise: true,
},
env: {
browser: false,
node: true,
},
overrides: [
// TypeScript Node files
{
files: ['packages/schema/src/**/*.ts', 'packages/compiler/src/**/*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'simple-import-sort', 'import'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended'],
rules: {
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
'no-unused-vars': 'off',
'require-atomic-updates': 'off',
'simple-import-sort/sort': ['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',
'node/no-missing-require': 'off',
},
env: {
browser: false,
node: true,
es6: true,
},
},
// JavaScript Node files
{
files: [
'.eslintrc.js',
'.prettierrc.js',
'bin/**',
'packages/ember/.ember-cli.js',
'packages/*/.eslintrc.js',
'packages/*/.template-lintrc.js',
'packages/ember/ember-cli-build.js',
'packages/*/Brocfile.js',
'packages/*/index.js',
'packages/*/testem.js',
'packages/*/blueprints/*/index.js',
'packages/ember/config/**/*.js',
'packages/ember/tests/dummy/config/**/*.js',
'packages/unpublished_*/ember-cli-build.js',
'packages/unpublished_*/.ember-cli.js',
'packages/unpublished_*/config/**/*.js',
'packages/unpublished_*/tests/dummy/config/**/*.js',
'packages/*/tests/**/*.js',
],
excludedFiles: [
'packages/ember/addon/**',
'packages/ember/app/**',
'packages/ember/tests/**',
'packages/ember/tests/dummy/app/**',
'packages/ember/tests/dummy/workers/**',
'packages/unpublished_*/addon/**',
'packages/unpublished_*/app/**',
'packages/unpublished_*/tests/**',
'packages/unpublished_*/tests/dummy/app/**',
'packages/compiler/tests/fixtures/**',
'packages/schema/tests/fixtures/**',
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2018,
},
env: {
browser: false,
node: true,
es6: true,
},
plugins: ['node', 'import'],
extends: 'plugin:node/recommended',
rules: {
'simple-import-sort/sort': 'off',
'no-restricted-globals': 'off',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'import/order': ['error', { 'newlines-between': 'always' }],
'node/no-missing-require': 'off',
},
},
// Node tests
{
files: ['packages/*/tests/**/*-test.js'],
excludedFiles: ['packages/ember/tests/**'],
env: {
qunit: true,
},
rules: {
'no-restricted-globals': 'off',
},
},
// bin files
{
files: ['bin/**'],
// eslint-disable-next-line node/no-unpublished-require
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
'no-console': 'off',
'no-process-exit': 'off',
'node/no-unpublished-require': 'off',
'node/no-unsupported-features/node-builtins': 'off',
}),
},
// Browser Typescript Files
{
files: ['packages/worker/src/**/*.ts', 'packages/service/src/**/*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'simple-import-sort', 'import'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended'],
rules: {
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
'no-unused-vars': 'off',
'require-atomic-updates': 'off',
'simple-import-sort/sort': ['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',
},
env: {
browser: true,
node: false,
es6: true,
},
},
// Browser Javascript Files
{
extends: ['eslint:recommended', 'plugin:ember/recommended'],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
env: {
browser: true,
node: false,
},
files: [
'packages/ember/addon/**',
'packages/ember/app/**',
'packages/ember/tests/**',
'packages/ember/tests/dummy/app/**',
'packages/ember/tests/dummy/workers/**',
'packages/unpublished_*/addon/**',
'packages/unpublished_*/app/**',
'packages/unpublished_*/tests/**',
'packages/unpublished_*/tests/dummy/app/**',
'packages/compiler/tests/fixtures/**/*.js',
'packages/schema/tests/fixtures/**/*.js',
],
excludedFiles: ['packages/ember/tests/dummy/config/**', 'packages/unpublished_*/tests/dummy/config/**'],
globals: {
Promise: false,
},
rules: {
'ember/no-jquery': 'error',
'no-restricted-globals': ['error', { name: 'Promise', message: 'Global Promise does not work in IE11' }],
},
},
// Worker JS files
{
files: ['**/workers/*.js'],
env: {
browser: true,
worker: true,
},
},
],
};