@cany748/eslint-config 4.0.0 → 4.1.0

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +5494 -5559
  2. package/dist/index.js +1099 -1203
  3. package/package.json +31 -32
package/dist/index.js CHANGED
@@ -1,1268 +1,1164 @@
1
- // src/configs/comments.ts
2
1
  import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
2
+ import pluginPrettier from "eslint-plugin-prettier";
3
+ import configPrettier from "eslint-plugin-prettier/recommended";
4
+ import * as pluginImport from "eslint-plugin-import-x";
5
+ import globals from "globals";
6
+ import pluginUnusedImports from "eslint-plugin-unused-imports";
7
+ import pluginNode from "eslint-plugin-n";
8
+ import { configs } from "eslint-plugin-regexp";
9
+ import pluginUnicorn from "eslint-plugin-unicorn";
10
+ import { isPackageExists } from "local-pkg";
11
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
12
+
13
+ //#region src/configs/comments.ts
3
14
  function comments() {
4
- return [
5
- {
6
- name: "@eslint-community/eslint-comments",
7
- plugins: {
8
- "@eslint-community/eslint-comments": pluginComments
9
- },
10
- rules: {
11
- ...pluginComments.configs.recommended.rules,
12
- "@eslint-community/eslint-comments/disable-enable-pair": "off"
13
- }
14
- }
15
- ];
15
+ return [{
16
+ name: "@eslint-community/eslint-comments",
17
+ plugins: { "@eslint-community/eslint-comments": pluginComments },
18
+ rules: {
19
+ ...pluginComments.configs.recommended.rules,
20
+ "@eslint-community/eslint-comments/disable-enable-pair": "off"
21
+ }
22
+ }];
16
23
  }
17
24
 
