@ghettoddos/eslint-config 1.3.0 → 1.4.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 +7520 -7650
  2. package/dist/index.js +1626 -1980
  3. package/package.json +30 -20
package/dist/index.js CHANGED
@@ -1,2078 +1,1724 @@
1
- // src/factory.ts
2
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
3
- import { isPackageExists as isPackageExists3 } from "local-pkg";
4
-
5
- // src/plugins.ts
6
- import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
7
- import { default as default3 } from "eslint-plugin-antfu";
2
+ import { isPackageExists } from "local-pkg";
3
+ import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
4
+ import pluginAntfu from "eslint-plugin-antfu";
8
5
  import * as pluginImport from "eslint-plugin-import-x";
9
- import { default as default4 } from "eslint-plugin-n";
10
- import { default as default5 } from "eslint-plugin-perfectionist";
11
- import { default as default6 } from "eslint-plugin-unicorn";
12
- import { default as default7 } from "eslint-plugin-unused-imports";
6
+ import pluginNode from "eslint-plugin-n";
7
+ import pluginPerfectionist from "eslint-plugin-perfectionist";
8
+ import pluginUnicorn from "eslint-plugin-unicorn";
9
+ import pluginUnusedImports from "eslint-plugin-unused-imports";
10
+ import process from "node:process";
11
+ import { fileURLToPath } from "node:url";
12
+ import globals from "globals";
13
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
14
+ import { configs } from "eslint-plugin-regexp";
13
15
 
14
- // src/configs/comments.ts
16
+ //#region src/configs/comments.ts
15
17
  async function comments() {
16
- return [
17
- {
18
- name: "eslint-comments/rules",
19
- plugins: {
20
- "eslint-comments": default2
21
- },
22
- rules: {
23
- "eslint-comments/no-aggregating-enable": "error",
24
- "eslint-comments/no-duplicate-disable": "error",
25
- "eslint-comments/no-unlimited-disable": "error",
26
- "eslint-comments/no-unused-enable": "error"
27
- }
28
- }
29
- ];
18
+ return [{
19
+ name: "eslint-comments/rules",
20
+ plugins: { "eslint-comments": pluginComments },
21
+ rules: {
22
+ "eslint-comments/no-aggregating-enable": "error",
23
+ "eslint-comments/no-duplicate-disable": "error",
24
+ "eslint-comments/no-unlimited-disable": "error",
25
+ "eslint-comments/no-unused-enable": "error"
26
+ }
27
+ }];
30
28
  }
31
29
 
