@biscuittin/eslint-config 0.0.6 → 0.1.0

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