18
- // src/globs.ts
19
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
20
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
21
- var GLOB_JS = "**/*.?([cm])js";
22
- var GLOB_JSX = "**/*.?([cm])jsx";
23
- var GLOB_TS = "**/*.?([cm])ts";
24
- var GLOB_TSX = "**/*.?([cm])tsx";
25
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
26
- var GLOB_CSS = "**/*.css";
27
- var GLOB_POSTCSS = "**/*.{p,post}css";
28
- var GLOB_LESS = "**/*.less";
29
- var GLOB_SCSS = "**/*.scss";
30
- var GLOB_JSON = "**/*.json";
31
- var GLOB_JSON5 = "**/*.json5";
32
- var GLOB_JSONC = "**/*.jsonc";
33
- var GLOB_MARKDOWN = "**/*.md";
34
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
35
- var GLOB_SVELTE = "**/*.svelte";
36
- var GLOB_VUE = "**/*.vue";
37
- var GLOB_YAML = "**/*.y?(a)ml";
38
- var GLOB_TOML = "**/*.toml";
39
- var GLOB_XML = "**/*.xml";
40
- var GLOB_HTML = "**/*.htm?(l)";
41
- var GLOB_ASTRO = "**/*.astro";
42
- var GLOB_ASTRO_TS = "**/*.astro/*.ts";
43
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
44
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
45
- var GLOB_TESTS = [
46
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
47
- `**/*.spec.${GLOB_SRC_EXT}`,
48
- `**/*.test.${GLOB_SRC_EXT}`,
49
- `**/*.bench.${GLOB_SRC_EXT}`,
50
- `**/*.benchmark.${GLOB_SRC_EXT}`
25
+ //#endregion
26
+ //#region src/globs.ts
27
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
28
+ const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
29
+ const GLOB_JS = "**/*.?([cm])js";
30
+ const GLOB_JSX = "**/*.?([cm])jsx";
31
+ const GLOB_TS = "**/*.?([cm])ts";
32
+ const GLOB_TSX = "**/*.?([cm])tsx";
33
+ const GLOB_STYLE = "**/*.{c,le,sc}ss";
34
+ const GLOB_CSS = "**/*.css";
35
+ const GLOB_POSTCSS = "**/*.{p,post}css";
36
+ const GLOB_LESS = "**/*.less";
37
+ const GLOB_SCSS = "**/*.scss";
38
+ const GLOB_JSON = "**/*.json";
39
+ const GLOB_JSON5 = "**/*.json5";
40
+ const GLOB_JSONC = "**/*.jsonc";
41
+ const GLOB_MARKDOWN = "**/*.md";
42
+ const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
43
+ const GLOB_SVELTE = "**/*.svelte";
44
+ const GLOB_VUE = "**/*.vue";
45
+ const GLOB_YAML = "**/*.y?(a)ml";
46
+ const GLOB_TOML = "**/*.toml";
47
+ const GLOB_XML = "**/*.xml";
48
+ const GLOB_HTML = "**/*.htm?(l)";
49
+ const GLOB_ASTRO = "**/*.astro";
50
+ const GLOB_ASTRO_TS = "**/*.astro/*.ts";
51
+ const GLOB_GRAPHQL = "**/*.{g,graph}ql";
52
+ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
53
+ const GLOB_TESTS = [
54
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
55
+ `**/*.spec.${GLOB_SRC_EXT}`,
56
+ `**/*.test.${GLOB_SRC_EXT}`,
57
+ `**/*.bench.${GLOB_SRC_EXT}`,
58
+ `**/*.benchmark.${GLOB_SRC_EXT}`
51
59
  ];
52
- var GLOB_ALL_SRC = [
53
- GLOB_SRC,
54
- GLOB_STYLE,
55
- GLOB_JSON,
56
- GLOB_JSON5,
57
- GLOB_MARKDOWN,
58
- GLOB_SVELTE,
59
- GLOB_VUE,
60
- GLOB_YAML,
61
- GLOB_XML,
62
- GLOB_HTML
60
+ const GLOB_ALL_SRC = [
61
+ GLOB_SRC,
62
+ GLOB_STYLE,
63
+ GLOB_JSON,
64
+ GLOB_JSON5,
65
+ GLOB_MARKDOWN,
66
+ GLOB_SVELTE,
67
+ GLOB_VUE,
68
+ GLOB_YAML,
69
+ GLOB_XML,
70
+ GLOB_HTML
63
71
  ];
64
- var GLOB_EXCLUDE = [
65
- "**/node_modules",
66
- "**/dist",
67
- "**/build",
68
- "**/vendor",
69
- "**/public",
70
- "**/out",
71
- "**/package-lock.json",
72
- "**/yarn.lock",
73
- "**/pnpm-lock.yaml",
74
- "**/bun.lockb",
75
- "**/output",
76
- "**/coverage",
77
- "**/temp",
78
- "**/.temp",
79
- "**/tmp",
80
- "**/.tmp",
81
- "**/.history",
82
- "**/.vitepress/cache",
83
- "**/.nuxt",
84
- "**/.next",
85
- "**/.svelte-kit",
86
- "**/.vercel",
87
- "**/.netlify",
88
- "**/.changeset",
89
- "**/.idea",
90
- "**/.cache",
91
- "**/.output",
92
- "**/.vite-inspect",
93
- "**/.yarn",
94
- "**/vite.config.*.timestamp-*",
95
- "**/CHANGELOG*.md",
96
- "**/*.min.*",
97
- "**/LICENSE*",
98
- "**/__snapshots__",
99
- "**/auto-import?(s).d.ts",
100
- "**/components.d.ts"
72
+ const GLOB_EXCLUDE = [
73
+ "**/node_modules",
74
+ "**/dist",
75
+ "**/build",
76
+ "**/vendor",
77
+ "**/public",
78
+ "**/out",
79
+ "**/package-lock.json",
80
+ "**/yarn.lock",
81
+ "**/pnpm-lock.yaml",
82
+ "**/bun.lockb",
83
+ "**/output",
84
+ "**/coverage",
85
+ "**/temp",
86
+ "**/.temp",
87
+ "**/tmp",
88
+ "**/.tmp",
89
+ "**/.history",
90
+ "**/.vitepress/cache",
91
+ "**/.nuxt",
92
+ "**/.next",
93
+ "**/.svelte-kit",
94
+ "**/.vercel",
95
+ "**/.netlify",
96
+ "**/.changeset",
97
+ "**/.idea",
98
+ "**/.cache",
99
+ "**/.output",
100
+ "**/.vite-inspect",
101
+ "**/.yarn",
102
+ "**/vite.config.*.timestamp-*",
103
+ "**/CHANGELOG*.md",
104
+ "**/*.min.*",
105
+ "**/LICENSE*",
106
+ "**/__snapshots__",
107
+ "**/auto-import?(s).d.ts",
108
+ "**/components.d.ts"
101
109
  ];
102
110
 
103
- // src/configs/disables.ts
111
+ //#endregion
112
+ //#region src/configs/disables.ts
104
113
  function disables() {
105
- return [
106
- {
107
- files: [`**/scripts/${GLOB_SRC}`],
108
- name: "disables/scripts",
109
- rules: {
110
- "no-console": "off",
111
- "@typescript-eslint/explicit-function-return-type": "off"
112
- }
113
- },
114
- {
115
- files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
116
- name: "disables/cli",
117
- rules: {
118
- "no-console": "off"
119
- }
120
- },
121
- {
122
- files: ["**/*.d.?([cm])ts"],
123
- name: "disables/dts",
124
- rules: {
125
- "@eslint-community/eslint-comments/no-unlimited-disable": "off",
126
- "import/no-duplicates": "off",
127
- "no-restricted-syntax": "off",
128
- "unused-imports/no-unused-vars": "off"
129
- }
130
- },
131
- {
132
- files: ["**/*.{test,spec}.([tj])s?(x)"],
133
- name: "disables/test",
134
- rules: {
135
- "no-unused-expressions": "off"
136
- }
137
- },
138
- {
139
- files: ["**/*.js", "**/*.cjs"],
140
- name: "disables/cjs",
141
- rules: {
142
- "@typescript-eslint/no-require-imports": "off"
143
- }
144
- },
145
- {
146
- files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
147
- name: "disables/config-files",
148
- rules: {
149
- "no-console": "off",
150
- "@typescript-eslint/explicit-function-return-type": "off"
151
- }
152
- }
153
- ];
114
+ return [
115
+ {
116
+ files: [`**/scripts/${GLOB_SRC}`],
117
+ name: "disables/scripts",
118
+ rules: {
119
+ "no-console": "off",
120
+ "@typescript-eslint/explicit-function-return-type": "off"
121
+ }
122
+ },
123
+ {
124
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
125
+ name: "disables/cli",
126
+ rules: { "no-console": "off" }
127
+ },
128
+ {
129
+ files: ["**/*.d.?([cm])ts"],
130
+ name: "disables/dts",
131
+ rules: {
132
+ "@eslint-community/eslint-comments/no-unlimited-disable": "off",
133
+ "import/no-duplicates": "off",
134
+ "no-restricted-syntax": "off",
135
+ "unused-imports/no-unused-vars": "off"
136
+ }
137
+ },
138
+ {
139
+ files: ["**/*.{test,spec}.([tj])s?(x)"],
140
+ name: "disables/test",
141
+ rules: { "no-unused-expressions": "off" }
142
+ },
143
+ {
144
+ files: ["**/*.js", "**/*.cjs"],
145
+ name: "disables/cjs",
146
+ rules: { "@typescript-eslint/no-require-imports": "off" }
147
+ },
148
+ {
149
+ files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
150
+ name: "disables/config-files",
151
+ rules: {
152
+ "no-console": "off",
153
+ "@typescript-eslint/explicit-function-return-type": "off"
154
+ }
155
+ }
156
+ ];
154
157
  }
155
158
 
156
- // src/configs/formatters.ts
157
- import pluginPrettier from "eslint-plugin-prettier";
158
- import configPrettier from "eslint-plugin-prettier/recommended";
159
-
160
- // src/utils.ts
161
- var parserPlain = {
162
- meta: {
163
- name: "parser-plain"
164
- },
165
- parseForESLint: (code) => ({
166
- ast: {
167
- body: [],
168
- comments: [],
169
- loc: { end: code.length, start: 0 },
170
- range: [0, code.length],
171
- tokens: [],
172
- type: "Program"
173
- },
174
- scopeManager: null,
175
- services: { isPlain: true },
176
- visitorKeys: {
177
- Program: []
178
- }
179
- })
159
+ //#endregion
160
+ //#region src/utils.ts
161
+ const parserPlain = {
162
+ meta: { name: "parser-plain" },
163
+ parseForESLint: (code) => ({
164
+ ast: {
165
+ body: [],
166
+ comments: [],
167
+ loc: {
168
+ end: code.length,
169
+ start: 0
170
+ },
171
+ range: [0, code.length],
172
+ tokens: [],
173
+ type: "Program"
174
+ },
175
+ scopeManager: null,
176
+ services: { isPlain: true },
177
+ visitorKeys: { Program: [] }
178
+ })
180
179
  };
181
- async function combine(...configs2) {
182
- const resolved = await Promise.all(configs2);
183
- return resolved.flat();
180
+ /**
181
+ * Combine array and non-array configs into a single array.
182
+ */
183
+ async function combine(...configs$1) {
184
+ const resolved = await Promise.all(configs$1);
185
+ return resolved.flat();
184
186
  }
185
187
  function toArray(value) {
186
- return Array.isArray(value) ? value : [value];
188
+ return Array.isArray(value) ? value : [value];
187
189
  }
188
190
  async function interopDefault(m) {
189
- const resolved = await m;
190
- return resolved.default || resolved;
191
+ const resolved = await m;
192
+ return resolved.default || resolved;
191
193
  }
192
194
  function isInGitHooksOrLintStaged() {
193
- return !!// eslint-disable-next-line no-constant-binary-expression
194
- (process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
195
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
195
196
  }
196
197
  function isInEditorEnv() {
197
- if (process.env.CI) return false;
198
- if (isInGitHooksOrLintStaged()) return false;
199
- return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
198
+ if (process.env.CI) return false;
199
+ if (isInGitHooksOrLintStaged()) return false;
200
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
200
201
  }
201
202
 
202
- // src/configs/formatters.ts
203
+ //#endregion
204
+ //#region src/configs/formatters.ts
203
205
  function formatters(options = true) {
204
- if (options === true) {
205
- options = {
206
- css: true,
207
- graphql: true,
208
- html: true,
209
- markdown: true
210
- };
211
- }
212
- const configs2 = [
213
- {
214
- name: "formatter/setup",
215
- plugins: {
216
- prettier: pluginPrettier
217
- },
218
- rules: configPrettier.rules
219
- }
220
- ];
221
- if (options.css) {
222
- configs2.push(
223
- {
224
- files: [GLOB_CSS, GLOB_POSTCSS],
225
- languageOptions: {
226
- parser: parserPlain
227
- },
228
- name: "formatter/css",
229
- rules: {
230
- "prettier/prettier": ["error", { parser: "css" }]
231
- }
232
- },
233
- {
234
- files: [GLOB_SCSS],
235
- languageOptions: {
236
- parser: parserPlain
237
- },
238
- name: "formatter/scss",
239
- rules: {
240
- "prettier/prettier": ["error", { parser: "scss" }]
241
- }
242
- },
243
- {
244
- files: [GLOB_LESS],
245
- languageOptions: {
246
- parser: parserPlain
247
- },
248
- name: "formatter/less",
249
- rules: {
250
- "prettier/prettier": ["error", { parser: "less" }]
251
- }
252
- }
253
- );
254
- }
255
- if (options.graphql) {
256
- configs2.push({
257
- files: [GLOB_GRAPHQL],
258
- languageOptions: {
259
- parser: parserPlain
260
- },
261
- name: "formatter/graphql",
262
- rules: {
263
- "prettier/prettier": ["error", { parser: "graphql" }]
264
- }
265
- });
266
- }
267
- if (options.html) {
268
- configs2.push({
269
- files: [GLOB_HTML],
270
- languageOptions: {
271
- parser: parserPlain
272
- },
273
- name: "formatter/html",
274
- rules: {
275
- "prettier/prettier": ["error", { parser: "html" }]
276
- }
277
- });
278
- }
279
- if (options.markdown) {
280
- configs2.push({
281
- files: [GLOB_MARKDOWN],
282
- languageOptions: {
283
- parser: parserPlain
284
- },
285
- name: "formatter/markdown",
286
- rules: {
287
- "prettier/prettier": ["error", { parser: "markdown" }]
288
- }
289
- });
290
- }
291
- return configs2;
206
+ if (options === true) options = {
207
+ css: true,
208
+ graphql: true,
209
+ html: true,
210
+ markdown: true
211
+ };
212
+ const configs$1 = [{
213
+ name: "formatter/setup",
214
+ plugins: { prettier: pluginPrettier },
215
+ rules: configPrettier.rules
216
+ }];
217
+ if (options.css) configs$1.push({
218
+ files: [GLOB_CSS, GLOB_POSTCSS],
219
+ languageOptions: { parser: parserPlain },
220
+ name: "formatter/css",
221
+ rules: { "prettier/prettier": ["error", { parser: "css" }] }
222
+ }, {
223
+ files: [GLOB_SCSS],
224
+ languageOptions: { parser: parserPlain },
225
+ name: "formatter/scss",
226
+ rules: { "prettier/prettier": ["error", { parser: "scss" }] }
227
+ }, {
228
+ files: [GLOB_LESS],
229
+ languageOptions: { parser: parserPlain },
230
+ name: "formatter/less",
231
+ rules: { "prettier/prettier": ["error", { parser: "less" }] }
232
+ });
233
+ if (options.graphql) configs$1.push({
234
+ files: [GLOB_GRAPHQL],
235
+ languageOptions: { parser: parserPlain },
236
+ name: "formatter/graphql",
237
+ rules: { "prettier/prettier": ["error", { parser: "graphql" }] }
238
+ });
239
+ if (options.html) configs$1.push({
240
+ files: [GLOB_HTML],
241
+ languageOptions: { parser: parserPlain },
242
+ name: "formatter/html",
243
+ rules: { "prettier/prettier": ["error", { parser: "html" }] }
244
+ });
245
+ if (options.markdown) configs$1.push({
246
+ files: [GLOB_MARKDOWN],
247
+ languageOptions: { parser: parserPlain },
248
+ name: "formatter/markdown",
249
+ rules: { "prettier/prettier": ["error", { parser: "markdown" }] }
250
+ });
251
+ return configs$1;
292
252
  }
293
253
 
294
- // src/configs/ignores.ts
254
+ //#endregion
255
+ //#region src/configs/ignores.ts
295
256
  function ignores(userIgnores = []) {
296
- return [
297
- {
298
- ignores: [...GLOB_EXCLUDE, ...userIgnores]
299
- }
300
- ];
257
+ return [{ ignores: [...GLOB_EXCLUDE, ...userIgnores] }];
301
258
  }
302
259
 
303
- // src/configs/imports.ts
304
- import * as pluginImport from "eslint-plugin-import-x";
260
+ //#endregion
261
+ //#region src/configs/imports.ts
305
262
  function imports() {
306
- return [
307
- {
308
- name: "imports",
309
- plugins: {
310
- import: pluginImport
311
- },
312
- rules: {
313
- "import/export": "error",
314
- "import/first": "error",
315
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }],
316
- "import/no-duplicates": "error",
317
- "import/no-mutable-exports": "error",
318
- "import/no-named-default": "error",
319
- "import/no-self-import": "error",
320
- "import/no-webpack-loader-syntax": "error",
321
- "import/order": "error"
322
- }
323
- }
324
- ];
263
+ return [{
264
+ name: "imports",
265
+ plugins: { import: pluginImport },
266
+ rules: {
267
+ "import/export": "error",
268
+ "import/first": "error",
269
+ "import/newline-after-import": ["error", {
270
+ considerComments: true,
271
+ count: 1
272
+ }],
273
+ "import/no-duplicates": "error",
274
+ "import/no-mutable-exports": "error",
275
+ "import/no-named-default": "error",
276
+ "import/no-self-import": "error",
277
+ "import/no-webpack-loader-syntax": "error",
278
+ "import/order": "error"
279
+ }
280
+ }];
325
281
  }
326
282
 
327
- // src/configs/javascript.ts
328
- import globals from "globals";
329
- import pluginUnusedImports from "eslint-plugin-unused-imports";
283
+ //#endregion
284
+ //#region src/configs/javascript.ts
330
285
  function javascript(options = {}) {
331
- const { isInEditor = false, overrides = {} } = options;
332
- return [
333
- {
334
- languageOptions: {
335
- ecmaVersion: 2022,
336
- globals: {
337
- ...globals.browser,
338
- ...globals.es2021,
339
- ...globals.node,
340
- document: "readonly",
341
- navigator: "readonly",
342
- window: "readonly"
343
- },
344
- parserOptions: {
345
- ecmaFeatures: {
346
- jsx: true
347
- },
348
- ecmaVersion: 2022,
349
- sourceType: "module"
350
- },
351
- sourceType: "module"
352
- },
353
- linterOptions: {
354
- reportUnusedDisableDirectives: true
355
- },
356
- name: "javascript/rules",
357
- plugins: {
358
- "unused-imports": pluginUnusedImports
359
- },
360
- rules: {
361
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
362
- "array-callback-return": "error",
363
- "block-scoped-var": "error",
364
- camelcase: [
365
- "error",
366
- { properties: "never", ignoreDestructuring: true, ignoreGlobals: true, ignoreImports: true, allow: ["^UNSAFE_"] }
367
- ],
368
- "constructor-super": "error",
369
- "default-case-last": "error",
370
- "dot-notation": ["error", { allowKeywords: true }],
371
- eqeqeq: ["error", "smart"],
372
- "for-direction": "error",
373
- "getter-return": "error",
374
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
375
- "no-alert": "error",
376
- "no-array-constructor": "error",
377
- "no-async-promise-executor": "error",
378
- "no-caller": "error",
379
- "no-case-declarations": "error",
380
- "no-class-assign": "error",
381
- "no-compare-neg-zero": "error",
382
- "no-cond-assign": ["error", "always"],
383
- "no-console": ["error", { allow: ["warn", "error"] }],
384
- "no-const-assign": "error",
385
- "no-constant-binary-expression": "error",
386
- "no-constant-condition": "error",
387
- "no-control-regex": "error",
388
- "no-debugger": "error",
389
- "no-delete-var": "error",
390
- "no-dupe-args": "error",
391
- "no-dupe-class-members": "error",
392
- "no-dupe-else-if": "error",
393
- "no-dupe-keys": "error",
394
- "no-duplicate-case": "error",
395
- "no-empty-character-class": "error",
396
- "no-empty-pattern": "error",
397
- "no-empty-static-block": "error",
398
- "no-empty": ["error", { allowEmptyCatch: true }],
399
- "no-eval": "error",
400
- "no-ex-assign": "error",
401
- "no-extend-native": "error",
402
- "no-extra-bind": "error",
403
- "no-extra-boolean-cast": "error",
404
- "no-fallthrough": "error",
405
- "no-func-assign": "error",
406
- "no-global-assign": "error",
407
- "no-implied-eval": "error",
408
- "no-import-assign": "error",
409
- "no-invalid-regexp": "error",
410
- "no-irregular-whitespace": "error",
411
- "no-iterator": "error",
412
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
413
- "no-lone-blocks": "error",
414
- "no-lonely-if": "error",
415
- "no-loss-of-precision": "error",
416
- "no-misleading-character-class": "error",
417
- "no-multi-str": "error",
418
- "no-new-func": "error",
419
- "no-new-native-nonconstructor": "error",
420
- "no-new-wrappers": "error",
421
- "no-new": "error",
422
- "no-nonoctal-decimal-escape": "error",
423
- "no-obj-calls": "error",
424
- "no-octal-escape": "error",
425
- "no-octal": "error",
426
- "no-proto": "error",
427
- "no-prototype-builtins": "error",
428
- "no-redeclare": ["error", { builtinGlobals: false }],
429
- "no-regex-spaces": "error",
430
- "no-restricted-globals": [
431
- "error",
432
- { message: "Use `globalThis` instead.", name: "global" },
433
- { message: "Use `globalThis` instead.", name: "self" }
434
- ],
435
- "no-restricted-properties": [
436
- "error",
437
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
438
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
439
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
440
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
441
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
442
- ],
443
- "no-restricted-syntax": ["error", "TSEnumDeclaration[const=true]", "TSExportAssignment"],
444
- "no-return-assign": ["error", "except-parens"],
445
- "no-self-assign": ["error", { props: true }],
446
- "no-self-compare": "error",
447
- "no-sequences": "error",
448
- "no-setter-return": "error",
449
- "no-shadow-restricted-names": "error",
450
- "no-sparse-arrays": "error",
451
- "no-template-curly-in-string": "error",
452
- "no-this-before-super": "error",
453
- "no-throw-literal": "error",
454
- "no-undef-init": "error",
455
- "no-undef": "error",
456
- "no-unexpected-multiline": "error",
457
- "no-unmodified-loop-condition": "error",
458
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
459
- "no-unreachable": "error",
460
- "no-unreachable-loop": "error",
461
- "no-unsafe-finally": "error",
462
- "no-unsafe-negation": "error",
463
- "no-unsafe-optional-chaining": "error",
464
- "no-unused-expressions": [
465
- "error",
466
- {
467
- allowShortCircuit: true,
468
- allowTaggedTemplates: true,
469
- allowTernary: true
470
- }
471
- ],
472
- "no-unused-private-class-members": "error",
473
- "no-unused-vars": "off",
474
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
475
- "no-useless-backreference": "error",
476
- "no-useless-call": "error",
477
- "no-useless-catch": "error",
478
- "no-useless-computed-key": "error",
479
- "no-useless-constructor": "error",
480
- "no-useless-escape": "error",
481
- "no-useless-rename": "error",
482
- "no-useless-return": "error",
483
- "no-var": "error",
484
- "no-void": ["error", { allowAsStatement: true }],
485
- "no-with": "error",
486
- "object-shorthand": [
487
- "error",
488
- "always",
489
- {
490
- avoidQuotes: true,
491
- ignoreConstructors: false
492
- }
493
- ],
494
- "one-var": ["error", { initialized: "never" }],
495
- "prefer-arrow-callback": [
496
- "error",
497
- {
498
- allowNamedFunctions: false,
499
- allowUnboundThis: true
500
- }
501
- ],
502
- "prefer-const": isInEditor ? "warn" : ["error", { destructuring: "all", ignoreReadBeforeAssign: true }],
503
- "prefer-exponentiation-operator": "error",
504
- "prefer-promise-reject-errors": "error",
505
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
506
- "prefer-rest-params": "error",
507
- "prefer-spread": "error",
508
- "prefer-template": "error",
509
- "require-await": "error",
510
- "require-yield": "error",
511
- "sort-imports": [
512
- "error",
513
- {
514
- allowSeparatedGroups: false,
515
- ignoreCase: false,
516
- ignoreDeclarationSort: true,
517
- ignoreMemberSort: false,
518
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
519
- }
520
- ],
521
- "symbol-description": "error",
522
- "unicode-bom": ["error", "never"],
523
- "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
524
- "unused-imports/no-unused-vars": [
525
- "error",
526
- {
527
- args: "after-used",
528
- argsIgnorePattern: "^_",
529
- ignoreRestSiblings: true,
530
- vars: "all",
531
- varsIgnorePattern: "^_"
532
- }
533
- ],
534
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
535
- "valid-typeof": ["error", { requireStringLiterals: true }],
536
- "vars-on-top": "error",
537
- yoda: ["error", "never"],
538
- ...overrides
539
- }
540
- }
541
- ];
286
+ const { isInEditor = false, overrides = {} } = options;
287
+ return [{
288
+ languageOptions: {
289
+ ecmaVersion: 2022,
290
+ globals: {
291
+ ...globals.browser,
292
+ ...globals.es2021,
293
+ ...globals.node,
294
+ document: "readonly",
295
+ navigator: "readonly",
296
+ window: "readonly"
297
+ },
298
+ parserOptions: {
299
+ ecmaFeatures: { jsx: true },
300
+ ecmaVersion: 2022,
301
+ sourceType: "module"
302
+ },
303
+ sourceType: "module"
304
+ },
305
+ linterOptions: { reportUnusedDisableDirectives: true },
306
+ name: "javascript/rules",
307
+ plugins: { "unused-imports": pluginUnusedImports },
308
+ rules: {
309
+ "accessor-pairs": ["error", {
310
+ enforceForClassMembers: true,
311
+ setWithoutGet: true
312
+ }],
313
+ "array-callback-return": "error",
314
+ "block-scoped-var": "error",
315
+ camelcase: ["error", {
316
+ properties: "never",
317
+ ignoreDestructuring: true,
318
+ ignoreGlobals: true,
319
+ ignoreImports: true,
320
+ allow: ["^UNSAFE_"]
321
+ }],
322
+ "constructor-super": "error",
323
+ "default-case-last": "error",
324
+ "dot-notation": ["error", { allowKeywords: true }],
325
+ eqeqeq: ["error", "smart"],
326
+ "for-direction": "error",
327
+ "getter-return": "error",
328
+ "new-cap": ["error", {
329
+ capIsNew: false,
330
+ newIsCap: true,
331
+ properties: true
332
+ }],
333
+ "no-alert": "error",
334
+ "no-array-constructor": "error",
335
+ "no-async-promise-executor": "error",
336
+ "no-caller": "error",
337
+ "no-case-declarations": "error",
338
+ "no-class-assign": "error",
339
+ "no-compare-neg-zero": "error",
340
+ "no-cond-assign": ["error", "always"],
341
+ "no-console": ["error", { allow: ["warn", "error"] }],
342
+ "no-const-assign": "error",
343
+ "no-constant-binary-expression": "error",
344
+ "no-constant-condition": "error",
345
+ "no-control-regex": "error",
346
+ "no-debugger": "error",
347
+ "no-delete-var": "error",
348
+ "no-dupe-args": "error",
349
+ "no-dupe-class-members": "error",
350
+ "no-dupe-else-if": "error",
351
+ "no-dupe-keys": "error",
352
+ "no-duplicate-case": "error",
353
+ "no-empty-character-class": "error",
354
+ "no-empty-pattern": "error",
355
+ "no-empty-static-block": "error",
356
+ "no-empty": ["error", { allowEmptyCatch: true }],
357
+ "no-eval": "error",
358
+ "no-ex-assign": "error",
359
+ "no-extend-native": "error",
360
+ "no-extra-bind": "error",
361
+ "no-extra-boolean-cast": "error",
362
+ "no-fallthrough": "error",
363
+ "no-func-assign": "error",
364
+ "no-global-assign": "error",
365
+ "no-implied-eval": "error",
366
+ "no-import-assign": "error",
367
+ "no-invalid-regexp": "error",
368
+ "no-irregular-whitespace": "error",
369
+ "no-iterator": "error",
370
+ "no-labels": ["error", {
371
+ allowLoop: false,
372
+ allowSwitch: false
373
+ }],
374
+ "no-lone-blocks": "error",
375
+ "no-lonely-if": "error",
376
+ "no-loss-of-precision": "error",
377
+ "no-misleading-character-class": "error",
378
+ "no-multi-str": "error",
379
+ "no-new-func": "error",
380
+ "no-new-native-nonconstructor": "error",
381
+ "no-new-wrappers": "error",
382
+ "no-new": "error",
383
+ "no-nonoctal-decimal-escape": "error",
384
+ "no-obj-calls": "error",
385
+ "no-octal-escape": "error",
386
+ "no-octal": "error",
387
+ "no-proto": "error",
388
+ "no-prototype-builtins": "error",
389
+ "no-redeclare": ["error", { builtinGlobals: false }],
390
+ "no-regex-spaces": "error",
391
+ "no-restricted-globals": [
392
+ "error",
393
+ {
394
+ message: "Use `globalThis` instead.",
395
+ name: "global"
396
+ },
397
+ {
398
+ message: "Use `globalThis` instead.",
399
+ name: "self"
400
+ }
401
+ ],
402
+ "no-restricted-properties": [
403
+ "error",
404
+ {
405
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
406
+ property: "__proto__"
407
+ },
408
+ {
409
+ message: "Use `Object.defineProperty` instead.",
410
+ property: "__defineGetter__"
411
+ },
412
+ {
413
+ message: "Use `Object.defineProperty` instead.",
414
+ property: "__defineSetter__"
415
+ },
416
+ {
417
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
418
+ property: "__lookupGetter__"
419
+ },
420
+ {
421
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
422
+ property: "__lookupSetter__"
423
+ }
424
+ ],
425
+ "no-restricted-syntax": [
426
+ "error",
427
+ "TSEnumDeclaration[const=true]",
428
+ "TSExportAssignment"
429
+ ],
430
+ "no-return-assign": ["error", "except-parens"],
431
+ "no-self-assign": ["error", { props: true }],
432
+ "no-self-compare": "error",
433
+ "no-sequences": "error",
434
+ "no-setter-return": "error",
435
+ "no-shadow-restricted-names": "error",
436
+ "no-sparse-arrays": "error",
437
+ "no-template-curly-in-string": "error",
438
+ "no-this-before-super": "error",
439
+ "no-throw-literal": "error",
440
+ "no-undef-init": "error",
441
+ "no-undef": "error",
442
+ "no-unexpected-multiline": "error",
443
+ "no-unmodified-loop-condition": "error",
444
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
445
+ "no-unreachable": "error",
446
+ "no-unreachable-loop": "error",
447
+ "no-unsafe-finally": "error",
448
+ "no-unsafe-negation": "error",
449
+ "no-unsafe-optional-chaining": "error",
450
+ "no-unused-expressions": ["error", {
451
+ allowShortCircuit: true,
452
+ allowTaggedTemplates: true,
453
+ allowTernary: true
454
+ }],
455
+ "no-unused-private-class-members": "error",
456
+ "no-unused-vars": "off",
457
+ "no-use-before-define": ["error", {
458
+ classes: false,
459
+ functions: false,
460
+ variables: true
461
+ }],
462
+ "no-useless-backreference": "error",
463
+ "no-useless-call": "error",
464
+ "no-useless-catch": "error",
465
+ "no-useless-computed-key": "error",
466
+ "no-useless-constructor": "error",
467
+ "no-useless-escape": "error",
468
+ "no-useless-rename": "error",
469
+ "no-useless-return": "error",
470
+ "no-var": "error",
471
+ "no-void": ["error", { allowAsStatement: true }],
472
+ "no-with": "error",
473
+ "object-shorthand": [
474
+ "error",
475
+ "always",
476
+ {
477
+ avoidQuotes: true,
478
+ ignoreConstructors: false
479
+ }
480
+ ],
481
+ "one-var": ["error", { initialized: "never" }],
482
+ "prefer-arrow-callback": ["error", {
483
+ allowNamedFunctions: false,
484
+ allowUnboundThis: true
485
+ }],
486
+ "prefer-const": isInEditor ? "warn" : ["error", {
487
+ destructuring: "all",
488
+ ignoreReadBeforeAssign: true
489
+ }],
490
+ "prefer-exponentiation-operator": "error",
491
+ "prefer-promise-reject-errors": "error",
492
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
493
+ "prefer-rest-params": "error",
494
+ "prefer-spread": "error",
495
+ "prefer-template": "error",
496
+ "require-await": "error",
497
+ "require-yield": "error",
498
+ "sort-imports": ["error", {
499
+ allowSeparatedGroups: false,
500
+ ignoreCase: false,
501
+ ignoreDeclarationSort: true,
502
+ ignoreMemberSort: false,
503
+ memberSyntaxSortOrder: [
504
+ "none",
505
+ "all",
506
+ "multiple",
507
+ "single"
508
+ ]
509
+ }],
510
+ "symbol-description": "error",
511
+ "unicode-bom": ["error", "never"],
512
+ "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
513
+ "unused-imports/no-unused-vars": ["error", {
514
+ args: "after-used",
515
+ argsIgnorePattern: "^_",
516
+ ignoreRestSiblings: true,
517
+ vars: "all",
518
+ varsIgnorePattern: "^_"
519
+ }],
520
+ "use-isnan": ["error", {
521
+ enforceForIndexOf: true,
522
+ enforceForSwitchCase: true
523
+ }],
524
+ "valid-typeof": ["error", { requireStringLiterals: true }],
525
+ "vars-on-top": "error",
526
+ yoda: ["error", "never"],
527
+ ...overrides
528
+ }
529
+ }];
542
530
  }
543
531
 
544
- // src/configs/jsonc.ts
532
+ //#endregion
533
+ //#region src/configs/jsonc.ts
545
534
  async function jsonc(options = {}) {
546
- const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC] } = options;
547
- const [pluginJsonc, parserJsonc] = await Promise.all([
548
- interopDefault(import("eslint-plugin-jsonc")),
549
- interopDefault(import("jsonc-eslint-parser"))
550
- ]);
551
- return [
552
- {
553
- name: "jsonc",
554
- files,
555
- languageOptions: {
556
- parser: parserJsonc
557
- },
558
- plugins: {
559
- jsonc: pluginJsonc
560
- },
561
- rules: {
562
- ...pluginJsonc.configs["recommended-with-jsonc"].rules,
563
- ...pluginJsonc.configs.prettier.rules
564
- }
565
- }
566
- ];
535
+ const { files = [
536
+ GLOB_JSON,
537
+ GLOB_JSON5,
538
+ GLOB_JSONC
539
+ ] } = options;
540
+ const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
541
+ return [{
542
+ name: "jsonc",
543
+ files,
544
+ languageOptions: { parser: parserJsonc },
545
+ plugins: { jsonc: pluginJsonc },
546
+ rules: {
547
+ ...pluginJsonc.configs["recommended-with-jsonc"].rules,
548
+ ...pluginJsonc.configs.prettier.rules
549
+ }
550
+ }];
567
551
  }
568
552
 
569
- // src/configs/node.ts
570
- import pluginNode from "eslint-plugin-n";
553
+ //#endregion
554
+ //#region src/configs/node.ts
571
555
  function node() {
572
- return [
573
- {
574
- name: "node",
575
- plugins: {
576
- n: pluginNode
577
- },
578
- rules: {
579
- "n/handle-callback-err": ["error", "^(err|error)$"],
580
- "n/no-deprecated-api": "error",
581
- "n/no-exports-assign": "error",
582
- "n/no-new-require": "error",
583
- "n/no-path-concat": "error",
584
- "n/prefer-global/buffer": ["error", "always"],
585
- "n/prefer-global/console": ["error", "always"],
586
- "n/prefer-global/process": ["error", "always"],
587
- "n/prefer-global/text-decoder": ["error", "always"],
588
- "n/prefer-global/text-encoder": ["error", "always"],
589
- "n/prefer-global/url": ["error", "always"],
590
- "n/prefer-global/url-search-params": ["error", "always"],
591
- "n/process-exit-as-throw": "error"
592
- }
593
- }
594
- ];
556
+ return [{
557
+ name: "node",
558
+ plugins: { n: pluginNode },
559
+ rules: {
560
+ "n/handle-callback-err": ["error", "^(err|error)$"],
561
+ "n/no-deprecated-api": "error",
562
+ "n/no-exports-assign": "error",
563
+ "n/no-new-require": "error",
564
+ "n/no-path-concat": "error",
565
+ "n/prefer-global/buffer": ["error", "always"],
566
+ "n/prefer-global/console": ["error", "always"],
567
+ "n/prefer-global/process": ["error", "always"],
568
+ "n/prefer-global/text-decoder": ["error", "always"],
569
+ "n/prefer-global/text-encoder": ["error", "always"],
570
+ "n/prefer-global/url": ["error", "always"],
571
+ "n/prefer-global/url-search-params": ["error", "always"],
572
+ "n/process-exit-as-throw": "error"
573
+ }
574
+ }];
595
575
  }
596
576
 
597
- // src/configs/regexp.ts
598
- import { configs } from "eslint-plugin-regexp";
577
+ //#endregion
578
+ //#region src/configs/regexp.ts
599
579
  function regexp(options = {}) {
600
- const config = configs["flat/recommended"];
601
- return [
602
- {
603
- ...config,
604
- name: "regexp",
605
- rules: {
606
- ...config.rules,
607
- "regexp/no-obscure-range": "off",
608
- ...options.overrides
609
- }
610
- }
611
- ];
580
+ const config = configs["flat/recommended"];
581
+ return [{
582
+ ...config,
583
+ name: "regexp",
584
+ rules: {
585
+ ...config.rules,
586
+ "regexp/no-obscure-range": "off",
587
+ ...options.overrides
588
+ }
589
+ }];
612
590
  }
613
591
 
614
- // src/configs/sort.ts
592
+ //#endregion
593
+ //#region src/configs/sort.ts
594
+ /**
595
+ * Sort package.json
596
+ *
597
+ * Requires `jsonc` config
598
+ */
615
599
  function sortPackageJson() {
616
- return [
617
- {
618
- files: ["**/package.json"],
619
- name: "sort/package-json",
620
- rules: {
621
- "jsonc/sort-array-values": [
622
- "error",
623
- {
624
- order: { type: "asc" },
625
- pathPattern: "^files$"
626
- }
627
- ],
628
- "jsonc/sort-keys": [
629
- "error",
630
- {
631
- order: [
632
- "publisher",
633
- "name",
634
- "displayName",
635
- "type",
636
- "version",
637
- "private",
638
- "packageManager",
639
- "description",
640
- "author",
641
- "contributors",
642
- "license",
643
- "funding",
644
- "homepage",
645
- "repository",
646
- "bugs",
647
- "keywords",
648
- "categories",
649
- "sideEffects",
650
- "exports",
651
- "main",
652
- "module",
653
- "unpkg",
654
- "jsdelivr",
655
- "types",
656
- "typesVersions",
657
- "bin",
658
- "icon",
659
- "files",
660
- "engines",
661
- "activationEvents",
662
- "contributes",
663
- "scripts",
664
- "peerDependencies",
665
- "peerDependenciesMeta",
666
- "dependencies",
667
- "optionalDependencies",
668
- "devDependencies",
669
- "pnpm",
670
- "overrides",
671
- "resolutions",
672
- "husky",
673
- "simple-git-hooks",
674
- "lint-staged",
675
- "eslintConfig",
676
- "prettier",
677
- "stylelint"
678
- ],
679
- pathPattern: "^$"
680
- },
681
- {
682
- order: { type: "asc" },
683
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
684
- },
685
- {
686
- order: { type: "asc" },
687
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
688
- },
689
- {
690
- order: ["types", "import", "require", "default"],
691
- pathPattern: "^exports.*$"
692
- },
693
- {
694
- order: [
695
- // client hooks only
696
- "pre-commit",
697
- "prepare-commit-msg",
698
- "commit-msg",
699
- "post-commit",
700
- "pre-rebase",
701
- "post-rewrite",
702
- "post-checkout",
703
- "post-merge",
704
- "pre-push",
705
- "pre-auto-gc"
706
- ],
707
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
708
- }
709
- ]
710
- }
711
- }
712
- ];
600
+ return [{
601
+ files: ["**/package.json"],
602
+ name: "sort/package-json",
603
+ rules: {
604
+ "jsonc/sort-array-values": ["error", {
605
+ order: { type: "asc" },
606
+ pathPattern: "^files$"
607
+ }],
608
+ "jsonc/sort-keys": [
609
+ "error",
610
+ {
611
+ order: [
612
+ "publisher",
613
+ "name",
614
+ "displayName",
615
+ "type",
616
+ "version",
617
+ "private",
618
+ "packageManager",
619
+ "description",
620
+ "author",
621
+ "contributors",
622
+ "license",
623
+ "funding",
624
+ "homepage",
625
+ "repository",
626
+ "bugs",
627
+ "keywords",
628
+ "categories",
629
+ "sideEffects",
630
+ "imports",
631
+ "exports",
632
+ "main",
633
+ "module",
634
+ "unpkg",
635
+ "jsdelivr",
636
+ "types",
637
+ "typesVersions",
638
+ "bin",
639
+ "icon",
640
+ "files",
641
+ "engines",
642
+ "activationEvents",
643
+ "contributes",
644
+ "scripts",
645
+ "peerDependencies",
646
+ "peerDependenciesMeta",
647
+ "dependencies",
648
+ "optionalDependencies",
649
+ "devDependencies",
650
+ "pnpm",
651
+ "overrides",
652
+ "resolutions",
653
+ "husky",
654
+ "simple-git-hooks",
655
+ "lint-staged",
656
+ "eslintConfig",
657
+ "prettier",
658
+ "stylelint"
659
+ ],
660
+ pathPattern: "^$"
661
+ },
662
+ {
663
+ order: { type: "asc" },
664
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
665
+ },
666
+ {
667
+ order: { type: "asc" },
668
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
669
+ },
670
+ {
671
+ order: [
672
+ "types",
673
+ "import",
674
+ "require",
675
+ "default"
676
+ ],
677
+ pathPattern: "^exports.*$"
678
+ },
679
+ {
680
+ order: [
681
+ "pre-commit",
682
+ "prepare-commit-msg",
683
+ "commit-msg",
684
+ "post-commit",
685
+ "pre-rebase",
686
+ "post-rewrite",
687
+ "post-checkout",
688
+ "post-merge",
689
+ "pre-push",
690
+ "pre-auto-gc"
691
+ ],
692
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
693
+ }
694
+ ]
695
+ }
696
+ }];
713
697
  }
698
+ /**
699
+ * Sort tsconfig.json
700
+ *
701
+ * Requires `jsonc` config
702
+ */
714
703
  function sortTsconfig() {
715
- return [
716
- {
717
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
718
- name: "sort/tsconfig-json",
719
- rules: {
720
- "jsonc/sort-keys": [
721
- "error",
722
- {
723
- order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
724
- pathPattern: "^$"
725
- },
726
- {
727
- order: [
728
- /* Projects */
729
- "incremental",
730
- "composite",
731
- "tsBuildInfoFile",
732
- "disableSourceOfProjectReferenceRedirect",
733
- "disableSolutionSearching",
734
- "disableReferencedProjectLoad",
735
- /* Language and Environment */
736
- "target",
737
- "jsx",
738
- "jsxFactory",
739
- "jsxFragmentFactory",
740
- "jsxImportSource",
741
- "lib",
742
- "moduleDetection",
743
- "noLib",
744
- "reactNamespace",
745
- "useDefineForClassFields",
746
- "emitDecoratorMetadata",
747
- "experimentalDecorators",
748
- "libReplacement",
749
- /* Modules */
750
- "baseUrl",
751
- "rootDir",
752
- "rootDirs",
753
- "customConditions",
754
- "module",
755
- "moduleResolution",
756
- "moduleSuffixes",
757
- "noResolve",
758
- "paths",
759
- "resolveJsonModule",
760
- "resolvePackageJsonExports",
761
- "resolvePackageJsonImports",
762
- "typeRoots",
763
- "types",
764
- "allowArbitraryExtensions",
765
- "allowImportingTsExtensions",
766
- "allowUmdGlobalAccess",
767
- /* JavaScript Support */
768
- "allowJs",
769
- "checkJs",
770
- "maxNodeModuleJsDepth",
771
- /* Type Checking */
772
- "strict",
773
- "strictBindCallApply",
774
- "strictFunctionTypes",
775
- "strictNullChecks",
776
- "strictPropertyInitialization",
777
- "allowUnreachableCode",
778
- "allowUnusedLabels",
779
- "alwaysStrict",
780
- "exactOptionalPropertyTypes",
781
- "noFallthroughCasesInSwitch",
782
- "noImplicitAny",
783
- "noImplicitOverride",
784
- "noImplicitReturns",
785
- "noImplicitThis",
786
- "noPropertyAccessFromIndexSignature",
787
- "noUncheckedIndexedAccess",
788
- "noUnusedLocals",
789
- "noUnusedParameters",
790
- "useUnknownInCatchVariables",
791
- /* Emit */
792
- "declaration",
793
- "declarationDir",
794
- "declarationMap",
795
- "downlevelIteration",
796
- "emitBOM",
797
- "emitDeclarationOnly",
798
- "importHelpers",
799
- "importsNotUsedAsValues",
800
- "inlineSourceMap",
801
- "inlineSources",
802
- "mapRoot",
803
- "newLine",
804
- "noEmit",
805
- "noEmitHelpers",
806
- "noEmitOnError",
807
- "outDir",
808
- "outFile",
809
- "preserveConstEnums",
810
- "preserveValueImports",
811
- "removeComments",
812
- "sourceMap",
813
- "sourceRoot",
814
- "stripInternal",
815
- /* Interop Constraints */
816
- "allowSyntheticDefaultImports",
817
- "esModuleInterop",
818
- "forceConsistentCasingInFileNames",
819
- "isolatedDeclarations",
820
- "isolatedModules",
821
- "preserveSymlinks",
822
- "verbatimModuleSyntax",
823
- "erasableSyntaxOnly",
824
- /* Completeness */
825
- "skipDefaultLibCheck",
826
- "skipLibCheck"
827
- ],
828
- pathPattern: "^compilerOptions$"
829
- }
830
- ]
831
- }
832
- }
833
- ];
704
+ return [{
705
+ files: ["**/[jt]sconfig.json", "**/[jt]sconfig.*.json"],
706
+ name: "sort/tsconfig-json",
707
+ rules: { "jsonc/sort-keys": [
708
+ "error",
709
+ {
710
+ order: [
711
+ "extends",
712
+ "compilerOptions",
713
+ "references",
714
+ "files",
715
+ "include",
716
+ "exclude"
717
+ ],
718
+ pathPattern: "^$"
719
+ },
720
+ {
721
+ order: [
722
+ "incremental",
723
+ "composite",
724
+ "tsBuildInfoFile",
725
+ "disableSourceOfProjectReferenceRedirect",
726
+ "disableSolutionSearching",
727
+ "disableReferencedProjectLoad",
728
+ "target",
729
+ "jsx",
730
+ "jsxFactory",
731
+ "jsxFragmentFactory",
732
+ "jsxImportSource",
733
+ "lib",
734
+ "moduleDetection",
735
+ "noLib",
736
+ "reactNamespace",
737
+ "useDefineForClassFields",
738
+ "emitDecoratorMetadata",
739
+ "experimentalDecorators",
740
+ "libReplacement",
741
+ "baseUrl",
742
+ "rootDir",
743
+ "rootDirs",
744
+ "customConditions",
745
+ "module",
746
+ "moduleResolution",
747
+ "moduleSuffixes",
748
+ "noResolve",
749
+ "paths",
750
+ "resolveJsonModule",
751
+ "resolvePackageJsonExports",
752
+ "resolvePackageJsonImports",
753
+ "typeRoots",
754
+ "types",
755
+ "allowArbitraryExtensions",
756
+ "allowImportingTsExtensions",
757
+ "allowUmdGlobalAccess",
758
+ "allowJs",
759
+ "checkJs",
760
+ "maxNodeModuleJsDepth",
761
+ "strict",
762
+ "strictBindCallApply",
763
+ "strictFunctionTypes",
764
+ "strictNullChecks",
765
+ "strictPropertyInitialization",
766
+ "allowUnreachableCode",
767
+ "allowUnusedLabels",
768
+ "alwaysStrict",
769
+ "exactOptionalPropertyTypes",
770
+ "noFallthroughCasesInSwitch",
771
+ "noImplicitAny",
772
+ "noImplicitOverride",
773
+ "noImplicitReturns",
774
+ "noImplicitThis",
775
+ "noPropertyAccessFromIndexSignature",
776
+ "noUncheckedIndexedAccess",
777
+ "noUnusedLocals",
778
+ "noUnusedParameters",
779
+ "useUnknownInCatchVariables",
780
+ "declaration",
781
+ "declarationDir",
782
+ "declarationMap",
783
+ "downlevelIteration",
784
+ "emitBOM",
785
+ "emitDeclarationOnly",
786
+ "importHelpers",
787
+ "importsNotUsedAsValues",
788
+ "inlineSourceMap",
789
+ "inlineSources",
790
+ "mapRoot",
791
+ "newLine",
792
+ "noEmit",
793
+ "noEmitHelpers",
794
+ "noEmitOnError",
795
+ "outDir",
796
+ "outFile",
797
+ "preserveConstEnums",
798
+ "preserveValueImports",
799
+ "removeComments",
800
+ "sourceMap",
801
+ "sourceRoot",
802
+ "stripInternal",
803
+ "allowSyntheticDefaultImports",
804
+ "esModuleInterop",
805
+ "forceConsistentCasingInFileNames",
806
+ "isolatedDeclarations",
807
+ "isolatedModules",
808
+ "preserveSymlinks",
809
+ "verbatimModuleSyntax",
810
+ "erasableSyntaxOnly",
811
+ "skipDefaultLibCheck",
812
+ "skipLibCheck"
813
+ ],
814
+ pathPattern: "^compilerOptions$"
815
+ }
816
+ ] }
817
+ }];
834
818
  }
835
819
 
836
- // src/configs/test.ts
837
- var _pluginTest;
820
+ //#endregion
821
+ //#region src/configs/test.ts
822
+ let _pluginTest;
838
823
  async function test(options = {}) {
839
- const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
840
- const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
841
- interopDefault(import("@vitest/eslint-plugin")),
842
- interopDefault(import("eslint-plugin-no-only-tests"))
843
- ]);
844
- _pluginTest = _pluginTest || {
845
- ...pluginVitest,
846
- rules: {
847
- ...pluginVitest.rules,
848
- ...pluginNoOnlyTests.rules
849
- }
850
- };
851
- return [
852
- {
853
- files,
854
- name: "test",
855
- plugins: {
856
- test: _pluginTest
857
- },
858
- rules: {
859
- "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
860
- "test/no-identical-title": "error",
861
- "test/no-import-node-test": "error",
862
- "test/no-only-tests": isInEditor ? "warn" : "error",
863
- "test/prefer-hooks-in-order": "error",
864
- "test/prefer-lowercase-title": "error",
865
- "no-unused-expressions": "off",
866
- "n/prefer-global/process": "off",
867
- "@typescript-eslint/explicit-function-return-type": "off",
868
- ...overrides
869
- }
870
- }
871
- ];
824
+ const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
825
+ const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
826
+ _pluginTest = _pluginTest || {
827
+ ...pluginVitest,
828
+ rules: {
829
+ ...pluginVitest.rules,
830
+ ...pluginNoOnlyTests.rules
831
+ }
832
+ };
833
+ return [{
834
+ files,
835
+ name: "test",
836
+ plugins: { test: _pluginTest },
837
+ rules: {
838
+ "test/consistent-test-it": ["error", {
839
+ fn: "it",
840
+ withinDescribe: "it"
841
+ }],
842
+ "test/no-identical-title": "error",
843
+ "test/no-import-node-test": "error",
844
+ "test/no-only-tests": isInEditor ? "warn" : "error",
845
+ "test/prefer-hooks-in-order": "error",
846
+ "test/prefer-lowercase-title": "error",
847
+ "no-unused-expressions": "off",
848
+ "n/prefer-global/process": "off",
849
+ "@typescript-eslint/explicit-function-return-type": "off",
850
+ ...overrides
851
+ }
852
+ }];
872
853
  }