32
- // src/globs.ts
33
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
34
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
35
- var GLOB_JS = "**/*.?([cm])js";
36
- var GLOB_JSX = "**/*.?([cm])jsx";
37
- var GLOB_TS = "**/*.?([cm])ts";
38
- var GLOB_TSX = "**/*.?([cm])tsx";
39
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
40
- var GLOB_CSS = "**/*.css";
41
- var GLOB_POSTCSS = "**/*.{p,post}css";
42
- var GLOB_SCSS = "**/*.scss";
43
- var GLOB_JSON = "**/*.json";
44
- var GLOB_JSON5 = "**/*.json5";
45
- var GLOB_JSONC = "**/*.jsonc";
46
- var GLOB_MARKDOWN = "**/*.md";
47
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
48
- var GLOB_YAML = "**/*.y?(a)ml";
49
- var GLOB_TOML = "**/*.toml";
50
- var GLOB_XML = "**/*.xml";
51
- var GLOB_SVG = "**/*.svg";
52
- var GLOB_HTML = "**/*.htm?(l)";
53
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
54
- var GLOB_ALL_SRC = [
55
- GLOB_SRC,
56
- GLOB_STYLE,
57
- GLOB_JSON,
58
- GLOB_JSON5,
59
- GLOB_MARKDOWN,
60
- GLOB_YAML,
61
- GLOB_XML,
62
- GLOB_HTML
30
+ //#endregion
31
+ //#region src/globs.ts
32
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
33
+ const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
34
+ const GLOB_JS = "**/*.?([cm])js";
35
+ const GLOB_JSX = "**/*.?([cm])jsx";
36
+ const GLOB_TS = "**/*.?([cm])ts";
37
+ const GLOB_TSX = "**/*.?([cm])tsx";
38
+ const GLOB_STYLE = "**/*.{c,le,sc}ss";
39
+ const GLOB_CSS = "**/*.css";
40
+ const GLOB_POSTCSS = "**/*.{p,post}css";
41
+ const GLOB_SCSS = "**/*.scss";
42
+ const GLOB_JSON = "**/*.json";
43
+ const GLOB_JSON5 = "**/*.json5";
44
+ const GLOB_JSONC = "**/*.jsonc";
45
+ const GLOB_MARKDOWN = "**/*.md";
46
+ const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
47
+ const GLOB_YAML = "**/*.y?(a)ml";
48
+ const GLOB_TOML = "**/*.toml";
49
+ const GLOB_XML = "**/*.xml";
50
+ const GLOB_SVG = "**/*.svg";
51
+ const GLOB_HTML = "**/*.htm?(l)";
52
+ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
53
+ const GLOB_ALL_SRC = [
54
+ GLOB_SRC,
55
+ GLOB_STYLE,
56
+ GLOB_JSON,
57
+ GLOB_JSON5,
58
+ GLOB_MARKDOWN,
59
+ GLOB_YAML,
60
+ GLOB_XML,
61
+ GLOB_HTML
63
62
  ];
64
- var GLOB_EXCLUDE = [
65
- "**/node_modules",
66
- "**/dist",
67
- "**/package-lock.json",
68
- "**/yarn.lock",
69
- "**/pnpm-lock.yaml",
70
- "**/bun.lockb",
71
- "**/output",
72
- "**/coverage",
73
- "**/temp",
74
- "**/.temp",
75
- "**/tmp",
76
- "**/.tmp",
77
- "**/.history",
78
- "**/.vitepress/cache",
79
- "**/.nuxt",
80
- "**/.next",
81
- "**/.svelte-kit",
82
- "**/.vercel",
83
- "**/.changeset",
84
- "**/.idea",
85
- "**/.cache",
86
- "**/.output",
87
- "**/.vite-inspect",
88
- "**/.yarn",
89
- "**/vite.config.*.timestamp-*",
90
- "**/CHANGELOG*.md",
91
- "**/*.min.*",
92
- "**/LICENSE*",
93
- "**/__snapshots__",
94
- "**/auto-import?(s).d.ts",
95
- "**/components.d.ts"
63
+ const GLOB_EXCLUDE = [
64
+ "**/node_modules",
65
+ "**/dist",
66
+ "**/package-lock.json",
67
+ "**/yarn.lock",
68
+ "**/pnpm-lock.yaml",
69
+ "**/bun.lockb",
70
+ "**/output",
71
+ "**/coverage",
72
+ "**/temp",
73
+ "**/.temp",
74
+ "**/tmp",
75
+ "**/.tmp",
76
+ "**/.history",
77
+ "**/.vitepress/cache",
78
+ "**/.nuxt",
79
+ "**/.next",
80
+ "**/.svelte-kit",
81
+ "**/.vercel",
82
+ "**/.changeset",
83
+ "**/.idea",
84
+ "**/.cache",
85
+ "**/.output",
86
+ "**/.vite-inspect",
87
+ "**/.yarn",
88
+ "**/vite.config.*.timestamp-*",
89
+ "**/CHANGELOG*.md",
90
+ "**/*.min.*",
91
+ "**/LICENSE*",
92
+ "**/__snapshots__",
93
+ "**/auto-import?(s).d.ts",
94
+ "**/components.d.ts"
96
95
  ];
97
96
 
98
- // src/configs/disables.ts
97
+ //#endregion
98
+ //#region src/configs/disables.ts
99
99
  async function disables() {
100
- return [
101
- {
102
- files: [`**/scripts/${GLOB_SRC}`],
103
- name: "disables/scripts",
104
- rules: {
105
- "antfu/no-top-level-await": "off",
106
- "no-console": "off",
107
- "ts/explicit-function-return-type": "off"
108
- }
109
- },
110
- {
111
- files: ["**/*.d.?([cm])ts"],
112
- name: "disables/dts",
113
- rules: {
114
- "eslint-comments/no-unlimited-disable": "off",
115
- "import/no-duplicates": "off",
116
- "no-restricted-syntax": "off",
117
- "unused-imports/no-unused-vars": "off"
118
- }
119
- },
120
- {
121
- files: ["**/*.js", "**/*.cjs"],
122
- name: "disables/cjs",
123
- rules: {
124
- "ts/no-require-imports": "off"
125
- }
126
- }
127
- ];
100
+ return [
101
+ {
102
+ files: [`**/scripts/${GLOB_SRC}`],
103
+ name: "disables/scripts",
104
+ rules: {
105
+ "antfu/no-top-level-await": "off",
106
+ "no-console": "off",
107
+ "ts/explicit-function-return-type": "off"
108
+ }
109
+ },
110
+ {
111
+ files: ["**/*.d.?([cm])ts"],
112
+ name: "disables/dts",
113
+ rules: {
114
+ "eslint-comments/no-unlimited-disable": "off",
115
+ "import/no-duplicates": "off",
116
+ "no-restricted-syntax": "off",
117
+ "unused-imports/no-unused-vars": "off"
118
+ }
119
+ },
120
+ {
121
+ files: ["**/*.js", "**/*.cjs"],
122
+ name: "disables/cjs",
123
+ rules: { "ts/no-require-imports": "off" }
124
+ }
125
+ ];
128
126
  }
129
127
 
130
- // src/utils.ts
131
- import process from "node:process";
132
- import { fileURLToPath } from "node:url";
133
- import { isPackageExists } from "local-pkg";
134
- var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
135
- var isCwdInScope = isPackageExists("@ghettoddos/eslint-config");
136
- var parserPlain = {
137
- meta: {
138
- name: "parser-plain"
139
- },
140
- parseForESLint: (code) => ({
141
- ast: {
142
- body: [],
143
- comments: [],
144
- loc: { end: code.length, start: 0 },
145
- range: [0, code.length],
146
- tokens: [],
147
- type: "Program"
148
- },
149
- scopeManager: null,
150
- services: { isPlain: true },
151
- visitorKeys: {
152
- Program: []
153
- }
154
- })
128
+ //#endregion
129
+ //#region src/utils.ts
130
+ const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
131
+ const isCwdInScope = isPackageExists("@ghettoddos/eslint-config");
132
+ const parserPlain = {
133
+ meta: { name: "parser-plain" },
134
+ parseForESLint: (code) => ({
135
+ ast: {
136
+ body: [],
137
+ comments: [],
138
+ loc: {
139
+ end: code.length,
140
+ start: 0
141
+ },
142
+ range: [0, code.length],
143
+ tokens: [],
144
+ type: "Program"
145
+ },
146
+ scopeManager: null,
147
+ services: { isPlain: true },
148
+ visitorKeys: { Program: [] }
149
+ })
155
150
  };
156
- async function combine(...configs2) {
157
- const resolved = await Promise.all(configs2);
158
- return resolved.flat();
151
+ /**
152
+ * Combine array and non-array configs into a single array.
153
+ */
154
+ async function combine(...configs$1) {
155
+ const resolved = await Promise.all(configs$1);
156
+ return resolved.flat();
159
157
  }
158
+ /**
159
+ * Rename plugin prefixes in a rule object.
160
+ * Accepts a map of prefixes to rename.
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * import { renameRules } from '@ghettoddos/eslint-config'
165
+ *
166
+ * export default [{
167
+ * rules: renameRules(
168
+ * {
169
+ * '@typescript-eslint/indent': 'error'
170
+ * },
171
+ * { '@typescript-eslint': 'ts' }
172
+ * )
173
+ * }]
174
+ * ```
175
+ */
160
176
  function renameRules(rules, map) {
161
- return Object.fromEntries(
162
- Object.entries(rules).map(([key, value]) => {
163
- for (const [from, to] of Object.entries(map)) {
164
- if (key.startsWith(`${from}/`)) {
165
- return [to + key.slice(from.length), value];
166
- }
167
- }
168
- return [key, value];
169
- })
170
- );
177
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
178
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
179
+ return [key, value];
180
+ }));
171
181
  }
172
182
  async function interopDefault(m) {
173
- const resolved = await m;
174
- return resolved.default || resolved;
183
+ const resolved = await m;
184
+ return resolved.default || resolved;
175
185
  }
176
186
  function isPackageInScope(name) {
177
- return isPackageExists(name, { paths: [scopeUrl] });
187
+ return isPackageExists(name, { paths: [scopeUrl] });
178
188
  }
179
189
  async function ensurePackages(packages) {
180
- if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) {
181
- return;
182
- }
183
- const nonExistingPackages = packages.filter(
184
- (i) => i && !isPackageInScope(i)
185
- );
186
- if (nonExistingPackages.length === 0) {
187
- return;
188
- }
189
- const p = await import("@clack/prompts");
190
- const result = await p.confirm({
191
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(
192
- ", "
193
- )}. Do you want to install them?`
194
- });
195
- if (result) {
196
- await import("@antfu/install-pkg").then(
197
- (i) => i.installPackage(nonExistingPackages, { dev: true })
198
- );
199
- }
190
+ if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) return;
191
+ const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
192
+ if (nonExistingPackages.length === 0) return;
193
+ const p = await import("@clack/prompts");
194
+ const result = await p.confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
195
+ if (result) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
200
196
  }
201
197
  function isInEditorEnv() {
202
- if (process.env.CI) {
203
- return false;
204
- }
205
- if (isInGitHooksOrLintStaged()) {
206
- return false;
207
- }
208
- 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);
209
201
  }
210
202
  function isInGitHooksOrLintStaged() {
211
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
203
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
212
204
  }
213
205
 
214
- // src/configs/stylistic.ts
215
- var StylisticConfigDefaults = {
216
- indent: 2,
217
- jsx: true,
218
- quotes: "single",
219
- semi: false
206
+ //#endregion
207
+ //#region src/configs/stylistic.ts
208
+ const StylisticConfigDefaults = {
209
+ indent: 2,
210
+ jsx: true,
211
+ quotes: "single",
212
+ semi: false
220
213
  };
221
214
  async function stylistic(options = {}) {
222
- const {
223
- indent,
224
- jsx: jsx2,
225
- overrides = {},
226
- quotes,
227
- semi
228
- } = {
229
- ...StylisticConfigDefaults,
230
- ...options
231
- };
232
- const pluginStylistic = await interopDefault(
233
- import("@stylistic/eslint-plugin")
234
- );
235
- const config2 = pluginStylistic.configs.customize({
236
- indent,
237
- jsx: jsx2,
238
- pluginName: "style",
239
- quotes,
240
- semi
241
- });
242
- return [
243
- {
244
- name: "stylistic/rules",
245
- plugins: {
246
- antfu: default3,
247
- style: pluginStylistic
248
- },
249
- rules: {
250
- ...config2.rules,
251
- "antfu/consistent-chaining": "error",
252
- "antfu/consistent-list-newline": "error",
253
- "antfu/curly": "error",
254
- "antfu/if-newline": "error",
255
- "antfu/top-level-function": "error",
256
- "style/generator-star-spacing": [
257
- "error",
258
- { after: true, before: false }
259
- ],
260
- "style/yield-star-spacing": ["error", { after: true, before: false }],
261
- ...overrides
262
- }
263
- }
264
- ];
215
+ const { indent, jsx: jsx$1, overrides = {}, quotes, semi } = {
216
+ ...StylisticConfigDefaults,
217
+ ...options
218
+ };
219
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
220
+ const config$1 = pluginStylistic.configs.customize({
221
+ indent,
222
+ jsx: jsx$1,
223
+ pluginName: "style",
224
+ quotes,
225
+ semi
226
+ });
227
+ return [{
228
+ name: "stylistic/rules",
229
+ plugins: {
230
+ antfu: pluginAntfu,
231
+ style: pluginStylistic
232
+ },
233
+ rules: {
234
+ ...config$1.rules,
235
+ "antfu/consistent-chaining": "error",
236
+ "antfu/consistent-list-newline": "error",
237
+ "antfu/curly": "error",
238
+ "antfu/if-newline": "error",
239
+ "antfu/top-level-function": "error",
240
+ "style/generator-star-spacing": ["error", {
241
+ after: true,
242
+ before: false
243
+ }],
244
+ "style/yield-star-spacing": ["error", {
245
+ after: true,
246
+ before: false
247
+ }],
248
+ ...overrides
249
+ }
250
+ }];
265
251
  }
266
252
 
267
- // src/configs/formatters.ts
253
+ //#endregion
254
+ //#region src/configs/formatters.ts
268
255
  function mergePrettierOptions(options, overrides = {}) {
269
- return {
270
- ...options,
271
- ...overrides,
272
- plugins: [...overrides.plugins || [], ...options.plugins || []]
273
- };
256
+ return {
257
+ ...options,
258
+ ...overrides,
259
+ plugins: [...overrides.plugins || [], ...options.plugins || []]
260
+ };
274
261
  }
275
- async function formatters(options = {}, stylistic2 = {}) {
276
- if (options === true) {
277
- const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
278
- options = {
279
- css: true,
280
- html: true,
281
- markdown: true,
282
- svg: isPrettierPluginXmlInScope,
283
- xml: isPrettierPluginXmlInScope
284
- };
285
- }
286
- await ensurePackages([
287
- "eslint-plugin-format",
288
- options.xml || options.svg ? "@prettier/plugin-xml" : void 0
289
- ]);
290
- const { indent, quotes, semi } = {
291
- ...StylisticConfigDefaults,
292
- ...stylistic2
293
- };
294
- const prettierOptions = Object.assign(
295
- {
296
- endOfLine: "auto",
297
- printWidth: 120,
298
- semi,
299
- singleQuote: quotes === "single",
300
- tabWidth: typeof indent === "number" ? indent : 2,
301
- trailingComma: "all",
302
- useTabs: indent === "tab"
303
- },
304
- options.prettierOptions || {}
305
- );
306
- const prettierXmlOptions = {
307
- xmlQuoteAttributes: "double",
308
- xmlSelfClosingSpace: true,
309
- xmlSortAttributesByKey: false,
310
- xmlWhitespaceSensitivity: "ignore"
311
- };
312
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
313
- const configs2 = [
314
- {
315
- name: "formatter/setup",
316
- plugins: {
317
- format: pluginFormat
318
- }
319
- }
320
- ];
321
- if (options.css) {
322
- configs2.push(
323
- {
324
- files: [GLOB_CSS, GLOB_POSTCSS],
325
- languageOptions: {
326
- parser: parserPlain
327
- },
328
- name: "formatter/css",
329
- rules: {
330
- "format/prettier": [
331
- "error",
332
- mergePrettierOptions(prettierOptions, {
333
- parser: "css"
334
- })
335
- ]
336
- }
337
- },
338
- {
339
- files: [GLOB_SCSS],
340
- languageOptions: {
341
- parser: parserPlain
342
- },
343
- name: "formatter/scss",
344
- rules: {
345
- "format/prettier": [
346
- "error",
347
- mergePrettierOptions(prettierOptions, {
348
- parser: "scss"
349
- })
350
- ]
351
- }
352
- }
353
- );
354
- }
355
- if (options.html) {
356
- configs2.push({
357
- files: [GLOB_HTML],
358
- languageOptions: {
359
- parser: parserPlain
360
- },
361
- name: "formatter/html",
362
- rules: {
363
- "format/prettier": [
364
- "error",
365
- mergePrettierOptions(prettierOptions, {
366
- parser: "html"
367
- })
368
- ]
369
- }
370
- });
371
- }
372
- if (options.xml) {
373
- configs2.push({
374
- files: [GLOB_XML],
375
- languageOptions: {
376
- parser: parserPlain
377
- },
378
- name: "formatter/xml",
379
- rules: {
380
- "format/prettier": [
381
- "error",
382
- mergePrettierOptions(
383
- { ...prettierXmlOptions, ...prettierOptions },
384
- {
385
- parser: "xml",
386
- plugins: ["@prettier/plugin-xml"]
387
- }
388
- )
389
- ]
390
- }
391
- });
392
- }
393
- if (options.svg) {
394
- configs2.push({
395
- files: [GLOB_SVG],
396
- languageOptions: {
397
- parser: parserPlain
398
- },
399
- name: "formatter/svg",
400
- rules: {
401
- "format/prettier": [
402
- "error",
403
- mergePrettierOptions(
404
- { ...prettierXmlOptions, ...prettierOptions },
405
- {
406
- parser: "xml",
407
- plugins: ["@prettier/plugin-xml"]
408
- }
409
- )
410
- ]
411
- }
412
- });
413
- }
414
- if (options.markdown) {
415
- configs2.push({
416
- files: [GLOB_MARKDOWN],
417
- languageOptions: {
418
- parser: parserPlain
419
- },
420
- name: "formatter/markdown",
421
- rules: {
422
- "format/prettier": [
423
- "error",
424
- mergePrettierOptions(prettierOptions, {
425
- embeddedLanguageFormatting: "off",
426
- parser: "markdown"
427
- })
428
- ]
429
- }
430
- });
431
- }
432
- return configs2;
262
+ async function formatters(options = {}, stylistic$1 = {}) {
263
+ if (options === true) {
264
+ const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
265
+ options = {
266
+ css: true,
267
+ html: true,
268
+ markdown: true,
269
+ svg: isPrettierPluginXmlInScope,
270
+ xml: isPrettierPluginXmlInScope
271
+ };
272
+ }
273
+ await ensurePackages(["eslint-plugin-format", options.xml || options.svg ? "@prettier/plugin-xml" : void 0]);
274
+ const { indent, quotes, semi } = {
275
+ ...StylisticConfigDefaults,
276
+ ...stylistic$1
277
+ };
278
+ const prettierOptions = Object.assign({
279
+ endOfLine: "auto",
280
+ printWidth: 120,
281
+ semi,
282
+ singleQuote: quotes === "single",
283
+ tabWidth: typeof indent === "number" ? indent : 2,
284
+ trailingComma: "all",
285
+ useTabs: indent === "tab"
286
+ }, options.prettierOptions || {});
287
+ const prettierXmlOptions = {
288
+ xmlQuoteAttributes: "double",
289
+ xmlSelfClosingSpace: true,
290
+ xmlSortAttributesByKey: false,
291
+ xmlWhitespaceSensitivity: "ignore"
292
+ };
293
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
294
+ const configs$1 = [{
295
+ name: "formatter/setup",
296
+ plugins: { format: pluginFormat }
297
+ }];
298
+ if (options.css) configs$1.push({
299
+ files: [GLOB_CSS, GLOB_POSTCSS],
300
+ languageOptions: { parser: parserPlain },
301
+ name: "formatter/css",
302
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "css" })] }
303
+ }, {
304
+ files: [GLOB_SCSS],
305
+ languageOptions: { parser: parserPlain },
306
+ name: "formatter/scss",
307
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "scss" })] }
308
+ });
309
+ if (options.html) configs$1.push({
310
+ files: [GLOB_HTML],
311
+ languageOptions: { parser: parserPlain },
312
+ name: "formatter/html",
313
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
314
+ });
315
+ if (options.xml) configs$1.push({
316
+ files: [GLOB_XML],
317
+ languageOptions: { parser: parserPlain },
318
+ name: "formatter/xml",
319
+ rules: { "format/prettier": ["error", mergePrettierOptions({
320
+ ...prettierXmlOptions,
321
+ ...prettierOptions
322
+ }, {
323
+ parser: "xml",
324
+ plugins: ["@prettier/plugin-xml"]
325
+ })] }
326
+ });
327
+ if (options.svg) configs$1.push({
328
+ files: [GLOB_SVG],
329
+ languageOptions: { parser: parserPlain },
330
+ name: "formatter/svg",
331
+ rules: { "format/prettier": ["error", mergePrettierOptions({
332
+ ...prettierXmlOptions,
333
+ ...prettierOptions
334
+ }, {
335
+ parser: "xml",
336
+ plugins: ["@prettier/plugin-xml"]
337
+ })] }
338
+ });
339
+ if (options.markdown) configs$1.push({
340
+ files: [GLOB_MARKDOWN],
341
+ languageOptions: { parser: parserPlain },
342
+ name: "formatter/markdown",
343
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
344
+ embeddedLanguageFormatting: "off",
345
+ parser: "markdown"
346
+ })] }
347
+ });
348
+ return configs$1;
433
349
  }
434
350
 
435
- // src/configs/ignores.ts
351
+ //#endregion
352
+ //#region src/configs/ignores.ts
436
353
  async function ignores(userIgnores = []) {
437
- return [
438
- {
439
- ignores: [...GLOB_EXCLUDE, ...userIgnores],
440
- name: "ignores"
441
- }
442
- ];
354
+ return [{
355
+ ignores: [...GLOB_EXCLUDE, ...userIgnores],
356
+ name: "ignores"
357
+ }];
443
358
  }
444
359
 
445
- // src/configs/imports.ts
360
+ //#endregion
361
+ //#region src/configs/imports.ts
446
362
  async function imports(options = {}) {
447
- const { stylistic: stylistic2 = true } = options;
448
- return [
449
- {
450
- name: "imports/rules",
451
- plugins: {
452
- antfu: default3,
453
- import: pluginImport
454
- },
455
- rules: {
456
- "antfu/import-dedupe": "error",
457
- "antfu/no-import-dist": "error",
458
- "antfu/no-import-node-modules-by-path": "error",
459
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
460
- "import/first": "error",
461
- "import/no-duplicates": "error",
462
- "import/no-mutable-exports": "error",
463
- "import/no-named-default": "error",
464
- "import/no-self-import": "error",
465
- "import/no-webpack-loader-syntax": "error",
466
- ...stylistic2 ? {
467
- "import/newline-after-import": ["error", { count: 1 }]
468
- } : {}
469
- }
470
- }
471
- ];
363
+ const { stylistic: stylistic$1 = true } = options;
364
+ return [{
365
+ name: "imports/rules",
366
+ plugins: {
367
+ antfu: pluginAntfu,
368
+ import: pluginImport
369
+ },
370
+ rules: {
371
+ "antfu/import-dedupe": "error",
372
+ "antfu/no-import-dist": "error",
373
+ "antfu/no-import-node-modules-by-path": "error",
374
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
375
+ "import/first": "error",
376
+ "import/no-duplicates": "error",
377
+ "import/no-mutable-exports": "error",
378
+ "import/no-named-default": "error",
379
+ "import/no-self-import": "error",
380
+ "import/no-webpack-loader-syntax": "error",
381
+ ...stylistic$1 ? { "import/newline-after-import": ["error", { count: 1 }] } : {}
382
+ }
383
+ }];
472
384
  }
473
385
 
474
- // src/configs/javascript.ts
475
- import globals from "globals";
386
+ //#endregion
387
+ //#region src/configs/javascript.ts
476
388
  async function javascript(options = {}) {
477
- const { isInEditor = false, overrides = {} } = options;
478
- return [
479
- {
480
- languageOptions: {
481
- ecmaVersion: 2022,
482
- globals: {
483
- ...globals.browser,
484
- ...globals.es2021,
485
- ...globals.node,
486
- document: "readonly",
487
- navigator: "readonly",
488
- window: "readonly"
489
- },
490
- parserOptions: {
491
- ecmaFeatures: {
492
- jsx: true
493
- },
494
- ecmaVersion: 2022,
495
- sourceType: "module"
496
- },
497
- sourceType: "module"
498
- },
499
- linterOptions: {
500
- reportUnusedDisableDirectives: true
501
- },
502
- name: "javascript/setup"
503
- },
504
- {
505
- name: "javascript/rules",
506
- plugins: {
507
- "antfu": default3,
508
- "unused-imports": default7
509
- },
510
- rules: {
511
- "accessor-pairs": [
512
- "error",
513
- { enforceForClassMembers: true, setWithoutGet: true }
514
- ],
515
- "antfu/no-top-level-await": "error",
516
- "array-callback-return": "error",
517
- "block-scoped-var": "error",
518
- "constructor-super": "error",
519
- "default-case-last": "error",
520
- "dot-notation": ["error", { allowKeywords: true }],
521
- "eqeqeq": ["error", "smart"],
522
- "new-cap": [
523
- "error",
524
- { capIsNew: false, newIsCap: true, properties: true }
525
- ],
526
- "no-alert": "error",
527
- "no-array-constructor": "error",
528
- "no-async-promise-executor": "error",
529
- "no-caller": "error",
530
- "no-case-declarations": "error",
531
- "no-class-assign": "error",
532
- "no-compare-neg-zero": "error",
533
- "no-cond-assign": ["error", "always"],
534
- "no-console": ["error", { allow: ["warn", "error"] }],
535
- "no-const-assign": "error",
536
- "no-control-regex": "error",
537
- "no-debugger": "error",
538
- "no-delete-var": "error",
539
- "no-dupe-args": "error",
540
- "no-dupe-class-members": "error",
541
- "no-dupe-keys": "error",
542
- "no-duplicate-case": "error",
543
- "no-empty": ["error", { allowEmptyCatch: true }],
544
- "no-empty-character-class": "error",
545
- "no-empty-pattern": "error",
546
- "no-eval": "error",
547
- "no-ex-assign": "error",
548
- "no-extend-native": "error",
549
- "no-extra-bind": "error",
550
- "no-extra-boolean-cast": "error",
551
- "no-fallthrough": "error",
552
- "no-func-assign": "error",
553
- "no-global-assign": "error",
554
- "no-implied-eval": "error",
555
- "no-import-assign": "error",
556
- "no-invalid-regexp": "error",
557
- "no-irregular-whitespace": "error",
558
- "no-iterator": "error",
559
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
560
- "no-lone-blocks": "error",
561
- "no-loss-of-precision": "error",
562
- "no-misleading-character-class": "error",
563
- "no-multi-str": "error",
564
- "no-new": "error",
565
- "no-new-func": "error",
566
- "no-new-native-nonconstructor": "error",
567
- "no-new-wrappers": "error",
568
- "no-obj-calls": "error",
569
- "no-octal": "error",
570
- "no-octal-escape": "error",
571
- "no-proto": "error",
572
- "no-prototype-builtins": "error",
573
- "no-redeclare": ["error", { builtinGlobals: false }],
574
- "no-regex-spaces": "error",
575
- "no-restricted-globals": [
576
- "error",
577
- { message: "Use `globalThis` instead.", name: "global" },
578
- { message: "Use `globalThis` instead.", name: "self" }
579
- ],
580
- "no-restricted-properties": [
581
- "error",
582
- {
583
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
584
- property: "__proto__"
585
- },
586
- {
587
- message: "Use `Object.defineProperty` instead.",
588
- property: "__defineGetter__"
589
- },
590
- {
591
- message: "Use `Object.defineProperty` instead.",
592
- property: "__defineSetter__"
593
- },
594
- {
595
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
596
- property: "__lookupGetter__"
597
- },
598
- {
599
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
600
- property: "__lookupSetter__"
601
- }
602
- ],
603
- "no-restricted-syntax": [
604
- "error",
605
- "TSEnumDeclaration[const=true]",
606
- "TSExportAssignment"
607
- ],
608
- "no-self-assign": ["error", { props: true }],
609
- "no-self-compare": "error",
610
- "no-sequences": "error",
611
- "no-shadow-restricted-names": "error",
612
- "no-sparse-arrays": "error",
613
- "no-template-curly-in-string": "error",
614
- "no-this-before-super": "error",
615
- "no-throw-literal": "error",
616
- "no-undef": "error",
617
- "no-undef-init": "error",
618
- "no-unexpected-multiline": "error",
619
- "no-unmodified-loop-condition": "error",
620
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
621
- "no-unreachable": "error",
622
- "no-unreachable-loop": "error",
623
- "no-unsafe-finally": "error",
624
- "no-unsafe-negation": "error",
625
- "no-unused-expressions": [
626
- "error",
627
- {
628
- allowShortCircuit: true,
629
- allowTaggedTemplates: true,
630
- allowTernary: true
631
- }
632
- ],
633
- "no-unused-vars": [
634
- "error",
635
- {
636
- args: "none",
637
- caughtErrors: "none",
638
- ignoreRestSiblings: true,
639
- vars: "all"
640
- }
641
- ],
642
- "no-use-before-define": [
643
- "error",
644
- { classes: false, functions: false, variables: true }
645
- ],
646
- "no-useless-backreference": "error",
647
- "no-useless-call": "error",
648
- "no-useless-catch": "error",
649
- "no-useless-computed-key": "error",
650
- "no-useless-constructor": "error",
651
- "no-useless-rename": "error",
652
- "no-useless-return": "error",
653
- "no-var": "error",
654
- "no-with": "error",
655
- "object-shorthand": [
656
- "error",
657
- "always",
658
- {
659
- avoidQuotes: true,
660
- ignoreConstructors: false
661
- }
662
- ],
663
- "one-var": ["error", { initialized: "never" }],
664
- "prefer-arrow-callback": [
665
- "error",
666
- {
667
- allowNamedFunctions: false,
668
- allowUnboundThis: true
669
- }
670
- ],
671
- "prefer-const": [
672
- isInEditor ? "warn" : "error",
673
- {
674
- destructuring: "all",
675
- ignoreReadBeforeAssign: true
676
- }
677
- ],
678
- "prefer-exponentiation-operator": "error",
679
- "prefer-promise-reject-errors": "error",
680
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
681
- "prefer-rest-params": "error",
682
- "prefer-spread": "error",
683
- "prefer-template": "error",
684
- "symbol-description": "error",
685
- "unicode-bom": ["error", "never"],
686
- "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
687
- "unused-imports/no-unused-vars": [
688
- "error",
689
- {
690
- args: "after-used",
691
- argsIgnorePattern: "^_",
692
- ignoreRestSiblings: true,
693
- vars: "all",
694
- varsIgnorePattern: "^_"
695
- }
696
- ],
697
- "use-isnan": [
698
- "error",
699
- { enforceForIndexOf: true, enforceForSwitchCase: true }
700
- ],
701
- "valid-typeof": ["error", { requireStringLiterals: true }],
702
- "vars-on-top": "error",
703
- "yoda": ["error", "never"],
704
- ...overrides
705
- }
706
- }
707
- ];
389
+ const { isInEditor = false, overrides = {} } = options;
390
+ return [{
391
+ languageOptions: {
392
+ ecmaVersion: 2022,
393
+ globals: {
394
+ ...globals.browser,
395
+ ...globals.es2021,
396
+ ...globals.node,
397
+ document: "readonly",
398
+ navigator: "readonly",
399
+ window: "readonly"
400
+ },
401
+ parserOptions: {
402
+ ecmaFeatures: { jsx: true },
403
+ ecmaVersion: 2022,
404
+ sourceType: "module"
405
+ },
406
+ sourceType: "module"
407
+ },
408
+ linterOptions: { reportUnusedDisableDirectives: true },
409
+ name: "javascript/setup"
410
+ }, {
411
+ name: "javascript/rules",
412
+ plugins: {
413
+ "antfu": pluginAntfu,
414
+ "unused-imports": pluginUnusedImports
415
+ },
416
+ rules: {
417
+ "accessor-pairs": ["error", {
418
+ enforceForClassMembers: true,
419
+ setWithoutGet: true
420
+ }],
421
+ "antfu/no-top-level-await": "error",
422
+ "array-callback-return": "error",
423
+ "block-scoped-var": "error",
424
+ "constructor-super": "error",
425
+ "default-case-last": "error",
426
+ "dot-notation": ["error", { allowKeywords: true }],
427
+ "eqeqeq": ["error", "smart"],
428
+ "new-cap": ["error", {
429
+ capIsNew: false,
430
+ newIsCap: true,
431
+ properties: true
432
+ }],
433
+ "no-alert": "error",
434
+ "no-array-constructor": "error",
435
+ "no-async-promise-executor": "error",
436
+ "no-caller": "error",
437
+ "no-case-declarations": "error",
438
+ "no-class-assign": "error",
439
+ "no-compare-neg-zero": "error",
440
+ "no-cond-assign": ["error", "always"],
441
+ "no-console": ["error", { allow: ["warn", "error"] }],
442
+ "no-const-assign": "error",
443
+ "no-control-regex": "error",
444
+ "no-debugger": "error",
445
+ "no-delete-var": "error",
446
+ "no-dupe-args": "error",
447
+ "no-dupe-class-members": "error",
448
+ "no-dupe-keys": "error",
449
+ "no-duplicate-case": "error",
450
+ "no-empty": ["error", { allowEmptyCatch: true }],
451
+ "no-empty-character-class": "error",
452
+ "no-empty-pattern": "error",
453
+ "no-eval": "error",
454
+ "no-ex-assign": "error",
455
+ "no-extend-native": "error",
456
+ "no-extra-bind": "error",
457
+ "no-extra-boolean-cast": "error",
458
+ "no-fallthrough": "error",
459
+ "no-func-assign": "error",
460
+ "no-global-assign": "error",
461
+ "no-implied-eval": "error",
462
+ "no-import-assign": "error",
463
+ "no-invalid-regexp": "error",
464
+ "no-irregular-whitespace": "error",
465
+ "no-iterator": "error",
466
+ "no-labels": ["error", {
467
+ allowLoop: false,
468
+ allowSwitch: false
469
+ }],
470
+ "no-lone-blocks": "error",
471
+ "no-loss-of-precision": "error",
472
+ "no-misleading-character-class": "error",
473
+ "no-multi-str": "error",
474
+ "no-new": "error",
475
+ "no-new-func": "error",
476
+ "no-new-native-nonconstructor": "error",
477
+ "no-new-wrappers": "error",
478
+ "no-obj-calls": "error",
479
+ "no-octal": "error",
480
+ "no-octal-escape": "error",
481
+ "no-proto": "error",
482
+ "no-prototype-builtins": "error",
483
+ "no-redeclare": ["error", { builtinGlobals: false }],
484
+ "no-regex-spaces": "error",
485
+ "no-restricted-globals": [
486
+ "error",
487
+ {
488
+ message: "Use `globalThis` instead.",
489
+ name: "global"
490
+ },
491
+ {
492
+ message: "Use `globalThis` instead.",
493
+ name: "self"
494
+ }
495
+ ],
496
+ "no-restricted-properties": [
497
+ "error",
498
+ {
499
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
500
+ property: "__proto__"
501
+ },
502
+ {
503
+ message: "Use `Object.defineProperty` instead.",
504
+ property: "__defineGetter__"
505
+ },
506
+ {
507
+ message: "Use `Object.defineProperty` instead.",
508
+ property: "__defineSetter__"
509
+ },
510
+ {
511
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
512
+ property: "__lookupGetter__"
513
+ },
514
+ {
515
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
516
+ property: "__lookupSetter__"
517
+ }
518
+ ],
519
+ "no-restricted-syntax": [
520
+ "error",
521
+ "TSEnumDeclaration[const=true]",
522
+ "TSExportAssignment"
523
+ ],
524
+ "no-self-assign": ["error", { props: true }],
525
+ "no-self-compare": "error",
526
+ "no-sequences": "error",
527
+ "no-shadow-restricted-names": "error",
528
+ "no-sparse-arrays": "error",
529
+ "no-template-curly-in-string": "error",
530
+ "no-this-before-super": "error",
531
+ "no-throw-literal": "error",
532
+ "no-undef": "error",
533
+ "no-undef-init": "error",
534
+ "no-unexpected-multiline": "error",
535
+ "no-unmodified-loop-condition": "error",
536
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
537
+ "no-unreachable": "error",
538
+ "no-unreachable-loop": "error",
539
+ "no-unsafe-finally": "error",
540
+ "no-unsafe-negation": "error",
541
+ "no-unused-expressions": ["error", {
542
+ allowShortCircuit: true,
543
+ allowTaggedTemplates: true,
544
+ allowTernary: true
545
+ }],
546
+ "no-unused-vars": ["error", {
547
+ args: "none",
548
+ caughtErrors: "none",
549
+ ignoreRestSiblings: true,
550
+ vars: "all"
551
+ }],
552
+ "no-use-before-define": ["error", {
553
+ classes: false,
554
+ functions: false,
555
+ variables: true
556
+ }],
557
+ "no-useless-backreference": "error",
558
+ "no-useless-call": "error",
559
+ "no-useless-catch": "error",
560
+ "no-useless-computed-key": "error",
561
+ "no-useless-constructor": "error",
562
+ "no-useless-rename": "error",
563
+ "no-useless-return": "error",
564
+ "no-var": "error",
565
+ "no-with": "error",
566
+ "object-shorthand": [
567
+ "error",
568
+ "always",
569
+ {
570
+ avoidQuotes: true,
571
+ ignoreConstructors: false
572
+ }
573
+ ],
574
+ "one-var": ["error", { initialized: "never" }],
575
+ "prefer-arrow-callback": ["error", {
576
+ allowNamedFunctions: false,
577
+ allowUnboundThis: true
578
+ }],
579
+ "prefer-const": [isInEditor ? "warn" : "error", {
580
+ destructuring: "all",
581
+ ignoreReadBeforeAssign: true
582
+ }],
583
+ "prefer-exponentiation-operator": "error",
584
+ "prefer-promise-reject-errors": "error",
585
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
586
+ "prefer-rest-params": "error",
587
+ "prefer-spread": "error",
588
+ "prefer-template": "error",
589
+ "symbol-description": "error",
590
+ "unicode-bom": ["error", "never"],
591
+ "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
592
+ "unused-imports/no-unused-vars": ["error", {
593
+ args: "after-used",
594
+ argsIgnorePattern: "^_",
595
+ ignoreRestSiblings: true,
596
+ vars: "all",
597
+ varsIgnorePattern: "^_"
598
+ }],
599
+ "use-isnan": ["error", {
600
+ enforceForIndexOf: true,
601
+ enforceForSwitchCase: true
602
+ }],
603
+ "valid-typeof": ["error", { requireStringLiterals: true }],
604
+ "vars-on-top": "error",
605
+ "yoda": ["error", "never"],
606
+ ...overrides
607
+ }
608
+ }];
708
609
  }
709
610
 
710
- // src/configs/jsonc.ts
611
+ //#endregion
612
+ //#region src/configs/jsonc.ts
711
613
  async function jsonc(options = {}) {
712
- const {
713
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
714
- overrides = {},
715
- stylistic: stylistic2 = true
716
- } = options;
717
- const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
718
- const [pluginJsonc, parserJsonc] = await Promise.all([
719
- interopDefault(import("eslint-plugin-jsonc")),
720
- interopDefault(import("jsonc-eslint-parser"))
721
- ]);
722
- return [
723
- {
724
- name: "jsonc/setup",
725
- plugins: {
726
- jsonc: pluginJsonc
727
- }
728
- },
729
- {
730
- files,
731
- languageOptions: {
732
- parser: parserJsonc
733
- },
734
- name: "jsonc/rules",
735
- rules: {
736
- "jsonc/no-bigint-literals": "error",
737
- "jsonc/no-binary-expression": "error",
738
- "jsonc/no-binary-numeric-literals": "error",
739
- "jsonc/no-dupe-keys": "error",
740
- "jsonc/no-escape-sequence-in-identifier": "error",
741
- "jsonc/no-floating-decimal": "error",
742
- "jsonc/no-hexadecimal-numeric-literals": "error",
743
- "jsonc/no-infinity": "error",
744
- "jsonc/no-multi-str": "error",
745
- "jsonc/no-nan": "error",
746
- "jsonc/no-number-props": "error",
747
- "jsonc/no-numeric-separators": "error",
748
- "jsonc/no-octal": "error",
749
- "jsonc/no-octal-escape": "error",
750
- "jsonc/no-octal-numeric-literals": "error",
751
- "jsonc/no-parenthesized": "error",
752
- "jsonc/no-plus-sign": "error",
753
- "jsonc/no-regexp-literals": "error",
754
- "jsonc/no-sparse-arrays": "error",
755
- "jsonc/no-template-literals": "error",
756
- "jsonc/no-undefined-value": "error",
757
- "jsonc/no-unicode-codepoint-escapes": "error",
758
- "jsonc/no-useless-escape": "error",
759
- "jsonc/space-unary-ops": "error",
760
- "jsonc/valid-json-number": "error",
761
- "jsonc/vue-custom-block/no-parsing-error": "error",
762
- ...stylistic2 ? {
763
- "jsonc/array-bracket-spacing": ["error", "never"],
764
- "jsonc/comma-dangle": ["error", "never"],
765
- "jsonc/comma-style": ["error", "last"],
766
- "jsonc/indent": ["error", indent],
767
- "jsonc/key-spacing": [
768
- "error",
769
- { afterColon: true, beforeColon: false }
770
- ],
771
- "jsonc/object-curly-newline": [
772
- "error",
773
- { consistent: true, multiline: true }
774
- ],
775
- "jsonc/object-curly-spacing": ["error", "always"],
776
- "jsonc/object-property-newline": [
777
- "error",
778
- { allowMultiplePropertiesPerLine: true }
779
- ],
780
- "jsonc/quote-props": "error",
781
- "jsonc/quotes": "error"
782
- } : {},
783
- ...overrides
784
- }
785
- }
786
- ];
614
+ const { files = [
615
+ GLOB_JSON,
616
+ GLOB_JSON5,
617
+ GLOB_JSONC
618
+ ], overrides = {}, stylistic: stylistic$1 = true } = options;
619
+ const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
620
+ const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
621
+ return [{
622
+ name: "jsonc/setup",
623
+ plugins: { jsonc: pluginJsonc }
624
+ }, {
625
+ files,
626
+ languageOptions: { parser: parserJsonc },
627
+ name: "jsonc/rules",
628
+ rules: {
629
+ "jsonc/no-bigint-literals": "error",
630
+ "jsonc/no-binary-expression": "error",
631
+ "jsonc/no-binary-numeric-literals": "error",
632
+ "jsonc/no-dupe-keys": "error",
633
+ "jsonc/no-escape-sequence-in-identifier": "error",
634
+ "jsonc/no-floating-decimal": "error",
635
+ "jsonc/no-hexadecimal-numeric-literals": "error",
636
+ "jsonc/no-infinity": "error",
637
+ "jsonc/no-multi-str": "error",
638
+ "jsonc/no-nan": "error",
639
+ "jsonc/no-number-props": "error",
640
+ "jsonc/no-numeric-separators": "error",
641
+ "jsonc/no-octal": "error",
642
+ "jsonc/no-octal-escape": "error",
643
+ "jsonc/no-octal-numeric-literals": "error",
644
+ "jsonc/no-parenthesized": "error",
645
+ "jsonc/no-plus-sign": "error",
646
+ "jsonc/no-regexp-literals": "error",
647
+ "jsonc/no-sparse-arrays": "error",
648
+ "jsonc/no-template-literals": "error",
649
+ "jsonc/no-undefined-value": "error",
650
+ "jsonc/no-unicode-codepoint-escapes": "error",
651
+ "jsonc/no-useless-escape": "error",
652
+ "jsonc/space-unary-ops": "error",
653
+ "jsonc/valid-json-number": "error",
654
+ "jsonc/vue-custom-block/no-parsing-error": "error",
655
+ ...stylistic$1 ? {
656
+ "jsonc/array-bracket-spacing": ["error", "never"],
657
+ "jsonc/comma-dangle": ["error", "never"],
658
+ "jsonc/comma-style": ["error", "last"],
659
+ "jsonc/indent": ["error", indent],
660
+ "jsonc/key-spacing": ["error", {
661
+ afterColon: true,
662
+ beforeColon: false
663
+ }],
664
+ "jsonc/object-curly-newline": ["error", {
665
+ consistent: true,
666
+ multiline: true
667
+ }],
668
+ "jsonc/object-curly-spacing": ["error", "always"],
669
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
670
+ "jsonc/quote-props": "error",
671
+ "jsonc/quotes": "error"
672
+ } : {},
673
+ ...overrides
674
+ }
675
+ }];
787
676
  }
788
677
 
789
- // src/configs/jsx.ts
678
+ //#endregion
679
+ //#region src/configs/jsx.ts
790
680
  async function jsx() {
791
- return [
792
- {
793
- files: [GLOB_JSX, GLOB_TSX],
794
- languageOptions: {
795
- parserOptions: {
796
- ecmaFeatures: {
797
- jsx: true
798
- }
799
- }
800
- },
801
- name: "jsx/setup"
802
- }
803
- ];
681
+ return [{
682
+ files: [GLOB_JSX, GLOB_TSX],
683
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
684
+ name: "jsx/setup"
685
+ }];
804
686
  }
805
687
 
806
- // src/configs/markdown.ts
807
- import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
688
+ //#endregion
689
+ //#region src/configs/jsx-a11y.ts
690
+ const NextJsPackages$1 = ["next"];
691
+ const isUsingNext = NextJsPackages$1.some((i) => isPackageExists(i));
692
+ async function jsxA11y(options = {}) {
693
+ const { overrides = {} } = options;
694
+ await ensurePackages(["eslint-plugin-jsx-a11y"]);
695
+ const [pluginJsxA11y] = await Promise.all([interopDefault(import("eslint-plugin-jsx-a11y"))]);
696
+ return [{
697
+ name: "jsx-a11y/rules",
698
+ plugins: { "jsx-a11y": pluginJsxA11y },
699
+ rules: {
700
+ "jsx-a11y/alt-text": ["warn", {
701
+ elements: ["img"],
702
+ img: [...isUsingNext ? ["Image"] : []]
703
+ }],
704
+ "jsx-a11y/aria-props": "warn",
705
+ "jsx-a11y/aria-proptypes": "warn",
706
+ "jsx-a11y/aria-unsupported-elements": "warn",
707
+ "jsx-a11y/role-has-required-aria-props": "warn",
708
+ "jsx-a11y/role-supports-aria-props": "warn",
709
+ ...overrides
710
+ }
711
+ }];
712
+ }
713
+
714
+ //#endregion
715
+ //#region src/configs/markdown.ts
808
716
  async function markdown(options = {}) {
809
- const {
810
- componentExts = [],
811
- files = [GLOB_MARKDOWN],
812
- overrides = {}
813
- } = options;
814
- const markdown2 = await interopDefault(import("@eslint/markdown"));
815
- return [
816
- {
817
- name: "markdown/setup",
818
- plugins: {
819
- markdown: markdown2
820
- }
821
- },
822
- {
823
- files,
824
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
825
- name: "markdown/processor",
826
- // `eslint-plugin-markdown` only creates virtual files for code blocks,
827
- // but not the markdown file itself. We use `eslint-merge-processors` to
828
- // add a pass-through processor for the markdown file itself.
829
- processor: mergeProcessors([
830
- markdown2.processors.markdown,
831
- processorPassThrough
832
- ])
833
- },
834
- {
835
- files,
836
- languageOptions: {
837
- parser: parserPlain
838
- },
839
- name: "markdown/parser"
840
- },
841
- {
842
- files: [
843
- GLOB_MARKDOWN_CODE,
844
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
845
- ],
846
- languageOptions: {
847
- parserOptions: {
848
- ecmaFeatures: {
849
- impliedStrict: true
850
- }
851
- }
852
- },
853
- name: "markdown/disables",
854
- rules: {
855
- "antfu/no-top-level-await": "off",
856
- "import/newline-after-import": "off",
857
- "no-alert": "off",
858
- "no-console": "off",
859
- "no-labels": "off",
860
- "no-lone-blocks": "off",
861
- "no-restricted-syntax": "off",
862
- "no-undef": "off",
863
- "no-unused-expressions": "off",
864
- "no-unused-labels": "off",
865
- "no-unused-vars": "off",
866
- "node/prefer-global/process": "off",
867
- "style/comma-dangle": "off",
868
- "style/eol-last": "off",
869
- "ts/consistent-type-imports": "off",
870
- "ts/explicit-function-return-type": "off",
871
- "ts/no-namespace": "off",
872
- "ts/no-redeclare": "off",
873
- "ts/no-require-imports": "off",
874
- "ts/no-unused-expressions": "off",
875
- "ts/no-unused-vars": "off",
876
- "ts/no-use-before-define": "off",
877
- "unicode-bom": "off",
878
- "unused-imports/no-unused-imports": "off",
879
- "unused-imports/no-unused-vars": "off",
880
- ...overrides
881
- }
882
- }
883
- ];
717
+ const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
718
+ const markdown$1 = await interopDefault(import("@eslint/markdown"));
719
+ return [
720
+ {
721
+ name: "markdown/setup",
722
+ plugins: { markdown: markdown$1 }
723
+ },
724
+ {
725
+ files,
726
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
727
+ name: "markdown/processor",
728
+ processor: mergeProcessors([markdown$1.processors.markdown, processorPassThrough])
729
+ },
730
+ {
731
+ files,
732
+ languageOptions: { parser: parserPlain },
733
+ name: "markdown/parser"
734
+ },
735
+ {
736
+ files: [GLOB_MARKDOWN_CODE, ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
737
+ languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
738
+ name: "markdown/disables",
739
+ rules: {
740
+ "antfu/no-top-level-await": "off",
741
+ "import/newline-after-import": "off",
742
+ "no-alert": "off",
743
+ "no-console": "off",
744
+ "no-labels": "off",
745
+ "no-lone-blocks": "off",
746
+ "no-restricted-syntax": "off",
747
+ "no-undef": "off",
748
+ "no-unused-expressions": "off",
749
+ "no-unused-labels": "off",
750
+ "no-unused-vars": "off",
751
+ "node/prefer-global/process": "off",
752
+ "style/comma-dangle": "off",
753
+ "style/eol-last": "off",
754
+ "ts/consistent-type-imports": "off",
755
+ "ts/explicit-function-return-type": "off",
756
+ "ts/no-namespace": "off",
757
+ "ts/no-redeclare": "off",
758
+ "ts/no-require-imports": "off",
759
+ "ts/no-unused-expressions": "off",
760
+ "ts/no-unused-vars": "off",
761
+ "ts/no-use-before-define": "off",
762
+ "unicode-bom": "off",
763
+ "unused-imports/no-unused-imports": "off",
764
+ "unused-imports/no-unused-vars": "off",
765
+ ...overrides
766
+ }
767
+ }
768
+ ];
884
769
  }
885
770
 
886
- // src/configs/node.ts
771
+ //#endregion
772
+ //#region src/configs/next.ts
773
+ async function next(options = {}) {
774
+ const { overrides = {} } = options;
775
+ await ensurePackages(["@next/eslint-plugin-next"]);
776
+ const [pluginNext] = await Promise.all([interopDefault(import("@next/eslint-plugin-next"))]);
777
+ return [{
778
+ name: "next/rules",
779
+ plugins: { next: pluginNext },
780
+ rules: {
781
+ "next/google-font-display": "warn",
782
+ "next/google-font-preconnect": "warn",
783
+ "next/inline-script-id": "error",
784
+ "next/next-script-for-ga": "warn",
785
+ "next/no-assign-module-variable": "error",
786
+ "next/no-async-client-component": "warn",
787
+ "next/no-before-interactive-script-outside-document": "warn",
788
+ "next/no-css-tags": "warn",
789
+ "next/no-document-import-in-page": "error",
790
+ "next/no-duplicate-head": "error",
791
+ "next/no-head-element": "warn",
792
+ "next/no-head-import-in-document": "error",
793
+ "next/no-html-link-for-pages": "warn",
794
+ "next/no-img-element": "warn",
795
+ "next/no-page-custom-font": "warn",
796
+ "next/no-script-component-in-head": "error",
797
+ "next/no-styled-jsx-in-document": "warn",
798
+ "next/no-sync-scripts": "warn",
799
+ "next/no-title-in-document-head": "warn",
800
+ "next/no-typos": "warn",
801
+ "next/no-unwanted-polyfillio": "warn",
802
+ ...overrides
803
+ }
804
+ }];
805
+ }
806
+
807
+ //#endregion
808
+ //#region src/configs/node.ts
887
809
  async function node() {
888
- return [
889
- {
890
- name: "node/rules",
891
- plugins: {
892
- node: default4
893
- },
894
- rules: {
895
- "node/handle-callback-err": ["error", "^(err|error)$"],
896
- "node/no-deprecated-api": "error",
897
- "node/no-exports-assign": "error",
898
- "node/no-new-require": "error",
899
- "node/no-path-concat": "error",
900
- "node/prefer-global/buffer": ["error", "never"],
901
- "node/prefer-global/process": ["error", "never"],
902
- "node/process-exit-as-throw": "error"
903
- }
904
- }
905
- ];
810
+ return [{
811
+ name: "node/rules",
812
+ plugins: { node: pluginNode },
813
+ rules: {
814
+ "node/handle-callback-err": ["error", "^(err|error)$"],
815
+ "node/no-deprecated-api": "error",
816
+ "node/no-exports-assign": "error",
817
+ "node/no-new-require": "error",
818
+ "node/no-path-concat": "error",
819
+ "node/prefer-global/buffer": ["error", "never"],
820
+ "node/prefer-global/process": ["error", "never"],
821
+ "node/process-exit-as-throw": "error"
822
+ }
823
+ }];
906
824
  }
907
825
 
908
- // src/configs/perfectionist.ts
826
+ //#endregion
827
+ //#region src/configs/perfectionist.ts
828
+ /**
829
+ * Perfectionist plugin for props and items sorting.
830
+ *
831
+ * @see https://github.com/azat-io/eslint-plugin-perfectionist
832
+ */
909
833
  async function perfectionist() {
910
- return [
911
- {
912
- name: "perfectionist/setup",
913
- plugins: {
914
- perfectionist: default5
915
- },
916
- rules: {
917
- "perfectionist/sort-exports": [
918
- "error",
919
- { order: "asc", type: "natural" }
920
- ],
921
- "perfectionist/sort-imports": [
922
- "error",
923
- {
924
- groups: [
925
- "type",
926
- ["parent-type", "sibling-type", "index-type", "internal-type"],
927
- "builtin",
928
- "external",
929
- "internal",
930
- ["parent", "sibling", "index"],
931
- "side-effect",
932
- "object",
933
- "unknown"
934
- ],
935
- newlinesBetween: "always",
936
- order: "asc",
937
- type: "natural"
938
- }
939
- ],
940
- "perfectionist/sort-named-exports": [
941
- "error",
942
- { order: "asc", type: "natural" }
943
- ],
944
- "perfectionist/sort-named-imports": [
945
- "error",
946
- { order: "asc", type: "natural" }
947
- ]
948
- }
949
- }
950
- ];
834
+ return [{
835
+ name: "perfectionist/setup",
836
+ plugins: { perfectionist: pluginPerfectionist },
837
+ rules: {
838
+ "perfectionist/sort-exports": ["error", {
839
+ order: "asc",
840
+ type: "natural"
841
+ }],
842
+ "perfectionist/sort-imports": ["error", {
843
+ groups: [
844
+ "type",
845
+ [
846
+ "parent-type",
847
+ "sibling-type",
848
+ "index-type",
849
+ "internal-type"
850
+ ],
851
+ "builtin",
852
+ "external",
853
+ "internal",
854
+ [
855
+ "parent",
856
+ "sibling",
857
+ "index"
858
+ ],
859
+ "side-effect",
860
+ "object",
861
+ "unknown"
862
+ ],
863
+ newlinesBetween: "always",
864
+ order: "asc",
865
+ type: "natural"
866
+ }],
867
+ "perfectionist/sort-named-exports": ["error", {
868
+ order: "asc",
869
+ type: "natural"
870
+ }],
871
+ "perfectionist/sort-named-imports": ["error", {
872
+ order: "asc",
873
+ type: "natural"
874
+ }]
875
+ }
876
+ }];
951
877
  }
952
878
 
953
- // src/configs/pnpm.ts
879
+ //#endregion
880
+ //#region src/configs/pnpm.ts
954
881
  async function pnpm() {
955
- const [
956
- pluginPnpm,
957
- yamlParser,
958
- jsoncParser
959
- ] = await Promise.all([
960
- interopDefault(import("eslint-plugin-pnpm")),
961
- interopDefault(import("yaml-eslint-parser")),
962
- interopDefault(import("jsonc-eslint-parser"))
963
- ]);
964
- return [
965
- {
966
- files: [
967
- "package.json",
968
- "**/package.json"
969
- ],
970
- languageOptions: {
971
- parser: jsoncParser
972
- },
973
- name: "pnpm/package-json",
974
- plugins: {
975
- pnpm: pluginPnpm
976
- },
977
- rules: {
978
- "pnpm/json-enforce-catalog": "error",
979
- "pnpm/json-prefer-workspace-settings": "error",
980
- "pnpm/json-valid-catalog": "error"
981
- }
982
- },
983
- {
984
- files: ["pnpm-workspace.yaml"],
985
- languageOptions: {
986
- parser: yamlParser
987
- },
988
- name: "pnpm/pnpm-workspace-yaml",
989
- plugins: {
990
- pnpm: pluginPnpm
991
- },
992
- rules: {
993
- "pnpm/yaml-no-duplicate-catalog-item": "error",
994
- "pnpm/yaml-no-unused-catalog-item": "error"
995
- }
996
- }
997
- ];
882
+ const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
883
+ interopDefault(import("eslint-plugin-pnpm")),
884
+ interopDefault(import("yaml-eslint-parser")),
885
+ interopDefault(import("jsonc-eslint-parser"))
886
+ ]);
887
+ return [{
888
+ files: ["package.json", "**/package.json"],
889
+ languageOptions: { parser: jsoncParser },
890
+ name: "pnpm/package-json",
891
+ plugins: { pnpm: pluginPnpm },
892
+ rules: {
893
+ "pnpm/json-enforce-catalog": "error",
894
+ "pnpm/json-prefer-workspace-settings": "error",
895
+ "pnpm/json-valid-catalog": "error"
896
+ }
897
+ }, {
898
+ files: ["pnpm-workspace.yaml"],
899
+ languageOptions: { parser: yamlParser },
900
+ name: "pnpm/pnpm-workspace-yaml",
901
+ plugins: { pnpm: pluginPnpm },
902
+ rules: {
903
+ "pnpm/yaml-no-duplicate-catalog-item": "error",
904
+ "pnpm/yaml-no-unused-catalog-item": "error"
905
+ }
906
+ }];
998
907
  }
999
908
 
1000
- // src/configs/react.ts
1001
- import { isPackageExists as isPackageExists2 } from "local-pkg";
1002
- var ReactRefreshAllowConstantExportPackages = ["vite"];
1003
- var ReactRouterPackages = [
1004
- "@react-router/node",
1005
- "@react-router/react",
1006
- "@react-router/serve",
1007
- "@react-router/dev"
909
+ //#endregion
910
+ //#region src/configs/react.ts
911
+ const ReactRefreshAllowConstantExportPackages = ["vite"];
912
+ const ReactRouterPackages = [
913
+ "@react-router/node",
914
+ "@react-router/react",
915
+ "@react-router/serve",
916
+ "@react-router/dev"
1008
917
  ];
1009
- var NextJsPackages = ["next"];
918
+ const NextJsPackages = ["next"];
1010
919
  async function react(options = {}) {
1011
- const {
1012
- files = [GLOB_SRC],
1013
- filesTypeAware = [GLOB_TS, GLOB_TSX],
1014
- ignoresTypeAware = [`${GLOB_MARKDOWN}/**`],
1015
- overrides = {},
1016
- tsconfigPath
1017
- } = options;
1018
- const isTypeAware = !!tsconfigPath;
1019
- const typeAwareRules = {
1020
- "react/no-leaked-conditional-rendering": "warn"
1021
- };
1022
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
1023
- [
1024
- interopDefault(import("@eslint-react/eslint-plugin")),
1025
- interopDefault(import("eslint-plugin-react-hooks")),
1026
- interopDefault(import("eslint-plugin-react-refresh"))
1027
- ]
1028
- );
1029
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1030
- (i) => isPackageExists2(i)
1031
- );
1032
- const isUsingReactRouter = ReactRouterPackages.some(
1033
- (i) => isPackageExists2(i)
1034
- );
1035
- const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
1036
- const plugins = pluginReact.configs.all.plugins;
1037
- return [
1038
- {
1039
- name: "react/setup",
1040
- plugins: {
1041
- "react": plugins["@eslint-react"],
1042
- "react-dom": plugins["@eslint-react/dom"],
1043
- "react-hooks": pluginReactHooks,
1044
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1045
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
1046
- "react-refresh": pluginReactRefresh,
1047
- "react-web-api": plugins["@eslint-react/web-api"]
1048
- }
1049
- },
1050
- {
1051
- files,
1052
- languageOptions: {
1053
- parserOptions: {
1054
- ecmaFeatures: {
1055
- jsx: true
1056
- }
1057
- },
1058
- sourceType: "module"
1059
- },
1060
- name: "react/rules",
1061
- rules: {
1062
- // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
1063
- "react/jsx-no-duplicate-props": "warn",
1064
- "react/jsx-uses-vars": "warn",
1065
- "react/no-access-state-in-setstate": "error",
1066
- "react/no-array-index-key": "warn",
1067
- "react/no-children-count": "warn",
1068
- "react/no-children-for-each": "warn",
1069
- "react/no-children-map": "warn",
1070
- "react/no-children-only": "warn",
1071
- "react/no-children-to-array": "warn",
1072
- "react/no-clone-element": "warn",
1073
- "react/no-comment-textnodes": "warn",
1074
- "react/no-component-will-mount": "error",
1075
- "react/no-component-will-receive-props": "error",
1076
- "react/no-component-will-update": "error",
1077
- "react/no-context-provider": "warn",
1078
- "react/no-create-ref": "error",
1079
- "react/no-default-props": "error",
1080
- "react/no-direct-mutation-state": "error",
1081
- "react/no-duplicate-key": "warn",
1082
- "react/no-forward-ref": "warn",
1083
- "react/no-implicit-key": "warn",
1084
- "react/no-missing-key": "error",
1085
- "react/no-nested-component-definitions": "error",
1086
- "react/no-prop-types": "error",
1087
- "react/no-redundant-should-component-update": "error",
1088
- "react/no-set-state-in-component-did-mount": "warn",
1089
- "react/no-set-state-in-component-did-update": "warn",
1090
- "react/no-set-state-in-component-will-update": "warn",
1091
- "react/no-string-refs": "error",
1092
- "react/no-unsafe-component-will-mount": "warn",
1093
- "react/no-unsafe-component-will-receive-props": "warn",
1094
- "react/no-unsafe-component-will-update": "warn",
1095
- "react/no-unstable-context-value": "warn",
1096
- "react/no-unstable-default-props": "warn",
1097
- "react/no-unused-class-component-members": "warn",
1098
- "react/no-unused-state": "warn",
1099
- "react/no-use-context": "warn",
1100
- "react/no-useless-forward-ref": "warn",
1101
- // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
1102
- "react-dom/no-dangerously-set-innerhtml": "warn",
1103
- "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1104
- "react-dom/no-find-dom-node": "error",
1105
- "react-dom/no-flush-sync": "error",
1106
- "react-dom/no-hydrate": "error",
1107
- "react-dom/no-missing-button-type": "warn",
1108
- "react-dom/no-missing-iframe-sandbox": "warn",
1109
- "react-dom/no-namespace": "error",
1110
- "react-dom/no-render": "error",
1111
- "react-dom/no-render-return-value": "error",
1112
- "react-dom/no-script-url": "warn",
1113
- "react-dom/no-unsafe-iframe-sandbox": "warn",
1114
- "react-dom/no-unsafe-target-blank": "warn",
1115
- "react-dom/no-use-form-state": "error",
1116
- "react-dom/no-void-elements-with-children": "error",
1117
- // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
1118
- "react-hooks/exhaustive-deps": "warn",
1119
- "react-hooks/rules-of-hooks": "error",
1120
- // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
1121
- "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1122
- "react-hooks-extra/no-unnecessary-use-prefix": "warn",
1123
- "react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
1124
- // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
1125
- "react-web-api/no-leaked-event-listener": "warn",
1126
- "react-web-api/no-leaked-interval": "warn",
1127
- "react-web-api/no-leaked-resize-observer": "warn",
1128
- "react-web-api/no-leaked-timeout": "warn",
1129
- // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
1130
- "react-refresh/only-export-components": [
1131
- "warn",
1132
- {
1133
- allowConstantExport: isAllowConstantExport,
1134
- allowExportNames: [
1135
- ...isUsingNext ? [
1136
- "dynamic",
1137
- "dynamicParams",
1138
- "revalidate",
1139
- "fetchCache",
1140
- "runtime",
1141
- "preferredRegion",
1142
- "maxDuration",
1143
- "config",
1144
- "generateStaticParams",
1145
- "metadata",
1146
- "generateMetadata",
1147
- "viewport",
1148
- "generateViewport"
1149
- ] : [],
1150
- ...isUsingReactRouter ? ["meta", "links", "headers", "loader", "action"] : []
1151
- ]
1152
- }
1153
- ],
1154
- // overrides
1155
- ...overrides
1156
- }
1157
- },
1158
- ...isTypeAware ? [
1159
- {
1160
- files: filesTypeAware,
1161
- ignores: ignoresTypeAware,
1162
- name: "react/type-aware-rules",
1163
- rules: {
1164
- ...typeAwareRules
1165
- }
1166
- }
1167
- ] : []
1168
- ];
920
+ const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`], overrides = {}, tsconfigPath } = options;
921
+ const isTypeAware = !!tsconfigPath;
922
+ const typeAwareRules = { "react/no-leaked-conditional-rendering": "warn" };
923
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
924
+ interopDefault(import("@eslint-react/eslint-plugin")),
925
+ interopDefault(import("eslint-plugin-react-hooks")),
926
+ interopDefault(import("eslint-plugin-react-refresh"))
927
+ ]);
928
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
929
+ const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
930
+ const isUsingNext$1 = NextJsPackages.some((i) => isPackageExists(i));
931
+ const plugins = pluginReact.configs.all.plugins;
932
+ return [
933
+ {
934
+ name: "react/setup",
935
+ plugins: {
936
+ "react": plugins["@eslint-react"],
937
+ "react-dom": plugins["@eslint-react/dom"],
938
+ "react-hooks": pluginReactHooks,
939
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
940
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
941
+ "react-refresh": pluginReactRefresh,
942
+ "react-web-api": plugins["@eslint-react/web-api"]
943
+ }
944
+ },
945
+ {
946
+ files,
947
+ languageOptions: {
948
+ parserOptions: { ecmaFeatures: { jsx: true } },
949
+ sourceType: "module"
950
+ },
951
+ name: "react/rules",
952
+ rules: {
953
+ "react/jsx-no-duplicate-props": "warn",
954
+ "react/jsx-uses-vars": "warn",
955
+ "react/no-access-state-in-setstate": "error",
956
+ "react/no-array-index-key": "warn",
957
+ "react/no-children-count": "warn",
958
+ "react/no-children-for-each": "warn",
959
+ "react/no-children-map": "warn",
960
+ "react/no-children-only": "warn",
961
+ "react/no-children-to-array": "warn",
962
+ "react/no-clone-element": "warn",
963
+ "react/no-comment-textnodes": "warn",
964
+ "react/no-component-will-mount": "error",
965
+ "react/no-component-will-receive-props": "error",
966
+ "react/no-component-will-update": "error",
967
+ "react/no-context-provider": "warn",
968
+ "react/no-create-ref": "error",
969
+ "react/no-default-props": "error",
970
+ "react/no-direct-mutation-state": "error",
971
+ "react/no-duplicate-key": "warn",
972
+ "react/no-forward-ref": "warn",
973
+ "react/no-implicit-key": "warn",
974
+ "react/no-missing-key": "error",
975
+ "react/no-nested-component-definitions": "error",
976
+ "react/no-prop-types": "error",
977
+ "react/no-redundant-should-component-update": "error",
978
+ "react/no-set-state-in-component-did-mount": "warn",
979
+ "react/no-set-state-in-component-did-update": "warn",
980
+ "react/no-set-state-in-component-will-update": "warn",
981
+ "react/no-string-refs": "error",
982
+ "react/no-unsafe-component-will-mount": "warn",
983
+ "react/no-unsafe-component-will-receive-props": "warn",
984
+ "react/no-unsafe-component-will-update": "warn",
985
+ "react/no-unstable-context-value": "warn",
986
+ "react/no-unstable-default-props": "warn",
987
+ "react/no-unused-class-component-members": "warn",
988
+ "react/no-unused-state": "warn",
989
+ "react/no-use-context": "warn",
990
+ "react/no-useless-forward-ref": "warn",
991
+ "react-dom/no-dangerously-set-innerhtml": "warn",
992
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
993
+ "react-dom/no-find-dom-node": "error",
994
+ "react-dom/no-flush-sync": "error",
995
+ "react-dom/no-hydrate": "error",
996
+ "react-dom/no-missing-button-type": "warn",
997
+ "react-dom/no-missing-iframe-sandbox": "warn",
998
+ "react-dom/no-namespace": "error",
999
+ "react-dom/no-render": "error",
1000
+ "react-dom/no-render-return-value": "error",
1001
+ "react-dom/no-script-url": "warn",
1002
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1003
+ "react-dom/no-unsafe-target-blank": "warn",
1004
+ "react-dom/no-use-form-state": "error",
1005
+ "react-dom/no-void-elements-with-children": "error",
1006
+ "react-hooks/exhaustive-deps": "warn",
1007
+ "react-hooks/rules-of-hooks": "error",
1008
+ "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1009
+ "react-hooks-extra/no-unnecessary-use-prefix": "warn",
1010
+ "react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
1011
+ "react-web-api/no-leaked-event-listener": "warn",
1012
+ "react-web-api/no-leaked-interval": "warn",
1013
+ "react-web-api/no-leaked-resize-observer": "warn",
1014
+ "react-web-api/no-leaked-timeout": "warn",
1015
+ "react-refresh/only-export-components": ["warn", {
1016
+ allowConstantExport: isAllowConstantExport,
1017
+ allowExportNames: [...isUsingNext$1 ? [
1018
+ "dynamic",
1019
+ "dynamicParams",
1020
+ "revalidate",
1021
+ "fetchCache",
1022
+ "runtime",
1023
+ "preferredRegion",
1024
+ "maxDuration",
1025
+ "config",
1026
+ "generateStaticParams",
1027
+ "metadata",
1028
+ "generateMetadata",
1029
+ "viewport",
1030
+ "generateViewport"
1031
+ ] : [], ...isUsingReactRouter ? [
1032
+ "meta",
1033
+ "links",
1034
+ "headers",
1035
+ "loader",
1036
+ "action"
1037
+ ] : []]
1038
+ }],
1039
+ ...overrides
1040
+ }
1041
+ },
1042
+ ...isTypeAware ? [{
1043
+ files: filesTypeAware,
1044
+ ignores: ignoresTypeAware,
1045
+ name: "react/type-aware-rules",
1046
+ rules: { ...typeAwareRules }
1047
+ }] : []
1048
+ ];
1169
1049
  }
1170
1050
 
1171
- // src/configs/regexp.ts
1172
- import { configs } from "eslint-plugin-regexp";
1051
+ //#endregion
1052
+ //#region src/configs/regexp.ts
1173
1053
  async function regexp(options = {}) {
1174
- const config2 = configs["flat/recommended"];
1175
- const rules = {
1176
- ...config2.rules
1177
- };
1178
- if (options.level === "warn") {
1179
- for (const key in rules) {
1180
- if (rules[key] === "error") {
1181
- rules[key] = "warn";
1182
- }
1183
- }
1184
- }
1185
- return [
1186
- {
1187
- ...config2,
1188
- name: "regexp/rules",
1189
- rules: {
1190
- ...rules,
1191
- ...options.overrides
1192
- }
1193
- }
1194
- ];
1054
+ const config$1 = configs["flat/recommended"];
1055
+ const rules = { ...config$1.rules };
1056
+ if (options.level === "warn") {
1057
+ for (const key in rules) if (rules[key] === "error") rules[key] = "warn";
1058
+ }
1059
+ return [{
1060
+ ...config$1,
1061
+ name: "regexp/rules",
1062
+ rules: {
1063
+ ...rules,
1064
+ ...options.overrides
1065
+ }
1066
+ }];
1195
1067
  }
1196
1068
 
1197
- // src/configs/sort.ts
1069
+ //#endregion
1070
+ //#region src/configs/sort.ts
1071
+ /**
1072
+ * Sort package.json
1073
+ *
1074
+ * Requires `jsonc` config
1075
+ */
1198
1076
  async function sortPackageJson() {
1199
- return [
1200
- {
1201
- files: ["**/package.json"],
1202
- name: "sort/package-json",
1203
- rules: {
1204
- "jsonc/sort-array-values": [
1205
- "error",
1206
- {
1207
- order: { type: "asc" },
1208
- pathPattern: "^files$"
1209
- }
1210
- ],
1211
- "jsonc/sort-keys": [
1212
- "error",
1213
- {
1214
- order: [
1215
- "publisher",
1216
- "name",
1217
- "displayName",
1218
- "type",
1219
- "version",
1220
- "private",
1221
- "packageManager",
1222
- "description",
1223
- "author",
1224
- "contributors",
1225
- "license",
1226
- "funding",
1227
- "homepage",
1228
- "repository",
1229
- "bugs",
1230
- "keywords",
1231
- "categories",
1232
- "sideEffects",
1233
- "imports",
1234
- "exports",
1235
- "main",
1236
- "module",
1237
- "unpkg",
1238
- "jsdelivr",
1239
- "types",
1240
- "typesVersions",
1241
- "bin",
1242
- "icon",
1243
- "files",
1244
- "engines",
1245
- "activationEvents",
1246
- "contributes",
1247
- "scripts",
1248
- "peerDependencies",
1249
- "peerDependenciesMeta",
1250
- "dependencies",
1251
- "optionalDependencies",
1252
- "devDependencies",
1253
- "pnpm",
1254
- "overrides",
1255
- "resolutions",
1256
- "husky",
1257
- "simple-git-hooks",
1258
- "lint-staged",
1259
- "eslintConfig"
1260
- ],
1261
- pathPattern: "^$"
1262
- },
1263
- {
1264
- order: { type: "asc" },
1265
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1266
- },
1267
- {
1268
- order: { type: "asc" },
1269
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1270
- },
1271
- {
1272
- order: ["types", "import", "require", "default"],
1273
- pathPattern: "^exports.*$"
1274
- },
1275
- {
1276
- order: [
1277
- // client hooks only
1278
- "pre-commit",
1279
- "prepare-commit-msg",
1280
- "commit-msg",
1281
- "post-commit",
1282
- "pre-rebase",
1283
- "post-rewrite",
1284
- "post-checkout",
1285
- "post-merge",
1286
- "pre-push",
1287
- "pre-auto-gc"
1288
- ],
1289
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1290
- }
1291
- ]
1292
- }
1293
- }
1294
- ];
1077
+ return [{
1078
+ files: ["**/package.json"],
1079
+ name: "sort/package-json",
1080
+ rules: {
1081
+ "jsonc/sort-array-values": ["error", {
1082
+ order: { type: "asc" },
1083
+ pathPattern: "^files$"
1084
+ }],
1085
+ "jsonc/sort-keys": [
1086
+ "error",
1087
+ {
1088
+ order: [
1089
+ "publisher",
1090
+ "name",
1091
+ "displayName",
1092
+ "type",
1093
+ "version",
1094
+ "private",
1095
+ "packageManager",
1096
+ "description",
1097
+ "author",
1098
+ "contributors",
1099
+ "license",
1100
+ "funding",
1101
+ "homepage",
1102
+ "repository",
1103
+ "bugs",
1104
+ "keywords",
1105
+ "categories",
1106
+ "sideEffects",
1107
+ "imports",
1108
+ "exports",
1109
+ "main",
1110
+ "module",
1111
+ "unpkg",
1112
+ "jsdelivr",
1113
+ "types",
1114
+ "typesVersions",
1115
+ "bin",
1116
+ "icon",
1117
+ "files",
1118
+ "engines",
1119
+ "activationEvents",
1120
+ "contributes",
1121
+ "scripts",
1122
+ "peerDependencies",
1123
+ "peerDependenciesMeta",
1124
+ "dependencies",
1125
+ "optionalDependencies",
1126
+ "devDependencies",
1127
+ "pnpm",
1128
+ "overrides",
1129
+ "resolutions",
1130
+ "husky",
1131
+ "simple-git-hooks",
1132
+ "lint-staged",
1133
+ "eslintConfig"
1134
+ ],
1135
+ pathPattern: "^$"
1136
+ },
1137
+ {
1138
+ order: { type: "asc" },
1139
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1140
+ },
1141
+ {
1142
+ order: { type: "asc" },
1143
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1144
+ },
1145
+ {
1146
+ order: [
1147
+ "types",
1148
+ "import",
1149
+ "require",
1150
+ "default"
1151
+ ],
1152
+ pathPattern: "^exports.*$"
1153
+ },
1154
+ {
1155
+ order: [
1156
+ "pre-commit",
1157
+ "prepare-commit-msg",
1158
+ "commit-msg",
1159
+ "post-commit",
1160
+ "pre-rebase",
1161
+ "post-rewrite",
1162
+ "post-checkout",
1163
+ "post-merge",
1164
+ "pre-push",
1165
+ "pre-auto-gc"
1166
+ ],
1167
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1168
+ }
1169
+ ]
1170
+ }
1171
+ }];
1295
1172
  }
1173
+ /**
1174
+ * Sort tsconfig.json
1175
+ *
1176
+ * Requires `jsonc` config
1177
+ */
1296
1178
  function sortTsconfig() {
1297
- return [
1298
- {
1299
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1300
- name: "sort/tsconfig-json",
1301
- rules: {
1302
- "jsonc/sort-keys": [
1303
- "error",
1304
- {
1305
- order: [
1306
- "extends",
1307
- "compilerOptions",
1308
- "references",
1309
- "files",
1310
- "include",
1311
- "exclude"
1312
- ],
1313
- pathPattern: "^$"
1314
- },
1315
- {
1316
- order: [
1317
- /* Projects */
1318
- "incremental",
1319
- "composite",
1320
- "tsBuildInfoFile",
1321
- "disableSourceOfProjectReferenceRedirect",
1322
- "disableSolutionSearching",
1323
- "disableReferencedProjectLoad",
1324
- /* Language and Environment */
1325
- "target",
1326
- "jsx",
1327
- "jsxFactory",
1328
- "jsxFragmentFactory",
1329
- "jsxImportSource",
1330
- "lib",
1331
- "moduleDetection",
1332
- "noLib",
1333
- "reactNamespace",
1334
- "useDefineForClassFields",
1335
- "emitDecoratorMetadata",
1336
- "experimentalDecorators",
1337
- "libReplacement",
1338
- /* Modules */
1339
- "baseUrl",
1340
- "rootDir",
1341
- "rootDirs",
1342
- "customConditions",
1343
- "module",
1344
- "moduleResolution",
1345
- "moduleSuffixes",
1346
- "noResolve",
1347
- "paths",
1348
- "resolveJsonModule",
1349
- "resolvePackageJsonExports",
1350
- "resolvePackageJsonImports",
1351
- "typeRoots",
1352
- "types",
1353
- "allowArbitraryExtensions",
1354
- "allowImportingTsExtensions",
1355
- "allowUmdGlobalAccess",
1356
- /* JavaScript Support */
1357
- "allowJs",
1358
- "checkJs",
1359
- "maxNodeModuleJsDepth",
1360
- /* Type Checking */
1361
- "strict",
1362
- "strictBindCallApply",
1363
- "strictFunctionTypes",
1364
- "strictNullChecks",
1365
- "strictPropertyInitialization",
1366
- "allowUnreachableCode",
1367
- "allowUnusedLabels",
1368
- "alwaysStrict",
1369
- "exactOptionalPropertyTypes",
1370
- "noFallthroughCasesInSwitch",
1371
- "noImplicitAny",
1372
- "noImplicitOverride",
1373
- "noImplicitReturns",
1374
- "noImplicitThis",
1375
- "noPropertyAccessFromIndexSignature",
1376
- "noUncheckedIndexedAccess",
1377
- "noUnusedLocals",
1378
- "noUnusedParameters",
1379
- "useUnknownInCatchVariables",
1380
- /* Emit */
1381
- "declaration",
1382
- "declarationDir",
1383
- "declarationMap",
1384
- "downlevelIteration",
1385
- "emitBOM",
1386
- "emitDeclarationOnly",
1387
- "importHelpers",
1388
- "importsNotUsedAsValues",
1389
- "inlineSourceMap",
1390
- "inlineSources",
1391
- "mapRoot",
1392
- "newLine",
1393
- "noEmit",
1394
- "noEmitHelpers",
1395
- "noEmitOnError",
1396
- "outDir",
1397
- "outFile",
1398
- "preserveConstEnums",
1399
- "preserveValueImports",
1400
- "removeComments",
1401
- "sourceMap",
1402
- "sourceRoot",
1403
- "stripInternal",
1404
- /* Interop Constraints */
1405
- "allowSyntheticDefaultImports",
1406
- "esModuleInterop",
1407
- "forceConsistentCasingInFileNames",
1408
- "isolatedDeclarations",
1409
- "isolatedModules",
1410
- "preserveSymlinks",
1411
- "verbatimModuleSyntax",
1412
- "erasableSyntaxOnly",
1413
- /* Completeness */
1414
- "skipDefaultLibCheck",
1415
- "skipLibCheck"
1416
- ],
1417
- pathPattern: "^compilerOptions$"
1418
- }
1419
- ]
1420
- }
1421
- }
1422
- ];
1179
+ return [{
1180
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1181
+ name: "sort/tsconfig-json",
1182
+ rules: { "jsonc/sort-keys": [
1183
+ "error",
1184
+ {
1185
+ order: [
1186
+ "extends",
1187
+ "compilerOptions",
1188
+ "references",
1189
+ "files",
1190
+ "include",
1191
+ "exclude"
1192
+ ],
1193
+ pathPattern: "^$"
1194
+ },
1195
+ {
1196
+ order: [
1197
+ "incremental",
1198
+ "composite",
1199
+ "tsBuildInfoFile",
1200
+ "disableSourceOfProjectReferenceRedirect",
1201
+ "disableSolutionSearching",
1202
+ "disableReferencedProjectLoad",
1203
+ "target",
1204
+ "jsx",
1205
+ "jsxFactory",
1206
+ "jsxFragmentFactory",
1207
+ "jsxImportSource",
1208
+ "lib",
1209
+ "moduleDetection",
1210
+ "noLib",
1211
+ "reactNamespace",
1212
+ "useDefineForClassFields",
1213
+ "emitDecoratorMetadata",
1214
+ "experimentalDecorators",
1215
+ "libReplacement",
1216
+ "baseUrl",
1217
+ "rootDir",
1218
+ "rootDirs",
1219
+ "customConditions",
1220
+ "module",
1221
+ "moduleResolution",
1222
+ "moduleSuffixes",
1223
+ "noResolve",
1224
+ "paths",
1225
+ "resolveJsonModule",
1226
+ "resolvePackageJsonExports",
1227
+ "resolvePackageJsonImports",
1228
+ "typeRoots",
1229
+ "types",
1230
+ "allowArbitraryExtensions",
1231
+ "allowImportingTsExtensions",
1232
+ "allowUmdGlobalAccess",
1233
+ "allowJs",
1234
+ "checkJs",
1235
+ "maxNodeModuleJsDepth",
1236
+ "strict",
1237
+ "strictBindCallApply",
1238
+ "strictFunctionTypes",
1239
+ "strictNullChecks",
1240
+ "strictPropertyInitialization",
1241
+ "allowUnreachableCode",
1242
+ "allowUnusedLabels",
1243
+ "alwaysStrict",
1244
+ "exactOptionalPropertyTypes",
1245
+ "noFallthroughCasesInSwitch",
1246
+ "noImplicitAny",
1247
+ "noImplicitOverride",
1248
+ "noImplicitReturns",
1249
+ "noImplicitThis",
1250
+ "noPropertyAccessFromIndexSignature",
1251
+ "noUncheckedIndexedAccess",
1252
+ "noUnusedLocals",
1253
+ "noUnusedParameters",
1254
+ "useUnknownInCatchVariables",
1255
+ "declaration",
1256
+ "declarationDir",
1257
+ "declarationMap",
1258
+ "downlevelIteration",
1259
+ "emitBOM",
1260
+ "emitDeclarationOnly",
1261
+ "importHelpers",
1262
+ "importsNotUsedAsValues",
1263
+ "inlineSourceMap",
1264
+ "inlineSources",
1265
+ "mapRoot",
1266
+ "newLine",
1267
+ "noEmit",
1268
+ "noEmitHelpers",
1269
+ "noEmitOnError",
1270
+ "outDir",
1271
+ "outFile",
1272
+ "preserveConstEnums",
1273
+ "preserveValueImports",
1274
+ "removeComments",
1275
+ "sourceMap",
1276
+ "sourceRoot",
1277
+ "stripInternal",
1278
+ "allowSyntheticDefaultImports",
1279
+ "esModuleInterop",
1280
+ "forceConsistentCasingInFileNames",
1281
+ "isolatedDeclarations",
1282
+ "isolatedModules",
1283
+ "preserveSymlinks",
1284
+ "verbatimModuleSyntax",
1285
+ "erasableSyntaxOnly",
1286
+ "skipDefaultLibCheck",
1287
+ "skipLibCheck"
1288
+ ],
1289
+ pathPattern: "^compilerOptions$"
1290
+ }
1291
+ ] }
1292
+ }];
1423
1293
  }
1424
1294
 
1425
- // src/configs/toml.ts
1295
+ //#endregion
1296
+ //#region src/configs/toml.ts
1426
1297
  async function toml(options = {}) {
1427
- const { files = [GLOB_TOML], overrides = {}, stylistic: stylistic2 = true } = options;
1428
- const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1429
- const [pluginToml, parserToml] = await Promise.all([
1430
- interopDefault(import("eslint-plugin-toml")),
1431
- interopDefault(import("toml-eslint-parser"))
1432
- ]);
1433
- return [
1434
- {
1435
- name: "toml/setup",
1436
- plugins: {
1437
- toml: pluginToml
1438
- }
1439
- },
1440
- {
1441
- files,
1442
- languageOptions: {
1443
- parser: parserToml
1444
- },
1445
- name: "toml/rules",
1446
- rules: {
1447
- "style/spaced-comment": "off",
1448
- "toml/comma-style": "error",
1449
- "toml/keys-order": "error",
1450
- "toml/no-space-dots": "error",
1451
- "toml/no-unreadable-number-separator": "error",
1452
- "toml/precision-of-fractional-seconds": "error",
1453
- "toml/precision-of-integer": "error",
1454
- "toml/tables-order": "error",
1455
- "toml/vue-custom-block/no-parsing-error": "error",
1456
- ...stylistic2 ? {
1457
- "toml/array-bracket-newline": "error",
1458
- "toml/array-bracket-spacing": "error",
1459
- "toml/array-element-newline": "error",
1460
- "toml/indent": ["error", indent === "tab" ? 2 : indent],
1461
- "toml/inline-table-curly-spacing": "error",
1462
- "toml/key-spacing": "error",
1463
- "toml/padding-line-between-pairs": "error",
1464
- "toml/padding-line-between-tables": "error",
1465
- "toml/quoted-keys": "error",
1466
- "toml/spaced-comment": "error",
1467
- "toml/table-bracket-spacing": "error"
1468
- } : {},
1469
- ...overrides
1470
- }
1471
- }
1472
- ];
1298
+ const { files = [GLOB_TOML], overrides = {}, stylistic: stylistic$1 = true } = options;
1299
+ const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1300
+ const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
1301
+ return [{
1302
+ name: "toml/setup",
1303
+ plugins: { toml: pluginToml }
1304
+ }, {
1305
+ files,
1306
+ languageOptions: { parser: parserToml },
1307
+ name: "toml/rules",
1308
+ rules: {
1309
+ "style/spaced-comment": "off",
1310
+ "toml/comma-style": "error",
1311
+ "toml/keys-order": "error",
1312
+ "toml/no-space-dots": "error",
1313
+ "toml/no-unreadable-number-separator": "error",
1314
+ "toml/precision-of-fractional-seconds": "error",
1315
+ "toml/precision-of-integer": "error",
1316
+ "toml/tables-order": "error",
1317
+ "toml/vue-custom-block/no-parsing-error": "error",
1318
+ ...stylistic$1 ? {
1319
+ "toml/array-bracket-newline": "error",
1320
+ "toml/array-bracket-spacing": "error",
1321
+ "toml/array-element-newline": "error",
1322
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1323
+ "toml/inline-table-curly-spacing": "error",
1324
+ "toml/key-spacing": "error",
1325
+ "toml/padding-line-between-pairs": "error",
1326
+ "toml/padding-line-between-tables": "error",
1327
+ "toml/quoted-keys": "error",
1328
+ "toml/spaced-comment": "error",
1329
+ "toml/table-bracket-spacing": "error"
1330
+ } : {},
1331
+ ...overrides
1332
+ }
1333
+ }];
1473
1334
  }
1474
1335
 
1475
- // src/configs/typescript.ts
1476
- import process2 from "node:process";
1336
+ //#endregion
1337
+ //#region src/configs/typescript.ts
1477
1338
  async function typescript(options = {}) {
1478
- const {
1479
- componentExts = [],
1480
- overrides = {},
1481
- overridesTypeAware = {},
1482
- parserOptions = {},
1483
- type = "app"
1484
- } = options;
1485
- const files = options.files ?? [
1486
- GLOB_TS,
1487
- GLOB_TSX,
1488
- ...componentExts.map((ext) => `**/*.${ext}`)
1489
- ];
1490
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1491
- const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
1492
- const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1493
- const isTypeAware = !!tsconfigPath;
1494
- const typeAwareRules = {
1495
- "dot-notation": "off",
1496
- "no-implied-eval": "off",
1497
- "ts/await-thenable": "error",
1498
- "ts/dot-notation": ["error", { allowKeywords: true }],
1499
- "ts/no-floating-promises": "error",
1500
- "ts/no-for-in-array": "error",
1501
- "ts/no-implied-eval": "error",
1502
- "ts/no-misused-promises": "error",
1503
- "ts/no-unnecessary-type-assertion": "error",
1504
- "ts/no-unsafe-argument": "error",
1505
- "ts/no-unsafe-assignment": "error",
1506
- "ts/no-unsafe-call": "error",
1507
- "ts/no-unsafe-member-access": "error",
1508
- "ts/no-unsafe-return": "error",
1509
- "ts/promise-function-async": "error",
1510
- "ts/restrict-plus-operands": "error",
1511
- "ts/restrict-template-expressions": "error",
1512
- "ts/return-await": ["error", "in-try-catch"],
1513
- "ts/strict-boolean-expressions": [
1514
- "error",
1515
- { allowNullableBoolean: true, allowNullableObject: true }
1516
- ],
1517
- "ts/switch-exhaustiveness-check": "error",
1518
- "ts/unbound-method": "error"
1519
- };
1520
- const [pluginTs, parserTs] = await Promise.all([
1521
- interopDefault(import("@typescript-eslint/eslint-plugin")),
1522
- interopDefault(import("@typescript-eslint/parser"))
1523
- ]);
1524
- function makeParser(typeAware, files2, ignores2) {
1525
- return {
1526
- files: files2,
1527
- ...ignores2 ? { ignores: ignores2 } : {},
1528
- languageOptions: {
1529
- parser: parserTs,
1530
- parserOptions: {
1531
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1532
- sourceType: "module",
1533
- ...typeAware ? {
1534
- projectService: {
1535
- allowDefaultProject: ["./*.js"],
1536
- defaultProject: tsconfigPath
1537
- },
1538
- tsconfigRootDir: process2.cwd()
1539
- } : {},
1540
- ...parserOptions
1541
- }
1542
- },
1543
- name: `typescript/${typeAware ? "type-aware-parser" : "parser"}`
1544
- };
1545
- }
1546
- return [
1547
- {
1548
- // Install the plugins without globs, so they can be configured separately.
1549
- name: "typescript/setup",
1550
- plugins: {
1551
- antfu: default3,
1552
- ts: pluginTs
1553
- }
1554
- },
1555
- // assign type-aware parser for type-aware files and type-unaware parser for the rest
1556
- ...isTypeAware ? [
1557
- makeParser(false, files),
1558
- makeParser(true, filesTypeAware, ignoresTypeAware)
1559
- ] : [makeParser(false, files)],
1560
- {
1561
- files,
1562
- name: "typescript/rules",
1563
- rules: {
1564
- ...renameRules(
1565
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
1566
- { "@typescript-eslint": "ts" }
1567
- ),
1568
- ...renameRules(pluginTs.configs.strict.rules, {
1569
- "@typescript-eslint": "ts"
1570
- }),
1571
- "no-dupe-class-members": "off",
1572
- "no-redeclare": "off",
1573
- "no-use-before-define": "off",
1574
- "no-useless-constructor": "off",
1575
- "ts/ban-ts-comment": [
1576
- "error",
1577
- { "ts-expect-error": "allow-with-description" }
1578
- ],
1579
- "ts/consistent-type-definitions": ["error", "interface"],
1580
- "ts/consistent-type-imports": [
1581
- "error",
1582
- {
1583
- disallowTypeAnnotations: false,
1584
- fixStyle: "separate-type-imports",
1585
- prefer: "type-imports"
1586
- }
1587
- ],
1588
- "ts/method-signature-style": ["error", "property"],
1589
- // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1590
- "ts/no-dupe-class-members": "error",
1591
- "ts/no-dynamic-delete": "off",
1592
- "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1593
- "ts/no-explicit-any": "off",
1594
- "ts/no-extraneous-class": "off",
1595
- "ts/no-import-type-side-effects": "error",
1596
- "ts/no-invalid-void-type": "off",
1597
- "ts/no-non-null-assertion": "off",
1598
- "ts/no-redeclare": ["error", { builtinGlobals: false }],
1599
- "ts/no-require-imports": "error",
1600
- "ts/no-unused-expressions": [
1601
- "error",
1602
- {
1603
- allowShortCircuit: true,
1604
- allowTaggedTemplates: true,
1605
- allowTernary: true
1606
- }
1607
- ],
1608
- "ts/no-unused-vars": "off",
1609
- "ts/no-use-before-define": [
1610
- "error",
1611
- { classes: false, functions: false, variables: true }
1612
- ],
1613
- "ts/no-useless-constructor": "off",
1614
- "ts/no-wrapper-object-types": "error",
1615
- "ts/triple-slash-reference": "off",
1616
- "ts/unified-signatures": "off",
1617
- ...type === "lib" ? {
1618
- "ts/explicit-function-return-type": [
1619
- "error",
1620
- {
1621
- allowExpressions: true,
1622
- allowHigherOrderFunctions: true,
1623
- allowIIFEs: true
1624
- }
1625
- ]
1626
- } : {},
1627
- ...overrides
1628
- }
1629
- },
1630
- ...isTypeAware ? [
1631
- {
1632
- files: filesTypeAware,
1633
- ignores: ignoresTypeAware,
1634
- name: "typescript/rules-type-aware",
1635
- rules: {
1636
- ...typeAwareRules,
1637
- ...overridesTypeAware
1638
- }
1639
- }
1640
- ] : []
1641
- ];
1339
+ const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
1340
+ const files = options.files ?? [
1341
+ GLOB_TS,
1342
+ GLOB_TSX,
1343
+ ...componentExts.map((ext) => `**/*.${ext}`)
1344
+ ];
1345
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1346
+ const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
1347
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1348
+ const isTypeAware = !!tsconfigPath;
1349
+ const typeAwareRules = {
1350
+ "dot-notation": "off",
1351
+ "no-implied-eval": "off",
1352
+ "ts/await-thenable": "error",
1353
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1354
+ "ts/no-floating-promises": "error",
1355
+ "ts/no-for-in-array": "error",
1356
+ "ts/no-implied-eval": "error",
1357
+ "ts/no-misused-promises": "error",
1358
+ "ts/no-unnecessary-type-assertion": "error",
1359
+ "ts/no-unsafe-argument": "error",
1360
+ "ts/no-unsafe-assignment": "error",
1361
+ "ts/no-unsafe-call": "error",
1362
+ "ts/no-unsafe-member-access": "error",
1363
+ "ts/no-unsafe-return": "error",
1364
+ "ts/promise-function-async": "error",
1365
+ "ts/restrict-plus-operands": "error",
1366
+ "ts/restrict-template-expressions": "error",
1367
+ "ts/return-await": ["error", "in-try-catch"],
1368
+ "ts/strict-boolean-expressions": ["error", {
1369
+ allowNullableBoolean: true,
1370
+ allowNullableObject: true
1371
+ }],
1372
+ "ts/switch-exhaustiveness-check": "error",
1373
+ "ts/unbound-method": "error"
1374
+ };
1375
+ const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
1376
+ function makeParser(typeAware, files$1, ignores$1) {
1377
+ return {
1378
+ files: files$1,
1379
+ ...ignores$1 ? { ignores: ignores$1 } : {},
1380
+ languageOptions: {
1381
+ parser: parserTs,
1382
+ parserOptions: {
1383
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1384
+ sourceType: "module",
1385
+ ...typeAware ? {
1386
+ projectService: {
1387
+ allowDefaultProject: ["./*.js"],
1388
+ defaultProject: tsconfigPath
1389
+ },
1390
+ tsconfigRootDir: process.cwd()
1391
+ } : {},
1392
+ ...parserOptions
1393
+ }
1394
+ },
1395
+ name: `typescript/${typeAware ? "type-aware-parser" : "parser"}`
1396
+ };
1397
+ }
1398
+ return [
1399
+ {
1400
+ name: "typescript/setup",
1401
+ plugins: {
1402
+ antfu: pluginAntfu,
1403
+ ts: pluginTs
1404
+ }
1405
+ },
1406
+ ...isTypeAware ? [makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, files)],
1407
+ {
1408
+ files,
1409
+ name: "typescript/rules",
1410
+ rules: {
1411
+ ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, { "@typescript-eslint": "ts" }),
1412
+ ...renameRules(pluginTs.configs.strict.rules, { "@typescript-eslint": "ts" }),
1413
+ "no-dupe-class-members": "off",
1414
+ "no-redeclare": "off",
1415
+ "no-use-before-define": "off",
1416
+ "no-useless-constructor": "off",
1417
+ "ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
1418
+ "ts/consistent-type-definitions": ["error", "interface"],
1419
+ "ts/consistent-type-imports": ["error", {
1420
+ disallowTypeAnnotations: false,
1421
+ fixStyle: "separate-type-imports",
1422
+ prefer: "type-imports"
1423
+ }],
1424
+ "ts/method-signature-style": ["error", "property"],
1425
+ "ts/no-dupe-class-members": "error",
1426
+ "ts/no-dynamic-delete": "off",
1427
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1428
+ "ts/no-explicit-any": "off",
1429
+ "ts/no-extraneous-class": "off",
1430
+ "ts/no-import-type-side-effects": "error",
1431
+ "ts/no-invalid-void-type": "off",
1432
+ "ts/no-non-null-assertion": "off",
1433
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
1434
+ "ts/no-require-imports": "error",
1435
+ "ts/no-unused-expressions": ["error", {
1436
+ allowShortCircuit: true,
1437
+ allowTaggedTemplates: true,
1438
+ allowTernary: true
1439
+ }],
1440
+ "ts/no-unused-vars": "off",
1441
+ "ts/no-use-before-define": ["error", {
1442
+ classes: false,
1443
+ functions: false,
1444
+ variables: true
1445
+ }],
1446
+ "ts/no-useless-constructor": "off",
1447
+ "ts/no-wrapper-object-types": "error",
1448
+ "ts/triple-slash-reference": "off",
1449
+ "ts/unified-signatures": "off",
1450
+ ...type === "lib" ? { "ts/explicit-function-return-type": ["error", {
1451
+ allowExpressions: true,
1452
+ allowHigherOrderFunctions: true,
1453
+ allowIIFEs: true
1454
+ }] } : {},
1455
+ ...overrides
1456
+ }
1457
+ },
1458
+ ...isTypeAware ? [{
1459
+ files: filesTypeAware,
1460
+ ignores: ignoresTypeAware,
1461
+ name: "typescript/rules-type-aware",
1462
+ rules: {
1463
+ ...typeAwareRules,
1464
+ ...overridesTypeAware
1465
+ }
1466
+ }] : []
1467
+ ];
1642
1468
  }
