@biscuittin/eslint-config 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,242 +1,267 @@
1
- import pluginESLintComments from '@eslint-community/eslint-plugin-eslint-comments';
2
- import pluginReact from '@eslint-react/eslint-plugin';
3
- import { eslint_plugin_jsx_a11y_minimal } from '@eslint-sukka/eslint-plugin-react-jsx-a11y';
4
- import pluginJson from '@eslint/json';
5
- import pluginNextJs from '@next/eslint-plugin-next';
6
- import pluginStylisticJsx from '@stylistic/eslint-plugin-jsx';
7
- import pluginAntfu from 'eslint-plugin-antfu';
8
- import pluginAutofix from 'eslint-plugin-autofix';
9
- import pluginFormat from 'eslint-plugin-format';
10
- import pluginImportX from 'eslint-plugin-import-x';
11
- import pluginJsonc from 'eslint-plugin-jsonc';
12
- import pluginNode from 'eslint-plugin-n';
13
- import pluginPerfectionist from 'eslint-plugin-perfectionist';
14
- import * as pluginReactCompiler from 'eslint-plugin-react-compiler';
15
- import * as pluginReactHooks from 'eslint-plugin-react-hooks';
16
- import pluginReactRefresh from 'eslint-plugin-react-refresh';
17
- import * as pluginRegexp from 'eslint-plugin-regexp';
18
- import pluginTailwindCSS from 'eslint-plugin-tailwindcss';
19
- import pluginUnicorn from 'eslint-plugin-unicorn';
20
- import pluginUnusedImports from 'eslint-plugin-unused-imports';
21
- import { plugin, parser, configs } from 'typescript-eslint';
22
- import fs from 'node:fs';
23
- import path from 'node:path';
24
- import process from 'node:process';
25
- import { findUp } from 'find-up';
26
- import fsp from 'node:fs/promises';
27
- import * as parserJsonc from 'jsonc-eslint-parser';
28
- import gitignore from 'eslint-config-flat-gitignore';
29
- import js from '@eslint/js';
30
- import globals from 'globals';
31
- export { default as globals } from 'globals';
32
- import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
33
- import { FlatConfigComposer } from 'eslint-flat-config-utils';
34
- import { isPackageExists } from 'local-pkg';
1
+ import pluginESLintComments from "@eslint-community/eslint-plugin-eslint-comments";
2
+ import pluginReact from "@eslint-react/eslint-plugin";
3
+ import { eslint_plugin_jsx_a11y_minimal } from "@eslint-sukka/eslint-plugin-react-jsx-a11y";
4
+ import pluginJson from "@eslint/json";
5
+ import pluginNextJs from "@next/eslint-plugin-next";
6
+ import pluginStylisticJsx from "@stylistic/eslint-plugin-jsx";
7
+ import pluginAntfu from "eslint-plugin-antfu";
8
+ import pluginAutofix from "eslint-plugin-autofix";
9
+ import pluginFormat from "eslint-plugin-format";
10
+ import pluginImportX, { configs, createNodeResolver } from "eslint-plugin-import-x";
11
+ import pluginJsonc from "eslint-plugin-jsonc";
12
+ import pluginNode from "eslint-plugin-n";
13
+ import pluginPerfectionist from "eslint-plugin-perfectionist";
14
+ import * as pluginReactCompiler from "eslint-plugin-react-compiler";
15
+ import * as pluginReactHooks from "eslint-plugin-react-hooks";
16
+ import pluginReactRefresh from "eslint-plugin-react-refresh";
17
+ import * as pluginRegexp from "eslint-plugin-regexp";
18
+ import pluginTailwindCSS from "eslint-plugin-tailwindcss";
19
+ import pluginUnicorn from "eslint-plugin-unicorn";
20
+ import pluginUnusedImports from "eslint-plugin-unused-imports";
21
+ import { configs as configs$1, parser, plugin } from "typescript-eslint";
22
+ import fs from "node:fs";
23
+ import path from "node:path";
24
+ import process from "node:process";
25
+ import { findUp } from "find-up";
26
+ import fsp from "node:fs/promises";
27
+ import * as parserJsonc from "jsonc-eslint-parser";
28
+ import gitignore from "eslint-config-flat-gitignore";
29
+ import js from "@eslint/js";
30
+ import globals, { default as globals$1 } from "globals";
31
+ import { createTypeScriptImportResolver, defaultExtensions } from "eslint-import-resolver-typescript";
32
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
33
+ import { isPackageExists } from "local-pkg";
35
34
 