873
854
 
874
- // src/configs/typescript.ts
855
+ //#endregion
856
+ //#region src/configs/typescript.ts
875
857
  async function typescript(options = {}) {
876
- const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
877
- const files = options.files ?? [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)];
878
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
879
- const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
880
- const tsconfigPath = options?.tsconfigPath;
881
- const isTypeAware = !!tsconfigPath;
882
- const [pluginTs, parserTs] = await Promise.all([
883
- interopDefault(import("@typescript-eslint/eslint-plugin")),
884
- interopDefault(import("@typescript-eslint/parser"))
885
- ]);
886
- function makeParser(typeAware, files2, ignores2) {
887
- return {
888
- files: files2,
889
- ...ignores2 ? { ignores: ignores2 } : {},
890
- languageOptions: {
891
- parser: parserTs,
892
- parserOptions: {
893
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
894
- sourceType: "module",
895
- ...typeAware ? {
896
- projectService: {
897
- allowDefaultProject: ["./*.js"],
898
- defaultProject: tsconfigPath
899
- },
900
- tsconfigRootDir: process.cwd()
901
- } : {},
902
- ...parserOptions
903
- }
904
- },
905
- name: `typescript/${typeAware ? "type-aware-parser" : "parser"}`
906
- };
907
- }
908
- return [
909
- {
910
- // Install the plugins without globs, so they can be configured separately.
911
- name: "typescript/setup",
912
- plugins: {
913
- "@typescript-eslint": pluginTs
914
- }
915
- },
916
- // assign type-aware parser for type-aware files and type-unaware parser for the rest
917
- ...isTypeAware ? [makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, files)],
918
- {
919
- files,
920
- name: "typescript/rules",
921
- rules: {
922
- ...pluginTs.configs["eslint-recommended"].overrides[0].rules,
923
- ...pluginTs.configs.strict.rules,
924
- "@typescript-eslint/consistent-type-assertions": "error",
925
- "@typescript-eslint/consistent-type-definitions": "off",
926
- "@typescript-eslint/consistent-type-imports": [
927
- "error",
928
- { disallowTypeAnnotations: false, prefer: "type-imports", fixStyle: "inline-type-imports" }
929
- ],
930
- "@typescript-eslint/method-signature-style": "error",
931
- "@typescript-eslint/no-dynamic-delete": "off",
932
- "@typescript-eslint/no-explicit-any": "off",
933
- "@typescript-eslint/no-import-type-side-effects": "error",
934
- "@typescript-eslint/no-invalid-void-type": "off",
935
- "@typescript-eslint/no-non-null-assertion": "off",
936
- "@typescript-eslint/no-require-imports": "error",
937
- "@typescript-eslint/triple-slash-reference": "off",
938
- "@typescript-eslint/unified-signatures": "off",
939
- // handled by unused-imports/no-unused-imports
940
- "@typescript-eslint/no-unused-vars": "off",
941
- "no-dupe-class-members": "off",
942
- "@typescript-eslint/no-dupe-class-members": "error",
943
- "no-invalid-this": "off",
944
- "@typescript-eslint/no-invalid-this": "error",
945
- "no-redeclare": "off",
946
- "@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
947
- "no-unused-expressions": "off",
948
- "@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true }],
949
- "no-use-before-define": "off",
950
- "@typescript-eslint/no-use-before-define": "error",
951
- ...type === "lib" ? {
952
- "@typescript-eslint/explicit-function-return-type": [
953
- "error",
954
- {
955
- allowExpressions: true,
956
- allowHigherOrderFunctions: true,
957
- allowIIFEs: true
958
- }
959
- ]
960
- } : {},
961
- ...overrides
962
- }
963
- },
964
- ...isTypeAware ? [
965
- {
966
- files: filesTypeAware,
967
- ignores: ignoresTypeAware,
968
- name: "typescript/rules-type-aware",
969
- rules: {
970
- ...tsconfigPath ? {
971
- ...pluginTs.configs["recommended-type-checked-only"].rules,
972
- "@typescript-eslint/no-confusing-void-expression": "error",
973
- "@typescript-eslint/promise-function-async": "error",
974
- "@typescript-eslint/restrict-template-expressions": "off",
975
- "@typescript-eslint/strict-boolean-expressions": "off",
976
- "dot-notation": "off",
977
- "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
978
- "no-throw-literal": "off",
979
- "@typescript-eslint/only-throw-error": "error"
980
- } : {},
981
- ...overridesTypeAware
982
- }
983
- }
984
- ] : []
985
- ];
858
+ const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
859
+ const files = options.files ?? [
860
+ GLOB_TS,
861
+ GLOB_TSX,
862
+ ...componentExts.map((ext) => `**/*.${ext}`)
863
+ ];
864
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
865
+ const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
866
+ const tsconfigPath = options?.tsconfigPath;
867
+ const isTypeAware = !!tsconfigPath;
868
+ const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
869
+ function makeParser(typeAware, files$1, ignores$1) {
870
+ return {
871
+ files: files$1,
872
+ ...ignores$1 ? { ignores: ignores$1 } : {},
873
+ languageOptions: {
874
+ parser: parserTs,
875
+ parserOptions: {
876
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
877
+ sourceType: "module",
878
+ ...typeAware ? {
879
+ projectService: {
880
+ allowDefaultProject: ["./*.js"],
881
+ defaultProject: tsconfigPath
882
+ },
883
+ tsconfigRootDir: process.cwd()
884
+ } : {},
885
+ ...parserOptions
886
+ }
887
+ },
888
+ name: `typescript/${typeAware ? "type-aware-parser" : "parser"}`
889
+ };
890
+ }
891
+ return [
892
+ {
893
+ name: "typescript/setup",
894
+ plugins: { "@typescript-eslint": pluginTs }
895
+ },
896
+ ...isTypeAware ? [makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, files)],
897
+ {
898
+ files,
899
+ name: "typescript/rules",
900
+ rules: {
901
+ ...pluginTs.configs["eslint-recommended"].overrides[0].rules,
902
+ ...pluginTs.configs.strict.rules,
903
+ "@typescript-eslint/consistent-type-assertions": "error",
904
+ "@typescript-eslint/consistent-type-definitions": "off",
905
+ "@typescript-eslint/consistent-type-imports": ["error", {
906
+ disallowTypeAnnotations: false,
907
+ prefer: "type-imports",
908
+ fixStyle: "inline-type-imports"
909
+ }],
910
+ "@typescript-eslint/method-signature-style": "error",
911
+ "@typescript-eslint/no-dynamic-delete": "off",
912
+ "@typescript-eslint/no-explicit-any": "off",
913
+ "@typescript-eslint/no-import-type-side-effects": "error",
914
+ "@typescript-eslint/no-invalid-void-type": "off",
915
+ "@typescript-eslint/no-non-null-assertion": "off",
916
+ "@typescript-eslint/no-require-imports": "error",
917
+ "@typescript-eslint/triple-slash-reference": "off",
918
+ "@typescript-eslint/unified-signatures": "off",
919
+ "@typescript-eslint/no-unused-vars": "off",
920
+ "no-dupe-class-members": "off",
921
+ "@typescript-eslint/no-dupe-class-members": "error",
922
+ "no-invalid-this": "off",
923
+ "@typescript-eslint/no-invalid-this": "error",
924
+ "no-redeclare": "off",
925
+ "@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
926
+ "no-unused-expressions": "off",
927
+ "@typescript-eslint/no-unused-expressions": ["error", {
928
+ allowShortCircuit: true,
929
+ allowTernary: true,
930
+ allowTaggedTemplates: true
931
+ }],
932
+ "no-use-before-define": "off",
933
+ "@typescript-eslint/no-use-before-define": "error",
934
+ ...type === "lib" ? { "@typescript-eslint/explicit-function-return-type": ["error", {
935
+ allowExpressions: true,
936
+ allowHigherOrderFunctions: true,
937
+ allowIIFEs: true
938
+ }] } : {},
939
+ ...overrides
940
+ }
941
+ },
942
+ ...isTypeAware ? [{
943
+ files: filesTypeAware,
944
+ ignores: ignoresTypeAware,
945
+ name: "typescript/rules-type-aware",
946
+ rules: {
947
+ ...tsconfigPath ? {
948
+ ...pluginTs.configs["recommended-type-checked-only"].rules,
949
+ "@typescript-eslint/no-confusing-void-expression": "error",
950
+ "@typescript-eslint/promise-function-async": "error",
951
+ "@typescript-eslint/restrict-template-expressions": "off",
952
+ "@typescript-eslint/strict-boolean-expressions": "off",
953
+ "dot-notation": "off",
954
+ "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
955
+ "no-throw-literal": "off",
956
+ "@typescript-eslint/only-throw-error": "error"
957
+ } : {},
958
+ ...overridesTypeAware
959
+ }
960
+ }] : []
961
+ ];
986
962
  }
