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