36
- async function combine(...configs) {
37
- const resolved = await Promise.all(configs);
38
- return resolved.flat();
35
+ //#region src/utils/combine.ts
36
+ /**
37
+ * Combine array and non-array configs into a single array.
38
+ * Copied from antfu/eslint-config
39
+ * Ref: https://github.com/antfu/eslint-config/blob/e283983d8cb72304424f67090a3e3bdccdf95c0d/src/utils.ts#L32
40
+ */
41
+ async function combine(...configs$2) {
42
+ const resolved = await Promise.all(configs$2);
43
+ return resolved.flat();
39
44
  }
40
45
 
46
+ //#endregion
47
+ //#region src/utils/get-flat-config-name.ts
41
48
  function getFlatConfigName(module) {
42
- return {
43
- base: `@biscuittin/eslint-config/${module}`,
44
- setup: `@biscuittin/eslint-config/${module}/setup`,
45
- rules: `@biscuittin/eslint-config/${module}/rules`,
46
- stylistic: `@biscuittin/eslint-config/${module}/stylistic`,
47
- commonjs: `@biscuittin/eslint-config/${module}/commonjs`,
48
- module: `@biscuittin/eslint-config/${module}/module`,
49
- script: `@biscuittin/eslint-config/${module}/script`
50
- };
49
+ return {
50
+ base: `@biscuittin/eslint-config/${module}`,
51
+ setup: `@biscuittin/eslint-config/${module}/setup`,
52
+ rules: `@biscuittin/eslint-config/${module}/rules`,
53
+ stylistic: `@biscuittin/eslint-config/${module}/stylistic`,
54
+ commonjs: `@biscuittin/eslint-config/${module}/commonjs`,
55
+ module: `@biscuittin/eslint-config/${module}/module`,
56
+ script: `@biscuittin/eslint-config/${module}/script`
57
+ };
51
58
  }
52
59
 
53
- var __defProp = Object.defineProperty;
54
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
55
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
60
+ //#endregion
61
+ //#region src/utils/get-package-json.ts
56
62
  const SKIP_TIME = 2e4;
57
- class Cache {
58
- constructor() {
59
- /**
60
- * Initialize this cache instance.
61
- */
62
- __publicField(this, "map", /* @__PURE__ */ new Map());
63
- }
64
- /**
65
- * Get the cached value of the given key.
66
- */
67
- get(key) {
68
- const entry = this.map.get(key);
69
- const now = Date.now();
70
- if (!entry) return null;
71
- if (entry.expire > now) {
72
- entry.expire = now + SKIP_TIME;
73
- return entry.value;
74
- }
75
- this.map.delete(key);
76
- return null;
77
- }
78
- /**
79
- * Set the value of the given key.
80
- */
81
- set(key, value) {
82
- const entry = this.map.get(key);
83
- const expire = Date.now() + SKIP_TIME;
84
- if (!entry) {
85
- this.map.set(key, { value, expire });
86
- return;
87
- }
88
- entry.value = value;
89
- entry.expire = expire;
90
- }
91
- }
63
+ /**
64
+ * The class of cache.
65
+ * The cache will dispose of each value if the value has not been accessed
66
+ * during 20 seconds.
67
+ */
68
+ var Cache = class {
69
+ /**
70
+ * Initialize this cache instance.
71
+ */
72
+ map = /* @__PURE__ */ new Map();
73
+ /**
74
+ * Get the cached value of the given key.
75
+ */
76
+ get(key) {
77
+ const entry = this.map.get(key);
78
+ const now = Date.now();
79
+ if (!entry) return null;
80
+ if (entry.expire > now) {
81
+ entry.expire = now + SKIP_TIME;
82
+ return entry.value;
83
+ }
84
+ this.map.delete(key);
85
+ return null;
86
+ }
87
+ /**
88
+ * Set the value of the given key.
89
+ */
90
+ set(key, value) {
91
+ const entry = this.map.get(key);
92
+ const expire = Date.now() + SKIP_TIME;
93
+ if (!entry) {
94
+ this.map.set(key, {
95
+ value,
96
+ expire
97
+ });
98
+ return;
99
+ }
100
+ entry.value = value;
101
+ entry.expire = expire;
102
+ }
103
+ };
92
104
  const cache = new Cache();
105
+ /**
106
+ * Reads the `package.json` data in a given path.
107
+ *
108
+ * Don't cache the data.
109
+ *
110
+ * @param directory - The path to a directory to read.
111
+ * @returns The read `package.json` data, or null.
112
+ */
93
113
  function readPackageJson(directory) {
94
- const filePath = path.join(directory, "package.json");
95
- try {
96
- const text = fs.readFileSync(filePath, "utf8");
97
- const data = JSON.parse(text);
98
- if (data && typeof data === "object") {
99
- data["filePath"] = filePath;
100
- return data;
101
- }
102
- } catch {
103
- }
104
- return null;
114
+ const filePath = path.join(directory, "package.json");
115
+ try {
116
+ const text = fs.readFileSync(filePath, "utf8");
117
+ const data = JSON.parse(text);
118
+ if (data && typeof data === "object") {
119
+ data["filePath"] = filePath;
120
+ return data;
121
+ }
122
+ } catch {}
123
+ return null;
105
124
  }
125
+ /**
126
+ * Gets a `package.json` data.
127
+ * The data is cached if found, then it's used after.
128
+ *
129
+ * @param startPath - A file path to lookup.
130
+ * @returns A found `package.json` data or `null`.
131
+ * This object have additional property `filePath`.
132
+ */
106
133
  function getPackageJson(startPath = "a.js") {
107
- const startDirectory = path.dirname(path.resolve(startPath));
108
- let directory = startDirectory;
109
- let previousDirectory = "";
110
- let data = null;
111
- do {
112
- data = cache.get(directory);
113
- if (data) {
114
- if (directory !== startDirectory) {
115
- cache.set(startDirectory, data);
116
- }
117
- return data;
118
- }
119
- data = readPackageJson(directory);
120
- if (data) {
121
- cache.set(directory, data);
122
- cache.set(startDirectory, data);
123
- return data;
124
- }
125
- previousDirectory = directory;
126
- directory = path.resolve(directory, "..");
127
- } while (directory !== previousDirectory);
128
- cache.set(startDirectory, null);
129
- return null;
134
+ const startDirectory = path.dirname(path.resolve(startPath));
135
+ let directory = startDirectory;
136
+ let previousDirectory = "";
137
+ let data = null;
138
+ do {
139
+ data = cache.get(directory);
140
+ if (data) {
141
+ if (directory !== startDirectory) cache.set(startDirectory, data);
142
+ return data;
143
+ }
144
+ data = readPackageJson(directory);
145
+ if (data) {
146
+ cache.set(directory, data);
147
+ cache.set(startDirectory, data);
148
+ return data;
149
+ }
150
+ previousDirectory = directory;
151
+ directory = path.resolve(directory, "..");
152
+ } while (directory !== previousDirectory);
153
+ cache.set(startDirectory, null);
154
+ return null;
130
155
  }
131
156
 
157
+ //#endregion
158
+ //#region src/utils/is-in-git-hooks.ts
132
159
  function isInGitHooksOrLintStaged() {
133
- return !!((process.env["GIT_PARAMS"] ?? "") || (process.env["VSCODE_GIT_COMMAND"] ?? "") || process.env["npm_lifecycle_script"]?.startsWith("lint-staged"));
160
+ return !!((process.env["GIT_PARAMS"] ?? "") || (process.env["VSCODE_GIT_COMMAND"] ?? "") || process.env["npm_lifecycle_script"]?.startsWith("lint-staged"));
134
161
  }
135
162
 
163
+ //#endregion
164
+ //#region src/utils/is-in-editor.ts
136
165
  function isInEditorEnv() {
137
- if (process.env["CI"] ?? "") return false;
138
- if (isInGitHooksOrLintStaged()) return false;
139
- return !!((process.env["VSCODE_PID"] ?? "") || (process.env["VSCODE_CWD"] ?? "") || (process.env["JETBRAINS_IDE"] ?? "") || (process.env["VIM"] ?? "") || (process.env["NVIM"] ?? ""));
166
+ if (process.env["CI"] ?? "") return false;
167
+ if (isInGitHooksOrLintStaged()) return false;
168
+ return !!((process.env["VSCODE_PID"] ?? "") || (process.env["VSCODE_CWD"] ?? "") || (process.env["JETBRAINS_IDE"] ?? "") || (process.env["VIM"] ?? "") || (process.env["NVIM"] ?? ""));
140
169
  }
141
170
 
142
- async function loadLocalFile(name, cwd = process.cwd()) {
143
- const path = await findUp(name, { cwd });
144
- if (!path || !fs.existsSync(path)) return null;
145
- return JSON.parse(await fsp.readFile(path, "utf8"));
171
+ //#endregion
172
+ //#region src/utils/load-local-file.ts
173
+ async function loadLocalFile(name$15, cwd = process.cwd()) {
174
+ const path$1 = await findUp(name$15, { cwd });
175
+ if (!path$1 || !fs.existsSync(path$1)) return null;
176
+ return JSON.parse(await fsp.readFile(path$1, "utf8"));
146
177
  }
147
178
 
179
+ //#endregion
180
+ //#region src/utils/memoize-eslint-plugin.ts
181
+ /**
182
+ * Every package manager has this flaw: Even if a pinned, same version of transitive dependency
183
+ * is depended on by multiple packages, all npm/pnpm/yarn/bun will not dedupe it, some package
184
+ * manager even doesn't have dedupe feature (yes, bun. You are literally wasting my disk space
185
+ * for speed).
186
+ *
187
+ * But if there are multiple copy of the same version of transitive dependency, they will not have
188
+ * the same referential identity, which causes ESLint to panic and throw error.
189
+ *
190
+ * So we have to memoize the plugins and configs to make sure they are the same referential identity.
191
+ *
192
+ * Copied from SukkaW/eslint-config-sukka
193
+ * Ref: https://github.com/SukkaW/eslint-config-sukka/blob/bbca2d568d738a1d287c473804ea8ccbf00d3c86/packages/shared/src/memoize-eslint-plugin.ts#L17
194
+ */
148
195
  function memo(function_, key) {
149
- var _a;
150
- let _key = key;
151
- if (_key === void 0 || !_key) {
152
- if (typeof function_.toString !== "function") throw new TypeError("memo() requires a key!");
153
- _key = function_.toString();
154
- }
155
- globalThis.__ESLINT_PLUGIN_MEMO__ ?? (globalThis.__ESLINT_PLUGIN_MEMO__ = {});
156
- (_a = globalThis.__ESLINT_PLUGIN_MEMO__)[_key] ?? (_a[_key] = function_);
157
- return globalThis.__ESLINT_PLUGIN_MEMO__[_key];
196
+ let _key = key;
197
+ if (_key === void 0 || !_key) {
198
+ if (typeof function_.toString !== "function") throw new TypeError("memo() requires a key!");
199
+ _key = function_.toString();
200
+ }
201
+ globalThis.__ESLINT_PLUGIN_MEMO__ ??= {};
202
+ globalThis.__ESLINT_PLUGIN_MEMO__[_key] ??= function_;
203
+ return globalThis.__ESLINT_PLUGIN_MEMO__[_key];
158
204
  }
159
205
 
206
+ //#endregion
207
+ //#region src/plugins.ts
160
208
  const reactPlugins = pluginReact.configs.all.plugins;
161
209
  const plugins = {
162
- pluginAntfu: memo(pluginAntfu, "eslint-plugin-antfu"),
163
- pluginAutofix: memo(pluginAutofix, "eslint-plugin-autofix"),
164
- pluginESLintComments: memo(
165
- pluginESLintComments,
166
- "eslint-plugin-eslint-comments"
167
- ),
168
- pluginFormat: memo(pluginFormat, "eslint-plugin-format"),
169
- pluginImportX: memo(pluginImportX, "eslint-plugin-import-x"),
170
- pluginJson: memo(pluginJson, "eslint-plugin-json"),
171
- pluginJsonc: memo(pluginJsonc, "eslint-plugin-jsonc"),
172
- pluginJsxA11y: memo(eslint_plugin_jsx_a11y_minimal, "eslint-plugin-react-jsx-a11y"),
173
- pluginNextJs: memo(pluginNextJs, "eslint-plugin-next"),
174
- pluginNode: memo(pluginNode, "eslint-plugin-n"),
175
- pluginPerfectionist: memo(pluginPerfectionist, "eslint-plugin-perfectionist"),
176
- pluginReact: memo(
177
- reactPlugins["@eslint-react"],
178
- "eslint-plugin-react-x"
179
- ),
180
- pluginReactCompiler: memo(
181
- pluginReactCompiler,
182
- "eslint-plugin-react-compiler"
183
- ),
184
- pluginReactDebug: memo(
185
- reactPlugins["@eslint-react/debug"],
186
- "eslint-plugin-react-debug"
187
- ),
188
- pluginReactDom: memo(
189
- reactPlugins["@eslint-react/dom"],
190
- "eslint-plugin-react-dom"
191
- ),
192
- pluginReactHooks: memo(pluginReactHooks, "eslint-plugin-react-hooks"),
193
- pluginReactHooksExtra: memo(
194
- reactPlugins["@eslint-react/hooks-extra"],
195
- "eslint-plugin-react-hooks-extra"
196
- ),
197
- pluginReactHooksNamingConvention: memo(
198
- reactPlugins["@eslint-react/naming-convention"],
199
- "eslint-plugin-react-naming-convention"
200
- ),
201
- pluginReactRefresh: memo(pluginReactRefresh, "eslint-plugin-react-refresh"),
202
- pluginReactWebApi: memo(
203
- reactPlugins["@eslint-react/web-api"],
204
- "eslint-plugin-react-web-api"
205
- ),
206
- pluginRegexp: memo(pluginRegexp, "eslint-plugin-regexp"),
207
- pluginStylisticJsx: memo(pluginStylisticJsx, "eslint-plugin-jsx"),
208
- pluginTailwindCSS: memo(pluginTailwindCSS, "eslint-plugin-tailwindcss"),
209
- pluginTypescript: memo(plugin, "typescript-eslint"),
210
- pluginUnicorn: memo(pluginUnicorn, "eslint-plugin-unicorn"),
211
- pluginUnusedImports: memo(pluginUnusedImports, "eslint-plugin-unused-imports")
210
+ pluginAntfu: memo(pluginAntfu, "eslint-plugin-antfu"),
211
+ pluginAutofix: memo(pluginAutofix, "eslint-plugin-autofix"),
212
+ pluginESLintComments: memo(pluginESLintComments, "eslint-plugin-eslint-comments"),
213
+ pluginFormat: memo(pluginFormat, "eslint-plugin-format"),
214
+ pluginImportX: memo(pluginImportX, "eslint-plugin-import-x"),
215
+ pluginJson: memo(pluginJson, "eslint-plugin-json"),
216
+ pluginJsonc: memo(pluginJsonc, "eslint-plugin-jsonc"),
217
+ pluginJsxA11y: memo(eslint_plugin_jsx_a11y_minimal, "eslint-plugin-react-jsx-a11y"),
218
+ pluginNextJs: memo(pluginNextJs, "eslint-plugin-next"),
219
+ pluginNode: memo(pluginNode, "eslint-plugin-n"),
220
+ pluginPerfectionist: memo(pluginPerfectionist, "eslint-plugin-perfectionist"),
221
+ pluginReact: memo(reactPlugins["@eslint-react"], "eslint-plugin-react-x"),
222
+ pluginReactCompiler: memo(pluginReactCompiler, "eslint-plugin-react-compiler"),
223
+ pluginReactDebug: memo(reactPlugins["@eslint-react/debug"], "eslint-plugin-react-debug"),
224
+ pluginReactDom: memo(reactPlugins["@eslint-react/dom"], "eslint-plugin-react-dom"),
225
+ pluginReactHooks: memo(pluginReactHooks, "eslint-plugin-react-hooks"),
226
+ pluginReactHooksExtra: memo(reactPlugins["@eslint-react/hooks-extra"], "eslint-plugin-react-hooks-extra"),
227
+ pluginReactHooksNamingConvention: memo(reactPlugins["@eslint-react/naming-convention"], "eslint-plugin-react-naming-convention"),
228
+ pluginReactRefresh: memo(pluginReactRefresh, "eslint-plugin-react-refresh"),
229
+ pluginReactWebApi: memo(reactPlugins["@eslint-react/web-api"], "eslint-plugin-react-web-api"),
230
+ pluginRegexp: memo(pluginRegexp, "eslint-plugin-regexp"),
231
+ pluginStylisticJsx: memo(pluginStylisticJsx, "eslint-plugin-jsx"),
232
+ pluginTailwindCSS: memo(pluginTailwindCSS, "eslint-plugin-tailwindcss"),
233
+ pluginTypescript: memo(plugin, "typescript-eslint"),
234
+ pluginUnicorn: memo(pluginUnicorn, "eslint-plugin-unicorn"),
235
+ pluginUnusedImports: memo(pluginUnusedImports, "eslint-plugin-unused-imports")
212
236
  };
237
+ var plugins_default = plugins;
213
238
 
214
- const name$e = getFlatConfigName("eslint-comments");
239
+ //#endregion
240
+ //#region src/configs/comments.ts
241
+ const name$14 = getFlatConfigName("eslint-comments");
215
242
  function comments() {
216
- return [
217
- {
218
- name: name$e.setup,
219
- plugins: {
220
- "@eslint-community/eslint-comments": plugins["pluginESLintComments"]
221
- }
222
- },
223
- {
224
- name: name$e.rules,
225
- rules: {
226
- "@eslint-community/eslint-comments/disable-enable-pair": [
227
- "error",
228
- { allowWholeFile: true }
229
- ],
230
- "@eslint-community/eslint-comments/no-aggregating-enable": "error",
231
- "@eslint-community/eslint-comments/no-duplicate-disable": "error",
232
- "@eslint-community/eslint-comments/no-unlimited-disable": "error",
233
- "@eslint-community/eslint-comments/no-unused-enable": "error",
234
- "@eslint-community/eslint-comments/require-description": "error"
235
- }
236
- }
237
- ];
243
+ return [{
244
+ name: name$14.setup,
245
+ plugins: { "@eslint-community/eslint-comments": plugins_default["pluginESLintComments"] }
246
+ }, {
247
+ name: name$14.rules,
248
+ rules: {
249
+ "@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
250
+ "@eslint-community/eslint-comments/no-aggregating-enable": "error",
251
+ "@eslint-community/eslint-comments/no-duplicate-disable": "error",
252
+ "@eslint-community/eslint-comments/no-unlimited-disable": "error",
253
+ "@eslint-community/eslint-comments/no-unused-enable": "error",
254
+ "@eslint-community/eslint-comments/require-description": "error"
255
+ }
256
+ }];
238
257
  }
239
258
 
259
+ //#endregion
260
+ //#region src/globs.ts
261
+ /**
262
+ * Copied from antfu/eslint-config
263
+ * Ref: https://github.com/antfu/eslint-config/blob/12718a47803bcd3fa1faf3f424430ecf1a9ddda9/src/globs.ts
264
+ */
240
265
  const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
241
266
  const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
242
267
  const GLOB_JS = "**/*.?([cm])js";
@@ -257,1483 +282,1285 @@ const GLOB_XML = "**/*.xml";
257
282
  const GLOB_HTML = "**/*.htm?(l)";
258
283
  const GLOB_SVG = "**/*.svg";
259
284
  const GLOB_ASTRO = "**/*.astro";
285
+ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
286
+ const GLOB_TESTS = [
287
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
288
+ `**/*.spec.${GLOB_SRC_EXT}`,
289
+ `**/*.test.${GLOB_SRC_EXT}`,
290
+ `**/*.bench.${GLOB_SRC_EXT}`,
291
+ `**/*.benchmark.${GLOB_SRC_EXT}`
292
+ ];
260
293
  const GLOB_ALL_SRC = [
261
- GLOB_SRC,
262
- GLOB_STYLE,
263
- GLOB_POSTCSS,
264
- GLOB_JSON,
265
- GLOB_JSON5,
266
- GLOB_JSONC,
267
- GLOB_MARKDOWN,
268
- GLOB_SVELTE,
269
- GLOB_VUE,
270
- GLOB_YAML,
271
- GLOB_TOML,
272
- GLOB_XML,
273
- GLOB_HTML,
274
- GLOB_SVG,
275
- GLOB_ASTRO
294
+ GLOB_SRC,
295
+ GLOB_STYLE,
296
+ GLOB_POSTCSS,
297
+ GLOB_JSON,
298
+ GLOB_JSON5,
299
+ GLOB_JSONC,
300
+ GLOB_MARKDOWN,
301
+ GLOB_SVELTE,
302
+ GLOB_VUE,
303
+ GLOB_YAML,
304
+ GLOB_TOML,
305
+ GLOB_XML,
306
+ GLOB_HTML,
307
+ GLOB_SVG,
308
+ GLOB_ASTRO
276
309
  ];
277
310
  const GLOB_EXCLUDE = [
278
- "**/node_modules",
279
- "**/dist",
280
- "**/package-lock.json",
281
- "**/yarn.lock",
282
- "**/pnpm-lock.yaml",
283
- "**/bun.lockb",
284
- "**/output",
285
- "**/coverage",
286
- "**/temp",
287
- "**/.temp",
288
- "**/tmp",
289
- "**/.tmp",
290
- "**/.history",
291
- "**/.vitepress/cache",
292
- "**/.nuxt",
293
- "**/.next",
294
- "**/.svelte-kit",
295
- "**/.vercel",
296
- "**/.changeset",
297
- "**/.idea",
298
- "**/.cache",
299
- "**/.output",
300
- "**/.vite-inspect",
301
- "**/.yarn",
302
- "**/vite.config.*.timestamp-*",
303
- "**/CHANGELOG*.md",
304
- "**/*.min.*",
305
- "**/LICENSE*",
306
- "**/__snapshots__",
307
- "**/auto-import?(s).d.ts",
308
- "**/components.d.ts"
311
+ "**/node_modules",
312
+ "**/dist",
313
+ "**/package-lock.json",
314
+ "**/yarn.lock",
315
+ "**/pnpm-lock.yaml",
316
+ "**/bun.lockb",
317
+ "**/output",
318
+ "**/coverage",
319
+ "**/temp",
320
+ "**/.temp",
321
+ "**/tmp",
322
+ "**/.tmp",
323
+ "**/.history",
324
+ "**/.vitepress/cache",
325
+ "**/.nuxt",
326
+ "**/.next",
327
+ "**/.svelte-kit",
328
+ "**/.vercel",
329
+ "**/.changeset",
330
+ "**/.idea",
331
+ "**/.cache",
332
+ "**/.output",
333
+ "**/.vite-inspect",
334
+ "**/.yarn",
335
+ "**/vite.config.*.timestamp-*",
336
+ "**/CHANGELOG*.md",
337
+ "**/*.min.*",
338
+ "**/LICENSE*",
339
+ "**/__snapshots__",
340
+ "**/auto-import?(s).d.ts",
341
+ "**/components.d.ts"
309
342
  ];
310
343
 
311
- const name$d = getFlatConfigName("disables");
344
+ //#endregion
345
+ //#region src/configs/disables.ts
346
+ const name$13 = getFlatConfigName("disables");
312
347
  function disables() {
313
- return [
314
- {
315
- name: name$d.script,
316
- files: [`**/scripts/${GLOB_SRC}`],
317
- rules: {
318
- "antfu/no-top-level-await": "off",
319
- "no-console": "off",
320
- "@typescript-eslint/explicit-function-return-type": "off"
321
- }
322
- },
323
- {
324
- name: `${name$d.base}/cli`,
325
- files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
326
- rules: {
327
- "antfu/no-top-level-await": "off",
328
- "no-console": "off"
329
- }
330
- },
331
- {
332
- name: `${name$d.base}/bin`,
333
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
334
- rules: {
335
- "antfu/no-import-dist": "off",
336
- "antfu/no-import-node-modules-by-path": "off"
337
- }
338
- },
339
- {
340
- name: `${name$d.base}/dts`,
341
- files: ["**/*.d.?([cm])ts"],
342
- rules: {
343
- "@typescript-eslint/no-empty-object-type": ["error", { allowInterfaces: "always" }],
344
- "@eslint-community/eslint-comments/no-unlimited-disable": "off",
345
- "import-x/no-duplicates": "off",
346
- "no-restricted-syntax": "off",
347
- "unused-imports/no-unused-vars": "off"
348
- }
349
- },
350
- {
351
- name: name$d.commonjs,
352
- files: ["**/*.js", "**/*.cjs"],
353
- rules: {
354
- "@typescript-eslint/no-require-imports": "off"
355
- }
356
- },
357
- {
358
- name: `${name$d.base}/config-files`,
359
- files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
360
- rules: {
361
- "antfu/no-top-level-await": "off",
362
- "no-console": "off",
363
- "@typescript-eslint/explicit-function-return-type": "off"
364
- }
365
- }
366
- ];
348
+ return [
349
+ {
350
+ name: name$13.script,
351
+ files: [`**/scripts/${GLOB_SRC}`],
352
+ rules: {
353
+ "antfu/no-top-level-await": "off",
354
+ "no-console": "off",
355
+ "@typescript-eslint/explicit-function-return-type": "off"
356
+ }
357
+ },
358
+ {
359
+ name: `${name$13.base}/cli`,
360
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
361
+ rules: {
362
+ "antfu/no-top-level-await": "off",
363
+ "no-console": "off"
364
+ }
365
+ },
366
+ {
367
+ name: `${name$13.base}/bin`,
368
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
369
+ rules: {
370
+ "antfu/no-import-dist": "off",
371
+ "antfu/no-import-node-modules-by-path": "off"
372
+ }
373
+ },
374
+ {
375
+ name: `${name$13.base}/dts`,
376
+ files: ["**/*.d.?([cm])ts"],
377
+ rules: {
378
+ "@typescript-eslint/no-empty-object-type": ["error", { allowInterfaces: "always" }],
379
+ "@eslint-community/eslint-comments/no-unlimited-disable": "off",
380
+ "import-x/no-duplicates": "off",
381
+ "no-restricted-syntax": "off",
382
+ "unused-imports/no-unused-vars": "off"
383
+ }
384
+ },
385
+ {
386
+ name: name$13.commonjs,
387
+ files: ["**/*.js", "**/*.cjs"],
388
+ rules: { "@typescript-eslint/no-require-imports": "off" }
389
+ },
390
+ {
391
+ name: `${name$13.base}/config-files`,
392
+ files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
393
+ rules: {
394
+ "antfu/no-top-level-await": "off",
395
+ "no-console": "off",
396
+ "@typescript-eslint/explicit-function-return-type": "off"
397
+ }
398
+ }
399
+ ];
367
400
  }
368
401
 
402
+ //#endregion
403
+ //#region src/parsers.ts
369
404
  const parsers = {
370
- parserJsonc,
371
- parserPlain: pluginFormat.parserPlain,
372
- parserTypescript: parser
405
+ parserJsonc,
406
+ parserPlain: pluginFormat.parserPlain,
407
+ parserTypescript: parser
373
408
  };
409
+ var parsers_default = parsers;
374
410
 
411
+ //#endregion
412
+ //#region src/configs/formatters.ts
375
413
  const quoteStyleMap = {
376
- single: "preferSingle",
377
- double: "preferDouble"
414
+ single: "preferSingle",
415
+ double: "preferDouble"
378
416
  };
379
417
  const trailingCommasMap = {
380
- none: "never",
381
- all: "always",
382
- multiline: "onlyMultiLine"
418
+ none: "never",
419
+ all: "always",
420
+ multiline: "onlyMultiLine"
383
421
  };
384
- const name$c = getFlatConfigName("formatters");
422
+ const name$12 = getFlatConfigName("formatters");
385
423
  async function formatters(options = {}) {
386
- const {
387
- dprintConfigPath = "dprint.json",
388
- printWidth = 120,
389
- indentWidth = 2,
390
- useTabs = false,
391
- semi = false,
392
- quotes = "single",
393
- jsxQuotes = "double",
394
- trailingComma = "multiline",
395
- endOfLine = "lf",
396
- extraJsonFiles = []
397
- } = options;
398
- const dprintConfig = await loadLocalFile(dprintConfigPath);
399
- function hasPlugin(name2) {
400
- return dprintConfig?.plugins.some((url) => url.includes(name2)) ?? false;
401
- }
402
- function getPluginUrl(name2) {
403
- return dprintConfig?.plugins.find((url) => url.includes(name2)) ?? name2;
404
- }
405
- const lineWidth = printWidth;
406
- const newLineKind = endOfLine;
407
- const lineBreak = newLineKind === "lf" ? "lf" : "crlf";
408
- return [
409
- {
410
- name: name$c.setup,
411
- plugins: {
412
- format: plugins["pluginFormat"]
413
- }
414
- },
415
- {
416
- name: `${name$c.rules}/typescript`,
417
- files: [GLOB_SRC],
418
- rules: hasPlugin("typescript") ? {
419
- "format/dprint": ["error", {
420
- language: getPluginUrl("typescript"),
421
- languageOptions: {
422
- lineWidth,
423
- indentWidth,
424
- useTabs,
425
- newLineKind,
426
- semiColons: semi ? "always" : "asi",
427
- quoteStyle: quoteStyleMap[quotes],
428
- "jsx.quoteStyle": quoteStyleMap[jsxQuotes],
429
- trailingCommas: trailingCommasMap[trailingComma],
430
- ...dprintConfig?.typescript
431
- }
432
- }]
433
- } : {}
434
- },
435
- {
436
- name: `${name$c.rules}/json`,
437
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC, ...extraJsonFiles],
438
- rules: hasPlugin("json") ? {
439
- // dprint handles the indent
440
- "jsonc/indent": "off",
441
- "format/dprint": ["error", {
442
- language: getPluginUrl("json"),
443
- languageOptions: {
444
- lineWidth,
445
- indentWidth,
446
- useTabs,
447
- newLineKind,
448
- ...dprintConfig?.json
449
- }
450
- }]
451
- } : {}
452
- },
453
- {
454
- name: `${name$c.rules}/markdown`,
455
- files: [GLOB_MARKDOWN],
456
- languageOptions: {
457
- parser: parsers["parserPlain"]
458
- },
459
- rules: hasPlugin("markdown") ? {
460
- "format/dprint": ["error", {
461
- language: getPluginUrl("markdown"),
462
- languageOptions: {
463
- lineWidth,
464
- newLineKind,
465
- ...dprintConfig?.markdown
466
- }
467
- }]
468
- } : {}
469
- },
470
- {
471
- name: `${name$c.rules}/malva`,
472
- files: [GLOB_STYLE, GLOB_POSTCSS],
473
- languageOptions: {
474
- parser: parsers["parserPlain"]
475
- },
476
- rules: hasPlugin("malva") ? {
477
- "format/dprint": ["error", {
478
- language: getPluginUrl("malva"),
479
- languageOptions: {
480
- printWidth,
481
- useTabs,
482
- indentWidth,
483
- lineBreak,
484
- trailingComma: trailingComma === "all" ? true : false,
485
- ...dprintConfig?.malva
486
- }
487
- }]
488
- } : {}
489
- },
490
- {
491
- name: `${name$c.rules}/markup`,
492
- files: [GLOB_HTML, GLOB_VUE, GLOB_SVELTE, GLOB_ASTRO],
493
- languageOptions: {
494
- parser: parsers["parserPlain"]
495
- },
496
- rules: hasPlugin("markup") ? {
497
- "format/dprint": ["error", {
498
- language: getPluginUrl("markup"),
499
- languageOptions: {
500
- printWidth,
501
- useTabs,
502
- indentWidth,
503
- lineBreak,
504
- ...dprintConfig?.markup
505
- }
506
- }]
507
- } : {}
508
- },
509
- {
510
- name: `${name$c.rules}/yaml`,
511
- files: [GLOB_YAML],
512
- languageOptions: {
513
- parser: parsers["parserPlain"]
514
- },
515
- rules: hasPlugin("yaml") ? {
516
- "format/dprint": ["error", {
517
- language: getPluginUrl("yaml"),
518
- languageOptions: {
519
- printWidth,
520
- indentWidth,
521
- lineBreak,
522
- quotes: quoteStyleMap[quotes],
523
- trailingComma: trailingComma === "none" ? false : true,
524
- ...dprintConfig?.yaml
525
- }
526
- }]
527
- } : {}
528
- }
529
- ];
424
+ const { dprintConfigPath = "dprint.json", printWidth = 120, indentWidth = 2, useTabs = false, semi = false, quotes = "single", jsxQuotes = "double", trailingComma = "multiline", endOfLine = "lf", extraJsonFiles = [] } = options;
425
+ const dprintConfig = await loadLocalFile(dprintConfigPath);
426
+ function hasPlugin(name$15) {
427
+ return dprintConfig?.plugins.some((url) => url.includes(name$15)) ?? false;
428
+ }
429
+ function getPluginUrl(name$15) {
430
+ return dprintConfig?.plugins.find((url) => url.includes(name$15)) ?? name$15;
431
+ }
432
+ const lineWidth = printWidth;
433
+ const newLineKind = endOfLine;
434
+ const lineBreak = newLineKind === "lf" ? "lf" : "crlf";
435
+ return [
436
+ {
437
+ name: name$12.setup,
438
+ plugins: { format: plugins_default["pluginFormat"] }
439
+ },
440
+ {
441
+ name: `${name$12.rules}/typescript`,
442
+ files: [GLOB_SRC],
443
+ rules: hasPlugin("typescript") ? { "format/dprint": ["error", {
444
+ language: getPluginUrl("typescript"),
445
+ languageOptions: {
446
+ lineWidth,
447
+ indentWidth,
448
+ useTabs,
449
+ newLineKind,
450
+ semiColons: semi ? "always" : "asi",
451
+ quoteStyle: quoteStyleMap[quotes],
452
+ "jsx.quoteStyle": quoteStyleMap[jsxQuotes],
453
+ trailingCommas: trailingCommasMap[trailingComma],
454
+ ...dprintConfig?.typescript
455
+ }
456
+ }] } : {}
457
+ },
458
+ {
459
+ name: `${name$12.rules}/json`,
460
+ files: [
461
+ GLOB_JSON,
462
+ GLOB_JSON5,
463
+ GLOB_JSONC,
464
+ ...extraJsonFiles
465
+ ],
466
+ rules: hasPlugin("json") ? {
467
+ "jsonc/indent": "off",
468
+ "format/dprint": ["error", {
469
+ language: getPluginUrl("json"),
470
+ languageOptions: {
471
+ lineWidth,
472
+ indentWidth,
473
+ useTabs,
474
+ newLineKind,
475
+ ...dprintConfig?.json
476
+ }
477
+ }]
478
+ } : {}
479
+ },
480
+ {
481
+ name: `${name$12.rules}/markdown`,
482
+ files: [GLOB_MARKDOWN],
483
+ languageOptions: { parser: parsers_default["parserPlain"] },
484
+ rules: hasPlugin("markdown") ? { "format/dprint": ["error", {
485
+ language: getPluginUrl("markdown"),
486
+ languageOptions: {
487
+ lineWidth,
488
+ newLineKind,
489
+ ...dprintConfig?.markdown
490
+ }
491
+ }] } : {}
492
+ },
493
+ {
494
+ name: `${name$12.rules}/malva`,
495
+ files: [GLOB_STYLE, GLOB_POSTCSS],
496
+ languageOptions: { parser: parsers_default["parserPlain"] },
497
+ rules: hasPlugin("malva") ? { "format/dprint": ["error", {
498
+ language: getPluginUrl("malva"),
499
+ languageOptions: {
500
+ printWidth,
501
+ useTabs,
502
+ indentWidth,
503
+ lineBreak,
504
+ trailingComma: trailingComma === "all" ? true : false,
505
+ ...dprintConfig?.malva
506
+ }
507
+ }] } : {}
508
+ },
509
+ {
510
+ name: `${name$12.rules}/markup`,
511
+ files: [
512
+ GLOB_HTML,
513
+ GLOB_VUE,
514
+ GLOB_SVELTE,
515
+ GLOB_ASTRO
516
+ ],
517
+ languageOptions: { parser: parsers_default["parserPlain"] },
518
+ rules: hasPlugin("markup") ? { "format/dprint": ["error", {
519
+ language: getPluginUrl("markup"),
520
+ languageOptions: {
521
+ printWidth,
522
+ useTabs,
523
+ indentWidth,
524
+ lineBreak,
525
+ ...dprintConfig?.markup
526
+ }
527
+ }] } : {}
528
+ },
529
+ {
530
+ name: `${name$12.rules}/yaml`,
531
+ files: [GLOB_YAML],
532
+ languageOptions: { parser: parsers_default["parserPlain"] },
533
+ rules: hasPlugin("yaml") ? { "format/dprint": ["error", {
534
+ language: getPluginUrl("yaml"),
535
+ languageOptions: {
536
+ printWidth,
537
+ indentWidth,
538
+ lineBreak,
539
+ quotes: quoteStyleMap[quotes],
540
+ trailingComma: trailingComma === "none" ? false : true,
541
+ ...dprintConfig?.yaml
542
+ }
543
+ }] } : {}
544
+ }
545
+ ];
530
546
  }
531
547
 
532
- const name$b = getFlatConfigName("ignores");
548
+ //#endregion
549
+ //#region src/configs/ignores.ts
550
+ const name$11 = getFlatConfigName("ignores");
533
551
  function ignores(userIgnores = []) {
534
- return [
535
- {
536
- name: `${name$b.base}/files`,
537
- ignores: [...GLOB_EXCLUDE, ...userIgnores]
538
- },
539
- gitignore({ name: `${name$b.base}/gitignore` })
540
- ];
552
+ return [{
553
+ name: `${name$11.base}/files`,
554
+ ignores: [...GLOB_EXCLUDE, ...userIgnores]
555
+ }, gitignore({ name: `${name$11.base}/gitignore` })];
541
556
  }
542
557
 
543
- const name$a = getFlatConfigName("imports");
558
+ //#endregion
559
+ //#region src/configs/imports.ts
560
+ const name$10 = getFlatConfigName("imports");
544
561
  const files$6 = [GLOB_SRC];
545
562
  function imports(options = {}) {
546
- const {
547
- tsconfigRootDir = process.cwd()
548
- } = options;
549
- return [
550
- {
551
- name: name$a.setup,
552
- files: files$6,
553
- plugins: {
554
- "import-x": plugins["pluginImportX"],
555
- "unused-imports": plugins["pluginUnusedImports"],
556
- antfu: plugins["pluginAntfu"],
557
- perfectionist: plugins["pluginPerfectionist"]
558
- },
559
- languageOptions: {
560
- sourceType: "module",
561
- ecmaVersion: "latest"
562
- }
563
- },
564
- {
565
- name: name$a.rules,
566
- files: files$6,
567
- rules: {
568
- // eslint-plugin-import-x
569
- // https://github.com/un-ts/eslint-plugin-import-x
570
- ...pluginImportX.configs.recommended.rules,
571
- // Copied from SukkaW/eslint-config-sukka
572
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/bbca2d568d738a1d287c473804ea8ccbf00d3c86/packages/eslint-config-sukka/src/modules/javascript.ts#L122
573
- "import-x/newline-after-import": ["error", { considerComments: false }],
574
- "import-x/no-absolute-path": "error",
575
- "import-x/no-empty-named-blocks": "error",
576
- "import-x/no-mutable-exports": "error",
577
- "import-x/no-useless-path-segments": "warn",
578
- "import-x/no-webpack-loader-syntax": "error",
579
- // prevent monorepo sibling imports
580
- "import-x/no-relative-packages": "warn",
581
- // eslint-plugin-unused-imports
582
- // https://github.com/sweepline/eslint-plugin-unused-imports
583
- "unused-imports/no-unused-imports": "error",
584
- // eslint-plugin-antfu
585
- // https://github.com/antfu/eslint-plugin-antfu
586
- "antfu/import-dedupe": "error",
587
- "antfu/no-import-dist": "error",
588
- "antfu/no-import-node-modules-by-path": "error"
589
- }
590
- },
591
- {
592
- name: name$a.stylistic,
593
- files: files$6,
594
- rules: {
595
- // rules that conflict with eslint-plugin-perfectionist are disabled.
596
- "sort-imports": "off",
597
- // eslint-plugin-perfectionist
598
- // https://github.com/azat-io/eslint-plugin-perfectionist
599
- "perfectionist/sort-imports": ["error", {
600
- groups: [
601
- "type",
602
- ["builtin", "external"],
603
- "internal-type",
604
- "internal",
605
- ["parent-type", "sibling-type", "index-type"],
606
- ["parent", "sibling", "index"],
607
- "object",
608
- "unknown"
609
- ],
610
- tsconfigRootDir,
611
- order: "asc",
612
- type: "natural"
613
- }],
614
- "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
615
- "perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }],
616
- "perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }]
617
- }
618
- }
619
- ];
563
+ const { tsconfigRootDir = process.cwd() } = options;
564
+ return [
565
+ {
566
+ name: name$10.setup,
567
+ files: files$6,
568
+ plugins: {
569
+ "import-x": plugins_default["pluginImportX"],
570
+ "unused-imports": plugins_default["pluginUnusedImports"],
571
+ antfu: plugins_default["pluginAntfu"],
572
+ perfectionist: plugins_default["pluginPerfectionist"]
573
+ }
574
+ },
575
+ {
576
+ name: name$10.rules,
577
+ files: files$6,
578
+ rules: {
579
+ ...configs.recommended.rules,
580
+ "import-x/newline-after-import": ["error", { considerComments: false }],
581
+ "import-x/no-absolute-path": "error",
582
+ "import-x/no-empty-named-blocks": "error",
583
+ "import-x/no-mutable-exports": "error",
584
+ "import-x/no-useless-path-segments": "warn",
585
+ "import-x/no-webpack-loader-syntax": "error",
586
+ "import-x/no-relative-packages": "warn",
587
+ "unused-imports/no-unused-imports": "error",
588
+ "antfu/import-dedupe": "error",
589
+ "antfu/no-import-dist": "error",
590
+ "antfu/no-import-node-modules-by-path": "error"
591
+ }
592
+ },
593
+ {
594
+ name: name$10.stylistic,
595
+ files: files$6,
596
+ rules: {
597
+ "sort-imports": "off",
598
+ "perfectionist/sort-imports": ["error", {
599
+ groups: [
600
+ "type",
601
+ ["builtin", "external"],
602
+ "internal-type",
603
+ "internal",
604
+ [
605
+ "parent-type",
606
+ "sibling-type",
607
+ "index-type"
608
+ ],
609
+ [
610
+ "parent",
611
+ "sibling",
612
+ "index"
613
+ ],
614
+ "object",
615
+ "unknown"
616
+ ],
617
+ tsconfigRootDir,
618
+ order: "asc",
619
+ type: "natural"
620
+ }],
621
+ "perfectionist/sort-exports": ["error", {
622
+ order: "asc",
623
+ type: "natural"
624
+ }],
625
+ "perfectionist/sort-named-imports": ["error", {
626
+ order: "asc",
627
+ type: "natural"
628
+ }],
629
+ "perfectionist/sort-named-exports": ["error", {
630
+ order: "asc",
631
+ type: "natural"
632
+ }]
633
+ }
634
+ }
635
+ ];
620
636
  }
621
637
 
638
+ //#endregion
639
+ //#region src/configs/javascript.ts
622
640
  const name$9 = getFlatConfigName("javascript");
623
- const files$5 = [GLOB_SRC];
624
- const commonjsGlobalsOffList = Object.keys(globals.commonjs).map((key) => ({ [key]: "off" }));
641
+ const files$5 = [GLOB_JS, GLOB_JSX];
642
+ const commonjsGlobalsOffList = Object.keys(globals$1.commonjs).map((key) => ({ [key]: "off" }));
625
643
  const commonjsGlobalsOff = Object.assign({}, ...commonjsGlobalsOffList);
644
+ const extensions = [
645
+ ".js",
646
+ ".jsx",
647
+ ".cjs",
648
+ ".mjs"
649
+ ];
626
650
  function javascript(options = {}) {
627
- const { env = { browser: true }, module = true } = options;
628
- const sourceType = module ? "module" : "commonjs";
629
- return [
630
- {
631
- name: name$9.setup,
632
- files: files$5,
633
- plugins: {
634
- "import-x": plugins["pluginImportX"],
635
- "unused-imports": plugins["pluginUnusedImports"],
636
- autofix: plugins["pluginAutofix"],
637
- antfu: plugins["pluginAntfu"]
638
- },
639
- linterOptions: {
640
- reportUnusedDisableDirectives: true
641
- },
642
- languageOptions: {
643
- // https://eslint.org/docs/latest/use/configure/language-options
644
- sourceType,
645
- ecmaVersion: "latest",
646
- parserOptions: {
647
- // https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options
648
- ecmaFeatures: {
649
- impliedStrict: true
650
- }
651
- },
652
- globals: {
653
- // https://eslint.org/docs/latest/use/configure/language-options#specifying-globals
654
- ...globals.es2025,
655
- ...module ? {} : globals.commonjs,
656
- ...env.browser ? globals.browser : {},
657
- ...env.customGlobals
658
- }
659
- },
660
- settings: {
661
- "import-x/extensions": [".js", ".jsx", ".cjs", ".mjs"]
662
- }
663
- },
664
- {
665
- name: name$9.commonjs,
666
- files: ["**/*.cjs"],
667
- languageOptions: {
668
- sourceType: "commonjs",
669
- globals: {
670
- ...globals.commonjs
671
- }
672
- }
673
- },
674
- {
675
- name: name$9.module,
676
- files: ["**/*.mjs"],
677
- languageOptions: {
678
- sourceType: "module",
679
- globals: {
680
- ...commonjsGlobalsOff
681
- }
682
- }
683
- },
684
- {
685
- name: name$9.rules,
686
- files: files$5,
687
- rules: {
688
- ...js.configs.recommended.rules,
689
- // Copied from SukkaW/eslint-config-sukka
690
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L451
691
- "no-unused-vars": [
692
- "error",
693
- {
694
- vars: "all",
695
- varsIgnorePattern: "^_",
696
- args: "after-used",
697
- argsIgnorePattern: "^_",
698
- ignoreRestSiblings: true
699
- }
700
- ],
701
- "unused-imports/no-unused-vars": "off",
702
- // disallow use of arguments.caller or arguments.callee
703
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L191
704
- "no-caller": "off",
705
- "autofix/no-caller": "error",
706
- // disallow usage of __proto__ property
707
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L275
708
- "no-proto": "off",
709
- "autofix/no-proto": "error",
710
- // disallow unnecessary catch clauses
711
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L343
712
- "no-useless-catch": "off",
713
- "autofix/no-useless-catch": "error",
714
- // disallow useless string concatenation
715
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L348
716
- "no-useless-concat": "off",
717
- "autofix/no-useless-concat": "error",
718
- // require use of the second argument for parseInt()
719
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L382
720
- radix: "off",
721
- "autofix/radix": "error",
722
- // ensure that the results of typeof are compared against a valid string
723
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L478
724
- "valid-typeof": "off",
725
- "autofix/valid-typeof": ["error", { requireStringLiterals: true }],
726
- // disallow new operators with global non-constructor functions
727
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L483
728
- "no-new-native-nonconstructor": "off",
729
- "autofix/no-new-native-nonconstructor": "error",
730
- // disallow use of Object.prototypes builtins directly
731
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3b1c6e5098bd92459237b637a3a63aa60d4cb326/packages/eslint-config-sukka/src/modules/javascript.ts#L1069
732
- "no-prototype-builtins": "off",
733
- "autofix/no-prototype-builtins": "error",
734
- // eslint-plugin-antfu
735
- // https://github.com/antfu/eslint-plugin-antfu
736
- "antfu/no-top-level-await": "error",
737
- "antfu/top-level-function": "error"
738
- }
739
- }
740
- ];
651
+ const { env = { browser: true }, module = true } = options;
652
+ const sourceType = module ? "module" : "commonjs";
653
+ return [
654
+ {
655
+ name: name$9.setup,
656
+ files: files$5,
657
+ plugins: {
658
+ "import-x": plugins_default["pluginImportX"],
659
+ "unused-imports": plugins_default["pluginUnusedImports"],
660
+ autofix: plugins_default["pluginAutofix"],
661
+ antfu: plugins_default["pluginAntfu"]
662
+ },
663
+ linterOptions: { reportUnusedDisableDirectives: true },
664
+ languageOptions: {
665
+ sourceType,
666
+ ecmaVersion: "latest",
667
+ parserOptions: { ecmaFeatures: { impliedStrict: true } },
668
+ globals: {
669
+ ...globals$1.es2025,
670
+ ...module ? {} : globals$1.commonjs,
671
+ ...env.browser ? globals$1.browser : {},
672
+ ...env.customGlobals
673
+ }
674
+ },
675
+ settings: {
676
+ "import-x/extensions": extensions,
677
+ "import-x/resolver-next": [createNodeResolver({ extensions })]
678
+ }
679
+ },
680
+ {
681
+ name: name$9.commonjs,
682
+ files: ["**/*.cjs"],
683
+ languageOptions: {
684
+ sourceType: "commonjs",
685
+ globals: { ...globals$1.commonjs }
686
+ }
687
+ },
688
+ {
689
+ name: name$9.module,
690
+ files: ["**/*.mjs"],
691
+ languageOptions: {
692
+ sourceType: "module",
693
+ globals: { ...commonjsGlobalsOff }
694
+ }
695
+ },
696
+ {
697
+ name: name$9.rules,
698
+ files: files$5,
699
+ rules: {
700
+ ...js.configs.recommended.rules,
701
+ "no-unused-vars": ["error", {
702
+ vars: "all",
703
+ varsIgnorePattern: "^_",
704
+ args: "after-used",
705
+ argsIgnorePattern: "^_",
706
+ ignoreRestSiblings: true
707
+ }],
708
+ "unused-imports/no-unused-vars": "off",
709
+ "no-caller": "off",
710
+ "autofix/no-caller": "error",
711
+ "no-proto": "off",
712
+ "autofix/no-proto": "error",
713
+ "no-useless-catch": "off",
714
+ "autofix/no-useless-catch": "error",
715
+ "no-useless-concat": "off",
716
+ "autofix/no-useless-concat": "error",
717
+ radix: "off",
718
+ "autofix/radix": "error",
719
+ "valid-typeof": "off",
720
+ "autofix/valid-typeof": ["error", { requireStringLiterals: true }],
721
+ "no-new-native-nonconstructor": "off",
722
+ "autofix/no-new-native-nonconstructor": "error",
723
+ "no-prototype-builtins": "off",
724
+ "autofix/no-prototype-builtins": "error",
725
+ "antfu/no-top-level-await": "error",
726
+ "antfu/top-level-function": "error"
727
+ }
728
+ }
729
+ ];
741
730
  }
742
731
 
732
+ //#endregion
733
+ //#region src/configs/json.ts
743
734
  const name$8 = getFlatConfigName("json");
744
- const jsoncRecommendedWithJsonRuleList = pluginJsonc.configs["flat/recommended-with-json"].map(
745
- (config) => config.rules
746
- );
747
- const jsoncRecommendedWithJsonRules = Object.assign(
748
- {},
749
- ...jsoncRecommendedWithJsonRuleList
750
- );
735
+ const jsoncRecommendedWithJsonRuleList = pluginJsonc.configs["flat/recommended-with-json"].map((config$1) => config$1.rules);
736
+ const jsoncRecommendedWithJsonRules = Object.assign({}, ...jsoncRecommendedWithJsonRuleList);
751
737
  function json(options = {}) {
752
- const { extraFiles = [], stylistic = { indentWidth: 2 } } = options;
753
- const { indentWidth = 2 } = typeof stylistic === "object" ? stylistic : { indentWidth: 2 };
754
- const files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC, ...extraFiles];
755
- return [
756
- {
757
- name: name$8.setup,
758
- files,
759
- plugins: {
760
- json: plugins["pluginJson"],
761
- jsonc: plugins["pluginJsonc"]
762
- },
763
- languageOptions: {
764
- parser: parsers["parserJsonc"]
765
- }
766
- },
767
- {
768
- name: name$8.rules,
769
- files,
770
- rules: {
771
- // @eslint/json
772
- // https://github.com/eslint/json
773
- "json/no-duplicate-keys": "error",
774
- "json/no-empty-keys": "error",
775
- "json/no-unsafe-values": "error",
776
- "json/no-unnormalized-keys": "error",
777
- "json/top-level-interop": "error",
778
- // eslint-plugin-jsonc
779
- // https://github.com/ota-meshi/eslint-plugin-jsonc
780
- // flat/recommended-with-json
781
- ...jsoncRecommendedWithJsonRules
782
- }
783
- },
784
- {
785
- name: name$8.stylistic,
786
- files,
787
- rules: stylistic ? {
788
- // Copied from antfu/eslint-config
789
- // Ref: https://github.com/antfu/eslint-config/blob/5d0c2a5ef25a7bc3a2d6d55c1ce157cc47b0bf55/src/configs/jsonc.ts#L70
790
- "jsonc/array-bracket-spacing": ["error", "never"],
791
- "jsonc/comma-dangle": ["error", "never"],
792
- "jsonc/comma-style": ["error", "last"],
793
- "jsonc/indent": ["error", indentWidth],
794
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
795
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
796
- "jsonc/object-curly-spacing": ["error", "always"],
797
- "jsonc/object-property-newline": [
798
- "error",
799
- { allowMultiplePropertiesPerLine: true }
800
- ],
801
- "jsonc/quote-props": "error",
802
- "jsonc/quotes": "error"
803
- } : {}
804
- },
805
- {
806
- name: `${name$8.base}/package-json`,
807
- files: ["**/package.json"],
808
- // Copied from antfu/eslint-config
809
- // Ref: https://github.com/antfu/eslint-config/blob/5d0c2a5ef25a7bc3a2d6d55c1ce157cc47b0bf55/src/configs/sort.ts#L13
810
- rules: {
811
- "jsonc/sort-array-values": [
812
- "error",
813
- {
814
- order: { type: "asc" },
815
- pathPattern: "^files$"
816
- }
817
- ],
818
- "jsonc/sort-keys": [
819
- "error",
820
- {
821
- order: [
822
- "publisher",
823
- "name",
824
- "displayName",
825
- "type",
826
- "version",
827
- "private",
828
- "packageManager",
829
- "description",
830
- "author",
831
- "contributors",
832
- "license",
833
- "funding",
834
- "homepage",
835
- "repository",
836
- "bugs",
837
- "keywords",
838
- "categories",
839
- "sideEffects",
840
- "exports",
841
- "main",
842
- "module",
843
- "unpkg",
844
- "jsdelivr",
845
- "types",
846
- "typesVersions",
847
- "bin",
848
- "icon",
849
- "files",
850
- "engines",
851
- "activationEvents",
852
- "contributes",
853
- "publishConfig",
854
- "scripts",
855
- "peerDependencies",
856
- "peerDependenciesMeta",
857
- "dependencies",
858
- "optionalDependencies",
859
- "devDependencies",
860
- "pnpm",
861
- "overrides",
862
- "resolutions",
863
- "husky",
864
- "simple-git-hooks",
865
- "lint-staged",
866
- "eslintConfig"
867
- ],
868
- pathPattern: "^$"
869
- },
870
- {
871
- order: { type: "asc" },
872
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
873
- },
874
- {
875
- order: { type: "asc" },
876
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
877
- },
878
- {
879
- order: ["types", "import", "require", "default"],
880
- pathPattern: "^exports.*$"
881
- },
882
- {
883
- order: [
884
- // client hooks only
885
- "pre-commit",
886
- "prepare-commit-msg",
887
- "commit-msg",
888
- "post-commit",
889
- "pre-rebase",
890
- "post-rewrite",
891
- "post-checkout",
892
- "post-merge",
893
- "pre-push",
894
- "pre-auto-gc"
895
- ],
896
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
897
- }
898
- ]
899
- }
900
- },
901
- {
902
- name: `${name$8.base}/tsconfig-json`,
903
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
904
- // Copied from antfu/eslint-config
905
- // Ref: https://github.com/antfu/eslint-config/blob/5d0c2a5ef25a7bc3a2d6d55c1ce157cc47b0bf55/src/configs/sort.ts#L121
906
- rules: {
907
- "jsonc/sort-keys": [
908
- "error",
909
- {
910
- order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
911
- pathPattern: "^$"
912
- },
913
- {
914
- order: [
915
- /* Projects */
916
- "incremental",
917
- "composite",
918
- "tsBuildInfoFile",
919
- "disableSourceOfProjectReferenceRedirect",
920
- "disableSolutionSearching",
921
- "disableReferencedProjectLoad",
922
- /* Language and Environment */
923
- "target",
924
- "jsx",
925
- "jsxFactory",
926
- "jsxFragmentFactory",
927
- "jsxImportSource",
928
- "lib",
929
- "moduleDetection",
930
- "noLib",
931
- "reactNamespace",
932
- "useDefineForClassFields",
933
- "emitDecoratorMetadata",
934
- "experimentalDecorators",
935
- /* Modules */
936
- "baseUrl",
937
- "rootDir",
938
- "rootDirs",
939
- "customConditions",
940
- "module",
941
- "moduleResolution",
942
- "moduleSuffixes",
943
- "noResolve",
944
- "paths",
945
- "resolveJsonModule",
946
- "resolvePackageJsonExports",
947
- "resolvePackageJsonImports",
948
- "typeRoots",
949
- "types",
950
- "allowArbitraryExtensions",
951
- "allowImportingTsExtensions",
952
- "allowUmdGlobalAccess",
953
- /* JavaScript Support */
954
- "allowJs",
955
- "checkJs",
956
- "maxNodeModuleJsDepth",
957
- /* Type Checking */
958
- "strict",
959
- "strictBindCallApply",
960
- "strictFunctionTypes",
961
- "strictNullChecks",
962
- "strictPropertyInitialization",
963
- "allowUnreachableCode",
964
- "allowUnusedLabels",
965
- "alwaysStrict",
966
- "exactOptionalPropertyTypes",
967
- "noFallthroughCasesInSwitch",
968
- "noImplicitAny",
969
- "noImplicitOverride",
970
- "noImplicitReturns",
971
- "noImplicitThis",
972
- "noPropertyAccessFromIndexSignature",
973
- "noUncheckedIndexedAccess",
974
- "noUnusedLocals",
975
- "noUnusedParameters",
976
- "useUnknownInCatchVariables",
977
- /* Emit */
978
- "declaration",
979
- "declarationDir",
980
- "declarationMap",
981
- "downlevelIteration",
982
- "emitBOM",
983
- "emitDeclarationOnly",
984
- "importHelpers",
985
- "importsNotUsedAsValues",
986
- "inlineSourceMap",
987
- "inlineSources",
988
- "mapRoot",
989
- "newLine",
990
- "noEmit",
991
- "noEmitHelpers",
992
- "noEmitOnError",
993
- "outDir",
994
- "outFile",
995
- "preserveConstEnums",
996
- "preserveValueImports",
997
- "removeComments",
998
- "sourceMap",
999
- "sourceRoot",
1000
- "stripInternal",
1001
- /* Interop Constraints */
1002
- "allowSyntheticDefaultImports",
1003
- "esModuleInterop",
1004
- "forceConsistentCasingInFileNames",
1005
- "isolatedDeclarations",
1006
- "isolatedModules",
1007
- "preserveSymlinks",
1008
- "verbatimModuleSyntax",
1009
- /* Completeness */
1010
- "skipDefaultLibCheck",
1011
- "skipLibCheck"
1012
- ],
1013
- pathPattern: "^compilerOptions$"
1014
- }
1015
- ]
1016
- }
1017
- }
1018
- ];
738
+ const { extraFiles = [], stylistic = { indentWidth: 2 } } = options;
739
+ const { indentWidth = 2 } = typeof stylistic === "object" ? stylistic : { indentWidth: 2 };
740
+ const files$7 = [
741
+ GLOB_JSON,
742
+ GLOB_JSON5,
743
+ GLOB_JSONC,
744
+ ...extraFiles
745
+ ];
746
+ return [
747
+ {
748
+ name: name$8.setup,
749
+ files: files$7,
750
+ plugins: {
751
+ json: plugins_default["pluginJson"],
752
+ jsonc: plugins_default["pluginJsonc"]
753
+ },
754
+ languageOptions: { parser: parsers_default["parserJsonc"] }
755
+ },
756
+ {
757
+ name: name$8.rules,
758
+ files: files$7,
759
+ rules: {
760
+ "json/no-duplicate-keys": "error",
761
+ "json/no-empty-keys": "error",
762
+ "json/no-unsafe-values": "error",
763
+ "json/no-unnormalized-keys": "error",
764
+ "json/top-level-interop": "error",
765
+ ...jsoncRecommendedWithJsonRules
766
+ }
767
+ },
768
+ {
769
+ name: name$8.stylistic,
770
+ files: files$7,
771
+ rules: stylistic ? {
772
+ "jsonc/array-bracket-spacing": ["error", "never"],
773
+ "jsonc/comma-dangle": ["error", "never"],
774
+ "jsonc/comma-style": ["error", "last"],
775
+ "jsonc/indent": ["error", indentWidth],
776
+ "jsonc/key-spacing": ["error", {
777
+ afterColon: true,
778
+ beforeColon: false
779
+ }],
780
+ "jsonc/object-curly-newline": ["error", {
781
+ consistent: true,
782
+ multiline: true
783
+ }],
784
+ "jsonc/object-curly-spacing": ["error", "always"],
785
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
786
+ "jsonc/quote-props": "error",
787
+ "jsonc/quotes": "error"
788
+ } : {}
789
+ },
790
+ {
791
+ name: `${name$8.base}/package-json`,
792
+ files: ["**/package.json"],
793
+ rules: {
794
+ "jsonc/sort-array-values": ["error", {
795
+ order: { type: "asc" },
796
+ pathPattern: "^files$"
797
+ }],
798
+ "jsonc/sort-keys": [
799
+ "error",
800
+ {
801
+ order: [
802
+ "publisher",
803
+ "name",
804
+ "displayName",
805
+ "type",
806
+ "version",
807
+ "private",
808
+ "packageManager",
809
+ "description",
810
+ "author",
811
+ "contributors",
812
+ "license",
813
+ "funding",
814
+ "homepage",
815
+ "repository",
816
+ "bugs",
817
+ "keywords",
818
+ "categories",
819
+ "sideEffects",
820
+ "exports",
821
+ "main",
822
+ "module",
823
+ "unpkg",
824
+ "jsdelivr",
825
+ "types",
826
+ "typesVersions",
827
+ "bin",
828
+ "icon",
829
+ "files",
830
+ "engines",
831
+ "activationEvents",
832
+ "contributes",
833
+ "publishConfig",
834
+ "scripts",
835
+ "peerDependencies",
836
+ "peerDependenciesMeta",
837
+ "dependencies",
838
+ "optionalDependencies",
839
+ "devDependencies",
840
+ "pnpm",
841
+ "overrides",
842
+ "resolutions",
843
+ "husky",
844
+ "simple-git-hooks",
845
+ "lint-staged",
846
+ "eslintConfig"
847
+ ],
848
+ pathPattern: "^$"
849
+ },
850
+ {
851
+ order: { type: "asc" },
852
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
853
+ },
854
+ {
855
+ order: { type: "asc" },
856
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
857
+ },
858
+ {
859
+ order: [
860
+ "types",
861
+ "import",
862
+ "require",
863
+ "default"
864
+ ],
865
+ pathPattern: "^exports.*$"
866
+ },
867
+ {
868
+ order: [
869
+ "pre-commit",
870
+ "prepare-commit-msg",
871
+ "commit-msg",
872
+ "post-commit",
873
+ "pre-rebase",
874
+ "post-rewrite",
875
+ "post-checkout",
876
+ "post-merge",
877
+ "pre-push",
878
+ "pre-auto-gc"
879
+ ],
880
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
881
+ }
882
+ ]
883
+ }
884
+ },
885
+ {
886
+ name: `${name$8.base}/tsconfig-json`,
887
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
888
+ rules: { "jsonc/sort-keys": [
889
+ "error",
890
+ {
891
+ order: [
892
+ "extends",
893
+ "compilerOptions",
894
+ "references",
895
+ "files",
896
+ "include",
897
+ "exclude"
898
+ ],
899
+ pathPattern: "^$"
900
+ },
901
+ {
902
+ order: [
903
+ "incremental",
904
+ "composite",
905
+ "tsBuildInfoFile",
906
+ "disableSourceOfProjectReferenceRedirect",
907
+ "disableSolutionSearching",
908
+ "disableReferencedProjectLoad",
909
+ "target",
910
+ "jsx",
911
+ "jsxFactory",
912
+ "jsxFragmentFactory",
913
+ "jsxImportSource",
914
+ "lib",
915
+ "moduleDetection",
916
+ "noLib",
917
+ "reactNamespace",
918
+ "useDefineForClassFields",
919
+ "emitDecoratorMetadata",
920
+ "experimentalDecorators",
921
+ "baseUrl",
922
+ "rootDir",
923
+ "rootDirs",
924
+ "customConditions",
925
+ "module",
926
+ "moduleResolution",
927
+ "moduleSuffixes",
928
+ "noResolve",
929
+ "paths",
930
+ "resolveJsonModule",
931
+ "resolvePackageJsonExports",
932
+ "resolvePackageJsonImports",
933
+ "typeRoots",
934
+ "types",
935
+ "allowArbitraryExtensions",
936
+ "allowImportingTsExtensions",
937
+ "allowUmdGlobalAccess",
938
+ "allowJs",
939
+ "checkJs",
940
+ "maxNodeModuleJsDepth",
941
+ "strict",
942
+ "strictBindCallApply",
943
+ "strictFunctionTypes",
944
+ "strictNullChecks",
945
+ "strictPropertyInitialization",
946
+ "allowUnreachableCode",
947
+ "allowUnusedLabels",
948
+ "alwaysStrict",
949
+ "exactOptionalPropertyTypes",
950
+ "noFallthroughCasesInSwitch",
951
+ "noImplicitAny",
952
+ "noImplicitOverride",
953
+ "noImplicitReturns",
954
+ "noImplicitThis",
955
+ "noPropertyAccessFromIndexSignature",
956
+ "noUncheckedIndexedAccess",
957
+ "noUnusedLocals",
958
+ "noUnusedParameters",
959
+ "useUnknownInCatchVariables",
960
+ "declaration",
961
+ "declarationDir",
962
+ "declarationMap",
963
+ "downlevelIteration",
964
+ "emitBOM",
965
+ "emitDeclarationOnly",
966
+ "importHelpers",
967
+ "importsNotUsedAsValues",
968
+ "inlineSourceMap",
969
+ "inlineSources",
970
+ "mapRoot",
971
+ "newLine",
972
+ "noEmit",
973
+ "noEmitHelpers",
974
+ "noEmitOnError",
975
+ "outDir",
976
+ "outFile",
977
+ "preserveConstEnums",
978
+ "preserveValueImports",
979
+ "removeComments",
980
+ "sourceMap",
981
+ "sourceRoot",
982
+ "stripInternal",
983
+ "allowSyntheticDefaultImports",
984
+ "esModuleInterop",
985
+ "forceConsistentCasingInFileNames",
986
+ "isolatedDeclarations",
987
+ "isolatedModules",
988
+ "preserveSymlinks",
989
+ "verbatimModuleSyntax",
990
+ "skipDefaultLibCheck",
991
+ "skipLibCheck"
992
+ ],
993
+ pathPattern: "^compilerOptions$"
994
+ }
995
+ ] }
996
+ }
997
+ ];
1019
998
  }
