@alexlit/config-eslint 84.2.0 → 84.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,379 +1,12 @@
1
- /* eslint-disable sonarjs/no-duplicate-string, import/order, no-undef */
1
+ const { FlatCompat } = require('@eslint/eslintrc');
2
2
 
3
- const { defineConfig } = require('eslint-define-config');
3
+ const { createConfig } = require('./utils/create-config');
4
4
  const { extendSpellChecker } = require('./utils/extend-spell-checker');
5
5
 
6
- const DEFAULT_PLUGINS = {
7
- /** @see [eslint-plugin-array-func](https://github.com/freaktechnik/eslint-plugin-array-func) */
8
- 'array-func': true,
6
+ const compat = new FlatCompat({
7
+ baseDirectory: __dirname,
8
+ });
9
9
 
10
- /** @see [eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat) */
11
- compat: true,
10
+ const createFlatConfig = () => [...compat.extends('./legacy.js')];
12
11
 
13
- /** @see [eslint-plugin-decorator-position](https://github.com/NullVoxPopuli/eslint-plugin-decorator-position) */
14
- 'decorator-position': true,
15
-
16
- /** @see [eslint-plugin-eslint-comments](hhttps://github.com/mysticatea/eslint-plugin-eslint-comments) */
17
- 'eslint-comments': true,
18
-
19
- /** @see [eslint-plugin-etc](https://github.com/cartant/eslint-plugin-etc) */
20
- etc: true,
21
-
22
- /** @see [eslint-plugin-ext](https://github.com/jiangfengming/eslint-plugin-ext) */
23
- ext: true,
24
-
25
- /** @see [eslint-plugin-filenames](https://github.com/selaux/eslint-plugin-filenames) */
26
- filenames: true,
27
-
28
- /**
29
- * @see [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import)
30
- * @see [eslint-import-resolver-alias](https://github.com/johvin/eslint-import-resolver-alias)
31
- */
32
- import: true,
33
-
34
- /** @see [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) */
35
- jsdoc: true,
36
-
37
- /** @see [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y) */
38
- 'jsx-a11y': true,
39
-
40
- /** @see [eslint-plugin-lit](https://github.com/43081j/eslint-plugin-lit) */
41
- lit: true,
42
-
43
- /** @see [eslint-plugin-lit-a11y](https://www.npmjs.com/package/eslint-plugin-lit-a11y) */
44
- 'lit-a11y': true,
45
-
46
- /** @see [eslint-plugin-more](https://github.com/WebbyLab/eslint-plugin-more) */
47
- more: true,
48
-
49
- /** @see [eslint-plugin-no-await-in-promise](https://github.com/hugo-vrijswijk/eslint-plugin-no-await-in-promise/) */
50
- 'no-await-in-promise': true,
51
-
52
- /** @see [eslint-plugin-no-constructor-bind](https://github.com/markalfred/eslint-plugin-no-constructor-bind) */
53
- 'no-constructor-bind': true,
54
-
55
- /** @see [eslint-plugin-no-explicit-type-exports](https://github.com/intuit/eslint-plugin-no-explicit-type-exports) */
56
- 'no-explicit-type-exports': true,
57
-
58
- /** @see [eslint-plugin-no-loops](https://github.com/buildo/eslint-plugin-no-loops) */
59
- 'no-loops': true,
60
-
61
- /** @see [eslint-plugin-no-secrets](https://github.com/nickdeis/eslint-plugin-no-secrets) */
62
- 'no-secrets': true,
63
-
64
- /** @see [eslint-plugin-no-use-extend-native](https://github.com/dustinspecker/eslint-plugin-no-use-extend-native) */
65
- 'no-use-extend-native': true,
66
-
67
- /** @see [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise) */
68
- promise: true,
69
-
70
- /** @see [eslint-plugin-regexp](https://github.com/ota-meshi/eslint-plugin-regexp) */
71
- regexp: true,
72
-
73
- /** @see [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort) */
74
- 'simple-import-sort': true,
75
-
76
- /** @see [eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs) */
77
- sonar: true,
78
-
79
- /** @see [eslint-plugin-sort-class-members](https://github.com/bryanrsmith/eslint-plugin-sort-class-members) */
80
- 'sort-class-members': true,
81
-
82
- /** @see [eslint-plugin-sort-destructure-keys](https://github.com/mthadley/eslint-plugin-sort-destructure-keys) */
83
- 'sort-destructure-keys': true,
84
-
85
- /** @see [eslint-plugin-sort-keys-fix](https://github.com/leo-buneev/eslint-plugin-sort-keys-fix) */
86
- 'sort-keys-fix': true,
87
-
88
- /** @see [eslint-plugin-spellcheck](https://github.com/aotaduy/eslint-plugin-spellcheck) */
89
- spellcheck: true,
90
-
91
- /** @see [eslint-plugin-sql](https://github.com/gajus/eslint-plugin-sql) */
92
- sql: true,
93
-
94
- /** @see [@tanstack/query](https://tanstack.com/query/v4/docs/react/eslint/eslint-plugin-query) */
95
- 'tanstack-query': true,
96
-
97
- /** @see [eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library) */
98
- 'testing-library': true,
99
-
100
- /** @see [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) */
101
- typescript: true,
102
-
103
- /** @see [eslint-plugin-typescript-sort-keys](https://github.com/infctr/eslint-plugin-typescript-sort-keys) */
104
- 'typescript-sort-keys': true,
105
-
106
- /** @see [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) */
107
- unicorn: true,
108
-
109
- /** @see [eslint-plugin-unused-imports](https://github.com/sweepline/eslint-plugin-unused-imports) */
110
- 'unused-imports': true,
111
-
112
- /** @see [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) */
113
- vitest: true,
114
-
115
- /** @see [eslint-plugin-vue](https://eslint.vuejs.org/rules/) */
116
- vue: true,
117
-
118
- /** @see [eslint-plugin-vue-i18n](https://eslint-plugin-vue-i18n.intlify.dev/) */
119
- 'vue-i18n': true,
120
-
121
- /** @see [eslint-plugin-vuejs-accessibility](https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility) */
122
- 'vuejs-accessibility': true,
123
-
124
- /** @see [eslint-plugin-wc](https://github.com/43081j/eslint-plugin-wc) */
125
- wc: true,
126
-
127
- /** @see [eslint-plugin-write-good-comments](https://github.com/kantord/eslint-plugin-write-good-comments) */
128
- 'write-good-comments': true,
129
- };
130
-
131
- const OPTIONAL_PLUGINS = {
132
- /** @see [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node) */
133
- node: false,
134
-
135
- /** @see [eslint-plugin-security](https://github.com/nodesecurity/eslint-plugin-security) */
136
- security: false,
137
- };
138
-
139
- const CODESTYLE_PLUGINS = {
140
- /** @see [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) */
141
- prettier: true,
142
- };
143
-
144
- const PLUGINS = {
145
- ...DEFAULT_PLUGINS,
146
- ...OPTIONAL_PLUGINS,
147
- ...CODESTYLE_PLUGINS,
148
- };
149
-
150
- /**
151
- * Create "extends" field
152
- *
153
- * @param {PLUGINS} plugins Enabled/disabled plugins list
154
- */
155
- const createPluginsList = (plugins = {}) => {
156
- const pluginsList = [];
157
-
158
- Object.entries({ ...PLUGINS, ...plugins })?.forEach(([name, isActive]) => {
159
- if (isActive) {
160
- pluginsList.push(require.resolve(`./plugins/${name}`));
161
- }
162
- });
163
-
164
- return pluginsList;
165
- };
166
-
167
- /**
168
- * Create eslint config
169
- *
170
- * @param {PLUGINS} plugins Enabled/disabled plugins list
171
- * @param {import('eslint-define-config').defineConfig} options Eslint options
172
- */
173
- const createConfig = (plugins = {}, options = {}) =>
174
- defineConfig({
175
- ...options,
176
-
177
- env: {
178
- browser: true,
179
- node: true,
180
-
181
- ...options.env,
182
- },
183
-
184
- extends: [
185
- /** @see [eslint-config-airbnb-base](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base) */
186
- 'airbnb-base',
187
-
188
- ...createPluginsList(plugins),
189
-
190
- ...(options.extends ?? []),
191
- ],
192
-
193
- ignorePatterns: [
194
- '.*',
195
- 'build',
196
- 'dist',
197
- 'docs',
198
- 'node_modules',
199
- 'storybook-*',
200
- 'sw.js',
201
- '!.*.js',
202
- '!.node',
203
- '!.storybook',
204
-
205
- ...(options.ignorePatterns ?? []),
206
- ],
207
-
208
- overrides: [
209
- {
210
- files: ['.*.cjs', '.*.js'],
211
-
212
- rules: {
213
- 'global-require': 'off',
214
- },
215
- },
216
- {
217
- files: ['**/store/**/*', '**/vuex/**/*', '**/pinia/**/*'],
218
-
219
- rules: {
220
- 'no-param-reassign': 'off',
221
- },
222
- },
223
-
224
- ...(options.overrides ?? []),
225
- ],
226
-
227
- parserOptions: {
228
- ecmaFeatures: { jsx: true },
229
- extraFileExtensions: ['.vue'],
230
- parser: '@typescript-eslint/parser',
231
- project: ['./tsconfig.json'],
232
-
233
- ...options.parserOptions,
234
- },
235
-
236
- root: options.root ?? true,
237
-
238
- rules: {
239
- 'class-methods-use-this': 'off',
240
- curly: 'error',
241
- 'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
242
- 'grouped-accessor-pairs': ['error', 'getBeforeSet'],
243
- indent: 'off',
244
-
245
- 'lines-around-comment': [
246
- 'warn',
247
- {
248
- afterBlockComment: false,
249
- afterLineComment: false,
250
-
251
- allowArrayEnd: true,
252
- allowArrayStart: true,
253
-
254
- allowBlockEnd: true,
255
- allowBlockStart: true,
256
-
257
- allowClassEnd: true,
258
- allowClassStart: true,
259
-
260
- allowObjectEnd: true,
261
- allowObjectStart: true,
262
-
263
- beforeBlockComment: true,
264
- beforeLineComment: false,
265
- },
266
- ],
267
-
268
- 'no-console': 'warn',
269
-
270
- 'no-implicit-coercion': 'error',
271
-
272
- 'no-param-reassign': ['error', { props: false }],
273
-
274
- 'no-restricted-exports': [
275
- 'error',
276
- {
277
- restrictedNamedExports: [
278
- 'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
279
- ],
280
- },
281
- ],
282
-
283
- 'no-restricted-imports': [
284
- 'error',
285
- {
286
- patterns: [
287
- {
288
- group: ['.', '..', '*/..'],
289
- message: 'Use absolute path instead',
290
- },
291
- ],
292
- },
293
- ],
294
-
295
- 'no-return-await': 'off',
296
-
297
- 'no-shadow': 'off',
298
-
299
- 'no-underscore-dangle': 'off',
300
-
301
- 'no-unused-vars': 'off',
302
-
303
- // delegate to eslint-plugin-unused-imports
304
- 'no-use-before-define': 'off',
305
-
306
- 'nonblock-statement-body-position': ['error', 'below'],
307
-
308
- 'padding-line-between-statements': [
309
- 'warn',
310
- // always
311
- { blankLine: 'always', next: '*', prev: 'block-like' },
312
- { blankLine: 'always', next: '*', prev: 'case' },
313
- { blankLine: 'always', next: '*', prev: 'cjs-export' },
314
- { blankLine: 'always', next: '*', prev: 'cjs-import' },
315
- { blankLine: 'always', next: '*', prev: 'class' },
316
- { blankLine: 'always', next: '*', prev: 'default' },
317
- { blankLine: 'always', next: '*', prev: 'directive' },
318
- { blankLine: 'always', next: '*', prev: 'expression' },
319
- { blankLine: 'always', next: '*', prev: 'iife' },
320
- { blankLine: 'always', next: '*', prev: 'multiline-block-like' },
321
- { blankLine: 'always', next: '*', prev: 'multiline-const' },
322
- { blankLine: 'always', next: '*', prev: 'multiline-expression' },
323
- { blankLine: 'always', next: '*', prev: 'multiline-let' },
324
- { blankLine: 'always', next: '*', prev: 'multiline-var' },
325
- { blankLine: 'always', next: '*', prev: 'singleline-const' },
326
- { blankLine: 'always', next: '*', prev: 'singleline-let' },
327
- { blankLine: 'always', next: '*', prev: 'singleline-var' },
328
- { blankLine: 'always', next: 'block-like', prev: '*' },
329
- { blankLine: 'always', next: 'cjs-export', prev: '*' },
330
- { blankLine: 'always', next: 'cjs-import', prev: '*' },
331
- { blankLine: 'always', next: 'class', prev: '*' },
332
- { blankLine: 'always', next: 'expression', prev: '*' },
333
- { blankLine: 'always', next: 'function', prev: '*' },
334
- { blankLine: 'always', next: 'iife', prev: '*' },
335
- { blankLine: 'always', next: 'multiline-block-like', prev: '*' },
336
- { blankLine: 'always', next: 'multiline-const', prev: '*' },
337
- { blankLine: 'always', next: 'multiline-expression', prev: '*' },
338
- { blankLine: 'always', next: 'multiline-let', prev: '*' },
339
- { blankLine: 'always', next: 'multiline-var', prev: '*' },
340
- { blankLine: 'always', next: 'return', prev: '*' },
341
- { blankLine: 'always', next: 'switch', prev: '*' },
342
- // any
343
- { blankLine: 'any', next: 'expression', prev: 'expression' },
344
- {
345
- blankLine: 'any',
346
- next: 'singleline-const',
347
- prev: 'singleline-const',
348
- },
349
- { blankLine: 'any', next: 'singleline-let', prev: 'singleline-let' },
350
- { blankLine: 'any', next: 'singleline-var', prev: 'singleline-var' },
351
- // never
352
- { blankLine: 'never', next: 'cjs-export', prev: 'cjs-export' },
353
- { blankLine: 'never', next: 'cjs-import', prev: 'cjs-import' },
354
- { blankLine: 'never', next: 'directive', prev: 'directive' },
355
- ],
356
-
357
- quotes: ['error', 'single'],
358
- 'require-await': 'off',
359
-
360
- 'sort-imports': [
361
- 'warn',
362
- {
363
- allowSeparatedGroups: true,
364
- ignoreCase: true,
365
- ignoreDeclarationSort: true,
366
- ignoreMemberSort: false,
367
- memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
368
- },
369
- ],
370
-
371
- 'sort-keys': 'off', // delegate to sort-keys-fix
372
-
373
- 'sort-vars': 'warn',
374
-
375
- ...options.rules,
376
- },
377
- });
378
-
379
- module.exports = { createConfig, extendSpellChecker };
12
+ module.exports = { createConfig, createFlatConfig, extendSpellChecker };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexlit/config-eslint",
3
- "version": "84.2.0",
3
+ "version": "84.3.1",
4
4
  "private": false,