987
963
 
988
- // src/configs/unicorn.ts
989
- import pluginUnicorn from "eslint-plugin-unicorn";
964
+ //#endregion
965
+ //#region src/configs/unicorn.ts
990
966
  function unicorn() {
991
- return [
992
- {
993
- name: "unicorn",
994
- plugins: {
995
- unicorn: pluginUnicorn
996
- },
997
- rules: {
998
- ...pluginUnicorn.configs["flat/recommended"].rules,
999
- "unicorn/consistent-function-scoping": "off",
1000
- "unicorn/filename-case": "off",
1001
- "unicorn/import-style": "off",
1002
- "unicorn/no-array-callback-reference": "off",
1003
- "unicorn/no-null": "off",
1004
- "unicorn/prefer-string-replace-all": "off",
1005
- "unicorn/prefer-structured-clone": "off",
1006
- "unicorn/prefer-top-level-await": "off",
1007
- "unicorn/prevent-abbreviations": "off"
1008
- }
1009
- }
1010
- ];
967
+ return [{
968
+ name: "unicorn",
969
+ plugins: { unicorn: pluginUnicorn },
970
+ rules: {
971
+ ...pluginUnicorn.configs.recommended.rules,
972
+ "unicorn/consistent-function-scoping": "off",
973
+ "unicorn/filename-case": "off",
974
+ "unicorn/import-style": "off",
975
+ "unicorn/no-array-callback-reference": "off",
976
+ "unicorn/no-null": "off",
977
+ "unicorn/prefer-string-replace-all": "off",
978
+ "unicorn/prefer-structured-clone": "off",
979
+ "unicorn/prefer-top-level-await": "off",
980
+ "unicorn/prevent-abbreviations": "off",
981
+ "unicorn/prefer-global-this": "off"
982
+ }
983
+ }];
1011
984
  }