1020
999
 
1000
+ //#endregion
1001
+ //#region src/configs/jsx.ts
1021
1002
  const name$7 = getFlatConfigName("jsx");
1022
1003
  function jsx() {
1023
- return [
1024
- {
1025
- name: name$7.setup,
1026
- files: [GLOB_JSX, GLOB_TSX],
1027
- languageOptions: {
1028
- parserOptions: {
1029
- ecmaFeatures: {
1030
- jsx: true
1031
- }
1032
- }
1033
- }
1034
- }
1035
- ];
1004
+ return [{
1005
+ name: name$7.setup,
1006
+ files: [GLOB_JSX, GLOB_TSX],
1007
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }
1008
+ }];
1036
1009
  }
1037
1010
 
1011
+ //#endregion
1012
+ //#region src/configs/next-js.ts
1038
1013
  const name$6 = getFlatConfigName("next-js");
1039
1014
  const files$4 = [GLOB_SRC];
1040
1015
  function nextJs() {
1041
- return [
1042
- {
1043
- name: name$6.setup,
1044
- files: files$4,
1045
- plugins: {
1046
- "@next/next": plugins["pluginNextJs"],
1047
- "react-refresh": plugins["pluginReactRefresh"]
1048
- }
1049
- },
1050
- {
1051
- name: name$6.rules,
1052
- files: files$4,
1053
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Next.js ESLint plugin missing types
1054
- rules: {
1055
- // @next/eslint-plugin-next
1056
- // https://www.npmjs.com/package/@next/eslint-plugin-next
1057
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Next.js ESLint plugin missing types
1058
- ...pluginNextJs?.configs?.recommended?.rules,
1059
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Next.js ESLint plugin missing types
1060
- ...pluginNextJs?.configs["core-web-vitals"].rules,
1061
- // eslint-plugin-react-refresh
1062
- // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
1063
- "react-refresh/only-export-components": ["warn", {
1064
- allowExportNames: [
1065
- "config",
1066
- "generateStaticParams",
1067
- "metadata",
1068
- "generateMetadata",
1069
- "viewport",
1070
- "generateViewport"
1071
- ]
1072
- }]
1073
- }
1074
- }
1075
- ];
1016
+ return [{
1017
+ name: name$6.setup,
1018
+ files: files$4,
1019
+ plugins: {
1020
+ "@next/next": plugins_default["pluginNextJs"],
1021
+ "react-refresh": plugins_default["pluginReactRefresh"]
1022
+ }
1023
+ }, {
1024
+ name: name$6.rules,
1025
+ files: files$4,
1026
+ rules: {
1027
+ ...pluginNextJs?.configs?.recommended?.rules,
1028
+ ...pluginNextJs?.configs["core-web-vitals"].rules,
1029
+ "react-refresh/only-export-components": ["warn", { allowExportNames: [
1030
+ "config",
1031
+ "generateStaticParams",
1032
+ "metadata",
1033
+ "generateMetadata",
1034
+ "viewport",
1035
+ "generateViewport"
1036
+ ] }]
1037
+ }
1038
+ }];
1076
1039
  }
