-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy patheslint.config.mjs
More file actions
234 lines (216 loc) · 5.97 KB
/
eslint.config.mjs
File metadata and controls
234 lines (216 loc) · 5.97 KB
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
/**
* Debugging:
* https://eslint.org/docs/latest/use/configure/debug
* ----------------------------------------------------
*
* Print a file's calculated configuration
*
* bunx eslint --print-config path/to/file.js
*
* Inspecting the config
*
* bunx eslint --inspect-config
*
*/
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin';
import eslintConfigEmberBase from 'eslint-plugin-ember/configs/base';
import eslintConfigEmberRecommended from 'eslint-plugin-ember/configs/recommended';
import eslintConfigEmberGJS from 'eslint-plugin-ember/configs/recommended-gjs';
import eslintConfigEmberGTS from 'eslint-plugin-ember/configs/recommended-gts';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginQunitRecommended from 'eslint-plugin-qunit/configs/recommended';
import n from 'eslint-plugin-n';
import babelParser from '@babel/eslint-parser';
import importPlugin from 'eslint-plugin-import';
const esmParserOptions = {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
requireConfigFile: false,
babelOptions: {
plugins: [['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }]],
},
};
export default defineConfig([
/**
* Global plugins & configs
*/
{
name: 'Global plugins & configs',
extends: [
js.configs.recommended,
stylistic.configs.recommended,
eslintConfigPrettier,
eslintConfigEmberBase,
eslintConfigEmberRecommended,
eslintConfigEmberGJS,
importPlugin.flatConfigs.recommended,
],
},
/**
* Ignores must be in their own object
* https://eslint.org/docs/latest/use/configure/ignore
*/
{
name: 'Ignore files',
ignores: ['dist/', 'node_modules/', 'coverage/', '!**/.*'],
},
/**
* https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options
*/
{
name: 'Linter options',
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
/**
* Override default rules
*/
{
name: 'Override default rules',
rules: {
'import/order': [
'error',
{
groups: [],
'newlines-between': 'never',
// alphabetize: {
// order: 'asc',
// },
},
],
'import/no-unresolved': 'off',
// These import/* module-resolution rules are redundant with TypeScript/Glint
// type checking for .ts files, and are extremely expensive.
// `import/namespace` alone accounts for 63.6% of ESLint rule time (7.4s).
'import/namespace': 'off',
'import/named': 'off',
'import/default': 'off',
'@stylistic/padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: '*', next: 'multiline-block-like' },
{ blankLine: 'always', prev: 'multiline-block-like', next: '*' },
],
'@stylistic/lines-between-class-members': [
'error',
'always',
{
exceptAfterSingleLine: true,
},
],
'ember/no-array-prototype-extensions': 'error', // Prototype extensions are deprecated since Ember 5.10
'ember/no-empty-glimmer-component-classes': 'off', // It's useful to have empty components since the names are shown in devtools
'ember/no-runloop': 'off', // Run-loop isn't deprecated yet. Switching to ember-concurrency would require a lot of effort. We can use ember-lifeline as a drop-in replacement whenever run-loop becomes deprecated.
'ember/no-at-ember-render-modifiers': 'off', // We use `did-insert` & `did-update` render modifiers a lot
'ember/no-builtin-form-components': 'off', // We use `Textarea` & `Input` components a lot
},
},
/**
* JavaScript files
*/
{
name: 'JavaScript parser',
files: ['**/*.js'],
languageOptions: {
parser: babelParser,
},
},
{
name: 'JavaScript files',
files: ['**/*.{js,gjs}'],
languageOptions: {
parserOptions: esmParserOptions,
globals: {
...globals.browser,
},
},
},
/**
* TypeScript files
*/
{
name: 'TypeScript files',
files: ['**/*.{ts,gts}'],
extends: [tseslint.configs.recommended, eslintConfigEmberGTS, importPlugin.flatConfigs.typescript],
rules: {
'no-constant-condition': ['error', { checkLoops: false }],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/member-ordering': [
'error',
{
default: {
memberTypes: ['constructor', 'get', 'set', 'method'],
order: 'alphabetically',
},
},
],
'@typescript-eslint/ban-ts-comment': 'off',
},
},
/**
* Test files
*/
{
name: 'Test files',
files: ['tests/**/*-test.{js,gjs,ts,gts}'],
extends: [eslintPluginQunitRecommended],
rules: {
'qunit/no-commented-tests': 'error',
'qunit/require-expect': 'off',
'ember/no-replace-test-comments': 'error',
},
},
/**
* CJS node files
*/
{
name: 'CSJ node files',
files: [
'**/*.cjs',
'config/**/*.js',
'tests/dummy/config/**/*.js',
'testem.js',
'testem*.js',
'index.js',
'.prettierrc.js',
'.stylelintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'lib/custom-file-plugin.js',
'lib/default-meta-tags/index.js',
],
plugins: {
n,
},
languageOptions: {
sourceType: 'script',
ecmaVersion: 'latest',
globals: {
...globals.node,
},
},
},
/**
* ESM node files
*/
{
name: 'ESM node files',
files: ['**/*.mjs'],
plugins: {
n,
},
languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
parserOptions: esmParserOptions,
globals: {
...globals.node,
},
},
},
]);