1012
985
 
1013
- // src/configs/unocss.ts
986
+ //#endregion
987
+ //#region src/configs/unocss.ts
1014
988
  async function unocss() {
1015
- const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
1016
- return [
1017
- {
1018
- ...pluginUnoCSS.configs.flat,
1019
- name: "unocss"
1020
- }
1021
- ];
989
+ const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
990
+ return [{
991
+ ...pluginUnoCSS.configs.flat,
992
+ name: "unocss"
993
+ }];
1022
994
  }
1023
995
 
1024
- // src/configs/vue.ts
996
+ //#endregion
997
+ //#region src/configs/vue.ts
1025
998
  async function vue(options = {}) {
1026
- const { files = [GLOB_VUE], overrides = {}, vueVersion = 3 } = options;
1027
- const [pluginVue, parserVue] = await Promise.all([
1028
- interopDefault(import("eslint-plugin-vue")),
1029
- interopDefault(import("vue-eslint-parser"))
1030
- ]);
1031
- return [
1032
- {
1033
- files,
1034
- languageOptions: {
1035
- parser: parserVue,
1036
- globals: {
1037
- computed: "readonly",
1038
- defineEmits: "readonly",
1039
- defineExpose: "readonly",
1040
- defineProps: "readonly",
1041
- onMounted: "readonly",
1042
- onUnmounted: "readonly",
1043
- reactive: "readonly",
1044
- ref: "readonly",
1045
- shallowReactive: "readonly",
1046
- shallowRef: "readonly",
1047
- toRef: "readonly",
1048
- toRefs: "readonly",
1049
- watch: "readonly",
1050
- watchEffect: "readonly"
1051
- },
1052
- parserOptions: {
1053
- ecmaFeatures: {
1054
- jsx: true
1055
- },
1056
- extraFileExtensions: [".vue"],
1057
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1058
- sourceType: "module"
1059
- }
1060
- },
1061
- name: "vue",
1062
- processor: pluginVue.processors[".vue"],
1063
- plugins: {
1064
- vue: pluginVue
1065
- },
1066
- rules: {
1067
- ...pluginVue.configs.base.rules,
1068
- ...vueVersion === 2 ? {
1069
- ...pluginVue.configs["vue2-essential"].rules,
1070
- ...pluginVue.configs["vue2-strongly-recommended"].rules,
1071
- ...pluginVue.configs["vue2-recommended"].rules
1072
- } : {
1073
- ...pluginVue.configs.essential.rules,
1074
- ...pluginVue.configs["strongly-recommended"].rules,
1075
- ...pluginVue.configs.recommended.rules
1076
- },
1077
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
1078
- "vue/component-options-name-casing": ["error", "PascalCase"],
1079
- "vue/custom-event-name-casing": ["error", "camelCase"],
1080
- "vue/define-macros-order": [
1081
- "error",
1082
- {
1083
- order: ["defineOptions", "defineModel", "defineProps", "defineEmits", "defineSlots"]
1084
- }
1085
- ],
1086
- "vue/dot-notation": "error",
1087
- "vue/eqeqeq": ["error", "smart"],
1088
- "vue/html-comment-content-spacing": ["error", "always", { exceptions: ["-"] }],
1089
- "vue/no-constant-condition": "error",
1090
- "vue/no-empty-pattern": "error",
1091
- "vue/no-irregular-whitespace": "error",
1092
- "vue/no-loss-of-precision": "error",
1093
- "vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
1094
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
1095
- "vue/no-sparse-arrays": "error",
1096
- "vue/no-unused-refs": "error",
1097
- "vue/no-useless-v-bind": "error",
1098
- "vue/no-v-html": "off",
1099
- "vue/object-shorthand": ["error", "always", { avoidQuotes: true, ignoreConstructors: false }],
1100
- "vue/prefer-separate-static-class": "error",
1101
- "vue/prefer-template": "error",
1102
- "vue/padding-line-between-blocks": ["error", "always"],
1103
- "vue/component-tags-order": "off",
1104
- "@typescript-eslint/explicit-function-return-type": "off",
1105
- ...overrides
1106
- }
1107
- }
1108
- ];
999
+ const { files = [GLOB_VUE], overrides = {}, vueVersion = 3 } = options;
1000
+ const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
1001
+ return [{
1002
+ files,
1003
+ languageOptions: {
1004
+ parser: parserVue,
1005
+ globals: {
1006
+ computed: "readonly",
1007
+ defineEmits: "readonly",
1008
+ defineExpose: "readonly",
1009
+ defineProps: "readonly",
1010
+ onMounted: "readonly",
1011
+ onUnmounted: "readonly",
1012
+ reactive: "readonly",
1013
+ ref: "readonly",
1014
+ shallowReactive: "readonly",
1015
+ shallowRef: "readonly",
1016
+ toRef: "readonly",
1017
+ toRefs: "readonly",
1018
+ watch: "readonly",
1019
+ watchEffect: "readonly"
1020
+ },
1021
+ parserOptions: {
1022
+ ecmaFeatures: { jsx: true },
1023
+ extraFileExtensions: [".vue"],
1024
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1025
+ sourceType: "module"
1026
+ }
1027
+ },
1028
+ name: "vue",
1029
+ processor: pluginVue.processors[".vue"],
1030
+ plugins: { vue: pluginVue },
1031
+ rules: {
1032
+ ...pluginVue.configs.base.rules,
1033
+ ...vueVersion === 2 ? {
1034
+ ...pluginVue.configs["vue2-essential"].rules,
1035
+ ...pluginVue.configs["vue2-strongly-recommended"].rules,
1036
+ ...pluginVue.configs["vue2-recommended"].rules
1037
+ } : {
1038
+ ...pluginVue.configs.essential.rules,
1039
+ ...pluginVue.configs["strongly-recommended"].rules,
1040
+ ...pluginVue.configs.recommended.rules
1041
+ },
1042
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1043
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1044
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1045
+ "vue/define-macros-order": ["error", { order: [
1046
+ "defineOptions",
1047
+ "defineModel",
1048
+ "defineProps",
1049
+ "defineEmits",
1050
+ "defineSlots"
1051
+ ] }],
1052
+ "vue/dot-notation": "error",
1053
+ "vue/eqeqeq": ["error", "smart"],
1054
+ "vue/html-comment-content-spacing": [
1055
+ "error",
1056
+ "always",
1057
+ { exceptions: ["-"] }
1058
+ ],
1059
+ "vue/no-constant-condition": "error",
1060
+ "vue/no-empty-pattern": "error",
1061
+ "vue/no-irregular-whitespace": "error",
1062
+ "vue/no-loss-of-precision": "error",
1063
+ "vue/no-restricted-syntax": [
1064
+ "error",
1065
+ "DebuggerStatement",
1066
+ "LabeledStatement",
1067
+ "WithStatement"
1068
+ ],
1069
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1070
+ "vue/no-sparse-arrays": "error",
1071
+ "vue/no-unused-refs": "error",
1072
+ "vue/no-useless-v-bind": "error",
1073
+ "vue/no-v-html": "off",
1074
+ "vue/object-shorthand": [
1075
+ "error",
1076
+ "always",
1077
+ {
1078
+ avoidQuotes: true,
1079
+ ignoreConstructors: false
1080
+ }
1081
+ ],
1082
+ "vue/prefer-separate-static-class": "error",
1083
+ "vue/prefer-template": "error",
1084
+ "vue/padding-line-between-blocks": ["error", "always"],
1085
+ "vue/component-tags-order": "off",
1086
+ "@typescript-eslint/explicit-function-return-type": "off",
1087
+ ...overrides
1088
+ }
1089
+ }];
1109
1090
  }