1077
1040
 
1041
+ //#endregion
1042
+ //#region src/configs/node-js.ts
1078
1043
  const name$5 = getFlatConfigName("node-js");
1079
1044
  const isModule = getPackageJson()?.type === "module";
1080
1045
  const globalsCommonJs = {
1081
- ...globals.es2025,
1082
- ...globals.node,
1083
- ...globals.commonjs,
1084
- __dirname: "readonly",
1085
- __filename: "readonly"
1046
+ ...globals$1.es2025,
1047
+ ...globals$1.node,
1048
+ ...globals$1.commonjs,
1049
+ __dirname: "readonly",
1050
+ __filename: "readonly"
1086
1051
  };
1087
1052
  const globalsModule = {
1088
- ...globals.es2025,
1089
- ...globals.node,
1090
- __dirname: "off",
1091
- __filename: "off",
1092
- exports: "off",
1093
- module: "off",
1094
- require: "off"
1053
+ ...globals$1.es2025,
1054
+ ...globals$1.node,
1055
+ __dirname: "off",
1056
+ __filename: "off",
1057
+ exports: "off",
1058
+ module: "off",
1059
+ require: "off"
1095
1060
  };
1096
1061
  function nodeJs(options = {}) {
1097
- const { module = isModule, extraFiles = [] } = options;
1098
- const files = [GLOB_JS, GLOB_TS, ...extraFiles];
1099
- return [
1100
- {
1101
- name: name$5.setup,
1102
- files,
1103
- plugins: {
1104
- node: plugins["pluginNode"]
1105
- },
1106
- languageOptions: {
1107
- ecmaVersion: "latest",
1108
- parserOptions: {
1109
- ecmaFeatures: {
1110
- impliedStrict: true
1111
- }
1112
- }
1113
- }
1114
- },
1115
- {
1116
- name: name$5.rules,
1117
- files,
1118
- rules: {
1119
- // eslint-plugin-n
1120
- // pluginNode.configs.commons
1121
- // Ref: https://github.com/eslint-community/eslint-plugin-n/blob/ccf5f9e482c32f2fd2d5f78649d7f837a5db8870/lib/configs/_commons.js#L6
1122
- "node/no-deprecated-api": "error",
1123
- "node/no-exports-assign": "error",
1124
- "node/no-process-exit": "error",
1125
- "node/no-unpublished-bin": "error",
1126
- "node/no-unpublished-import": "error",
1127
- "node/no-unpublished-require": "error",
1128
- "node/no-unsupported-features/es-builtins": "error",
1129
- "node/no-unsupported-features/es-syntax": ["error", { ignores: ["modules"] }],
1130
- "node/no-unsupported-features/node-builtins": "error",
1131
- "node/process-exit-as-throw": "error",
1132
- "node/hashbang": "error",
1133
- // Will handled by `eslint-plugin-import-x`
1134
- "node/no-extraneous-import": "off",
1135
- "node/no-extraneous-require": "off",
1136
- "node/no-missing-import": "off",
1137
- "node/no-missing-require": "off",
1138
- // Require error handling in callbacks
1139
- "node/handle-callback-err": ["error", "^error$"],
1140
- // Disallow `new` operators with calls to `require`
1141
- "node/no-new-require": "error",
1142
- // Disallow string concatenation with `__dirname` and `__filename`
1143
- "node/no-path-concat": "error",
1144
- // Bundler specific rules
1145
- "node/prefer-global/buffer": ["error", "never"],
1146
- "node/prefer-global/console": ["error", "always"],
1147
- "node/prefer-global/process": ["error", "never"],
1148
- "node/prefer-global/text-decoder": ["error", "always"],
1149
- "node/prefer-global/text-encoder": ["error", "always"],
1150
- "node/prefer-global/url": ["error", "always"],
1151
- "node/prefer-global/url-search-params": ["error", "always"],
1152
- ...!module && {
1153
- strict: ["error", "global"],
1154
- "node/no-unsupported-features/es-syntax": ["error", { ignores: [] }]
1155
- }
1156
- }
1157
- },
1158
- {
1159
- name: name$5.script,
1160
- files: ["**/*.[jt]s"],
1161
- languageOptions: {
1162
- sourceType: module ? "module" : "commonjs",
1163
- parserOptions: {
1164
- ecmaFeatures: {
1165
- globalReturn: !module
1166
- }
1167
- },
1168
- globals: {
1169
- ...module ? globalsModule : globalsCommonJs
1170
- }
1171
- }
1172
- },
1173
- {
1174
- name: name$5.commonjs,
1175
- files: ["**/*.c[jt]s"],
1176
- languageOptions: {
1177
- sourceType: "commonjs",
1178
- parserOptions: {
1179
- ecmaFeatures: {
1180
- globalReturn: true
1181
- }
1182
- },
1183
- globals: {
1184
- ...globalsCommonJs
1185
- }
1186
- },
1187
- rules: {
1188
- strict: ["error", "global"],
1189
- "node/no-unsupported-features/es-syntax": ["error", { ignores: [] }]
1190
- }
1191
- },
1192
- {
1193
- name: name$5.module,
1194
- files: ["**/*.m[jt]s"],
1195
- languageOptions: {
1196
- sourceType: "module",
1197
- parserOptions: {
1198
- ecmaFeatures: {
1199
- globalReturn: false
1200
- }
1201
- },
1202
- globals: {
1203
- ...globalsModule
1204
- }
1205
- }
1206
- }
1207
- ];
1062
+ const { module = isModule, extraFiles = [] } = options;
1063
+ const files$7 = [
1064
+ GLOB_JS,
1065
+ GLOB_TS,
1066
+ ...extraFiles
1067
+ ];
1068
+ return [
1069
+ {
1070
+ name: name$5.setup,
1071
+ files: files$7,
1072
+ plugins: { node: plugins_default["pluginNode"] },
1073
+ languageOptions: {
1074
+ ecmaVersion: "latest",
1075
+ parserOptions: { ecmaFeatures: { impliedStrict: true } }
1076
+ }
1077
+ },
1078
+ {
1079
+ name: name$5.rules,
1080
+ files: files$7,
1081
+ rules: {
1082
+ "node/no-deprecated-api": "error",
1083
+ "node/no-exports-assign": "error",
1084
+ "node/no-process-exit": "error",
1085
+ "node/no-unpublished-bin": "error",
1086
+ "node/no-unpublished-import": "error",
1087
+ "node/no-unpublished-require": "error",
1088
+ "node/no-unsupported-features/es-builtins": "error",
1089
+ "node/no-unsupported-features/es-syntax": ["error", { ignores: ["modules"] }],
1090
+ "node/no-unsupported-features/node-builtins": "error",
1091
+ "node/process-exit-as-throw": "error",
1092
+ "node/hashbang": "error",
1093
+ "node/no-extraneous-import": "off",
1094
+ "node/no-extraneous-require": "off",
1095
+ "node/no-missing-import": "off",
1096
+ "node/no-missing-require": "off",
1097
+ "node/handle-callback-err": ["error", "^error$"],
1098
+ "node/no-new-require": "error",
1099
+ "node/no-path-concat": "error",
1100
+ "node/prefer-global/buffer": ["error", "never"],
1101
+ "node/prefer-global/console": ["error", "always"],
1102
+ "node/prefer-global/process": ["error", "never"],
1103
+ "node/prefer-global/text-decoder": ["error", "always"],
1104
+ "node/prefer-global/text-encoder": ["error", "always"],
1105
+ "node/prefer-global/url": ["error", "always"],
1106
+ "node/prefer-global/url-search-params": ["error", "always"],
1107
+ ...!module && {
1108
+ strict: ["error", "global"],
1109
+ "node/no-unsupported-features/es-syntax": ["error", { ignores: [] }]
1110
+ }
1111
+ }
1112
+ },
1113
+ {
1114
+ name: name$5.script,
1115
+ files: ["**/*.[jt]s"],
1116
+ languageOptions: {
1117
+ sourceType: module ? "module" : "commonjs",
1118
+ parserOptions: { ecmaFeatures: { globalReturn: !module } },
1119
+ globals: { ...module ? globalsModule : globalsCommonJs }
1120
+ }
1121
+ },
1122
+ {
1123
+ name: name$5.commonjs,
1124
+ files: ["**/*.c[jt]s"],
1125
+ languageOptions: {
1126
+ sourceType: "commonjs",
1127
+ parserOptions: { ecmaFeatures: { globalReturn: true } },
1128
+ globals: { ...globalsCommonJs }
1129
+ },
1130
+ rules: {
1131
+ strict: ["error", "global"],
1132
+ "node/no-unsupported-features/es-syntax": ["error", { ignores: [] }]
1133
+ }
1134
+ },
1135
+ {
1136
+ name: name$5.module,
1137
+ files: ["**/*.m[jt]s"],
1138
+ languageOptions: {
1139
+ sourceType: "module",
1140
+ parserOptions: { ecmaFeatures: { globalReturn: false } },
1141
+ globals: { ...globalsModule }
1142
+ }
1143
+ }
1144
+ ];
1208
1145
  }