1643
1469
 
1644
- // src/configs/unicorn.ts
1470
+ //#endregion
1471
+ //#region src/configs/unicorn.ts
1645
1472
  async function unicorn(options = {}) {
1646
- const {
1647
- allRecommended = false,
1648
- overrides = {}
1649
- } = options;
1650
- return [
1651
- {
1652
- name: "unicorn/rules",
1653
- plugins: {
1654
- unicorn: default6
1655
- },
1656
- rules: {
1657
- ...allRecommended ? default6.configs.recommended.rules : {
1658
- "unicorn/consistent-empty-array-spread": "error",
1659
- "unicorn/error-message": "error",
1660
- "unicorn/escape-case": "error",
1661
- "unicorn/new-for-builtins": "error",
1662
- "unicorn/no-instanceof-builtins": "error",
1663
- "unicorn/no-new-array": "error",
1664
- "unicorn/no-new-buffer": "error",
1665
- "unicorn/number-literal-case": "error",
1666
- "unicorn/prefer-dom-node-text-content": "error",
1667
- "unicorn/prefer-includes": "error",
1668
- "unicorn/prefer-node-protocol": "error",
1669
- "unicorn/prefer-number-properties": "error",
1670
- "unicorn/prefer-string-starts-ends-with": "error",
1671
- "unicorn/prefer-type-error": "error",
1672
- "unicorn/throw-new-error": "error"
1673
- },
1674
- ...overrides
1675
- }
1676
- }
1677
- ];
1473
+ const { allRecommended = false, overrides = {} } = options;
1474
+ return [{
1475
+ name: "unicorn/rules",
1476
+ plugins: { unicorn: pluginUnicorn },
1477
+ rules: {
1478
+ ...allRecommended ? pluginUnicorn.configs.recommended.rules : {
1479
+ "unicorn/consistent-empty-array-spread": "error",
1480
+ "unicorn/error-message": "error",
1481
+ "unicorn/escape-case": "error",
1482
+ "unicorn/new-for-builtins": "error",
1483
+ "unicorn/no-instanceof-builtins": "error",
1484
+ "unicorn/no-new-array": "error",
1485
+ "unicorn/no-new-buffer": "error",
1486
+ "unicorn/number-literal-case": "error",
1487
+ "unicorn/prefer-dom-node-text-content": "error",
1488
+ "unicorn/prefer-includes": "error",
1489
+ "unicorn/prefer-node-protocol": "error",
1490
+ "unicorn/prefer-number-properties": "error",
1491
+ "unicorn/prefer-string-starts-ends-with": "error",
1492
+ "unicorn/prefer-type-error": "error",
1493
+ "unicorn/throw-new-error": "error"
1494
+ },
1495
+ ...overrides
1496
+ }
1497
+ }];
1678
1498
  }