1110
1091
 
1111
- // src/factory.ts
1112
- import { isPackageExists } from "local-pkg";
1113
- import { FlatConfigComposer } from "eslint-flat-config-utils";
1114
- var flatConfigProps = [
1115
- "name",
1116
- "languageOptions",
1117
- "linterOptions",
1118
- "processor",
1119
- "plugins",
1120
- "rules",
1121
- "settings"
1092
+ //#endregion
1093
+ //#region src/factory.ts
1094
+ const flatConfigProps = [
1095
+ "name",
1096
+ "languageOptions",
1097
+ "linterOptions",
1098
+ "processor",
1099
+ "plugins",
1100
+ "rules",
1101
+ "settings"
1122
1102
  ];
1123
- var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
1124
- var factoryConfig = function(options = {}, ...userConfigs) {
1125
- const {
1126
- componentExts = [],
1127
- formatters: enableFormatters = true,
1128
- gitignore: enableGitignore = true,
1129
- jsonc: enableJSONC = true,
1130
- regexp: enableRegexp = true,
1131
- test: enableTest = true,
1132
- typescript: enableTypeScript = isPackageExists("typescript"),
1133
- unocss: enableUnoCSS = isPackageExists("unocss"),
1134
- vue: enableVue = VuePackages.some((i) => isPackageExists(i))
1135
- } = options;
1136
- let isInEditor = options.isInEditor;
1137
- if (isInEditor == null) {
1138
- isInEditor = isInEditorEnv();
1139
- if (isInEditor) console.log("[@cany748/eslint-config] Detected running in editor, some rules are disabled.");
1140
- }
1141
- const configs2 = [];
1142
- if (enableGitignore) {
1143
- if (typeof enableGitignore === "boolean") {
1144
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
1145
- } else {
1146
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1147
- }
1148
- }
1149
- configs2.push(
1150
- comments(),
1151
- ignores(options.ignores),
1152
- imports(),
1153
- javascript({
1154
- isInEditor,
1155
- overrides: options.javascript?.overrides
1156
- }),
1157
- node(),
1158
- unicorn()
1159
- );
1160
- if (enableVue) {
1161
- componentExts.push("vue");
1162
- }
1163
- if (enableTypeScript) {
1164
- configs2.push(
1165
- typescript({
1166
- ...typeof enableTypeScript === "boolean" ? {} : enableTypeScript || {},
1167
- componentExts,
1168
- type: options.type
1169
- })
1170
- );
1171
- }
1172
- if (enableRegexp) {
1173
- configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1174
- }
1175
- if (enableTest) {
1176
- configs2.push(
1177
- test({
1178
- isInEditor,
1179
- overrides: typeof enableTest === "boolean" ? {} : enableTest?.overrides
1180
- })
1181
- );
1182
- }
1183
- if (enableVue) {
1184
- configs2.push(
1185
- vue({
1186
- ...typeof enableVue === "boolean" ? {} : enableVue || {},
1187
- typescript: !!enableTypeScript
1188
- })
1189
- );
1190
- }
1191
- if (enableUnoCSS) {
1192
- configs2.push(unocss());
1193
- }
1194
- if (enableJSONC) {
1195
- configs2.push(jsonc(typeof enableJSONC === "boolean" ? {} : enableJSONC), sortPackageJson(), sortTsconfig());
1196
- }
1197
- if (enableFormatters) {
1198
- configs2.push(formatters(enableFormatters));
1199
- }
1200
- configs2.push(disables());
1201
- if ("files" in options) {
1202
- throw new Error(
1203
- '[@cany748/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.'
1204
- );
1205
- }
1206
- const fusedConfig = flatConfigProps.reduce((acc, key) => {
1207
- if (key in options) acc[key] = options[key];
1208
- return acc;
1209
- }, {});
1210
- if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
1211
- let composer = new FlatConfigComposer();
1212
- composer = composer.append(...configs2, ...userConfigs);
1213
- return composer;
1214
- };
1215
- export {
1216
- GLOB_ALL_SRC,
1217
- GLOB_ASTRO,
1218
- GLOB_ASTRO_TS,
1219
- GLOB_CSS,
1220
- GLOB_EXCLUDE,
1221
- GLOB_GRAPHQL,
1222
- GLOB_HTML,
1223
- GLOB_JS,
1224
- GLOB_JSON,
1225
- GLOB_JSON5,
1226
- GLOB_JSONC,
1227
- GLOB_JSX,
1228
- GLOB_LESS,
1229
- GLOB_MARKDOWN,
1230
- GLOB_MARKDOWN_CODE,
1231
- GLOB_MARKDOWN_IN_MARKDOWN,
1232
- GLOB_POSTCSS,
1233
- GLOB_SCSS,
1234
- GLOB_SRC,
1235
- GLOB_SRC_EXT,
1236
- GLOB_STYLE,
1237
- GLOB_SVELTE,
1238
- GLOB_TESTS,
1239
- GLOB_TOML,
1240
- GLOB_TS,
1241
- GLOB_TSX,
1242
- GLOB_VUE,
1243
- GLOB_XML,
1244
- GLOB_YAML,
1245
- combine,
1246
- comments,
1247
- disables,
1248
- factoryConfig,
1249
- formatters,
1250
- ignores,
1251
- imports,
1252
- interopDefault,
1253
- isInEditorEnv,
1254
- isInGitHooksOrLintStaged,
1255
- javascript,
1256
- jsonc,
1257
- node,
1258
- parserPlain,
1259
- regexp,
1260
- sortPackageJson,
1261
- sortTsconfig,
1262
- test,
1263
- toArray,
1264
- typescript,
1265
- unicorn,
1266
- unocss,
1267
- vue
1103
+ const VuePackages = [
1104
+ "vue",
1105
+ "nuxt",
1106
+ "vitepress",
1107
+ "@slidev/cli"
1108
+ ];
1109
+ /**
1110
+ * Construct an array of ESLint flat config items.
1111
+ *
1112
+ * @param {OptionsConfig & TypedFlatConfigItem} options
1113
+ * The options for generating the ESLint configurations.
1114
+ * @param {Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]} userConfigs
1115
+ * The user configurations to be merged with the generated configurations.
1116
+ * @returns {Promise<TypedFlatConfigItem[]>}
1117
+ * The merged ESLint configurations.
1118
+ */
1119
+ const factoryConfig = function(options = {}, ...userConfigs) {
1120
+ const { componentExts = [], formatters: enableFormatters = true, gitignore: enableGitignore = true, jsonc: enableJSONC = true, regexp: enableRegexp = true, test: enableTest = true, typescript: enableTypeScript = isPackageExists("typescript"), unocss: enableUnoCSS = isPackageExists("unocss"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
1121
+ let isInEditor = options.isInEditor;
1122
+ if (isInEditor == null) {
1123
+ isInEditor = isInEditorEnv();
1124
+ if (isInEditor) console.log("[@cany748/eslint-config] Detected running in editor, some rules are disabled.");
1125
+ }
1126
+ const configs$1 = [];
1127
+ if (enableGitignore) if (typeof enableGitignore === "boolean") configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
1128
+ else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1129
+ configs$1.push(comments(), ignores(options.ignores), imports(), javascript({
1130
+ isInEditor,
1131
+ overrides: options.javascript?.overrides
1132
+ }), node(), unicorn());
1133
+ if (enableVue) componentExts.push("vue");
1134
+ if (enableTypeScript) configs$1.push(typescript({
1135
+ ...typeof enableTypeScript === "boolean" ? {} : enableTypeScript || {},
1136
+ componentExts,
1137
+ type: options.type
1138
+ }));
1139
+ if (enableRegexp) configs$1.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1140
+ if (enableTest) configs$1.push(test({
1141
+ isInEditor,
1142
+ overrides: typeof enableTest === "boolean" ? {} : enableTest?.overrides
1143
+ }));
1144
+ if (enableVue) configs$1.push(vue({
1145
+ ...typeof enableVue === "boolean" ? {} : enableVue || {},
1146
+ typescript: !!enableTypeScript
1147
+ }));
1148
+ if (enableUnoCSS) configs$1.push(unocss());
1149
+ if (enableJSONC) configs$1.push(jsonc(typeof enableJSONC === "boolean" ? {} : enableJSONC), sortPackageJson(), sortTsconfig());
1150
+ if (enableFormatters) configs$1.push(formatters(enableFormatters));
1151
+ configs$1.push(disables());
1152
+ if ("files" in options) throw new Error("[@cany748/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
1153
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
1154
+ if (key in options) acc[key] = options[key];
1155
+ return acc;
1156
+ }, {});
1157
+ if (Object.keys(fusedConfig).length > 0) configs$1.push([fusedConfig]);
1158
+ let composer = new FlatConfigComposer();
1159
+ composer = composer.append(...configs$1, ...userConfigs);
1160
+ return composer;
1268
1161
  };
1162
+
1163
+ //#endregion
1164
+ export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, combine, comments, disables, factoryConfig, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, javascript, jsonc, node, parserPlain, regexp, sortPackageJson, sortTsconfig, test, toArray, typescript, unicorn, unocss, vue };