1209
1146
 
1147
+ //#endregion
1148
+ //#region src/configs/react.ts
1210
1149
  const name$4 = getFlatConfigName("react");
1211
1150
  const files$3 = [GLOB_SRC];
1212
1151
  function react(options = {}) {
1213
- const { stylistic = true, reactCompiler = false } = options;
1214
- return [
1215
- {
1216
- name: name$4.setup,
1217
- files: files$3,
1218
- plugins: {
1219
- "react-hooks": plugins["pluginReactHooks"],
1220
- "react-compiler": plugins["pluginReactCompiler"],
1221
- "react-refresh": plugins["pluginReactRefresh"],
1222
- "jsx-a11y": plugins["pluginJsxA11y"],
1223
- "@stylistic/jsx": plugins["pluginStylisticJsx"],
1224
- "@eslint-react": plugins["pluginReact"],
1225
- "@eslint-react/dom": plugins["pluginReactDom"],
1226
- "@eslint-react/web-api": plugins["pluginReactWebApi"],
1227
- "@eslint-react/debug": plugins["pluginReactDebug"],
1228
- "@eslint-react/hooks-extra": plugins["pluginReactHooksExtra"],
1229
- "@eslint-react/naming-convention": plugins["pluginReactHooksNamingConvention"]
1230
- },
1231
- settings: {
1232
- "react-x": {
1233
- importSource: "react",
1234
- jsxPragma: "createElement",
1235
- jsxPragmaFrag: "Fragment",
1236
- polymorphicPropName: "as",
1237
- strict: true,
1238
- strictImportCheck: true,
1239
- version: "detect",
1240
- additionalHooks: {
1241
- useEffect: ["useIsomorphicLayoutEffect"],
1242
- useLayoutEffect: ["useIsomorphicLayoutEffect"]
1243
- }
1244
- }
1245
- }
1246
- },
1247
- {
1248
- name: name$4.rules,
1249
- files: files$3,
1250
- rules: {
1251
- // eslint-plugin-react-hooks
1252
- // https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks
1253
- "react-hooks/rules-of-hooks": "error",
1254
- "react-hooks/exhaustive-deps": "error",
1255
- // eslint-plugin-react-compiler
1256
- // https://github.com/facebook/react/tree/main/compiler/packages/eslint-plugin-react-compiler
1257
- "react-compiler/react-compiler": reactCompiler ? "error" : "off",
1258
- // eslint-plugin-react-refresh
1259
- // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
1260
- "react-refresh/only-export-components": "warn",
1261
- // @eslint-sukka/eslint-plugin-react-jsx-a11y
1262
- // https://github.com/SukkaW/eslint-config-sukka/tree/master/packages/eslint-plugin-react-jsx-a11y
1263
- // Copied from SukkaW/eslint-config-sukka
1264
- // Ref: https://github.com/SukkaW/eslint-config-sukka/blob/3a04c31727e0b5bab98fda1a6440f9932fe42dd8/packages/react/src/react.ts#L383
1265
- "jsx-a11y/alt-text": ["warn", { elements: ["img"], img: ["Image"] }],
1266
- "jsx-a11y/aria-props": "warn",
1267
- "jsx-a11y/aria-proptypes": "warn",
1268
- "jsx-a11y/aria-role": "warn",
1269
- "jsx-a11y/aria-unsupported-elements": "warn",
1270
- "jsx-a11y/iframe-has-title": "warn",
1271
- "jsx-a11y/no-access-key": "warn",
1272
- "jsx-a11y/role-has-required-aria-props": "warn",
1273
- "jsx-a11y/role-supports-aria-props": "warn",
1274
- "jsx-a11y/tabindex-no-positive": "warn",
1275
- // @eslint-react/eslint-plugin
1276
- // https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin
1277
- ...pluginReact.configs.recommended.rules,
1278
- "@eslint-react/ensure-forward-ref-using-ref": "error",
1279
- "@eslint-react/no-duplicate-jsx-props": "error",
1280
- "@eslint-react/no-duplicate-key": "error",
1281
- "@eslint-react/no-children-count": "error",
1282
- "@eslint-react/no-children-for-each": "error",
1283
- "@eslint-react/no-children-only": "error",
1284
- "@eslint-react/no-children-to-array": "error",
1285
- "@eslint-react/no-clone-element": "error",
1286
- "@eslint-react/no-comment-textnodes": "error",
1287
- "@eslint-react/no-implicit-key": "error",
1288
- "@eslint-react/no-missing-component-display-name": "error",
1289
- "@eslint-react/no-unstable-context-value": "error",
1290
- // Update as of 2021: All current versions of major browsers now automatically use the
1291
- // behavior of rel="noopener" for any target="_blank" link, nullifying this issue.
1292
- // See: https://chromestatus.com/feature/6140064063029248.
1293
- // See: https://stackoverflow.com/a/50709724
1294
- "@eslint-react/dom/no-unsafe-target-blank": "off",
1295
- "@eslint-react/dom/no-void-elements-with-children": "error",
1296
- "@eslint-react/web-api/no-leaked-event-listener": "error",
1297
- "@eslint-react/web-api/no-leaked-interval": "error",
1298
- "@eslint-react/web-api/no-leaked-resize-observer": "error",
1299
- "@eslint-react/web-api/no-leaked-timeout": "error",
1300
- "@eslint-react/hooks-extra/no-unnecessary-use-callback": "error",
1301
- "@eslint-react/hooks-extra/no-unnecessary-use-memo": "error",
1302
- "@eslint-react/hooks-extra/no-useless-custom-hooks": "error",
1303
- "@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "error",
1304
- "@eslint-react/hooks-extra/no-direct-set-state-in-use-layout-effect": "error"
1305
- }
1306
- },
1307
- {
1308
- name: name$4.stylistic,
1309
- files: files$3,
1310
- rules: stylistic ? {
1311
- // @eslint-react/eslint-plugin
1312
- // https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin
1313
- "@eslint-react/prefer-destructuring-assignment": "error",
1314
- "@eslint-react/prefer-react-namespace-import": "warn",
1315
- "@eslint-react/prefer-shorthand-boolean": "error",
1316
- "@eslint-react/prefer-shorthand-fragment": "off",
1317
- "@eslint-react/avoid-shorthand-boolean": "off",
1318
- "@eslint-react/avoid-shorthand-fragment": "error",
1319
- // @stylistic/eslint-plugin-jsx
1320
- // https://github.com/eslint-stylistic/eslint-stylistic/tree/main/packages/eslint-plugin-jsx
1321
- "@stylistic/jsx/jsx-closing-bracket-location": "error",
1322
- "@stylistic/jsx/jsx-closing-tag-location": "error",
1323
- "@stylistic/jsx/jsx-curly-brace-presence": [
1324
- "error",
1325
- { propElementValues: "always" }
1326
- ],
1327
- "@stylistic/jsx/jsx-equals-spacing": "error",
1328
- "@stylistic/jsx/jsx-first-prop-new-line": ["error", "multiline"],
1329
- "@stylistic/jsx/jsx-function-call-newline": ["error", "multiline"],
1330
- "@stylistic/jsx/jsx-max-props-per-line": [
1331
- "error",
1332
- { maximum: 1, when: "multiline" }
1333
- ],
1334
- "@stylistic/jsx/jsx-one-expression-per-line": ["error", { allow: "non-jsx" }],
1335
- "@stylistic/jsx/jsx-pascal-case": [
1336
- "error",
1337
- { allowNamespace: true, ignore: ["motion"] }
1338
- ],
1339
- "@stylistic/jsx/jsx-self-closing-comp": ["error", { component: true, html: true }],
1340
- "@stylistic/jsx/jsx-tag-spacing": [
1341
- "error",
1342
- {
1343
- afterOpening: "never",
1344
- beforeClosing: "never",
1345
- beforeSelfClosing: "always",
1346
- closingSlash: "never"
1347
- }
1348
- ],
1349
- "@stylistic/jsx/jsx-wrap-multilines": [
1350
- "error",
1351
- {
1352
- arrow: "parens-new-line",
1353
- assignment: "parens-new-line",
1354
- condition: "parens-new-line",
1355
- declaration: "parens-new-line",
1356
- logical: "parens-new-line",
1357
- prop: "parens-new-line",
1358
- propertyValue: "parens-new-line",
1359
- return: "parens-new-line"
1360
- }
1361
- ],
1362
- "@stylistic/jsx/jsx-sort-props": [
1363
- "error",
1364
- {
1365
- callbacksLast: true,
1366
- shorthandFirst: true,
1367
- multiline: "last",
1368
- reservedFirst: true
1369
- }
1370
- ]
1371
- } : {}
1372
- }
1373
- ];
1152
+ const { stylistic = true, reactCompiler = false } = options;
1153
+ return [
1154
+ {
1155
+ name: name$4.setup,
1156
+ files: files$3,
1157
+ plugins: {
1158
+ "react-hooks": plugins_default["pluginReactHooks"],
1159
+ "react-compiler": plugins_default["pluginReactCompiler"],
1160
+ "react-refresh": plugins_default["pluginReactRefresh"],
1161
+ "jsx-a11y": plugins_default["pluginJsxA11y"],
1162
+ "@stylistic/jsx": plugins_default["pluginStylisticJsx"],
1163
+ "@eslint-react": plugins_default["pluginReact"],
1164
+ "@eslint-react/dom": plugins_default["pluginReactDom"],
1165
+ "@eslint-react/web-api": plugins_default["pluginReactWebApi"],
1166
+ "@eslint-react/debug": plugins_default["pluginReactDebug"],
1167
+ "@eslint-react/hooks-extra": plugins_default["pluginReactHooksExtra"],
1168
+ "@eslint-react/naming-convention": plugins_default["pluginReactHooksNamingConvention"]
1169
+ },
1170
+ settings: { "react-x": {
1171
+ importSource: "react",
1172
+ jsxPragma: "createElement",
1173
+ jsxPragmaFrag: "Fragment",
1174
+ polymorphicPropName: "as",
1175
+ strict: true,
1176
+ strictImportCheck: true,
1177
+ version: "detect",
1178
+ additionalHooks: {
1179
+ useEffect: ["useIsomorphicLayoutEffect"],
1180
+ useLayoutEffect: ["useIsomorphicLayoutEffect"]
1181
+ }
1182
+ } }
1183
+ },
1184
+ {
1185
+ name: name$4.rules,
1186
+ files: files$3,
1187
+ rules: {
1188
+ "react-hooks/rules-of-hooks": "error",
1189
+ "react-hooks/exhaustive-deps": "error",
1190
+ "react-compiler/react-compiler": reactCompiler ? "error" : "off",
1191
+ "react-refresh/only-export-components": "warn",
1192
+ "jsx-a11y/alt-text": ["warn", {
1193
+ elements: ["img"],
1194
+ img: ["Image"]
1195
+ }],
1196
+ "jsx-a11y/aria-props": "warn",
1197
+ "jsx-a11y/aria-proptypes": "warn",
1198
+ "jsx-a11y/aria-role": "warn",
1199
+ "jsx-a11y/aria-unsupported-elements": "warn",
1200
+ "jsx-a11y/iframe-has-title": "warn",
1201
+ "jsx-a11y/no-access-key": "warn",
1202
+ "jsx-a11y/role-has-required-aria-props": "warn",
1203
+ "jsx-a11y/role-supports-aria-props": "warn",
1204
+ "jsx-a11y/tabindex-no-positive": "warn",
1205
+ ...pluginReact.configs.recommended.rules,
1206
+ "@eslint-react/ensure-forward-ref-using-ref": "error",
1207
+ "@eslint-react/no-duplicate-jsx-props": "error",
1208
+ "@eslint-react/no-duplicate-key": "error",
1209
+ "@eslint-react/no-children-count": "error",
1210
+ "@eslint-react/no-children-for-each": "error",
1211
+ "@eslint-react/no-children-only": "error",
1212
+ "@eslint-react/no-children-to-array": "error",
1213
+ "@eslint-react/no-clone-element": "error",
1214
+ "@eslint-react/no-comment-textnodes": "error",
1215
+ "@eslint-react/no-implicit-key": "error",
1216
+ "@eslint-react/no-missing-component-display-name": "error",
1217
+ "@eslint-react/no-unstable-context-value": "error",
1218
+ "@eslint-react/dom/no-unsafe-target-blank": "off",
1219
+ "@eslint-react/dom/no-void-elements-with-children": "error",
1220
+ "@eslint-react/web-api/no-leaked-event-listener": "error",
1221
+ "@eslint-react/web-api/no-leaked-interval": "error",
1222
+ "@eslint-react/web-api/no-leaked-resize-observer": "error",
1223
+ "@eslint-react/web-api/no-leaked-timeout": "error",
1224
+ "@eslint-react/hooks-extra/no-unnecessary-use-callback": "error",
1225
+ "@eslint-react/hooks-extra/no-unnecessary-use-memo": "error",
1226
+ "@eslint-react/hooks-extra/no-useless-custom-hooks": "error",
1227
+ "@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": "error",
1228
+ "@eslint-react/hooks-extra/no-direct-set-state-in-use-layout-effect": "error"
1229
+ }
1230
+ },
1231
+ {
1232
+ name: name$4.stylistic,
1233
+ files: files$3,
1234
+ rules: stylistic ? {
1235
+ "@eslint-react/prefer-destructuring-assignment": "error",
1236
+ "@eslint-react/prefer-react-namespace-import": "warn",
1237
+ "@eslint-react/prefer-shorthand-boolean": "error",
1238
+ "@eslint-react/prefer-shorthand-fragment": "off",
1239
+ "@eslint-react/avoid-shorthand-boolean": "off",
1240
+ "@eslint-react/avoid-shorthand-fragment": "error",
1241
+ "@stylistic/jsx/jsx-closing-bracket-location": "error",
1242
+ "@stylistic/jsx/jsx-closing-tag-location": "error",
1243
+ "@stylistic/jsx/jsx-curly-brace-presence": ["error", { propElementValues: "always" }],
1244
+ "@stylistic/jsx/jsx-equals-spacing": "error",
1245
+ "@stylistic/jsx/jsx-first-prop-new-line": ["error", "multiline"],
1246
+ "@stylistic/jsx/jsx-function-call-newline": ["error", "multiline"],
1247
+ "@stylistic/jsx/jsx-max-props-per-line": ["error", {
1248
+ maximum: 1,
1249
+ when: "multiline"
1250
+ }],
1251
+ "@stylistic/jsx/jsx-one-expression-per-line": ["error", { allow: "non-jsx" }],
1252
+ "@stylistic/jsx/jsx-pascal-case": ["error", {
1253
+ allowNamespace: true,
1254
+ ignore: ["motion"]
1255
+ }],
1256
+ "@stylistic/jsx/jsx-self-closing-comp": ["error", {
1257
+ component: true,
1258
+ html: true
1259
+ }],
1260
+ "@stylistic/jsx/jsx-tag-spacing": ["error", {
1261
+ afterOpening: "never",
1262
+ beforeClosing: "never",
1263
+ beforeSelfClosing: "always",
1264
+ closingSlash: "never"
1265
+ }],
1266
+ "@stylistic/jsx/jsx-wrap-multilines": ["error", {
1267
+ arrow: "parens-new-line",
1268
+ assignment: "parens-new-line",
1269
+ condition: "parens-new-line",
1270
+ declaration: "parens-new-line",
1271
+ logical: "parens-new-line",
1272
+ prop: "parens-new-line",
1273
+ propertyValue: "parens-new-line",
1274
+ return: "parens-new-line"
1275
+ }],
1276
+ "@stylistic/jsx/jsx-sort-props": ["error", {
1277
+ callbacksLast: true,
1278
+ shorthandFirst: true,
1279
+ multiline: "last",
1280
+ reservedFirst: true
1281
+ }]
1282
+ } : {}
1283
+ }
1284
+ ];
1374
1285
  }