1679
1499
 
1680
- // src/configs/unocss.ts
1500
+ //#endregion
1501
+ //#region src/configs/unocss.ts
1681
1502
  async function unocss(options = {}) {
1682
- const { attributify = true, strict = false } = options;
1683
- await ensurePackages(["@unocss/eslint-plugin"]);
1684
- const [pluginUnoCSS] = await Promise.all([
1685
- interopDefault(import("@unocss/eslint-plugin"))
1686
- ]);
1687
- return [
1688
- {
1689
- name: "unocss",
1690
- plugins: {
1691
- unocss: pluginUnoCSS
1692
- },
1693
- rules: {
1694
- "unocss/order": "warn",
1695
- ...attributify ? {
1696
- "unocss/order-attributify": "warn"
1697
- } : {},
1698
- ...strict ? {
1699
- "unocss/blocklist": "error"
1700
- } : {}
1701
- }
1702
- }
1703
- ];
1503
+ const { attributify = true, strict = false } = options;
1504
+ await ensurePackages(["@unocss/eslint-plugin"]);
1505
+ const [pluginUnoCSS] = await Promise.all([interopDefault(import("@unocss/eslint-plugin"))]);
1506
+ return [{
1507
+ name: "unocss",
1508
+ plugins: { unocss: pluginUnoCSS },
1509
+ rules: {
1510
+ "unocss/order": "warn",
1511
+ ...attributify ? { "unocss/order-attributify": "warn" } : {},
1512
+ ...strict ? { "unocss/blocklist": "error" } : {}
1513
+ }
1514
+ }];
1704
1515
  }