5
5
  "description": "Eslint config",
6
6
  "keywords": [
@@ -37,6 +37,8 @@
37
37
  "up": "../../scripts/up.sh"
38
38
  },
39
39
  "dependencies": {
40
+ "@babel/eslint-parser": "^7.24.5",
41
+ "@eslint/eslintrc": "^3.1.0",
40
42
  "@intlify/eslint-plugin-vue-i18n": "^2.0.0",
41
43
  "@tanstack/eslint-plugin-query": "^5.35.6",
42
44
  "@typescript-eslint/eslint-plugin": "^7.9.0",
@@ -54,12 +56,12 @@
54
56
  "eslint-plugin-ext": "^0.1.0",
55
57
  "eslint-plugin-filenames": "^1.3.2",
56
58
  "eslint-plugin-import": "^2.29.1",
57
- "eslint-plugin-jsdoc": "^48.2.4",
59
+ "eslint-plugin-jsdoc": "^48.2.5",
58
60
  "eslint-plugin-jsx-a11y": "^6.8.0",
59
61
  "eslint-plugin-lit": "^1.13.0",
60
62
  "eslint-plugin-lit-a11y": "^4.1.2",
61
63
  "eslint-plugin-more": "^1.0.5",
62
- "eslint-plugin-no-await-in-promise": "^1.1.6",
64
+ "eslint-plugin-no-await-in-promise": "^2.0.0",
63
65
  "eslint-plugin-no-constructor-bind": "^2.0.4",
64
66
  "eslint-plugin-no-explicit-type-exports": "^0.12.1",
65
67
  "eslint-plugin-no-loops": "^0.3.0",
@@ -89,11 +91,11 @@
89
91
  "typescript": "^5.4.5"
90
92
  },