1375
1286
 
1287
+ //#endregion
1288
+ //#region src/configs/regexp.ts
1376
1289
  const name$3 = getFlatConfigName("regexp");
1377
1290
  const files$2 = [GLOB_SRC];
1378
1291
  function regexp() {
1379
- return [
1380
- {
1381
- name: name$3.setup,
1382
- files: files$2,
1383
- plugins: {
1384
- regexp: plugins["pluginRegexp"]
1385
- }
1386
- },
1387
- {
1388
- name: name$3.rules,
1389
- files: files$2,
1390
- rules: {
1391
- // eslint-plugin-regexp
1392
- // https://github.com/ota-meshi/eslint-plugin-regexp
1393
- ...pluginRegexp.configs["flat/recommended"].rules
1394
- }
1395
- }
1396
- ];
1292
+ return [{
1293
+ name: name$3.setup,
1294
+ files: files$2,
1295
+ plugins: { regexp: plugins_default["pluginRegexp"] }
1296
+ }, {
1297
+ name: name$3.rules,
1298
+ files: files$2,
1299
+ rules: { ...pluginRegexp.configs["flat/recommended"].rules }
1300
+ }];
1397
1301
  }
1398
1302
 
1303
+ //#endregion
1304
+ //#region src/configs/tailwindcss.ts
1399
1305
  const name$2 = getFlatConfigName("tailwindcss");