1705
1516
 
1706
- // src/configs/yaml.ts
1517
+ //#endregion
1518
+ //#region src/configs/yaml.ts
1707
1519
  async function yaml(options = {}) {
1708
- const { files = [GLOB_YAML], overrides = {}, stylistic: stylistic2 = true } = options;
1709
- const { indent = 2, quotes = "single" } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1710
- const [pluginYaml, parserYaml] = await Promise.all([
1711
- interopDefault(import("eslint-plugin-yml")),
1712
- interopDefault(import("yaml-eslint-parser"))
1713
- ]);
1714
- return [
1715
- {
1716
- name: "yaml/setup",
1717
- plugins: {
1718
- yaml: pluginYaml
1719
- }
1720
- },
1721
- {
1722
- files,
1723
- languageOptions: {
1724
- parser: parserYaml
1725
- },
1726
- name: "yaml/rules",
1727
- rules: {
1728
- "style/spaced-comment": "off",
1729
- "yaml/block-mapping": "error",
1730
- "yaml/block-sequence": "error",
1731
- "yaml/no-empty-key": "error",
1732
- "yaml/no-empty-sequence-entry": "error",
1733
- "yaml/no-irregular-whitespace": "error",
1734
- "yaml/plain-scalar": "error",
1735
- "yaml/vue-custom-block/no-parsing-error": "error",
1736
- ...stylistic2 ? {
1737
- "yaml/block-mapping-question-indicator-newline": "error",
1738
- "yaml/block-sequence-hyphen-indicator-newline": "error",
1739
- "yaml/flow-mapping-curly-newline": "error",
1740
- "yaml/flow-mapping-curly-spacing": "error",
1741
- "yaml/flow-sequence-bracket-newline": "error",
1742
- "yaml/flow-sequence-bracket-spacing": "error",
1743
- "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1744
- "yaml/key-spacing": "error",
1745
- "yaml/no-tab-indent": "error",
1746
- "yaml/quotes": [
1747
- "error",
1748
- {
1749
- avoidEscape: true,
1750
- prefer: quotes === "backtick" ? "single" : quotes
1751
- }
1752
- ],
1753
- "yaml/spaced-comment": "error"
1754
- } : {},
1755
- ...overrides
1756
- }
1757
- },
1758
- {
1759
- files: ["pnpm-workspace.yaml"],
1760
- name: "yaml/pnpm-workspace",
1761
- rules: {
1762
- "yaml/sort-keys": [
1763
- "error",
1764
- {
1765
- order: [
1766
- "packages",
1767
- "overrides",
1768
- "patchedDependencies",
1769
- "hoistPattern",
1770
- "catalog",
1771
- "catalogs",
1772
- "allowedDeprecatedVersions",
1773
- "allowNonAppliedPatches",
1774
- "configDependencies",
1775
- "ignoredBuiltDependencies",
1776
- "ignoredOptionalDependencies",
1777
- "neverBuiltDependencies",
1778
- "onlyBuiltDependencies",
1779
- "onlyBuiltDependenciesFile",
1780
- "packageExtensions",
1781
- "peerDependencyRules",
1782
- "supportedArchitectures"
1783
- ],
1784
- pathPattern: "^$"
1785
- },
1786
- {
1787
- order: { type: "asc" },
1788
- pathPattern: ".*"
1789
- }
1790
- ]
1791
- }
1792
- }
1793
- ];
1520
+ const { files = [GLOB_YAML], overrides = {}, stylistic: stylistic$1 = true } = options;
1521
+ const { indent = 2, quotes = "single" } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1522
+ const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
1523
+ return [
1524
+ {
1525
+ name: "yaml/setup",
1526
+ plugins: { yaml: pluginYaml }
1527
+ },
1528
+ {
1529
+ files,
1530
+ languageOptions: { parser: parserYaml },
1531
+ name: "yaml/rules",
1532
+ rules: {
1533
+ "style/spaced-comment": "off",
1534
+ "yaml/block-mapping": "error",
1535
+ "yaml/block-sequence": "error",
1536
+ "yaml/no-empty-key": "error",
1537
+ "yaml/no-empty-sequence-entry": "error",
1538
+ "yaml/no-irregular-whitespace": "error",
1539
+ "yaml/plain-scalar": "error",
1540
+ "yaml/vue-custom-block/no-parsing-error": "error",
1541
+ ...stylistic$1 ? {
1542
+ "yaml/block-mapping-question-indicator-newline": "error",
1543
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1544
+ "yaml/flow-mapping-curly-newline": "error",
1545
+ "yaml/flow-mapping-curly-spacing": "error",
1546
+ "yaml/flow-sequence-bracket-newline": "error",
1547
+ "yaml/flow-sequence-bracket-spacing": "error",
1548
+ "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1549
+ "yaml/key-spacing": "error",
1550
+ "yaml/no-tab-indent": "error",
1551
+ "yaml/quotes": ["error", {
1552
+ avoidEscape: true,
1553
+ prefer: quotes === "backtick" ? "single" : quotes
1554
+ }],
1555
+ "yaml/spaced-comment": "error"
1556
+ } : {},
1557
+ ...overrides
1558
+ }
1559
+ },
1560
+ {
1561
+ files: ["pnpm-workspace.yaml"],
1562
+ name: "yaml/pnpm-workspace",
1563
+ rules: { "yaml/sort-keys": [
1564
+ "error",
1565
+ {
1566
+ order: [
1567
+ "packages",
1568
+ "overrides",
1569
+ "patchedDependencies",
1570
+ "hoistPattern",
1571
+ "catalog",
1572
+ "catalogs",
1573
+ "allowedDeprecatedVersions",
1574
+ "allowNonAppliedPatches",
1575
+ "configDependencies",
1576
+ "ignoredBuiltDependencies",
1577
+ "ignoredOptionalDependencies",
1578
+ "neverBuiltDependencies",
1579
+ "onlyBuiltDependencies",
1580
+ "onlyBuiltDependenciesFile",
1581
+ "packageExtensions",
1582
+ "peerDependencyRules",
1583
+ "supportedArchitectures"
1584
+ ],
1585
+ pathPattern: "^$"
1586
+ },
1587
+ {
1588
+ order: { type: "asc" },
1589
+ pathPattern: ".*"
1590
+ }
1591
+ ] }
1592
+ }
1593
+ ];
1794
1594
  }
