forked from emberjs/data
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eslintrc.js
191 lines (184 loc) · 5.81 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
// 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
[`^@ember\-data`],
// 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: 2017,
sourceType: 'module',
},
plugins: ['prettier', 'qunit', 'mocha', 'simple-import-sort', 'import'],
extends: ['eslint:recommended', 'prettier', 'plugin:qunit/recommended'],
rules: {
'no-restricted-globals': ['error', { name: 'Promise', message: 'Global Promise does not work in IE11' }],
'mocha/no-exclusive-tests': 'error',
'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: {
heimdall: true,
Map: false,
WeakMap: true,
Set: true,
Promise: false,
},
env: {
browser: true,
node: false,
},
overrides: [
// TypeScript files
{
files: ['**/*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'ember-data', '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',
'ember-data/prefer-type-only-import': 'error',
'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 files
{
files: [
'.mocharc.js',
'.eslintrc.js',
'.prettierrc.js',
'bin/**',
'packages/private-build-infra/src/**/*.js',
'packages/unpublished-test-infra/src/**/*.js',
'packages/unpublished-eslint-rules/src/**/*.js',
'packages/*/.ember-cli.js',
'packages/*/.eslintrc.js',
'packages/*/.template-lintrc.js',
'packages/*/ember-cli-build.js',
'packages/*/index.js',
'packages/*/testem.js',
'packages/*/blueprints/*/index.js',
'packages/*/config/**/*.js',
'packages/*/tests/dummy/config/**/*.js',
'packages/*/node-tests/**/*.js',
],
excludedFiles: [
'packages/*/addon/**',
'packages/*/addon-test-support/**',
'packages/*/app/**',
'packages/*/tests/dummy/app/**',
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015,
},
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 tests
{
files: ['packages/*/node-tests/**', 'packages/unpublished-test-infra/src/node-test-helpers/**/*'],
env: {
mocha: true,
},
rules: {
'no-restricted-globals': 'off',
},
},
// docs
{
files: ['packages/-ember-data/node-tests/docs/*.js'],
env: {
qunit: true,
es6: false,
},
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',
}),
},
],
};