1400
- const files$1 = [GLOB_SRC, GLOB_STYLE, GLOB_POSTCSS, GLOB_HTML];
1306
+ const files$1 = [
1307
+ GLOB_SRC,
1308
+ GLOB_STYLE,
1309
+ GLOB_POSTCSS,
1310
+ GLOB_HTML
1311
+ ];
1401
1312
  function tailwindcss() {
1402
- return [
1403
- {
1404
- name: name$2.setup,
1405
- files: files$1,
1406
- plugins: {
1407
- tailwindcss: plugins["pluginTailwindCSS"]
1408
- },
1409
- settings: {
1410
- tailwindcss: {
1411
- callees: ["classnames", "clsx", "ctl", "cva", "cn", "tv"]
1412
- }
1413
- }
1414
- },
1415
- {
1416
- name: name$2.rules,
1417
- files: files$1,
1418
- rules: {
1419
- // eslint-plugin-tailwindcss
1420
- // https://github.com/francoismassart/eslint-plugin-tailwindcss
1421
- "tailwindcss/classnames-order": "error",
1422
- "tailwindcss/enforces-negative-arbitrary-values": "error",
1423
- "tailwindcss/enforces-shorthand": "warn",
1424
- "tailwindcss/no-arbitrary-value": "off",
1425
- "tailwindcss/no-custom-classname": "warn",
1426
- "tailwindcss/no-contradicting-classname": "error",
1427
- "tailwindcss/no-unnecessary-arbitrary-value": "error"
1428
- }
1429
- }
1430
- ];
1313
+ return [{
1314
+ name: name$2.setup,
1315
+ files: files$1,
1316
+ plugins: { tailwindcss: plugins_default["pluginTailwindCSS"] },
1317
+ settings: { tailwindcss: { callees: [
1318
+ "classnames",
1319
+ "clsx",
1320
+ "ctl",
1321
+ "cva",
1322
+ "cn",
1323
+ "tv"
1324
+ ] } }
1325
+ }, {
1326
+ name: name$2.rules,
1327
+ files: files$1,
1328
+ rules: {
1329
+ "tailwindcss/classnames-order": "error",
1330
+ "tailwindcss/enforces-negative-arbitrary-values": "error",
1331
+ "tailwindcss/enforces-shorthand": "warn",
1332
+ "tailwindcss/no-arbitrary-value": "off",
1333
+ "tailwindcss/no-custom-classname": "warn",
1334
+ "tailwindcss/no-contradicting-classname": "error",
1335
+ "tailwindcss/no-unnecessary-arbitrary-value": "error"
1336
+ }
1337
+ }];
1431
1338
  }
1432
1339
 
1340
+ //#endregion
1341
+ //#region src/configs/typescript.ts
1433
1342
  const name$1 = getFlatConfigName("typescript");