1795
1595
 
1796
- // src/factory.ts
1797
- var flatConfigProps = [
1798
- "name",
1799
- "languageOptions",
1800
- "linterOptions",
1801
- "processor",
1802
- "plugins",
1803
- "rules",
1804
- "settings"
1596
+ //#endregion
1597
+ //#region src/factory.ts
1598
+ const flatConfigProps = [
1599
+ "name",
1600
+ "languageOptions",
1601
+ "linterOptions",
1602
+ "processor",
1603
+ "plugins",
1604
+ "rules",
1605
+ "settings"
1805
1606
  ];
1806
- var ReactPackages = ["react", "nest"];
1807
- var defaultPluginRenaming = {
1808
- "@eslint-react": "react",
1809
- "@eslint-react/dom": "react-dom",
1810
- "@eslint-react/hooks-extra": "react-hooks-extra",
1811
- "@eslint-react/naming-convention": "react-naming-convention",
1812
- "@stylistic": "style",
1813
- "@typescript-eslint": "ts",
1814
- "import-x": "import",
1815
- "n": "node",
1816
- "yml": "yaml"
1607
+ const ReactPackages = ["react", "nest"];
1608
+ const defaultPluginRenaming = {
1609
+ "@eslint-react": "react",
1610
+ "@eslint-react/dom": "react-dom",
1611
+ "@eslint-react/hooks-extra": "react-hooks-extra",
1612
+ "@eslint-react/naming-convention": "react-naming-convention",
1613
+ "@stylistic": "style",
1614
+ "@typescript-eslint": "ts",
1615
+ "import-x": "import",
1616
+ "n": "node",
1617
+ "yml": "yaml"
1817
1618
  };
1619
+ /**
1620
+ * Construct an array of ESLint flat config items.
1621
+ *
1622
+ * @param {OptionsConfig & TypedFlatConfigItem} options
1623
+ * The options for generating the ESLint configurations.
1624
+ * @param {Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]} userConfigs
1625
+ * The user configurations to be merged with the generated configurations.
1626
+ * @returns {Promise<TypedFlatConfigItem[]>}
1627
+ * The merged ESLint configurations.
1628
+ */
1818
1629
  function config(options = {}, ...userConfigs) {
1819
- const {
1820
- autoRenamePlugins = true,
1821
- componentExts = [],
1822
- gitignore: enableGitignore = true,
1823
- jsx: enableJsx = true,
1824
- pnpm: enableCatalogs = false,
1825
- react: enableReact = ReactPackages.some((i) => isPackageExists3(i)),
1826
- regexp: enableRegexp = true,
1827
- typescript: enableTypeScript = isPackageExists3("typescript"),
1828
- unicorn: enableUnicorn = true,
1829
- unocss: enableUnoCSS = false
1830
- } = options;
1831
- let isInEditor = options.isInEditor;
1832
- if (isInEditor == null) {
1833
- isInEditor = isInEditorEnv();
1834
- if (isInEditor) {
1835
- console.log(
1836
- "[@ghettoddos/eslint-config] Detected running in editor, some rules are disabled."
1837
- );
1838
- }
1839
- }
1840
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1841
- if (stylisticOptions && !("jsx" in stylisticOptions)) {
1842
- stylisticOptions.jsx = enableJsx;
1843
- }
1844
- const configs2 = [];
1845
- if (enableGitignore) {
1846
- if (typeof enableGitignore !== "boolean") {
1847
- configs2.push(
1848
- interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1849
- r({
1850
- name: "gitignore",
1851
- ...enableGitignore
1852
- })
1853
- ])
1854
- );
1855
- } else {
1856
- configs2.push(
1857
- interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1858
- r({
1859
- name: "gitignore",
1860
- strict: false
1861
- })
1862
- ])
1863
- );
1864
- }
1865
- }
1866
- const typescriptOptions = resolveSubOptions(options, "typescript");
1867
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
1868
- configs2.push(
1869
- ignores(options.ignores),
1870
- javascript({
1871
- isInEditor,
1872
- overrides: getOverrides(options, "javascript")
1873
- }),
1874
- comments(),
1875
- node(),
1876
- imports({
1877
- stylistic: stylisticOptions
1878
- }),
1879
- // Optional plugins (installed but not enabled by default)
1880
- perfectionist()
1881
- );
1882
- if (enableUnicorn) {
1883
- configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
1884
- }
1885
- if (enableJsx) {
1886
- configs2.push(jsx());
1887
- }
1888
- if (enableTypeScript) {
1889
- configs2.push(
1890
- typescript({
1891
- ...typescriptOptions,
1892
- componentExts,
1893
- overrides: getOverrides(options, "typescript"),
1894
- type: options.type
1895
- })
1896
- );
1897
- }
1898
- if (stylisticOptions) {
1899
- configs2.push(
1900
- stylistic({
1901
- ...stylisticOptions,
1902
- overrides: getOverrides(options, "stylistic")
1903
- })
1904
- );
1905
- }
1906
- if (enableRegexp) {
1907
- configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1908
- }
1909
- if (enableReact) {
1910
- configs2.push(
1911
- react({
1912
- ...typescriptOptions,
1913
- overrides: getOverrides(options, "react"),
1914
- tsconfigPath
1915
- })
1916
- );
1917
- }
1918
- if (enableUnoCSS) {
1919
- configs2.push(
1920
- unocss({
1921
- ...resolveSubOptions(options, "unocss"),
1922
- overrides: getOverrides(options, "unocss")
1923
- })
1924
- );
1925
- }
1926
- if (options.jsonc ?? true) {
1927
- configs2.push(
1928
- jsonc({
1929
- overrides: getOverrides(options, "jsonc"),
1930
- stylistic: stylisticOptions
1931
- }),
1932
- sortPackageJson(),
1933
- sortTsconfig()
1934
- );
1935
- }
1936
- if (enableCatalogs) {
1937
- configs2.push(
1938
- pnpm()
1939
- );
1940
- }
1941
- if (options.yaml ?? true) {
1942
- configs2.push(
1943
- yaml({
1944
- overrides: getOverrides(options, "yaml"),
1945
- stylistic: stylisticOptions
1946
- })
1947
- );
1948
- }
1949
- if (options.toml ?? true) {
1950
- configs2.push(
1951
- toml({
1952
- overrides: getOverrides(options, "toml"),
1953
- stylistic: stylisticOptions
1954
- })
1955
- );
1956
- }
1957
- if (options.markdown ?? true) {
1958
- configs2.push(
1959
- markdown({
1960
- componentExts,
1961
- overrides: getOverrides(options, "markdown")
1962
- })
1963
- );
1964
- }
1965
- if (options.formatters) {
1966
- configs2.push(
1967
- formatters(
1968
- options.formatters,
1969
- typeof stylisticOptions === "boolean" ? {} : stylisticOptions
1970
- )
1971
- );
1972
- }
1973
- configs2.push(disables());
1974
- if ("files" in options) {
1975
- throw new Error(
1976
- '[@ghettoddos/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.'
1977
- );
1978
- }
1979
- const fusedConfig = flatConfigProps.reduce((acc, key) => {
1980
- if (key in options) {
1981
- acc[key] = options[key];
1982
- }
1983
- return acc;
1984
- }, {});
1985
- if (Object.keys(fusedConfig).length) {
1986
- configs2.push([fusedConfig]);
1987
- }
1988
- let composer = new FlatConfigComposer();
1989
- composer = composer.append(...configs2, ...userConfigs);
1990
- if (autoRenamePlugins) {
1991
- composer = composer.renamePlugins(defaultPluginRenaming);
1992
- }
1993
- if (isInEditor) {
1994
- composer = composer.disableRulesFix(
1995
- ["unused-imports/no-unused-imports", "prefer-const"],
1996
- {
1997
- builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then(
1998
- (r) => r.builtinRules
1999
- )
2000
- }
2001
- );
2002
- }
2003
- return composer;
1630
+ const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, jsx: enableJsx = true, jsxA11y: enableJsxA11y = ReactPackages.some((i) => isPackageExists(i)), next: enableNext = isPackageExists("next"), pnpm: enableCatalogs = false, react: enableReact = ReactPackages.some((i) => isPackageExists(i)), regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false } = options;
1631
+ let isInEditor = options.isInEditor;
1632
+ if (isInEditor == null) {
1633
+ isInEditor = isInEditorEnv();
1634
+ if (isInEditor) console.log("[@ghettoddos/eslint-config] Detected running in editor, some rules are disabled.");
1635
+ }
1636
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1637
+ if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
1638
+ const configs$1 = [];
1639
+ if (enableGitignore) if (typeof enableGitignore !== "boolean") configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
1640
+ name: "gitignore",
1641
+ ...enableGitignore
1642
+ })]));
1643
+ else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
1644
+ name: "gitignore",
1645
+ strict: false
1646
+ })]));
1647
+ const typescriptOptions = resolveSubOptions(options, "typescript");
1648
+ const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
1649
+ configs$1.push(ignores(options.ignores), javascript({
1650
+ isInEditor,
1651
+ overrides: getOverrides(options, "javascript")
1652
+ }), comments(), node(), imports({ stylistic: stylisticOptions }), perfectionist());
1653
+ if (enableUnicorn) configs$1.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
1654
+ if (enableJsx) configs$1.push(jsx());
1655
+ if (enableTypeScript) configs$1.push(typescript({
1656
+ ...typescriptOptions,
1657
+ componentExts,
1658
+ overrides: getOverrides(options, "typescript"),
1659
+ type: options.type
1660
+ }));
1661
+ if (stylisticOptions) configs$1.push(stylistic({
1662
+ ...stylisticOptions,
1663
+ overrides: getOverrides(options, "stylistic")
1664
+ }));
1665
+ if (enableRegexp) configs$1.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1666
+ if (enableReact) configs$1.push(react({
1667
+ ...typescriptOptions,
1668
+ overrides: getOverrides(options, "react"),
1669
+ tsconfigPath
1670
+ }));
1671
+ if (enableJsxA11y) configs$1.push(jsxA11y({ overrides: getOverrides(options, "jsxA11y") }));
1672
+ if (enableNext) configs$1.push(next({ overrides: getOverrides(options, "next") }));
1673
+ if (enableUnoCSS) configs$1.push(unocss({
1674
+ ...resolveSubOptions(options, "unocss"),
1675
+ overrides: getOverrides(options, "unocss")
1676
+ }));
1677
+ if (options.jsonc ?? true) configs$1.push(jsonc({
1678
+ overrides: getOverrides(options, "jsonc"),
1679
+ stylistic: stylisticOptions
1680
+ }), sortPackageJson(), sortTsconfig());
1681
+ if (enableCatalogs) configs$1.push(pnpm());
1682
+ if (options.yaml ?? true) configs$1.push(yaml({
1683
+ overrides: getOverrides(options, "yaml"),
1684
+ stylistic: stylisticOptions
1685
+ }));
1686
+ if (options.toml ?? true) configs$1.push(toml({
1687
+ overrides: getOverrides(options, "toml"),
1688
+ stylistic: stylisticOptions
1689
+ }));
1690
+ if (options.markdown ?? true) configs$1.push(markdown({
1691
+ componentExts,
1692
+ overrides: getOverrides(options, "markdown")
1693
+ }));
1694
+ if (options.formatters) configs$1.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
1695
+ configs$1.push(disables());
1696
+ if ("files" in options) throw new Error("[@ghettoddos/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.");
1697
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
1698
+ if (key in options) acc[key] = options[key];
1699
+ return acc;
1700
+ }, {});
1701
+ if (Object.keys(fusedConfig).length) configs$1.push([fusedConfig]);
1702
+ let composer = new FlatConfigComposer();
1703
+ composer = composer.append(...configs$1, ...userConfigs);
1704
+ if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
1705
+ if (isInEditor) composer = composer.disableRulesFix(["unused-imports/no-unused-imports", "prefer-const"], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
1706
+ return composer;
2004
1707
  }