91
93
  "engines": {
92
- "node": ">=18"
94
+ "node": ">=18.18"
93
95
  },
94
96
  "overrides": {
95
97
  "eslint": "^8.57.0",
96
98
  "eslint-plugin-array-func": "^4.0.0",
97
99
  "eslint-plugin-vitest": "^0.5.4"
98
100
  }
99
- }
101
+ }
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- extends: ['plugin:no-await-in-promise/recommended'],
2
+ extends: ['plugin:no-await-in-promise/recommended-legacy'],
3
3
 
4
- plugins: ['eslint-plugin-no-await-in-promise'],
4
+ plugins: ['no-await-in-promise'],
5
5
  };
@@ -0,0 +1,377 @@
1
+ /* eslint-disable sonarjs/no-duplicate-string, import/order, no-undef */
2
+
3
+ const { defineConfig } = require('eslint-define-config');
4
+
5
+ const DEFAULT_PLUGINS = {
6
+ /** @see [eslint-plugin-array-func](https://github.com/freaktechnik/eslint-plugin-array-func) */
7
+ 'array-func': true,
8
+
9
+ /** @see [eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat) */
10
+ compat: true,
11
+
12
+ /** @see [eslint-plugin-decorator-position](https://github.com/NullVoxPopuli/eslint-plugin-decorator-position) */
13
+ 'decorator-position': true,
14
+
15
+ /** @see [eslint-plugin-eslint-comments](hhttps://github.com/mysticatea/eslint-plugin-eslint-comments) */
16
+ 'eslint-comments': true,
17
+
18
+ /** @see [eslint-plugin-etc](https://github.com/cartant/eslint-plugin-etc) */
19
+ etc: true,
20
+
21
+ /** @see [eslint-plugin-ext](https://github.com/jiangfengming/eslint-plugin-ext) */
22
+ ext: true,
23
+
24
+ /** @see [eslint-plugin-filenames](https://github.com/selaux/eslint-plugin-filenames) */
25
+ filenames: true,
26
+
27
+ /**
28
+ * @see [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import)
29
+ * @see [eslint-import-resolver-alias](https://github.com/johvin/eslint-import-resolver-alias)
30
+ */
31
+ import: true,
32
+
33
+ /** @see [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) */
34
+ jsdoc: true,
35
+
36
+ /** @see [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y) */
37
+ 'jsx-a11y': true,
38
+
39
+ /** @see [eslint-plugin-lit](https://github.com/43081j/eslint-plugin-lit) */
40
+ lit: true,
41
+
42
+ /** @see [eslint-plugin-lit-a11y](https://www.npmjs.com/package/eslint-plugin-lit-a11y) */
43
+ 'lit-a11y': true,
44
+
45
+ /** @see [eslint-plugin-more](https://github.com/WebbyLab/eslint-plugin-more) */
46
+ more: true,
47
+
48
+ /** @see [eslint-plugin-no-constructor-bind](https://github.com/markalfred/eslint-plugin-no-constructor-bind) */
49
+ 'no-constructor-bind': true,
50
+
51
+ /** @see [eslint-plugin-no-explicit-type-exports](https://github.com/intuit/eslint-plugin-no-explicit-type-exports) */
52
+ 'no-explicit-type-exports': true,
53
+
54
+ /** @see [eslint-plugin-no-loops](https://github.com/buildo/eslint-plugin-no-loops) */
55
+ 'no-loops': true,
56
+
57
+ /** @see [eslint-plugin-no-secrets](https://github.com/nickdeis/eslint-plugin-no-secrets) */
58
+ 'no-secrets': true,
59
+
60
+ /** @see [eslint-plugin-no-use-extend-native](https://github.com/dustinspecker/eslint-plugin-no-use-extend-native) */
61
+ 'no-use-extend-native': true,
62
+
63
+ /** @see [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise) */
64
+ promise: true,
65
+
66
+ /** @see [eslint-plugin-regexp](https://github.com/ota-meshi/eslint-plugin-regexp) */
67
+ regexp: true,
68
+
69
+ /** @see [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort) */
70
+ 'simple-import-sort': true,
71
+
72
+ /** @see [eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs) */
73
+ sonar: true,
74
+
75
+ /** @see [eslint-plugin-sort-class-members](https://github.com/bryanrsmith/eslint-plugin-sort-class-members) */
76
+ 'sort-class-members': true,
77
+
78
+ /** @see [eslint-plugin-sort-destructure-keys](https://github.com/mthadley/eslint-plugin-sort-destructure-keys) */
79
+ 'sort-destructure-keys': true,
80
+
81
+ /** @see [eslint-plugin-sort-keys-fix](https://github.com/leo-buneev/eslint-plugin-sort-keys-fix) */
82
+ 'sort-keys-fix': true,
83
+
84
+ /** @see [eslint-plugin-spellcheck](https://github.com/aotaduy/eslint-plugin-spellcheck) */
85
+ spellcheck: true,
86
+
87
+ /** @see [eslint-plugin-sql](https://github.com/gajus/eslint-plugin-sql) */
88
+ sql: true,
89
+
90
+ /** @see [@tanstack/query](https://tanstack.com/query/v4/docs/react/eslint/eslint-plugin-query) */
91
+ 'tanstack-query': true,
92
+
93
+ /** @see [eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library) */
94
+ 'testing-library': true,
95
+
96
+ /** @see [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) */
97
+ typescript: true,
98
+
99
+ /** @see [eslint-plugin-typescript-sort-keys](https://github.com/infctr/eslint-plugin-typescript-sort-keys) */
100
+ 'typescript-sort-keys': true,
101
+
102
+ /** @see [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) */
103
+ unicorn: true,
104
+
105
+ /** @see [eslint-plugin-unused-imports](https://github.com/sweepline/eslint-plugin-unused-imports) */
106
+ 'unused-imports': true,
107
+
108
+ /** @see [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) */
109
+ vitest: true,
110
+
111
+ /** @see [eslint-plugin-vue](https://eslint.vuejs.org/rules/) */
112
+ vue: true,
113
+
114
+ /** @see [eslint-plugin-vue-i18n](https://eslint-plugin-vue-i18n.intlify.dev/) */
115
+ 'vue-i18n': true,
116
+
117
+ /** @see [eslint-plugin-vuejs-accessibility](https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility) */
118
+ 'vuejs-accessibility': true,
119
+
120
+ /** @see [eslint-plugin-wc](https://github.com/43081j/eslint-plugin-wc) */
121
+ wc: true,
122
+
123
+ /** @see [eslint-plugin-write-good-comments](https://github.com/kantord/eslint-plugin-write-good-comments) */
124
+ 'write-good-comments': true,
125
+ };
126
+
127
+ const OPTIONAL_PLUGINS = {
128
+ /** @see [eslint-plugin-no-await-in-promise](https://github.com/hugo-vrijswijk/eslint-plugin-no-await-in-promise/) */
129
+ 'no-await-in-promise': false, // won't work
130
+
131
+ /** @see [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node) */
132
+ node: false,
133
+
134
+ /** @see [eslint-plugin-security](https://github.com/nodesecurity/eslint-plugin-security) */
135
+ security: false,
136
+ };
137
+
138
+ const CODESTYLE_PLUGINS = {
139
+ /** @see [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) */
140
+ prettier: true,
141
+ };
142
+
143
+ const PLUGINS = {
144
+ ...DEFAULT_PLUGINS,
145
+ ...OPTIONAL_PLUGINS,
146
+ ...CODESTYLE_PLUGINS,
147
+ };
148
+
149
+ /**
150
+ * Create "extends" field
151
+ *
152
+ * @param {PLUGINS} plugins Enabled/disabled plugins list
153
+ */
154
+ const createPluginsList = (plugins = {}) => {
155
+ const pluginsList = [];
156
+
157
+ Object.entries({ ...PLUGINS, ...plugins })?.forEach(([name, isActive]) => {
158
+ if (isActive) {
159
+ pluginsList.push(require.resolve(`../plugins/${name}`));
160
+ }
161
+ });
162
+
163
+ return pluginsList;
164
+ };
165
+
166
+ /**
167
+ * Create eslint config
168
+ *
169
+ * @param {PLUGINS} plugins Enabled/disabled plugins list
170
+ * @param {import('eslint-define-config').defineConfig} options Eslint options
171
+ */
172
+ const createConfig = (plugins = {}, options = {}) =>
173
+ defineConfig({
174
+ ...options,
175
+
176
+ env: {
177
+ browser: true,
178
+ node: true,
179
+
180
+ ...options.env,
181
+ },
182
+
183
+ extends: [
184
+ /** @see [eslint-config-airbnb-base](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base) */
185
+ 'airbnb-base',
186
+
187
+ ...createPluginsList(plugins),
188
+
189
+ ...(options.extends ?? []),
190
+ ],
191
+
192
+ ignorePatterns: [
193
+ 'build',
194
+ 'dist',
195
+ 'docs',
196
+ 'node_modules',
197
+ 'storybook-*',
198
+ 'sw.js',
199
+ '!.*.js',
200
+ '!.node',
201
+ '!.storybook',
202
+
203
+ ...(options.ignorePatterns ?? []),
204
+ ],
205
+
206
+ overrides: [
207
+ {
208
+ files: ['.*.cjs', '.*.js'],
209
+
210
+ rules: {
211
+ 'global-require': 'off',
212
+ },
213
+ },
214
+ {
215
+ files: ['**/store/**/*', '**/vuex/**/*', '**/pinia/**/*'],
216
+
217
+ rules: {
218
+ 'no-param-reassign': 'off',
219
+ },
220
+ },
221
+
222
+ ...(options.overrides ?? []),
223
+ ],
224
+
225
+ parserOptions: {
226
+ ecmaFeatures: { jsx: true },
227
+ extraFileExtensions: ['.vue'],
228
+ parser: '@typescript-eslint/parser',
229
+ project: ['./tsconfig.json'],
230
+
231
+ ...options.parserOptions,
232
+ },
233
+
234
+ root: options.root ?? true,
235
+
236
+ rules: {
237
+ 'class-methods-use-this': 'off',
238
+ curly: 'error',
239
+ 'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
240
+ 'grouped-accessor-pairs': ['error', 'getBeforeSet'],
241
+ indent: 'off',
242
+
243
+ 'lines-around-comment': [
244
+ 'warn',
245
+ {
246
+ afterBlockComment: false,
247
+ afterLineComment: false,
248
+
249
+ allowArrayEnd: true,
250
+ allowArrayStart: true,
251
+
252
+ allowBlockEnd: true,
253
+ allowBlockStart: true,
254
+
255
+ allowClassEnd: true,
256
+ allowClassStart: true,
257
+
258
+ allowObjectEnd: true,
259
+ allowObjectStart: true,
260
+
261
+ beforeBlockComment: true,
262
+ beforeLineComment: false,
263
+ },
264
+ ],
265
+
266
+ 'no-console': 'warn',
267
+
268
+ 'no-implicit-coercion': 'error',
269
+
270
+ 'no-param-reassign': ['error', { props: false }],
271
+
272
+ 'no-restricted-exports': [
273
+ 'error',
274
+ {
275
+ restrictedNamedExports: [
276
+ 'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
277
+ ],
278
+ },
279
+ ],
280
+
281
+ 'no-restricted-imports': [
282
+ 'error',
283
+ {
284
+ patterns: [
285
+ {
286
+ group: ['.', '..', '*/..'],
287
+ message: 'Use absolute path instead',
288
+ },
289
+ ],
290
+ },
291
+ ],
292
+
293
+ 'no-return-await': 'off',
294
+
295
+ 'no-shadow': 'off',
296
+
297
+ 'no-underscore-dangle': 'off',
298
+
299
+ 'no-unused-vars': 'off',
300
+
301
+ // delegate to eslint-plugin-unused-imports
302
+ 'no-use-before-define': 'off',
303
+
304
+ 'nonblock-statement-body-position': ['error', 'below'],
305
+
306
+ 'padding-line-between-statements': [
307
+ 'warn',
308
+ // always
309
+ { blankLine: 'always', next: '*', prev: 'block-like' },
310
+ { blankLine: 'always', next: '*', prev: 'case' },
311
+ { blankLine: 'always', next: '*', prev: 'cjs-export' },
312
+ { blankLine: 'always', next: '*', prev: 'cjs-import' },
313
+ { blankLine: 'always', next: '*', prev: 'class' },
314
+ { blankLine: 'always', next: '*', prev: 'default' },
315
+ { blankLine: 'always', next: '*', prev: 'directive' },
316
+ { blankLine: 'always', next: '*', prev: 'expression' },
317
+ { blankLine: 'always', next: '*', prev: 'iife' },
318
+ { blankLine: 'always', next: '*', prev: 'multiline-block-like' },
319
+ { blankLine: 'always', next: '*', prev: 'multiline-const' },
320
+ { blankLine: 'always', next: '*', prev: 'multiline-expression' },
321
+ { blankLine: 'always', next: '*', prev: 'multiline-let' },
322
+ { blankLine: 'always', next: '*', prev: 'multiline-var' },
323
+ { blankLine: 'always', next: '*', prev: 'singleline-const' },
324
+ { blankLine: 'always', next: '*', prev: 'singleline-let' },
325
+ { blankLine: 'always', next: '*', prev: 'singleline-var' },
326
+ { blankLine: 'always', next: 'block-like', prev: '*' },
327
+ { blankLine: 'always', next: 'cjs-export', prev: '*' },
328
+ { blankLine: 'always', next: 'cjs-import', prev: '*' },
329
+ { blankLine: 'always', next: 'class', prev: '*' },
330
+ { blankLine: 'always', next: 'expression', prev: '*' },
331
+ { blankLine: 'always', next: 'function', prev: '*' },
332
+ { blankLine: 'always', next: 'iife', prev: '*' },
333
+ { blankLine: 'always', next: 'multiline-block-like', prev: '*' },
334
+ { blankLine: 'always', next: 'multiline-const', prev: '*' },
335
+ { blankLine: 'always', next: 'multiline-expression', prev: '*' },
336
+ { blankLine: 'always', next: 'multiline-let', prev: '*' },
337
+ { blankLine: 'always', next: 'multiline-var', prev: '*' },
338
+ { blankLine: 'always', next: 'return', prev: '*' },
339
+ { blankLine: 'always', next: 'switch', prev: '*' },
340
+ // any
341
+ { blankLine: 'any', next: 'expression', prev: 'expression' },
342
+ {
343
+ blankLine: 'any',
344
+ next: 'singleline-const',
345
+ prev: 'singleline-const',
346
+ },
347
+ { blankLine: 'any', next: 'singleline-let', prev: 'singleline-let' },
348
+ { blankLine: 'any', next: 'singleline-var', prev: 'singleline-var' },
349
+ // never
350
+ { blankLine: 'never', next: 'cjs-export', prev: 'cjs-export' },
351
+ { blankLine: 'never', next: 'cjs-import', prev: 'cjs-import' },
352
+ { blankLine: 'never', next: 'directive', prev: 'directive' },
353
+ ],
354
+
355
+ quotes: ['error', 'single'],
356
+ 'require-await': 'off',
357
+
358
+ 'sort-imports': [
359
+ 'warn',
360
+ {
361
+ allowSeparatedGroups: true,
362
+ ignoreCase: true,
363
+ ignoreDeclarationSort: true,
364
+ ignoreMemberSort: false,
365
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
366
+ },
367
+ ],
368
+
369
+ 'sort-keys': 'off', // delegate to sort-keys-fix
370
+
371
+ 'sort-vars': 'warn',
372
+
373
+ ...options.rules,
374
+ },
375
+ });
376
+
377
+ module.exports = { createConfig };