1434
- const typescriptStrictTypeCheckedRuleList = configs.strictTypeChecked.map(
1435
- (config) => config.rules
1436
- );
1437
- const typescriptStrictTypeCheckedRules = Object.assign(
1438
- {},
1439
- ...typescriptStrictTypeCheckedRuleList
1440
- );
1441
- const typescriptStylisticTypeCheckedRuleList = configs.stylisticTypeChecked.map(
1442
- (config) => config.rules
1443
- );
1444
- const typescriptStylisticTypeCheckedRules = Object.assign(
1445
- {},
1446
- ...typescriptStylisticTypeCheckedRuleList
1447
- );
1343
+ const typescriptStrictTypeCheckedRuleList = configs$1.strictTypeChecked.map((config$1) => config$1.rules);
1344
+ const typescriptStrictTypeCheckedRules = Object.assign({}, ...typescriptStrictTypeCheckedRuleList);
1345
+ const typescriptStylisticTypeCheckedRuleList = configs$1.stylisticTypeChecked.map((config$1) => config$1.rules);
1346
+ const typescriptStylisticTypeCheckedRules = Object.assign({}, ...typescriptStylisticTypeCheckedRuleList);
1347
+ const externalModuleFolders = ["node_modules", "node_modules/@types"];
1448
1348
  function typescript(options = {}) {
1449
- const {
1450
- isInEditor = false,
1451
- tsconfigPath = true,
1452
- tsconfigRootDir = process.cwd(),
1453
- allowDefaultProject = [],
1454
- extraFileExtensions = [],
1455
- reactTypeCheck = false
1456
- } = options;
1457
- const files = [
1458
- GLOB_TS,
1459
- GLOB_TSX,
1460
- ...extraFileExtensions.map((extension) => `**/*${extension}`)
1461
- ];
1462
- const tsProjectOptions = tsconfigPath === true ? {
1463
- projectService: {
1464
- allowDefaultProject,
1465
- loadTypeScriptPlugins: isInEditor
1466
- }
1467
- } : { project: tsconfigPath };
1468
- return [
1469
- {
1470
- name: name$1.setup,
1471
- files,
1472
- plugins: {
1473
- "import-x": plugins["pluginImportX"],
1474
- "@typescript-eslint": plugins["pluginTypescript"],
1475
- antfu: plugins["pluginAntfu"]
1476
- },
1477
- languageOptions: {
1478
- sourceType: "module",
1479
- ecmaVersion: "latest",
1480
- parser: parsers["parserTypescript"],
1481
- parserOptions: {
1482
- // https://typescript-eslint.io/packages/parser#configuration
1483
- ecmaVersion: "latest",
1484
- extraFileExtensions,
1485
- // Assuming using JSX transform
1486
- // eslint-disable-next-line unicorn/no-null -- Set to null when using JSX transform
1487
- jsxPragma: null,
1488
- ...tsProjectOptions,
1489
- tsconfigRootDir,
1490
- warnOnUnsupportedTypeScriptVersion: true
1491
- }
1492
- },
1493
- settings: {
1494
- "import-x/extensions": [
1495
- ".js",
1496
- ".jsx",
1497
- ".cjs",
1498
- ".mjs",
1499
- ".ts",
1500
- ".tsx",
1501
- ".cts",
1502
- ".mts",
1503
- ...extraFileExtensions
1504
- ],
1505
- "import-x/external-module-folders": ["node_modules", "node_modules/@types"],
1506
- "import-x/parsers": {
1507
- "@typescript-eslint/parser": [".ts", ".tsx", ".cts", ".mts", ...extraFileExtensions]
1508
- },
1509
- "import-x/resolver-next": [
1510
- // eslint-import-resolver-typescript
1511
- // https://github.com/import-js/eslint-import-resolver-typescript
1512
- createTypeScriptImportResolver({
1513
- alwaysTryTypes: true,
1514
- project: tsconfigPath === true ? void 0 : tsconfigPath,
1515
- extensions: [
1516
- ".ts",
1517
- ".tsx",
1518
- ".d.ts",
1519
- ".js",
1520
- ".jsx",
1521
- ".json",
1522
- ".node",
1523
- ...extraFileExtensions
1524
- ]
1525
- })
1526
- ]
1527
- }
1528
- },
1529
- {
1530
- name: name$1.rules,
1531
- files,
1532
- rules: {
1533
- // eslint-plugin-import-x
1534
- // https://github.com/un-ts/eslint-plugin-import-x
1535
- // TypeScript compilation already ensures that named imports exist in the referenced module
1536
- ...pluginImportX.configs.typescript.rules,
1537
- // Contains all of `recommended`, `recommended-type-checked`, and `strict`, along with additional strict rules that require type information.
1538
- // https://typescript-eslint.io/users/configs#strict-type-checked
1539
- ...typescriptStrictTypeCheckedRules,
1540
- // Contains all of `stylistic`, along with additional stylistic rules that require type information.
1541
- // https://typescript-eslint.io/users/configs#stylistic-type-checked
1542
- ...typescriptStylisticTypeCheckedRules,
1543
- // Disallow `@ts-<directive>` comments or require descriptions after directives
1544
- // https://typescript-eslint.io/rules/ban-ts-comment
1545
- "@typescript-eslint/ban-ts-comment": [
1546
- "error",
1547
- {
1548
- minimumDescriptionLength: 10,
1549
- "ts-check": false,
1550
- "ts-expect-error": "allow-with-description",
1551
- "ts-ignore": true,
1552
- "ts-nocheck": true
1553
- }
1554
- ],
1555
- // enforce naming conventions for everything across a codebase
1556
- // https://typescript-eslint.io/rules/naming-convention
1557
- "@typescript-eslint/naming-convention": [
1558
- "warn",
1559
- // Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
1560
- {
1561
- selector: "variable",
1562
- format: ["camelCase", "PascalCase", "UPPER_CASE"],
1563
- leadingUnderscore: "allowSingleOrDouble",
1564
- trailingUnderscore: "forbid"
1565
- },
1566
- // Allow camelCase functions (23.2), and PascalCase functions (23.8)
1567
- {
1568
- selector: "function",
1569
- format: ["camelCase", "PascalCase"],
1570
- leadingUnderscore: "allowSingleOrDouble",
1571
- trailingUnderscore: "forbid"
1572
- },
1573
- // Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make TypeScript recommendations,
1574
- // we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums
1575
- {
1576
- selector: "typeLike",
1577
- format: ["PascalCase"],
1578
- leadingUnderscore: "forbid",
1579
- trailingUnderscore: "forbid"
1580
- }
1581
- ],
1582
- // Allow number literals to be used in template expressions
1583
- "@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
1584
- // eslint-plugin-antfu
1585
- // https://github.com/antfu/eslint-plugin-antfu
1586
- "antfu/no-ts-export-equal": "error"
1587
- }
1588
- },
1589
- {
1590
- name: `${name$1.base}/react-type-checked`,
1591
- files,
1592
- plugins: {
1593
- "@eslint-react": plugins["pluginReact"],
1594
- "@eslint-react/dom": plugins["pluginReactDom"]
1595
- },
1596
- rules: reactTypeCheck ? {
1597
- // Disables checking an asynchronous function passed as a JSX attribute expected to be a function that returns `void`
1598
- "@typescript-eslint/no-misused-promises": ["error", {
1599
- checksVoidReturn: { attributes: false }
1600
- }],
1601
- // @eslint-react/eslint-plugin
1602
- // https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin
1603
- // pluginReact.configs.['recommended-typescript'].rules
1604
- "@eslint-react/dom/no-unknown-property": "off",
1605
- "@eslint-react/no-duplicate-jsx-props": "off",
1606
- "@eslint-react/use-jsx-vars": "off",
1607
- // pluginReact.configs.['recommended-type-checked'].rules
1608
- // https://eslint-react.xyz/docs/rules/no-leaked-conditional-rendering
1609
- "@eslint-react/no-leaked-conditional-rendering": "error",
1610
- "@eslint-react/prefer-read-only-props": "warn"
1611
- } : {}
1612
- },
1613
- {
1614
- files: ["**/*.cts"],
1615
- rules: {
1616
- "@typescript-eslint/no-require-imports": "off"
1617
- }
1618
- }
1619
- ];
1349
+ const { isInEditor = false, tsconfigPath = true, tsconfigRootDir = process.cwd(), allowDefaultProject = [], extraFileExtensions = [], reactTypeCheck = false } = options;
1350
+ const files$7 = [
1351
+ GLOB_TS,
1352
+ GLOB_TSX,
1353
+ ...extraFileExtensions.map((extension) => `**/*${extension}`)
1354
+ ];
1355
+ const extensions$1 = [
1356
+ ".cjs",
1357
+ ".mjs",
1358
+ ".cts",
1359
+ ".mts",
1360
+ ...defaultExtensions,
1361
+ ...extraFileExtensions
1362
+ ];
1363
+ if (process.versions["pnp"]) externalModuleFolders.push(".yarn");
1364
+ const tsProjectOptions = tsconfigPath === true ? { projectService: {
1365
+ allowDefaultProject,
1366
+ loadTypeScriptPlugins: isInEditor
1367
+ } } : { project: tsconfigPath };
1368
+ return [
1369
+ {
1370
+ name: name$1.setup,
1371
+ files: files$7,
1372
+ plugins: {
1373
+ "import-x": plugins_default["pluginImportX"],
1374
+ "@typescript-eslint": plugins_default["pluginTypescript"],
1375
+ antfu: plugins_default["pluginAntfu"]
1376
+ },
1377
+ languageOptions: {
1378
+ sourceType: "module",
1379
+ ecmaVersion: "latest",
1380
+ parser: parsers_default["parserTypescript"],
1381
+ parserOptions: {
1382
+ ecmaVersion: "latest",
1383
+ extraFileExtensions,
1384
+ jsxPragma: null,
1385
+ ...tsProjectOptions,
1386
+ tsconfigRootDir,
1387
+ warnOnUnsupportedTypeScriptVersion: true
1388
+ }
1389
+ },
1390
+ settings: {
1391
+ "import-x/extensions": extensions$1,
1392
+ "import-x/external-module-folders": externalModuleFolders,
1393
+ "import-x/parsers": { "@typescript-eslint/parser": [
1394
+ ".ts",
1395
+ ".tsx",
1396
+ ".cts",
1397
+ ".mts",
1398
+ ...extraFileExtensions
1399
+ ] },
1400
+ "import-x/resolver-next": [createTypeScriptImportResolver({
1401
+ alwaysTryTypes: true,
1402
+ project: tsconfigPath === true ? void 0 : tsconfigPath,
1403
+ extensions: extensions$1
1404
+ })]
1405
+ }
1406
+ },
1407
+ {
1408
+ name: name$1.rules,
1409
+ files: files$7,
1410
+ rules: {
1411
+ ...configs.typescript.rules,
1412
+ ...typescriptStrictTypeCheckedRules,
1413
+ ...typescriptStylisticTypeCheckedRules,
1414
+ "@typescript-eslint/ban-ts-comment": ["error", {
1415
+ minimumDescriptionLength: 10,
1416
+ "ts-check": false,
1417
+ "ts-expect-error": "allow-with-description",
1418
+ "ts-ignore": true,
1419
+ "ts-nocheck": true
1420
+ }],
1421
+ "@typescript-eslint/naming-convention": [
1422
+ "warn",
1423
+ {
1424
+ selector: "variable",
1425
+ format: [
1426
+ "camelCase",
1427
+ "PascalCase",
1428
+ "UPPER_CASE"
1429
+ ],
1430
+ leadingUnderscore: "allowSingleOrDouble",
1431
+ trailingUnderscore: "forbid"
1432
+ },
1433
+ {
1434
+ selector: "function",
1435
+ format: ["camelCase", "PascalCase"],
1436
+ leadingUnderscore: "allowSingleOrDouble",
1437
+ trailingUnderscore: "forbid"
1438
+ },
1439
+ {
1440
+ selector: "typeLike",
1441
+ format: ["PascalCase"],
1442
+ leadingUnderscore: "forbid",
1443
+ trailingUnderscore: "forbid"
1444
+ }
1445
+ ],
1446
+ "@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
1447
+ "antfu/no-ts-export-equal": "error"
1448
+ }
1449
+ },
1450
+ {
1451
+ name: `${name$1.base}/react-type-checked`,
1452
+ files: files$7,
1453
+ plugins: {
1454
+ "@eslint-react": plugins_default["pluginReact"],
1455
+ "@eslint-react/dom": plugins_default["pluginReactDom"]
1456
+ },
1457
+ rules: reactTypeCheck ? {
1458
+ "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: { attributes: false } }],
1459
+ "@eslint-react/dom/no-unknown-property": "off",
1460
+ "@eslint-react/no-duplicate-jsx-props": "off",
1461
+ "@eslint-react/use-jsx-vars": "off",
1462
+ "@eslint-react/no-leaked-conditional-rendering": "error",
1463
+ "@eslint-react/prefer-read-only-props": "warn"
1464
+ } : {}
1465
+ },
1466
+ {
1467
+ files: ["**/*.cts"],
1468
+ rules: { "@typescript-eslint/no-require-imports": "off" }
1469
+ }
1470
+ ];
1620
1471
  }
1621
1472
 
1473
+ //#endregion
1474
+ //#region src/configs/unicorn.ts
1622
1475
  const name = getFlatConfigName("unicorn");
1623
1476
  const files = [GLOB_SRC];
1624
1477
  const allFiles = [...GLOB_ALL_SRC];
1625
1478
  function unicorn() {
1626
- return [
1627
- {
1628
- name: `${name.setup}/all-src`,
1629
- files: allFiles,
1630
- plugins: {
1631
- unicorn: plugins["pluginUnicorn"]
1632
- }
1633
- },
1634
- {
1635
- name: `${name.setup}/src`,
1636
- files,
1637
- languageOptions: {
1638
- globals: {
1639
- ...globals.builtin
1640
- }
1641
- }
1642
- },
1643
- {
1644
- name: `${name.rules}/all-src`,
1645
- files: allFiles,
1646
- rules: {
1647
- // Let all files use kebab-case for filenames.
1648
- // kebab-case forces filenames to be lowercase and hyphen-separated,
1649
- // some file systems are case-insensitive, so this rule can help prevent
1650
- // issues with importing files on case-sensitive file systems.
1651
- "unicorn/filename-case": ["error", {
1652
- cases: { kebabCase: true },
1653
- // Ignore case for specific files
1654
- ignore: ["README.md", "LICENSE.md", "CHANGELOG.md", "CODE_OF_CONDUCT.md"]
1655
- }]
1656
- }
1657
- },
1658
- {
1659
- name: `${name.rules}/src`,
1660
- files,
1661
- rules: {
1662
- // eslint-plugin-unicorn
1663
- // https://github.com/sindresorhus/eslint-plugin-unicorn
1664
- ...pluginUnicorn.configs["flat/recommended"].rules
1665
- }
1666
- }
1667
- ];
1479
+ return [
1480
+ {
1481
+ name: `${name.setup}/all-src`,
1482
+ files: allFiles,
1483
+ plugins: { unicorn: plugins_default["pluginUnicorn"] }
1484
+ },
1485
+ {
1486
+ name: `${name.setup}/src`,
1487
+ files,
1488
+ languageOptions: { globals: { ...globals$1.builtin } }
1489
+ },
1490
+ {
1491
+ name: `${name.rules}/all-src`,
1492
+ files: allFiles,
1493
+ rules: { "unicorn/filename-case": ["error", {
1494
+ cases: { kebabCase: true },
1495
+ ignore: [
1496
+ "README.md",
1497
+ "LICENSE.md",
1498
+ "CHANGELOG.md",
1499
+ "CODE_OF_CONDUCT.md"
1500
+ ]
1501
+ }] }
1502
+ },
1503
+ {
1504
+ name: `${name.rules}/src`,
1505
+ files,
1506
+ rules: { ...pluginUnicorn.configs["flat/recommended"].rules }
1507
+ }
1508
+ ];
1668
1509
  }
1669
1510
 
1511
+ //#endregion
1512
+ //#region src/factory.ts
1670
1513
  function enabled(options, defaults = false) {
1671
- if (typeof options === "boolean") return options;
1672
- if (options === void 0) return defaults;
1673
- if (options.enable) return true;
1674
- return defaults;
1514
+ if (typeof options === "boolean") return options;
1515
+ if (options === void 0) return defaults;
1516
+ if (options.enable) return true;
1517
+ return defaults;
1675
1518
  }
1676
1519
  function configOptions(options, defaultOptions) {
1677
- const isInEditor = isInEditorEnv();
1678
- if (options === void 0) return { isInEditor };
1679
- if (typeof options === "boolean") return { isInEditor };
1680
- return { ...defaultOptions, ...options, isInEditor };
1520
+ const isInEditor = isInEditorEnv();
1521
+ if (options === void 0) return { isInEditor };
1522
+ if (typeof options === "boolean") return { isInEditor };
1523
+ return {
1524
+ ...defaultOptions,
1525
+ ...options,
1526
+ isInEditor
1527
+ };
1681
1528
  }
1682
- const pluginRenaming = {
1683
- "import-x": "import"
1684
- };
1529
+ /**
1530
+ * Construct an array of ESLint flat config items.
1531
+ *
1532
+ * @param options
1533
+ * The options for generating the ESLint configurations.
1534
+ * @param userConfigs
1535
+ * The user configurations to be merged with the generated configurations.
1536
+ * @returns The merged ESLint configurations.
1537
+ */
1685
1538
  async function config(options, ...userConfigs) {
1686
- const configs = [];
1687
- const enableTypeScript = enabled(options?.typescript, isPackageExists("typescript"));
1688
- const enableReact = enabled(options?.react, isPackageExists("react"));
1689
- const importsOption = enableTypeScript ? configOptions(options?.typescript) : {};
1690
- configs.push(ignores(options?.ignores), comments(), imports(importsOption));
1691
- if (enabled(options?.javascript, true)) {
1692
- configs.push(javascript(configOptions(options?.javascript)));
1693
- }
1694
- if (enableTypeScript) {
1695
- configs.push(
1696
- typescript(configOptions(options?.typescript, { reactTypeCheck: enableReact }))
1697
- );
1698
- }
1699
- if (enabled(options?.json, true)) {
1700
- const formatOption = configOptions(options?.format, { indentWidth: 2 });
1701
- configs.push(json(configOptions(options?.json, { stylistic: formatOption })));
1702
- }
1703
- if (enableReact) {
1704
- configs.push(
1705
- jsx(),
1706
- react(
1707
- configOptions(options?.react, {
1708
- reactCompiler: isPackageExists("babel-plugin-react-compiler") || isPackageExists("react-compiler-webpack")
1709
- })
1710
- )
1711
- );
1712
- }
1713
- if (enabled(options?.react, isPackageExists("next"))) {
1714
- configs.push(nextJs());
1715
- }
1716
- if (enabled(options?.node, isPackageExists("@types/node"))) {
1717
- configs.push(nodeJs(configOptions(options?.node)));
1718
- }
1719
- if (enabled(void 0, isPackageExists("tailwindcss"))) {
1720
- configs.push(tailwindcss());
1721
- }
1722
- configs.push(regexp(), unicorn(), disables());
1723
- if (enabled(options?.format, isPackageExists("dprint"))) {
1724
- const jsonOptions = configOptions(options?.json);
1725
- configs.push(
1726
- formatters(
1727
- configOptions(options?.format, {
1728
- extraJsonFiles: jsonOptions.extraFiles
1729
- })
1730
- )
1731
- );
1732
- }
1733
- let composer = new FlatConfigComposer(...configs);
1734
- const _userConfigs = userConfigs;
1735
- composer = composer.append(..._userConfigs).renamePlugins(pluginRenaming);
1736
- return composer;
1539
+ const configs$2 = [];
1540
+ const enableTypeScript = enabled(options?.typescript, isPackageExists("typescript"));
1541
+ const enableReact = enabled(options?.react, isPackageExists("react"));
1542
+ const importsOption = enableTypeScript ? configOptions(options?.typescript) : {};
1543
+ configs$2.push(ignores(options?.ignores), comments(), imports(importsOption));
1544
+ if (enabled(options?.javascript, true)) configs$2.push(javascript(configOptions(options?.javascript)));
1545
+ if (enableTypeScript) configs$2.push(typescript(configOptions(options?.typescript, { reactTypeCheck: enableReact })));
1546
+ if (enabled(options?.json, true)) {
1547
+ const formatOption = configOptions(options?.format, { indentWidth: 2 });
1548
+ configs$2.push(json(configOptions(options?.json, { stylistic: formatOption })));
1549
+ }
1550
+ if (enableReact) configs$2.push(jsx(), react(configOptions(options?.react, { reactCompiler: isPackageExists("babel-plugin-react-compiler") || isPackageExists("react-compiler-webpack") })));
1551
+ if (enabled(options?.react, isPackageExists("next"))) configs$2.push(nextJs());
1552
+ if (enabled(options?.node, isPackageExists("@types/node"))) configs$2.push(nodeJs(configOptions(options?.node)));
1553
+ if (enabled(void 0, isPackageExists("tailwindcss"))) configs$2.push(tailwindcss());
1554
+ configs$2.push(regexp(), unicorn(), disables());
1555
+ if (enabled(options?.format, isPackageExists("dprint"))) {
1556
+ const jsonOptions = configOptions(options?.json);
1557
+ configs$2.push(formatters(configOptions(options?.format, { extraJsonFiles: jsonOptions.extraFiles })));
1558
+ }
1559
+ let composer = new FlatConfigComposer(...configs$2);
1560
+ const _userConfigs = userConfigs;
1561
+ composer = composer.append(..._userConfigs);
1562
+ return composer;
1737
1563
  }
1738
1564
 
1739
- export { combine, comments, config as default, disables, formatters, getFlatConfigName, getPackageJson, ignores, imports, isInEditorEnv, isInGitHooksOrLintStaged, javascript, json, jsx, loadLocalFile, memo, nextJs, nodeJs, react, regexp, tailwindcss, typescript, unicorn };
1565
+ //#endregion
1566
+ export { combine, comments, config as default, disables, formatters, getFlatConfigName, getPackageJson, globals, ignores, imports, isInEditorEnv, isInGitHooksOrLintStaged, javascript, json, jsx, loadLocalFile, memo, nextJs, nodeJs, react, regexp, tailwindcss, typescript, unicorn };