2005
1708
  function resolveSubOptions(options, key) {
2006
- return typeof options[key] === "boolean" ? {} : options[key] || {};
1709
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
2007
1710
  }
2008
1711
  function getOverrides(options, key) {
2009
- const sub = resolveSubOptions(options, key);
2010
- return {
2011
- ...options.overrides?.[key],
2012
- ..."overrides" in sub ? sub.overrides : {}
2013
- };
1712
+ const sub = resolveSubOptions(options, key);
1713
+ return {
1714
+ ...options.overrides?.[key],
1715
+ ..."overrides" in sub ? sub.overrides : {}
1716
+ };
2014
1717
  }
2015
1718
 
2016
- // src/index.ts
2017
- var index_default = config;
2018
- export {
2019
- GLOB_ALL_SRC,
2020
- GLOB_CSS,
2021
- GLOB_EXCLUDE,
2022
- GLOB_HTML,
2023
- GLOB_JS,
2024
- GLOB_JSON,
2025
- GLOB_JSON5,
2026
- GLOB_JSONC,
2027
- GLOB_JSX,
2028
- GLOB_MARKDOWN,
2029
- GLOB_MARKDOWN_CODE,
2030
- GLOB_MARKDOWN_IN_MARKDOWN,
2031
- GLOB_POSTCSS,
2032
- GLOB_SCSS,
2033
- GLOB_SRC,
2034
- GLOB_SRC_EXT,
2035
- GLOB_STYLE,
2036
- GLOB_SVG,
2037
- GLOB_TOML,
2038
- GLOB_TS,
2039
- GLOB_TSX,
2040
- GLOB_XML,
2041
- GLOB_YAML,
2042
- StylisticConfigDefaults,
2043
- combine,
2044
- comments,
2045
- config,
2046
- index_default as default,
2047
- defaultPluginRenaming,
2048
- disables,
2049
- ensurePackages,
2050
- formatters,
2051
- getOverrides,
2052
- ignores,
2053
- imports,
2054
- interopDefault,
2055
- isInEditorEnv,
2056
- isInGitHooksOrLintStaged,
2057
- isPackageInScope,
2058
- javascript,
2059
- jsonc,
2060
- jsx,
2061
- markdown,
2062
- node,
2063
- parserPlain,
2064
- perfectionist,
2065
- pnpm,
2066
- react,
2067
- regexp,
2068
- renameRules,
2069
- resolveSubOptions,
2070
- sortPackageJson,
2071
- sortTsconfig,
2072
- stylistic,
2073
- toml,
2074
- typescript,
2075
- unicorn,
2076
- unocss,
2077
- yaml
2078
- };
1719
+ //#endregion
1720
+ //#region src/index.ts
1721
+ var src_default = config;
1722
+
1723
+ //#endregion
1724
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, combine, comments, config, src_default as default, defaultPluginRenaming, disables, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsonc, jsx, jsxA11y, markdown, next, node, parserPlain, perfectionist, pnpm, react, regexp, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, toml, typescript, unicorn, unocss, yaml };