@moso/eslint-config 3.0.4 → 3.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/README.md +155 -62
- package/dist/index.d.mts +3903 -594
- package/dist/index.mjs +1015 -850
- package/package.json +54 -46
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
2
|
import { getPackageInfo, isPackageExists } from "local-pkg";
|
|
3
3
|
import assert from "node:assert/strict";
|
|
4
|
+
import globals from "globals";
|
|
4
5
|
import { AST_NODE_TYPES, AST_TOKEN_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
5
6
|
import { isIdentifier } from "@typescript-eslint/utils/ast-utils";
|
|
6
|
-
import globals from "globals";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
9
9
|
//#region src/utils.ts
|
|
@@ -32,10 +32,23 @@ const checkFilePath = (path) => {
|
|
|
32
32
|
if (path.trim() !== path) throw new Error("FilePath cannot have leading/trailing whitespace");
|
|
33
33
|
return path;
|
|
34
34
|
};
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Merge the `rules` of a shared flat-config array into a single rule map.
|
|
37
|
+
*
|
|
38
|
+
* Plugins ship their presets as an array (a setup item, then one item per rule layer),
|
|
39
|
+
* this keeps only the rules so they can be spread into a config item
|
|
40
|
+
* that declares its own `files`, `plugins`, and parser.
|
|
41
|
+
*
|
|
42
|
+
* @param configs - A plugin's exported flat config array.
|
|
43
|
+
* @returns Every config's rules merged in order.
|
|
44
|
+
*/
|
|
45
|
+
const flattenRules = (configs) => configs.reduce((acc, config) => Object.assign(acc, config.rules), {});
|
|
46
|
+
/**
|
|
47
|
+
* Auto-numbering for unnamed `globalIgnores` items.
|
|
48
|
+
*/
|
|
36
49
|
const nextGlobalIgnoresName = (() => {
|
|
37
|
-
|
|
38
|
-
return () => `globalIgnores ${
|
|
50
|
+
const mut_counter = { count: 0 };
|
|
51
|
+
return () => `globalIgnores ${String(mut_counter.count++)}`;
|
|
39
52
|
})();
|
|
40
53
|
/**
|
|
41
54
|
* Build a global-ignores config item (an item with only `ignores`,
|
|
@@ -57,8 +70,8 @@ const globalIgnores = (ignorePatterns, name) => {
|
|
|
57
70
|
/**
|
|
58
71
|
* Await a value and unwrap its `default` export when present.
|
|
59
72
|
*
|
|
60
|
-
* Smooths over the CJS/ESM interop difference where `import()` of a CJS
|
|
61
|
-
*
|
|
73
|
+
* Smooths over the CJS/ESM interop difference where `import()` of a CJS module
|
|
74
|
+
* yields `{ default: ... }` while an ESM module may not.
|
|
62
75
|
*
|
|
63
76
|
* @param value - A module (or promise of one) whose default export should be unwrapped.
|
|
64
77
|
* @returns The default export when one exists, otherwise the resolved value itself.
|
|
@@ -67,7 +80,9 @@ const interopDefault = async (value) => {
|
|
|
67
80
|
const resolved = await value;
|
|
68
81
|
return resolved.default ?? resolved;
|
|
69
82
|
};
|
|
70
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Whether ESLint is running from a git hook or lint-staged rather than an editor.
|
|
85
|
+
*/
|
|
71
86
|
const isInGitHooksOrLintStaged = () => Boolean(process.env.GIT_PARAMS) || Boolean(process.env.VSCODE_GIT_COMMAND) || Boolean(process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
72
87
|
/**
|
|
73
88
|
* Detect whether ESLint is running inside an editor/IDE integration.
|
|
@@ -84,14 +99,14 @@ const isInEditorEnv = () => {
|
|
|
84
99
|
return Boolean(process.env.VSCODE_PID) || Boolean(process.env.VSCODE_CWD) || Boolean(process.env.JETBRAINS_IDE) || Boolean(process.env.VIM) || Boolean(process.env.NVIM);
|
|
85
100
|
};
|
|
86
101
|
/**
|
|
87
|
-
* Normalize a factory option that accepts `boolean | string | object`
|
|
102
|
+
* Normalize a factory option that accepts `boolean | string | number | object`
|
|
88
103
|
* down to its object form.
|
|
89
104
|
*
|
|
90
105
|
* @param options - The full factory options object.
|
|
91
106
|
* @param key - The option key to resolve.
|
|
92
|
-
* @returns The option's object form; `{}` when the option was a boolean, string, or absent.
|
|
107
|
+
* @returns The option's object form; `{}` when the option was a boolean, string, number, or absent.
|
|
93
108
|
*/
|
|
94
|
-
const resolveSubOptions = (options, key) => typeof options[key] === "
|
|
109
|
+
const resolveSubOptions = (options, key) => typeof options[key] === "object" ? options[key] : {};
|
|
95
110
|
/**
|
|
96
111
|
* Extract the `overrides` rule map from a factory option, regardless of
|
|
97
112
|
* whether the option was given as a boolean, string, or object.
|
|
@@ -104,46 +119,6 @@ const getOverrides = (options, key) => {
|
|
|
104
119
|
const sub = resolveSubOptions(options, key);
|
|
105
120
|
return ("overrides" in sub ? sub.overrides : {}) ?? {};
|
|
106
121
|
};
|
|
107
|
-
const scopeURL = import.meta.dirname;
|
|
108
|
-
/** Whether `name` resolves from this package's own directory (not the consumer's cwd). */
|
|
109
|
-
const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeURL] });
|
|
110
|
-
/** Whether an install prompt could ever be shown: a TTY outside CI. */
|
|
111
|
-
const isInteractive = () => {
|
|
112
|
-
if (Boolean(process.env.CI)) return false;
|
|
113
|
-
return process.stdout.isTTY;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Offer to install missing packages through an interactive prompt.
|
|
117
|
-
* No-op in CI or when stdout is not a TTY.
|
|
118
|
-
*
|
|
119
|
-
* @param packages - Package names to check and offer for installation.
|
|
120
|
-
*/
|
|
121
|
-
const ensurePackages = async (packages) => {
|
|
122
|
-
if (!isInteractive()) return;
|
|
123
|
-
const missingPackages = packages.filter((x) => !isPackageInScope(x));
|
|
124
|
-
if (missingPackages.length === 0) return;
|
|
125
|
-
if (await (await import("@clack/prompts")).confirm({ message: missingPackages.length === 1 ? `${missingPackages[0]} is required. Do you want to install it?` : `These packages are required: ${missingPackages.join(", ")}.\nDo you want to install them?` }) === true) {
|
|
126
|
-
const { installPackage } = await import("@antfu/install-pkg");
|
|
127
|
-
await installPackage(missingPackages, { dev: true });
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Dynamically import a list of packages, unwrapping default exports.
|
|
132
|
-
*
|
|
133
|
-
* In interactive sessions, missing packages trigger an install prompt first
|
|
134
|
-
* (see `ensurePackages`). Call sites destructure the result as a tuple:
|
|
135
|
-
* `const [plugin] = (await loadPackages(['pkg'])) as [Type]`.
|
|
136
|
-
*
|
|
137
|
-
* @param packageIds - Package names to import, in order.
|
|
138
|
-
* @returns The imported modules (default exports unwrapped), in input order.
|
|
139
|
-
*/
|
|
140
|
-
const loadPackages = async (packageIds) => {
|
|
141
|
-
if (isInteractive()) {
|
|
142
|
-
const missing = packageIds.filter((id) => !isPackageExists(id));
|
|
143
|
-
if (missing.length > 0) await ensurePackages(missing);
|
|
144
|
-
}
|
|
145
|
-
return Promise.all(packageIds.map(async (id) => interopDefault(import(id))));
|
|
146
|
-
};
|
|
147
122
|
/**
|
|
148
123
|
* Return one shared instance per plugin key, registering `plugin` on first use.
|
|
149
124
|
*
|
|
@@ -153,10 +128,11 @@ const loadPackages = async (packageIds) => {
|
|
|
153
128
|
* with different references. Stored realm-wide on `globalThis` so duplicated
|
|
154
129
|
* copies of this package still share one store.
|
|
155
130
|
*
|
|
131
|
+
* @see https://github.com/SukkaW/eslint-config-sukka/blob/master/packages/shared/src/memoize-eslint-plugin.ts
|
|
132
|
+
*
|
|
156
133
|
* @param plugin - The plugin instance to register when the key is unseen.
|
|
157
134
|
* @param key - Stable identifier; must be identical everywhere the same package is registered.
|
|
158
135
|
* @returns The first instance ever registered under `key`.
|
|
159
|
-
* @see https://github.com/SukkaW/eslint-config-sukka/blob/master/packages/shared/src/memoize-eslint-plugin.ts
|
|
160
136
|
*/
|
|
161
137
|
const memoize = (plugin, key) => {
|
|
162
138
|
globalThis.__ESLINT_PLUGIN_MEMO__ ??= /* @__PURE__ */ new Map();
|
|
@@ -215,74 +191,139 @@ const vueInlineElements = [
|
|
|
215
191
|
"video"
|
|
216
192
|
];
|
|
217
193
|
//#endregion
|
|
194
|
+
//#region src/tools.ts
|
|
195
|
+
const scopeURL = import.meta.dirname;
|
|
196
|
+
/**
|
|
197
|
+
* Whether `name` resolves from this package's own directory (not the user's cwd).
|
|
198
|
+
*/
|
|
199
|
+
const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeURL] });
|
|
200
|
+
/**
|
|
201
|
+
* Whether an install prompt could ever be shown: a TTY outside CI.
|
|
202
|
+
*/
|
|
203
|
+
const isInteractive = () => {
|
|
204
|
+
if (Boolean(process.env.CI)) return false;
|
|
205
|
+
return process.stdout.isTTY;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Offer to install missing packages through an interactive prompt.
|
|
209
|
+
* Only called from `loadPackages` after it has verified the session is interactive.
|
|
210
|
+
*
|
|
211
|
+
* @param packages - Package names to check and offer for installation.
|
|
212
|
+
*/
|
|
213
|
+
const ensurePackages = async (packages) => {
|
|
214
|
+
const missingPackages = packages.filter((x) => !isPackageInScope(x));
|
|
215
|
+
if (missingPackages.length === 0) return;
|
|
216
|
+
if (await (await import("@clack/prompts")).confirm({ message: missingPackages.length === 1 ? `${missingPackages[0]} is required. Do you want to install it?` : `These packages are required: ${missingPackages.join(", ")}.\nDo you want to install them?` }) === true) {
|
|
217
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
218
|
+
await installPackage(missingPackages, { dev: true });
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Dynamically import a list of packages, unwrapping default exports.
|
|
223
|
+
*
|
|
224
|
+
* In interactive sessions, missing packages trigger an install prompt first.
|
|
225
|
+
* The package-name literals are mapped to module types through `PackageTypes`,
|
|
226
|
+
* so call sites destructure a fully typed tuple without casts:
|
|
227
|
+
* `const [plugin] = await loadPackages(['pkg'])`.
|
|
228
|
+
*
|
|
229
|
+
* @param packageIds - Package names to import, in order.
|
|
230
|
+
* @returns The imported modules (default exports unwrapped), in input order.
|
|
231
|
+
*/
|
|
232
|
+
const loadPackages = async (packageIds) => {
|
|
233
|
+
if (isInteractive()) {
|
|
234
|
+
const missing = packageIds.filter((id) => !isPackageExists(id));
|
|
235
|
+
if (missing.length > 0) await ensurePackages(missing);
|
|
236
|
+
}
|
|
237
|
+
return Promise.all(packageIds.map(async (id) => interopDefault(import(id))));
|
|
238
|
+
};
|
|
239
|
+
//#endregion
|
|
218
240
|
//#region src/configs/astro.ts
|
|
219
241
|
const astro = async (options) => {
|
|
220
242
|
const { a11y, files, lessOpinionated, overrides, overridesA11y, parserOptions, stylistic, typescript } = options;
|
|
221
|
-
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
222
243
|
const stylisticEnabled = stylistic !== false;
|
|
223
|
-
const [typescriptParser] = typescript ? await loadPackages(["@typescript-eslint/parser"]) : [void 0];
|
|
224
244
|
const [astroParser, astroPlugin] = await loadPackages(["astro-eslint-parser", "eslint-plugin-astro"]);
|
|
245
|
+
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
246
|
+
const [typescriptParser] = typescript ? await loadPackages(["@typescript-eslint/parser"]) : [void 0];
|
|
225
247
|
const { projectService, ...typeAwareParserOptions } = parserOptions ?? {};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
{
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
return [{
|
|
249
|
+
name: "moso/astro/setup",
|
|
250
|
+
plugins: {
|
|
251
|
+
"astro": memoize(astroPlugin, "eslint-plugin-astro"),
|
|
252
|
+
...jsxA11yPlugin && { "jsx-a11y": memoize(jsxA11yPlugin, "eslint-plugin-jsx-a11y") }
|
|
253
|
+
}
|
|
254
|
+
}, {
|
|
255
|
+
name: "moso/astro/rules",
|
|
256
|
+
files,
|
|
257
|
+
languageOptions: {
|
|
258
|
+
globals: { ...astroPlugin.environments.astro.globals },
|
|
259
|
+
parser: memoize(astroParser, "astro-eslint-parser"),
|
|
260
|
+
parserOptions: {
|
|
261
|
+
extraFileExtensions: [".astro"],
|
|
262
|
+
parser: typescript ? typescriptParser : void 0,
|
|
263
|
+
...typescript && {
|
|
264
|
+
...typeAwareParserOptions,
|
|
265
|
+
...Boolean(projectService) && { project: true }
|
|
266
|
+
}
|
|
243
267
|
},
|
|
244
|
-
|
|
245
|
-
plugins: { "astro": memoize(astroPlugin, "eslint-plugin-astro") }
|
|
268
|
+
sourceType: "module"
|
|
246
269
|
},
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
"astro/no-set-text-directive": "error",
|
|
258
|
-
"astro/no-unsafe-inline-scripts": "error",
|
|
259
|
-
...stylisticEnabled && {
|
|
260
|
-
"astro/prefer-class-list-directive": "error",
|
|
261
|
-
"astro/prefer-object-class-list": "error",
|
|
262
|
-
"astro/prefer-split-class-list": "error",
|
|
263
|
-
"astro/sort-attributes": "off"
|
|
264
|
-
}
|
|
265
|
-
},
|
|
270
|
+
processor: "astro/client-side-ts",
|
|
271
|
+
rules: {
|
|
272
|
+
"@moso/no-top-level-await": "off",
|
|
273
|
+
"node/no-top-level-await": "off",
|
|
274
|
+
"unicorn/no-await-expression-member": "off",
|
|
275
|
+
...flattenRules(astroPlugin.configs.recommended),
|
|
276
|
+
...!lessOpinionated && {
|
|
277
|
+
"astro/no-set-html-directive": "error",
|
|
278
|
+
"astro/no-set-text-directive": "error",
|
|
279
|
+
"astro/no-unsafe-inline-scripts": "error",
|
|
266
280
|
...stylisticEnabled && {
|
|
267
|
-
"
|
|
268
|
-
"
|
|
269
|
-
"
|
|
270
|
-
"
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
+
"astro/prefer-class-list-directive": "error",
|
|
282
|
+
"astro/prefer-object-class-list": "error",
|
|
283
|
+
"astro/prefer-split-class-list": "error",
|
|
284
|
+
"astro/sort-attributes": "off"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
...stylisticEnabled && {
|
|
288
|
+
"@stylistic/indent": "off",
|
|
289
|
+
"@stylistic/jsx-closing-tag-location": "off",
|
|
290
|
+
"@stylistic/jsx-one-expression-per-line": "off",
|
|
291
|
+
"@stylistic/no-multiple-empty-lines": "off",
|
|
292
|
+
"astro/semi": ["error", stylistic.semi ? "always" : "never"]
|
|
293
|
+
},
|
|
294
|
+
...jsxA11yPlugin && {
|
|
281
295
|
...flattenRules(astroPlugin.configs[lessOpinionated ? "jsx-a11y-recommended" : "jsx-a11y-strict"]),
|
|
282
296
|
...overridesA11y
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
297
|
+
},
|
|
298
|
+
...overrides
|
|
299
|
+
}
|
|
300
|
+
}];
|
|
301
|
+
};
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/configs/baseline.ts
|
|
304
|
+
const defaultIgnoreFeatures = ["functions-caller-arguments"];
|
|
305
|
+
const baseline = async (options) => {
|
|
306
|
+
const { baseline, files, filesTypeAware, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, projectRoot, typescript } = options;
|
|
307
|
+
const isTypeAware = typescript && typeof projectRoot === "string";
|
|
308
|
+
const [baselinePlugin] = await loadPackages(["eslint-plugin-baseline-js"]);
|
|
309
|
+
return [{
|
|
310
|
+
name: "moso/baseline/setup",
|
|
311
|
+
plugins: { "baseline-js": memoize(baselinePlugin, "eslint-plugin-baseline-js") }
|
|
312
|
+
}, {
|
|
313
|
+
name: `moso/baseline/${isTypeAware ? "type-aware-rules" : "rules"}`,
|
|
314
|
+
files: isTypeAware ? filesTypeAware : files,
|
|
315
|
+
ignores: isTypeAware ? ignoresTypeAware : {},
|
|
316
|
+
rules: {
|
|
317
|
+
"baseline-js/use-baseline": ["warn", {
|
|
318
|
+
available: baseline ?? "widely",
|
|
319
|
+
ignoreFeatures: [...defaultIgnoreFeatures, ...ignoreFeatures ?? []],
|
|
320
|
+
ignoreNodeTypes,
|
|
321
|
+
includeJsBuiltins: { preset: isTypeAware ? "type-aware" : "auto" },
|
|
322
|
+
includeWebApis: { preset: isTypeAware ? "type-aware" : "auto" }
|
|
323
|
+
}],
|
|
324
|
+
...isTypeAware ? { ...overridesTypeAware } : { ...overrides }
|
|
325
|
+
}
|
|
326
|
+
}];
|
|
286
327
|
};
|
|
287
328
|
//#endregion
|
|
288
329
|
//#region src/globs.ts
|
|
@@ -307,6 +348,7 @@ const GLOB_CSS = "**/?(.)*.css";
|
|
|
307
348
|
const GLOB_POSTCSS = "**/?(.)*.{p,post}css";
|
|
308
349
|
const GLOB_LESS = "**/?(.)*.less";
|
|
309
350
|
const GLOB_SCSS = "**/?(.)*.scss";
|
|
351
|
+
const GLOB_CSS_IN_JS = "**/*.css.{j,t}s";
|
|
310
352
|
const GLOB_JSON = "**/*.json";
|
|
311
353
|
const GLOB_JSON5 = "**/*.json5";
|
|
312
354
|
const GLOB_JSONC = "**/*.jsonc";
|
|
@@ -316,8 +358,11 @@ const GLOB_HTML = "**/*.htm?(l)";
|
|
|
316
358
|
const GLOB_MARKDOWN = "**/*.md";
|
|
317
359
|
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
318
360
|
const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
361
|
+
const GLOB_SVELTE = "**/*.svelte?(.{js,ts})";
|
|
362
|
+
const GLOB_SVG = "**/*.svg";
|
|
319
363
|
const GLOB_TOML = "**/*.toml";
|
|
320
364
|
const GLOB_VUE = "**/*.vue";
|
|
365
|
+
const GLOB_XML = "**/*.xml";
|
|
321
366
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
322
367
|
const GLOB_TYPINGS = "typings/**/?(.)*.?([cm])ts";
|
|
323
368
|
const GLOB_TESTS = [
|
|
@@ -334,53 +379,77 @@ const GLOB_ALL_SRC = [
|
|
|
334
379
|
GLOB_JSON5,
|
|
335
380
|
GLOB_HTML,
|
|
336
381
|
GLOB_MARKDOWN,
|
|
382
|
+
GLOB_SVELTE,
|
|
337
383
|
GLOB_VUE,
|
|
338
|
-
GLOB_YAML
|
|
384
|
+
GLOB_YAML,
|
|
385
|
+
GLOB_XML
|
|
339
386
|
];
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
"**/lib",
|
|
387
|
+
const GLOB_NODE_MODULES = "**/node_modules";
|
|
388
|
+
const GLOB_DIST = "**/dist";
|
|
389
|
+
const GLOB_LOCKFILE = [
|
|
344
390
|
"**/package-lock.json",
|
|
345
|
-
"**/
|
|
391
|
+
"**/bun.lock?(b)",
|
|
346
392
|
"**/pnpm-lock.yaml",
|
|
347
|
-
"**/
|
|
348
|
-
|
|
393
|
+
"**/yarn.lock"
|
|
394
|
+
];
|
|
395
|
+
const GLOB_AI = [
|
|
396
|
+
"**/.agents",
|
|
397
|
+
"**/.claude",
|
|
398
|
+
"**/.context",
|
|
399
|
+
"**/.*/skills"
|
|
400
|
+
];
|
|
401
|
+
const GLOB_EXCLUDE = [
|
|
402
|
+
GLOB_NODE_MODULES,
|
|
403
|
+
GLOB_DIST,
|
|
404
|
+
...GLOB_LOCKFILE,
|
|
405
|
+
"**/fixtures",
|
|
406
|
+
"**/lib",
|
|
349
407
|
"**/output",
|
|
350
408
|
"**/coverage",
|
|
351
409
|
"**/temp",
|
|
352
|
-
"**/.temp",
|
|
353
410
|
"**/tmp",
|
|
354
|
-
"**/.
|
|
355
|
-
"**/.history",
|
|
356
|
-
"**/.vitepress/cache",
|
|
357
|
-
"**/.nuxt",
|
|
358
|
-
"**/.next",
|
|
359
|
-
"**/.vercel",
|
|
411
|
+
"**/.cache",
|
|
360
412
|
"**/.changeset",
|
|
413
|
+
"**/.history",
|
|
361
414
|
"**/.idea",
|
|
362
|
-
"**/.
|
|
415
|
+
"**/.next",
|
|
416
|
+
"**/.nitro",
|
|
417
|
+
"**/.nuxt",
|
|
363
418
|
"**/.output",
|
|
419
|
+
"**/.temp",
|
|
420
|
+
"**/.tmp",
|
|
421
|
+
"**/.vercel",
|
|
364
422
|
"**/.vite-inspect",
|
|
423
|
+
"**/.vitepress/cache",
|
|
365
424
|
"**/.yarn",
|
|
366
|
-
"**/vite.config.*.timestamp-*",
|
|
367
425
|
"**/CHANGELOG*.md",
|
|
368
|
-
"
|
|
426
|
+
"**/?(.)*.min.*",
|
|
369
427
|
"**/LICENSE*",
|
|
370
428
|
"**/__snapshots__",
|
|
371
|
-
"**/auto-import?(s).ts",
|
|
372
|
-
"**/
|
|
373
|
-
"**/
|
|
374
|
-
"**/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
"**/*.css.ts"
|
|
429
|
+
"**/auto-import?(s)?(.d).ts",
|
|
430
|
+
"**/components?(.d).ts",
|
|
431
|
+
"**/typegen?(.d).ts",
|
|
432
|
+
"**/vite.config.*.timestamp-*",
|
|
433
|
+
GLOB_CSS_IN_JS,
|
|
434
|
+
...GLOB_AI
|
|
378
435
|
];
|
|
379
436
|
//#endregion
|
|
380
437
|
//#region src/configs/disables.ts
|
|
381
438
|
const disables = async () => {
|
|
382
439
|
const [functionalPlugin] = await loadPackages(["eslint-plugin-functional"]);
|
|
383
440
|
return [
|
|
441
|
+
{
|
|
442
|
+
name: "moso/disables/allow-default-export",
|
|
443
|
+
files: [
|
|
444
|
+
`**/config*.${GLOB_SRC_EXT}`,
|
|
445
|
+
`**/{api,helpers,middleware,modules,pages,plugins,routes,views}/${GLOB_SRC}`,
|
|
446
|
+
`**/{esbuild,farm,index,next,nuxt,rolldown,rollup,rspack,vite,webpack}.${GLOB_SRC_EXT}`,
|
|
447
|
+
`${GLOB_MARKDOWN}/**`,
|
|
448
|
+
"**/*.d.ts",
|
|
449
|
+
"**/.prettierrc"
|
|
450
|
+
],
|
|
451
|
+
rules: { "import-lite/no-default-export": "off" }
|
|
452
|
+
},
|
|
384
453
|
{
|
|
385
454
|
name: "moso/disables/bin",
|
|
386
455
|
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
@@ -399,12 +468,18 @@ const disables = async () => {
|
|
|
399
468
|
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
400
469
|
rules: {
|
|
401
470
|
"@moso/no-top-level-await": "off",
|
|
471
|
+
"baseline-js/use-baseline": "off",
|
|
402
472
|
"no-console": "off"
|
|
403
473
|
}
|
|
404
474
|
},
|
|
475
|
+
{
|
|
476
|
+
name: "moso/disables/components",
|
|
477
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
478
|
+
rules: { "unicorn/no-anonymous-default-export": "off" }
|
|
479
|
+
},
|
|
405
480
|
{
|
|
406
481
|
name: "moso/disables/config-files",
|
|
407
|
-
files: [`**/*.config.${GLOB_SRC_EXT}`,
|
|
482
|
+
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/{esbuild,farm,index,next,nuxt,rolldown,rollup,rspack,vite,webpack}.${GLOB_SRC_EXT}`],
|
|
408
483
|
rules: {
|
|
409
484
|
"@moso/no-top-level-await": "off",
|
|
410
485
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
@@ -415,17 +490,51 @@ const disables = async () => {
|
|
|
415
490
|
name: "moso/disables/dts",
|
|
416
491
|
files: ["**/*.d.?([cm])ts"],
|
|
417
492
|
rules: {
|
|
493
|
+
"no-restricted-syntax": "off",
|
|
418
494
|
"@eslint-community/eslint-comments/no-unlimited-disable": "off",
|
|
419
495
|
"import-lite/no-duplicates": "off",
|
|
420
|
-
"unused-imports/no-unused-vars": "off"
|
|
421
|
-
"no-restricted-syntax": "off"
|
|
496
|
+
"unused-imports/no-unused-vars": "off"
|
|
422
497
|
}
|
|
423
498
|
},
|
|
499
|
+
{
|
|
500
|
+
name: "moso/disables/github",
|
|
501
|
+
files: ["**/ISSUES_TEMPLATE/**"],
|
|
502
|
+
rules: { "unicorn/filename-case": "off" }
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: "moso/disables/node-frameworks",
|
|
506
|
+
files: [
|
|
507
|
+
GLOB_ASTRO,
|
|
508
|
+
GLOB_ASTRO_TS,
|
|
509
|
+
GLOB_DTS,
|
|
510
|
+
GLOB_JSX,
|
|
511
|
+
GLOB_TS,
|
|
512
|
+
GLOB_TSX,
|
|
513
|
+
GLOB_VUE
|
|
514
|
+
],
|
|
515
|
+
rules: {
|
|
516
|
+
"node/no-extraneous-import": "off",
|
|
517
|
+
"node/no-missing-import": "off",
|
|
518
|
+
"node/no-restricted-import": "off"
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
name: "moso/disables/node-typescript",
|
|
523
|
+
files: [
|
|
524
|
+
GLOB_DTS,
|
|
525
|
+
GLOB_MJS,
|
|
526
|
+
GLOB_TS,
|
|
527
|
+
GLOB_TSX
|
|
528
|
+
],
|
|
529
|
+
rules: { "node/no-unsupported-features/es-syntax": "off" }
|
|
530
|
+
},
|
|
424
531
|
{
|
|
425
532
|
name: "moso/disables/scripts",
|
|
426
533
|
files: [`**/scripts/${GLOB_SRC}`],
|
|
427
534
|
rules: {
|
|
428
535
|
"@moso/no-top-level-await": "off",
|
|
536
|
+
"baseline-js/use-baseline": "off",
|
|
537
|
+
"no-console": "off",
|
|
429
538
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
430
539
|
"functional/no-conditional-statements": "off",
|
|
431
540
|
"functional/no-expression-statements": "off",
|
|
@@ -433,8 +542,33 @@ const disables = async () => {
|
|
|
433
542
|
"functional/no-return-void": "off",
|
|
434
543
|
"functional/no-throw-statements": "off",
|
|
435
544
|
"node/no-sync": "off",
|
|
436
|
-
"node/no-unpublished-import": "off"
|
|
437
|
-
|
|
545
|
+
"node/no-unpublished-import": "off"
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
name: "moso/disables/tests",
|
|
550
|
+
files: GLOB_TESTS,
|
|
551
|
+
rules: {
|
|
552
|
+
"@moso/no-top-level-await": "off",
|
|
553
|
+
"baseline-js/use-baseline": "off",
|
|
554
|
+
"e18e/prefer-static-regex": "off",
|
|
555
|
+
"no-unused-expressions": "off",
|
|
556
|
+
"jsdoc/require-jsdoc": "off",
|
|
557
|
+
"node/no-sync": "off",
|
|
558
|
+
"node/prefer-global/process": "off",
|
|
559
|
+
"regexp/no-super-linear-backtracking": "off",
|
|
560
|
+
"unicorn/consistent-function-scoping": "off",
|
|
561
|
+
"unicorn/prefer-module": "off",
|
|
562
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
563
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
564
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
565
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
566
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
567
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
568
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
569
|
+
"@typescript-eslint/no-unused-expressions": "off",
|
|
570
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
571
|
+
"@typescript-eslint/strict-boolean-expressions": "off"
|
|
438
572
|
}
|
|
439
573
|
},
|
|
440
574
|
{
|
|
@@ -491,16 +625,12 @@ const e18e = async (options) => {
|
|
|
491
625
|
const enablePerformanceImprovements = performanceImprovements !== false;
|
|
492
626
|
return [{
|
|
493
627
|
name: "moso/e18e/rules",
|
|
494
|
-
files: [
|
|
495
|
-
GLOB_SRC,
|
|
496
|
-
GLOB_ASTRO,
|
|
497
|
-
GLOB_VUE
|
|
498
|
-
],
|
|
499
628
|
plugins: { "e18e": memoize(e18ePlugin, "@e18e/eslint-plugin") },
|
|
500
629
|
rules: {
|
|
501
630
|
...enableModernization && { ...(assert.ok(!Array.isArray(e18ePlugin.configs.modernization)), e18ePlugin.configs.modernization.rules) },
|
|
502
631
|
...enableModuleReplacements && { ...(assert.ok(!Array.isArray(e18ePlugin.configs.moduleReplacements)), e18ePlugin.configs.moduleReplacements.rules) },
|
|
503
632
|
...enablePerformanceImprovements && { ...(assert.ok(!Array.isArray(e18ePlugin.configs.performanceImprovements)), e18ePlugin.configs.performanceImprovements.rules) },
|
|
633
|
+
...mode === "library" && { "e18e/prefer-static-regex": "off" },
|
|
504
634
|
...lessOpinionated && {
|
|
505
635
|
"e18e/prefer-array-at": "off",
|
|
506
636
|
"e18e/prefer-array-from-map": "off",
|
|
@@ -511,28 +641,15 @@ const e18e = async (options) => {
|
|
|
511
641
|
},
|
|
512
642
|
...overrides
|
|
513
643
|
}
|
|
514
|
-
}
|
|
515
|
-
name: "moso/e18e/library-disables",
|
|
516
|
-
files: [
|
|
517
|
-
GLOB_SRC,
|
|
518
|
-
GLOB_ASTRO,
|
|
519
|
-
GLOB_VUE
|
|
520
|
-
],
|
|
521
|
-
rules: { "e18e/prefer-static-regex": "off" }
|
|
522
|
-
}]];
|
|
644
|
+
}];
|
|
523
645
|
};
|
|
524
646
|
//#endregion
|
|
525
647
|
//#region src/configs/eslint-comments.ts
|
|
526
|
-
const comments = async (options
|
|
648
|
+
const comments = async (options) => {
|
|
527
649
|
const { overrides } = options;
|
|
528
650
|
const [eslintComments] = await loadPackages(["@eslint-community/eslint-plugin-eslint-comments"]);
|
|
529
651
|
return [{
|
|
530
652
|
name: "moso/eslint-comments",
|
|
531
|
-
files: [
|
|
532
|
-
GLOB_SRC,
|
|
533
|
-
GLOB_ASTRO,
|
|
534
|
-
GLOB_VUE
|
|
535
|
-
],
|
|
536
653
|
plugins: { "@eslint-community/eslint-comments": memoize(eslintComments, "@eslint-community/eslint-comments") },
|
|
537
654
|
rules: {
|
|
538
655
|
...(assert.ok(!Array.isArray(eslintComments.configs?.recommended)), eslintComments.configs?.recommended.rules),
|
|
@@ -544,10 +661,9 @@ const comments = async (options = {}) => {
|
|
|
544
661
|
//#endregion
|
|
545
662
|
//#region src/configs/functional.ts
|
|
546
663
|
const functional = async (options) => {
|
|
547
|
-
const { functionalEnforcement, ignoreNamePattern, mode, overrides,
|
|
664
|
+
const { filesTypeAware, functionalEnforcement, ignoreNamePattern, mode, overrides, stylistic } = options;
|
|
548
665
|
const [functionalPlugin] = await loadPackages(["eslint-plugin-functional"]);
|
|
549
666
|
const stylisticEnabled = stylistic !== false;
|
|
550
|
-
const isTypeAware = typeof projectRoot === "string";
|
|
551
667
|
const commonRules = {
|
|
552
668
|
"functional/functional-parameters": ["error", {
|
|
553
669
|
allowRestParameter: true,
|
|
@@ -620,12 +736,6 @@ const functional = async (options) => {
|
|
|
620
736
|
};
|
|
621
737
|
return [{
|
|
622
738
|
name: "moso/functional",
|
|
623
|
-
files: [
|
|
624
|
-
GLOB_SRC,
|
|
625
|
-
GLOB_ASTRO,
|
|
626
|
-
GLOB_VUE
|
|
627
|
-
],
|
|
628
|
-
plugins: { "functional": memoize(functionalPlugin, "eslint-plugin-functional") },
|
|
629
739
|
settings: { immutability: { overrides: [
|
|
630
740
|
{
|
|
631
741
|
type: "^Readonly<.+>$",
|
|
@@ -640,18 +750,15 @@ const functional = async (options) => {
|
|
|
640
750
|
to: "Immutable"
|
|
641
751
|
}
|
|
642
752
|
] } },
|
|
753
|
+
plugins: { "functional": memoize(functionalPlugin, "eslint-plugin-functional") },
|
|
643
754
|
rules: {
|
|
644
755
|
...(assert.ok(!Array.isArray(functionalPlugin.configs.off)), functionalPlugin.configs.off.rules),
|
|
645
756
|
...functionalEnforcement === "lite" ? liteRules : functionalEnforcement === "strict" ? strictRules : recommendedRules,
|
|
646
757
|
...overrides
|
|
647
758
|
}
|
|
648
|
-
},
|
|
759
|
+
}, {
|
|
649
760
|
name: "moso/functional/disable-type-aware",
|
|
650
|
-
|
|
651
|
-
GLOB_SRC,
|
|
652
|
-
GLOB_ASTRO,
|
|
653
|
-
GLOB_VUE
|
|
654
|
-
],
|
|
761
|
+
ignores: filesTypeAware,
|
|
655
762
|
rules: {
|
|
656
763
|
...(assert.ok(!Array.isArray(functionalPlugin.configs.disableTypeChecked)), functionalPlugin.configs.disableTypeChecked.rules),
|
|
657
764
|
"functional/no-let": ["error", {
|
|
@@ -659,12 +766,12 @@ const functional = async (options) => {
|
|
|
659
766
|
ignoreIdentifierPattern: ignoreNamePattern
|
|
660
767
|
}]
|
|
661
768
|
}
|
|
662
|
-
}]
|
|
769
|
+
}];
|
|
663
770
|
};
|
|
664
771
|
//#endregion
|
|
665
772
|
//#region src/configs/ignores.ts
|
|
666
773
|
const ignores = async (options) => {
|
|
667
|
-
const { gitignore, ignoreTypeScript, userIgnores } = options;
|
|
774
|
+
const { gitignore = true, ignoreTypeScript, userIgnores } = options;
|
|
668
775
|
const [eslintConfigFlatGitIgnore] = await loadPackages(["eslint-config-flat-gitignore"]);
|
|
669
776
|
const mut_configs = [];
|
|
670
777
|
const mut_ignores = userIgnores === false || userIgnores === void 0 ? [...GLOB_EXCLUDE] : typeof userIgnores === "function" ? userIgnores(GLOB_EXCLUDE) : typeof userIgnores === "string" ? [...GLOB_EXCLUDE, userIgnores] : [...GLOB_EXCLUDE, ...userIgnores];
|
|
@@ -683,163 +790,43 @@ const ignores = async (options) => {
|
|
|
683
790
|
return mut_configs;
|
|
684
791
|
};
|
|
685
792
|
//#endregion
|
|
686
|
-
//#region
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
"
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
"
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
".": "./dist/index.mjs",
|
|
719
|
-
"./package.json": "./package.json"
|
|
720
|
-
},
|
|
721
|
-
types: "./dist/index.d.mts",
|
|
722
|
-
files: [
|
|
723
|
-
"./LICENSE",
|
|
724
|
-
"./README.md",
|
|
725
|
-
"./package.json",
|
|
726
|
-
"dist/"
|
|
727
|
-
],
|
|
728
|
-
engines: { "node": "^22.22.3 || >=24" },
|
|
729
|
-
scripts: {
|
|
730
|
-
"build": "bun run typegen && tsdown --clean --dts",
|
|
731
|
-
"build:inspector": "bun run build && bunx @eslint/config-inspector build --config eslint.config.ts --out-dir ./.eslint-config-inspector",
|
|
732
|
-
"dev": "bunx @eslint/config-inspector --config eslint.config.ts",
|
|
733
|
-
"lint": "eslint",
|
|
734
|
-
"prepack": "bun run build",
|
|
735
|
-
"prepare": "bun run simple-git-hooks",
|
|
736
|
-
"release": "bumpp --recursive && bun publish",
|
|
737
|
-
"test": "vitest run",
|
|
738
|
-
"test:update-snapshots": "vitest --update",
|
|
739
|
-
"typecheck": "tsc --noEmit",
|
|
740
|
-
"typegen": "tsx scripts/typegen.ts",
|
|
741
|
-
"watch": "tsdown --watch"
|
|
742
|
-
},
|
|
743
|
-
workspaces: ["src/rules"],
|
|
744
|
-
peerDependencies: {
|
|
745
|
-
"@eslint-react/eslint-plugin": "^5.17.1",
|
|
746
|
-
"@next/eslint-plugin-next": "^16.2.10",
|
|
747
|
-
"astro-eslint-parser": "^3.0.0",
|
|
748
|
-
"eslint": "^10.0.0",
|
|
749
|
-
"eslint-plugin-astro": "^3.0.1",
|
|
750
|
-
"eslint-plugin-erasable-syntax-only": "^0.4.2",
|
|
751
|
-
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
752
|
-
"eslint-plugin-react-hooks": "^7.1.1",
|
|
753
|
-
"eslint-plugin-react-refresh": "^0.5.3",
|
|
754
|
-
"eslint-plugin-react-you-might-not-need-an-effect": "^1.0.1",
|
|
755
|
-
"eslint-plugin-vue": "^10.9.2",
|
|
756
|
-
"eslint-plugin-vuejs-accessibility": "^2.5.0",
|
|
757
|
-
"typescript": "^6.0.0"
|
|
758
|
-
},
|
|
759
|
-
peerDependenciesMeta: {
|
|
760
|
-
"@eslint-react/eslint-plugin": { "optional": true },
|
|
761
|
-
"@next/eslint-plugin-next": { "optional": true },
|
|
762
|
-
"astro-eslint-parser": { "optional": true },
|
|
763
|
-
"eslint-plugin-astro": { "optional": true },
|
|
764
|
-
"eslint-plugin-erasable-syntax-only": { "optional": true },
|
|
765
|
-
"eslint-plugin-jsx-a11y": { "optional": true },
|
|
766
|
-
"eslint-plugin-react-hooks": { "optional": true },
|
|
767
|
-
"eslint-plugin-react-refresh": { "optional": true },
|
|
768
|
-
"eslint-plugin-react-you-might-not-need-an-effect": { "optional": true },
|
|
769
|
-
"eslint-plugin-vue": { "optional": true },
|
|
770
|
-
"eslint-plugin-vuejs-accessibility": { "optional": true },
|
|
771
|
-
"typescript": { "optional": true }
|
|
772
|
-
},
|
|
773
|
-
dependencies: {
|
|
774
|
-
"@antfu/install-pkg": "^1.1.0",
|
|
775
|
-
"@clack/prompts": "^1.7.0",
|
|
776
|
-
"@e18e/eslint-plugin": "^0.5.1",
|
|
777
|
-
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.2",
|
|
778
|
-
"@eslint/js": "^10.0.1",
|
|
779
|
-
"@stylistic/eslint-plugin": "^5.10.0",
|
|
780
|
-
"@typescript-eslint/eslint-plugin": "^8.64.0",
|
|
781
|
-
"@typescript-eslint/parser": "^8.64.0",
|
|
782
|
-
"@typescript-eslint/utils": "^8.64.0",
|
|
783
|
-
"@vitest/eslint-plugin": "^1.6.23",
|
|
784
|
-
"eslint-config-flat-gitignore": "^2.3.0",
|
|
785
|
-
"eslint-flat-config-utils": "^3.2.0",
|
|
786
|
-
"eslint-merge-processors": "^2.0.0",
|
|
787
|
-
"eslint-plugin-de-morgan": "^2.1.3",
|
|
788
|
-
"eslint-plugin-functional": "^10.0.0",
|
|
789
|
-
"eslint-plugin-import-lite": "^0.6.0",
|
|
790
|
-
"eslint-plugin-jsdoc": "^63.0.14",
|
|
791
|
-
"eslint-plugin-jsonc": "^3.3.0",
|
|
792
|
-
"eslint-plugin-n": "^18.2.2",
|
|
793
|
-
"eslint-plugin-no-only-tests": "^3.4.0",
|
|
794
|
-
"eslint-plugin-perfectionist": "^5.10.0",
|
|
795
|
-
"eslint-plugin-promise": "^7.3.0",
|
|
796
|
-
"eslint-plugin-regexp": "^3.1.1",
|
|
797
|
-
"eslint-plugin-toml": "^1.4.0",
|
|
798
|
-
"eslint-plugin-unicorn": "^72.0.0",
|
|
799
|
-
"eslint-plugin-unused-imports": "^4.4.1",
|
|
800
|
-
"eslint-plugin-yml": "^3.6.0",
|
|
801
|
-
"eslint-processor-vue-blocks": "^2.0.0",
|
|
802
|
-
"globals": "^17.7.0",
|
|
803
|
-
"jsonc-eslint-parser": "^3.1.0",
|
|
804
|
-
"local-pkg": "^1.2.1",
|
|
805
|
-
"toml-eslint-parser": "^1.0.3",
|
|
806
|
-
"vue-eslint-parser": "^10.4.1",
|
|
807
|
-
"yaml-eslint-parser": "^2.1.0"
|
|
808
|
-
},
|
|
809
|
-
devDependencies: {
|
|
810
|
-
"@eslint-react/eslint-plugin": "^5.17.1",
|
|
811
|
-
"@eslint/compat": "^2.1.0",
|
|
812
|
-
"@eslint/config-inspector": "^3.1.0",
|
|
813
|
-
"@moso/eslint-plugin": "workspace:*",
|
|
814
|
-
"@next/eslint-plugin-next": "^16.2.10",
|
|
815
|
-
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
816
|
-
"@types/node": "^26.1.1",
|
|
817
|
-
"@typescript-eslint/rule-tester": "^8.64.0",
|
|
818
|
-
"astro-eslint-parser": "^3.0.0",
|
|
819
|
-
"bumpp": "^11.1.0",
|
|
820
|
-
"eslint": "^10.7.0",
|
|
821
|
-
"eslint-plugin-astro": "^3.0.1",
|
|
822
|
-
"eslint-plugin-erasable-syntax-only": "^0.4.2",
|
|
823
|
-
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
824
|
-
"eslint-plugin-react-hooks": "^7.1.1",
|
|
825
|
-
"eslint-plugin-react-refresh": "^0.5.3",
|
|
826
|
-
"eslint-plugin-react-you-might-not-need-an-effect": "^1.0.1",
|
|
827
|
-
"eslint-plugin-vue": "^10.9.2",
|
|
828
|
-
"eslint-plugin-vuejs-accessibility": "^2.5.0",
|
|
829
|
-
"eslint-typegen": "^2.3.1",
|
|
830
|
-
"jiti": "^2.7.0",
|
|
831
|
-
"nano-staged": "^1.0.2",
|
|
832
|
-
"simple-git-hooks": "^2.13.1",
|
|
833
|
-
"ts-dedent": "^2.3.0",
|
|
834
|
-
"tsdown": "^0.22.9",
|
|
835
|
-
"tsx": "^4.23.1",
|
|
836
|
-
"typescript": "^6.0.3",
|
|
837
|
-
"vitest": "^4.1.10"
|
|
838
|
-
},
|
|
839
|
-
"simple-git-hooks": { "pre-commit": "bunx nano-staged" },
|
|
840
|
-
"nano-staged": { "*": "eslint --fix" }
|
|
793
|
+
//#region src/configs/imports.ts
|
|
794
|
+
const imports = async (options) => {
|
|
795
|
+
const { files, overrides, stylistic, typescript } = options;
|
|
796
|
+
const [importLite] = await loadPackages(["eslint-plugin-import-lite"]);
|
|
797
|
+
const stylisticEnabled = stylistic !== false;
|
|
798
|
+
return [{
|
|
799
|
+
name: "moso/imports",
|
|
800
|
+
plugins: { "import-lite": memoize(importLite, "eslint-plugin-import-lite") },
|
|
801
|
+
rules: {
|
|
802
|
+
"@moso/no-import-duplicates": "error",
|
|
803
|
+
"@moso/no-import-from-dist": "error",
|
|
804
|
+
"@moso/no-import-node-modules-by-path": "error",
|
|
805
|
+
"import-lite/consistent-type-specifier-style": "error",
|
|
806
|
+
"import-lite/first": "error",
|
|
807
|
+
"import-lite/no-duplicates": "error",
|
|
808
|
+
"import-lite/no-mutable-exports": "error",
|
|
809
|
+
"import-lite/no-named-default": "error",
|
|
810
|
+
...stylisticEnabled && { "import-lite/newline-after-import": ["error", { considerComments: false }] },
|
|
811
|
+
...overrides
|
|
812
|
+
}
|
|
813
|
+
}, ...typescript ? [{
|
|
814
|
+
name: "moso/imports/typescript",
|
|
815
|
+
files,
|
|
816
|
+
rules: {
|
|
817
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
818
|
+
"@typescript-eslint/consistent-type-imports": [stylisticEnabled ? "error" : "off", {
|
|
819
|
+
disallowTypeAnnotations: false,
|
|
820
|
+
fixStyle: "inline-type-imports",
|
|
821
|
+
prefer: "type-imports"
|
|
822
|
+
}]
|
|
823
|
+
}
|
|
824
|
+
}] : []];
|
|
841
825
|
};
|
|
842
826
|
//#endregion
|
|
827
|
+
//#region package.json
|
|
828
|
+
var version = "3.1.0";
|
|
829
|
+
//#endregion
|
|
843
830
|
//#region src/rules/utils.ts
|
|
844
831
|
/**
|
|
845
832
|
* Typed rule factory for every rule in this plugin.
|
|
@@ -945,8 +932,8 @@ const getValue = (token) => {
|
|
|
945
932
|
case AST_TOKEN_TYPES.RegularExpression: return token.regex.pattern;
|
|
946
933
|
case AST_TOKEN_TYPES.String:
|
|
947
934
|
case AST_TOKEN_TYPES.Template: return token.value.slice(1, -1);
|
|
935
|
+
default: return false;
|
|
948
936
|
}
|
|
949
|
-
return false;
|
|
950
937
|
};
|
|
951
938
|
const functionLikeTypes = /* @__PURE__ */ new Set([
|
|
952
939
|
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
@@ -1233,7 +1220,7 @@ const ruleNoImportNodeModulesByPath = createRule({
|
|
|
1233
1220
|
//#endregion
|
|
1234
1221
|
//#region src/rules/no-invisible-characters/no-invisible-characters.ts
|
|
1235
1222
|
const combinePattern = (...patterns) => {
|
|
1236
|
-
const source = patterns.map((pattern) =>
|
|
1223
|
+
const source = patterns.map((pattern) => pattern.source).join("");
|
|
1237
1224
|
return new RegExp(`[${source}]`, "u");
|
|
1238
1225
|
};
|
|
1239
1226
|
const INVISIBLE_PATTERN = combinePattern(/\u{AD}\u{34F}\u{61C}\u{17B4}\u{17B5}\u{FEFF}\u{FFFC}/u, /\u{180B}-\u{180E}/u, /\u{200B}-\u{200F}/u, /\u{202A}-\u{202E}/u, /\u{2060}-\u{206F}/u, /\u{FE00}-\u{FE0F}/u, /\u{FFF0}-\u{FFF8}/u, /\u{1D173}-\u{1D17A}/u, /\u{E0000}-\u{E007F}/u, /\u{E0100}-\u{E01EF}/u);
|
|
@@ -1291,15 +1278,19 @@ const ruleNoRedundantVariables = createRule({
|
|
|
1291
1278
|
messages: { noRedundantVar: "Disallow redundant variables." }
|
|
1292
1279
|
},
|
|
1293
1280
|
create: (context) => ({ BlockStatement: ({ body }) => {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1281
|
+
let mut_previous;
|
|
1282
|
+
for (const statement of body) {
|
|
1283
|
+
if (!isReturnStatement(statement)) {
|
|
1284
|
+
mut_previous = statement;
|
|
1285
|
+
continue;
|
|
1286
|
+
}
|
|
1287
|
+
if (isRedundantVariable(mut_previous, statement)) context.report({
|
|
1288
|
+
node: statement,
|
|
1289
|
+
messageId: "noRedundantVar",
|
|
1290
|
+
fix: isRedundantVariableFixer(context.sourceCode, mut_previous, statement)
|
|
1291
|
+
});
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1303
1294
|
} })
|
|
1304
1295
|
});
|
|
1305
1296
|
//#endregion
|
|
@@ -1534,11 +1525,212 @@ const rulePreferReduceOverChaining = createRule({
|
|
|
1534
1525
|
} })
|
|
1535
1526
|
});
|
|
1536
1527
|
//#endregion
|
|
1528
|
+
//#region src/rules/prefer-strict-number-guards/prefer-strict-number-guards.ts
|
|
1529
|
+
const allGuards = [
|
|
1530
|
+
"check-parse-result",
|
|
1531
|
+
"encode-input-rule",
|
|
1532
|
+
"guard-array-index",
|
|
1533
|
+
"guard-derived-value",
|
|
1534
|
+
"use-direct-operands",
|
|
1535
|
+
"write-explicit-condition"
|
|
1536
|
+
];
|
|
1537
|
+
const defaultGuards = [
|
|
1538
|
+
"check-parse-result",
|
|
1539
|
+
"guard-derived-value",
|
|
1540
|
+
"use-direct-operands",
|
|
1541
|
+
"write-explicit-condition"
|
|
1542
|
+
];
|
|
1543
|
+
const arithmeticOperators = /* @__PURE__ */ new Set([
|
|
1544
|
+
"%",
|
|
1545
|
+
"*",
|
|
1546
|
+
"**",
|
|
1547
|
+
"+",
|
|
1548
|
+
"-",
|
|
1549
|
+
"/"
|
|
1550
|
+
]);
|
|
1551
|
+
const parseFunctions = [
|
|
1552
|
+
"Number",
|
|
1553
|
+
"parseFloat",
|
|
1554
|
+
"parseInt"
|
|
1555
|
+
];
|
|
1556
|
+
const indexNamePattern = /^(?:[ijk]|idx|index)$/iu;
|
|
1557
|
+
const indexSuffixPattern = /(?:Idx|Index)$/u;
|
|
1558
|
+
const isConsoleAssert = (statement) => {
|
|
1559
|
+
if (statement.type !== AST_NODE_TYPES.ExpressionStatement) return false;
|
|
1560
|
+
if (statement.expression.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
1561
|
+
const { callee } = statement.expression;
|
|
1562
|
+
return callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && isIdentifierName(callee.object, "console") && isIdentifierName(callee.property, "assert");
|
|
1563
|
+
};
|
|
1564
|
+
const isConsumedDirectly = (node) => {
|
|
1565
|
+
const { parent } = node;
|
|
1566
|
+
if (parent.type === AST_NODE_TYPES.BinaryExpression) return arithmeticOperators.has(parent.operator);
|
|
1567
|
+
return parent.type === AST_NODE_TYPES.MemberExpression && parent.computed && parent.property === node;
|
|
1568
|
+
};
|
|
1569
|
+
const isGuardedIndex = (node) => {
|
|
1570
|
+
const { parent } = node;
|
|
1571
|
+
if (parent.type === AST_NODE_TYPES.TSNonNullExpression) return true;
|
|
1572
|
+
return parent.type === AST_NODE_TYPES.LogicalExpression && parent.operator === "??" && parent.left === node;
|
|
1573
|
+
};
|
|
1574
|
+
const isMathCall = (node, methods) => {
|
|
1575
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
1576
|
+
const { callee } = node;
|
|
1577
|
+
return callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && isIdentifierName(callee.object, "Math") && (methods === void 0 || isIdentifierName(callee.property, methods));
|
|
1578
|
+
};
|
|
1579
|
+
const isWriteTarget = (node) => {
|
|
1580
|
+
const { parent } = node;
|
|
1581
|
+
if (parent.type === AST_NODE_TYPES.AssignmentExpression) return parent.left === node;
|
|
1582
|
+
if (parent.type === AST_NODE_TYPES.UpdateExpression) return true;
|
|
1583
|
+
return parent.type === AST_NODE_TYPES.UnaryExpression && parent.operator === "delete";
|
|
1584
|
+
};
|
|
1585
|
+
const assertedNames = (node, sourceCode) => {
|
|
1586
|
+
if (node.body.type !== AST_NODE_TYPES.BlockStatement) return /* @__PURE__ */ new Set();
|
|
1587
|
+
const mut_names = /* @__PURE__ */ new Set();
|
|
1588
|
+
for (const statement of node.body.body) {
|
|
1589
|
+
if (!isConsoleAssert(statement)) break;
|
|
1590
|
+
for (const token of sourceCode.getTokens(statement)) if (token.type === AST_TOKEN_TYPES.Identifier) mut_names.add(token.value);
|
|
1591
|
+
}
|
|
1592
|
+
return mut_names;
|
|
1593
|
+
};
|
|
1594
|
+
const looksLikeIndex = (node) => {
|
|
1595
|
+
if (node.type === AST_NODE_TYPES.BinaryExpression) return arithmeticOperators.has(node.operator);
|
|
1596
|
+
if (node.type === AST_NODE_TYPES.CallExpression) return isMathCall(node);
|
|
1597
|
+
return isIdentifierName(node, (name) => indexNamePattern.test(name) || indexSuffixPattern.test(name));
|
|
1598
|
+
};
|
|
1599
|
+
const numberParameterNames = (node) => {
|
|
1600
|
+
const mut_names = /* @__PURE__ */ new Set();
|
|
1601
|
+
for (const parameter of node.params) {
|
|
1602
|
+
if (parameter.type !== AST_NODE_TYPES.Identifier) continue;
|
|
1603
|
+
if (parameter.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES.TSNumberKeyword) continue;
|
|
1604
|
+
mut_names.add(parameter.name);
|
|
1605
|
+
}
|
|
1606
|
+
return mut_names;
|
|
1607
|
+
};
|
|
1608
|
+
const rulePreferStrictNumberGuards = createRule({
|
|
1609
|
+
name: "prefer-strict-number-guards",
|
|
1610
|
+
meta: {
|
|
1611
|
+
type: "problem",
|
|
1612
|
+
docs: {
|
|
1613
|
+
description: "Enforce the syntactic patterns that keep numeric code analyzable.",
|
|
1614
|
+
recommended: "stylistic",
|
|
1615
|
+
url: "https://github.com/chenglou/freerange"
|
|
1616
|
+
},
|
|
1617
|
+
schema: [{
|
|
1618
|
+
type: "object",
|
|
1619
|
+
description: "Which of the Freerange authoring rules to enforce.",
|
|
1620
|
+
properties: { guards: {
|
|
1621
|
+
type: "array",
|
|
1622
|
+
description: "The audit codes to enforce. The heuristic `encode-input-rule` and `guard-array-index` are off by default.",
|
|
1623
|
+
items: {
|
|
1624
|
+
type: "string",
|
|
1625
|
+
enum: [...allGuards]
|
|
1626
|
+
},
|
|
1627
|
+
uniqueItems: true,
|
|
1628
|
+
default: [...defaultGuards]
|
|
1629
|
+
} },
|
|
1630
|
+
additionalProperties: false
|
|
1631
|
+
}],
|
|
1632
|
+
messages: {
|
|
1633
|
+
checkParseResult: "This can produce `NaN` or `±Infinity`. Check the result with `Number.isFinite` or `Number.isNaN` before using it.",
|
|
1634
|
+
encodeInputRule: "The `number` parameter `{{name}}` is used as a divisor or an index without stating its rule. Open the function with `console.assert({{name}} >= 1)`, or normalise it at the use site with `Math.max`/`Math.floor`.",
|
|
1635
|
+
guardArrayIndex: "Indexing with a computed value can yield `undefined`. Default it with `?? fallback`, or assert it with `!` once the index is known to be in range.",
|
|
1636
|
+
guardDerivedValue: "Dividing by a calculation hides whether that calculation can be zero. Name it in a `const`, check that name for zero, then divide.",
|
|
1637
|
+
useDirectOperands: "A nested division introduces a ratio that can round to zero. Use the direct operands instead - `a / (b / c)` is `(a * c) / b`.",
|
|
1638
|
+
writeExplicitCondition: "`0` is falsy, so a `||` fallback silently replaces a legitimate zero. Write `value === 0 ? fallback : value` instead."
|
|
1639
|
+
}
|
|
1640
|
+
},
|
|
1641
|
+
defaultOptions: [{ guards: [...defaultGuards] }],
|
|
1642
|
+
create: (context, [{ guards }]) => {
|
|
1643
|
+
const enabled = new Set(guards);
|
|
1644
|
+
const mut_scopes = [];
|
|
1645
|
+
const enterFunction = (node) => {
|
|
1646
|
+
mut_scopes.push({
|
|
1647
|
+
asserted: assertedNames(node, context.sourceCode),
|
|
1648
|
+
numberParams: numberParameterNames(node)
|
|
1649
|
+
});
|
|
1650
|
+
};
|
|
1651
|
+
const exitFunction = () => mut_scopes.pop();
|
|
1652
|
+
const reportUnencodedInput = (node) => {
|
|
1653
|
+
if (!enabled.has("encode-input-rule")) return;
|
|
1654
|
+
if (node.type !== AST_NODE_TYPES.Identifier) return;
|
|
1655
|
+
const scope = mut_scopes.at(-1);
|
|
1656
|
+
if (!scope) return;
|
|
1657
|
+
if (!scope.numberParams.has(node.name)) return;
|
|
1658
|
+
if (scope.asserted.has(node.name)) return;
|
|
1659
|
+
context.report({
|
|
1660
|
+
node,
|
|
1661
|
+
messageId: "encodeInputRule",
|
|
1662
|
+
data: { name: node.name }
|
|
1663
|
+
});
|
|
1664
|
+
};
|
|
1665
|
+
return {
|
|
1666
|
+
"ArrowFunctionExpression": enterFunction,
|
|
1667
|
+
"ArrowFunctionExpression:exit": exitFunction,
|
|
1668
|
+
"BinaryExpression": (node) => {
|
|
1669
|
+
if (node.operator !== "/" && node.operator !== "%") return;
|
|
1670
|
+
const divisor = node.right;
|
|
1671
|
+
if (divisor.type === AST_NODE_TYPES.BinaryExpression && arithmeticOperators.has(divisor.operator)) {
|
|
1672
|
+
const nested = divisor.operator === "/";
|
|
1673
|
+
const guard = nested ? "use-direct-operands" : "guard-derived-value";
|
|
1674
|
+
if (!enabled.has(guard)) return;
|
|
1675
|
+
context.report({
|
|
1676
|
+
node: divisor,
|
|
1677
|
+
messageId: nested ? "useDirectOperands" : "guardDerivedValue"
|
|
1678
|
+
});
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
reportUnencodedInput(divisor);
|
|
1682
|
+
},
|
|
1683
|
+
"CallExpression": (node) => {
|
|
1684
|
+
if (!enabled.has("check-parse-result")) return;
|
|
1685
|
+
if (isIdentifierName(node.callee, parseFunctions) && isConsumedDirectly(node)) {
|
|
1686
|
+
context.report({
|
|
1687
|
+
node,
|
|
1688
|
+
messageId: "checkParseResult"
|
|
1689
|
+
});
|
|
1690
|
+
return;
|
|
1691
|
+
}
|
|
1692
|
+
if (!isMathCall(node, ["max", "min"])) return;
|
|
1693
|
+
if (!(node.arguments.length === 0 || node.arguments.some((argument) => argument.type === AST_NODE_TYPES.SpreadElement))) return;
|
|
1694
|
+
context.report({
|
|
1695
|
+
node,
|
|
1696
|
+
messageId: "checkParseResult"
|
|
1697
|
+
});
|
|
1698
|
+
},
|
|
1699
|
+
"FunctionDeclaration": enterFunction,
|
|
1700
|
+
"FunctionDeclaration:exit": exitFunction,
|
|
1701
|
+
"FunctionExpression": enterFunction,
|
|
1702
|
+
"FunctionExpression:exit": exitFunction,
|
|
1703
|
+
"LogicalExpression": (node) => {
|
|
1704
|
+
if (!enabled.has("write-explicit-condition")) return;
|
|
1705
|
+
if (node.operator !== "||") return;
|
|
1706
|
+
if (node.right.type !== AST_NODE_TYPES.Literal) return;
|
|
1707
|
+
if (typeof node.right.value !== "number") return;
|
|
1708
|
+
context.report({
|
|
1709
|
+
node,
|
|
1710
|
+
messageId: "writeExplicitCondition"
|
|
1711
|
+
});
|
|
1712
|
+
},
|
|
1713
|
+
"MemberExpression": (node) => {
|
|
1714
|
+
if (!node.computed) return;
|
|
1715
|
+
if (node.property.type === AST_NODE_TYPES.Literal) return;
|
|
1716
|
+
reportUnencodedInput(node.property);
|
|
1717
|
+
if (!enabled.has("guard-array-index")) return;
|
|
1718
|
+
if (!looksLikeIndex(node.property)) return;
|
|
1719
|
+
if (isGuardedIndex(node) || isWriteTarget(node)) return;
|
|
1720
|
+
context.report({
|
|
1721
|
+
node,
|
|
1722
|
+
messageId: "guardArrayIndex"
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
//#endregion
|
|
1537
1729
|
//#region src/rules/index.ts
|
|
1538
1730
|
const plugin = {
|
|
1539
1731
|
meta: {
|
|
1540
1732
|
name: "@moso/eslint-plugin",
|
|
1541
|
-
version
|
|
1733
|
+
version
|
|
1542
1734
|
},
|
|
1543
1735
|
rules: {
|
|
1544
1736
|
"avoid-barrel-files": ruleAvoidBarrelFiles,
|
|
@@ -1554,7 +1746,8 @@ const plugin = {
|
|
|
1554
1746
|
"no-unneeded-array-flat-map": ruleNoUnneededArrayFlatMap,
|
|
1555
1747
|
"prefer-early-return": rulePreferEarlyReturns,
|
|
1556
1748
|
"prefer-fetch": rulePreferFetch,
|
|
1557
|
-
"prefer-reduce-over-chaining": rulePreferReduceOverChaining
|
|
1749
|
+
"prefer-reduce-over-chaining": rulePreferReduceOverChaining,
|
|
1750
|
+
"prefer-strict-number-guards": rulePreferStrictNumberGuards
|
|
1558
1751
|
}
|
|
1559
1752
|
};
|
|
1560
1753
|
const configs = { recommended: {
|
|
@@ -1576,47 +1769,6 @@ var rules_default = {
|
|
|
1576
1769
|
configs
|
|
1577
1770
|
};
|
|
1578
1771
|
//#endregion
|
|
1579
|
-
//#region src/configs/imports.ts
|
|
1580
|
-
const imports = async (options) => {
|
|
1581
|
-
const { overrides, stylistic, typescript } = options;
|
|
1582
|
-
const [importLite] = await loadPackages(["eslint-plugin-import-lite"]);
|
|
1583
|
-
const stylisticEnabled = stylistic !== false;
|
|
1584
|
-
return [{
|
|
1585
|
-
name: "moso/imports",
|
|
1586
|
-
plugins: {
|
|
1587
|
-
"@moso": memoize(rules_default, "@moso/eslint-plugin"),
|
|
1588
|
-
"import-lite": memoize(importLite, "eslint-plugin-import-lite")
|
|
1589
|
-
},
|
|
1590
|
-
rules: {
|
|
1591
|
-
"@moso/no-import-duplicates": "error",
|
|
1592
|
-
"@moso/no-import-from-dist": "error",
|
|
1593
|
-
"@moso/no-import-node-modules-by-path": "error",
|
|
1594
|
-
"import-lite/consistent-type-specifier-style": "error",
|
|
1595
|
-
"import-lite/first": "error",
|
|
1596
|
-
"import-lite/no-duplicates": "error",
|
|
1597
|
-
"import-lite/no-mutable-exports": "error",
|
|
1598
|
-
"import-lite/no-named-default": "error",
|
|
1599
|
-
...stylisticEnabled && { "import-lite/newline-after-import": ["error", { considerComments: false }] },
|
|
1600
|
-
...overrides
|
|
1601
|
-
}
|
|
1602
|
-
}, ...typescript ? [{
|
|
1603
|
-
name: "moso/imports/typescript",
|
|
1604
|
-
files: [
|
|
1605
|
-
GLOB_DTS,
|
|
1606
|
-
GLOB_TS,
|
|
1607
|
-
GLOB_TSX
|
|
1608
|
-
],
|
|
1609
|
-
rules: {
|
|
1610
|
-
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
1611
|
-
"@typescript-eslint/consistent-type-imports": [stylisticEnabled ? "error" : "off", {
|
|
1612
|
-
disallowTypeAnnotations: false,
|
|
1613
|
-
fixStyle: "inline-type-imports",
|
|
1614
|
-
prefer: "type-imports"
|
|
1615
|
-
}]
|
|
1616
|
-
}
|
|
1617
|
-
}] : []];
|
|
1618
|
-
};
|
|
1619
|
-
//#endregion
|
|
1620
1772
|
//#region src/configs/javascript.ts
|
|
1621
1773
|
const useNumberIsFinite = "Please use `Number.isFinite` instead.";
|
|
1622
1774
|
const useNumberIsNan = "Please use `Number.isNaN` instead.";
|
|
@@ -1648,10 +1800,7 @@ const javascript = async (options) => {
|
|
|
1648
1800
|
sourceType: "module"
|
|
1649
1801
|
},
|
|
1650
1802
|
linterOptions: { reportUnusedDisableDirectives: true },
|
|
1651
|
-
plugins: {
|
|
1652
|
-
"@eslint/js": memoize(eslintJs, "@eslint/js"),
|
|
1653
|
-
"unused-imports": memoize(unusedImportsPlugin, "eslint-plugin-unused-imports")
|
|
1654
|
-
},
|
|
1803
|
+
plugins: { "unused-imports": memoize(unusedImportsPlugin, "eslint-plugin-unused-imports") },
|
|
1655
1804
|
rules: {
|
|
1656
1805
|
...(assert.ok(!Array.isArray(eslintJs.configs.recommended)), eslintJs.configs.recommended.rules),
|
|
1657
1806
|
"array-callback-return": ["error", { allowImplicit: true }],
|
|
@@ -1809,16 +1958,12 @@ const javascript = async (options) => {
|
|
|
1809
1958
|
message: "Labeled statements are not allowed.",
|
|
1810
1959
|
selector: "LabeledStatement"
|
|
1811
1960
|
},
|
|
1812
|
-
{
|
|
1813
|
-
message: "Const enums are forbidden to increase interoperability. Use regular enums instead.",
|
|
1814
|
-
selector: "TSEnumDeclaration[const=true]"
|
|
1815
|
-
},
|
|
1816
1961
|
{
|
|
1817
1962
|
message: "TypeScript's own parser uses `ExportAssignment` for both `export default` and `export =`.",
|
|
1818
1963
|
selector: "TSExportAssignment"
|
|
1819
1964
|
},
|
|
1820
1965
|
{
|
|
1821
|
-
message: "`with` is disallowed in strict mode because it makes code
|
|
1966
|
+
message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
|
1822
1967
|
selector: "WithStatement"
|
|
1823
1968
|
}
|
|
1824
1969
|
],
|
|
@@ -1934,6 +2079,7 @@ const javascript = async (options) => {
|
|
|
1934
2079
|
"@moso/prefer-early-return": ["error", { maximumStatements: 1 }],
|
|
1935
2080
|
"@moso/prefer-fetch": "error",
|
|
1936
2081
|
"@moso/prefer-reduce-over-chaining": "error",
|
|
2082
|
+
"@moso/prefer-strict-number-guards": "error",
|
|
1937
2083
|
"de-morgan/no-negated-conjunction": "error",
|
|
1938
2084
|
"de-morgan/no-negated-disjunction": "error"
|
|
1939
2085
|
}
|
|
@@ -1942,12 +2088,15 @@ const javascript = async (options) => {
|
|
|
1942
2088
|
//#endregion
|
|
1943
2089
|
//#region src/configs/jsdoc.ts
|
|
1944
2090
|
const jsdoc = async (options) => {
|
|
1945
|
-
const { lessOpinionated, overrides, stylistic } = options;
|
|
2091
|
+
const { files, lessOpinionated, overrides, stylistic } = options;
|
|
1946
2092
|
const [jsdocPlugin] = await loadPackages(["eslint-plugin-jsdoc"]);
|
|
1947
2093
|
const stylisticEnabled = stylistic === false ? "off" : "error";
|
|
1948
2094
|
return [{
|
|
1949
|
-
name: "moso/jsdoc",
|
|
1950
|
-
plugins: { "jsdoc": memoize(jsdocPlugin, "eslint-plugin-jsdoc") }
|
|
2095
|
+
name: "moso/jsdoc/setup",
|
|
2096
|
+
plugins: { "jsdoc": memoize(jsdocPlugin, "eslint-plugin-jsdoc") }
|
|
2097
|
+
}, {
|
|
2098
|
+
name: "moso/jsdoc/rules",
|
|
2099
|
+
files,
|
|
1951
2100
|
rules: {
|
|
1952
2101
|
"jsdoc/check-access": "warn",
|
|
1953
2102
|
"jsdoc/check-alignment": stylisticEnabled,
|
|
@@ -2029,9 +2178,11 @@ const jsonc = async (options) => {
|
|
|
2029
2178
|
const [jsoncPlugin, jsoncParser] = await loadPackages(["eslint-plugin-jsonc", "jsonc-eslint-parser"]);
|
|
2030
2179
|
const stylisticEnabled = stylistic === false ? "off" : "error";
|
|
2031
2180
|
return [{
|
|
2032
|
-
name: "moso/jsonc",
|
|
2181
|
+
name: "moso/jsonc/setup",
|
|
2182
|
+
plugins: { "jsonc": memoize(jsoncPlugin, "eslint-plugin-jsonc") }
|
|
2183
|
+
}, {
|
|
2184
|
+
name: "moso/jsonc/rules",
|
|
2033
2185
|
files,
|
|
2034
|
-
plugins: { "jsonc": memoize(jsoncPlugin, "eslint-plugin-jsonc") },
|
|
2035
2186
|
languageOptions: { parser: memoize(jsoncParser, "jsonc-eslint-parser") },
|
|
2036
2187
|
rules: {
|
|
2037
2188
|
"jsonc/no-bigint-literals": "error",
|
|
@@ -2085,33 +2236,25 @@ const jsonc = async (options) => {
|
|
|
2085
2236
|
const jsx = async (options) => {
|
|
2086
2237
|
const { a11y, files, lessOpinionated, overrides, overridesA11y, stylistic } = options;
|
|
2087
2238
|
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
"
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
...overrides
|
|
2108
|
-
}
|
|
2109
|
-
},
|
|
2110
|
-
...jsxA11yPlugin ? [{
|
|
2111
|
-
name: "moso/jsx/a11y",
|
|
2112
|
-
files,
|
|
2113
|
-
plugins: { "jsx-a11y": memoize(jsxA11yPlugin, "eslint-plugin-jsx-a11y") },
|
|
2114
|
-
rules: {
|
|
2239
|
+
const stylisticEnabled = stylistic !== false;
|
|
2240
|
+
return [{
|
|
2241
|
+
name: "moso/jsx/setup",
|
|
2242
|
+
plugins: { ...jsxA11yPlugin && { "jsx-a11y": memoize(jsxA11yPlugin, "eslint-plugin-jsx-a11y") } }
|
|
2243
|
+
}, {
|
|
2244
|
+
name: "moso/jsx/rules",
|
|
2245
|
+
files,
|
|
2246
|
+
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
2247
|
+
rules: {
|
|
2248
|
+
...stylisticEnabled && {
|
|
2249
|
+
"@stylistic/jsx-curly-spacing": ["error", {
|
|
2250
|
+
"when": "always",
|
|
2251
|
+
"allowMultiline": false,
|
|
2252
|
+
"children": false,
|
|
2253
|
+
"spacing": { "objectLiterals": "never" }
|
|
2254
|
+
}],
|
|
2255
|
+
"@stylistic/jsx-one-expression-per-line": "off"
|
|
2256
|
+
},
|
|
2257
|
+
...jsxA11yPlugin && {
|
|
2115
2258
|
...lessOpinionated ? { ...(assert.ok(!Array.isArray(jsxA11yPlugin.flatConfigs.recommended)), jsxA11yPlugin.flatConfigs.recommended.rules) } : {
|
|
2116
2259
|
"jsx-a11y/alt-text": ["warn", {
|
|
2117
2260
|
elements: ["img"],
|
|
@@ -2147,43 +2290,38 @@ const jsx = async (options) => {
|
|
|
2147
2290
|
}]
|
|
2148
2291
|
},
|
|
2149
2292
|
...overridesA11y
|
|
2150
|
-
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2293
|
+
},
|
|
2294
|
+
...overrides
|
|
2295
|
+
}
|
|
2296
|
+
}];
|
|
2153
2297
|
};
|
|
2154
2298
|
//#endregion
|
|
2155
2299
|
//#region src/configs/nextjs.ts
|
|
2156
2300
|
const nextjs = async (options) => {
|
|
2157
2301
|
const { files, mode, overrides } = options;
|
|
2158
2302
|
const [nextjsPlugin] = await loadPackages(["@next/eslint-plugin-next"]);
|
|
2159
|
-
return [
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
},
|
|
2169
|
-
{
|
|
2170
|
-
name: "moso/nextjs/rules",
|
|
2171
|
-
files,
|
|
2172
|
-
rules: {
|
|
2173
|
-
...(assert.ok(!Array.isArray(nextjsPlugin.configs.recommended)), nextjsPlugin.configs.recommended.rules),
|
|
2174
|
-
...(assert.ok(!Array.isArray(nextjsPlugin.configs["core-web-vitals"])), nextjsPlugin.configs["core-web-vitals"].rules),
|
|
2175
|
-
...overrides
|
|
2176
|
-
}
|
|
2303
|
+
return [{
|
|
2304
|
+
name: "moso/nextjs/setup",
|
|
2305
|
+
plugins: { "@next/next": memoize(nextjsPlugin, "@next/eslint-plugin-next") }
|
|
2306
|
+
}, {
|
|
2307
|
+
name: "moso/nextjs/rules",
|
|
2308
|
+
files,
|
|
2309
|
+
languageOptions: {
|
|
2310
|
+
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
2311
|
+
sourceType: "module"
|
|
2177
2312
|
},
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
rules
|
|
2181
|
-
|
|
2182
|
-
|
|
2313
|
+
settings: { react: { version: "detect" } },
|
|
2314
|
+
rules: {
|
|
2315
|
+
...(assert.ok(!Array.isArray(nextjsPlugin.configs.recommended)), nextjsPlugin.configs.recommended.rules),
|
|
2316
|
+
...(assert.ok(!Array.isArray(nextjsPlugin.configs["core-web-vitals"])), nextjsPlugin.configs["core-web-vitals"].rules),
|
|
2317
|
+
...mode === "library" && { "@next/next/no-html-link-for-pages": "off" },
|
|
2318
|
+
...overrides
|
|
2319
|
+
}
|
|
2320
|
+
}];
|
|
2183
2321
|
};
|
|
2184
2322
|
//#endregion
|
|
2185
2323
|
//#region src/configs/node.ts
|
|
2186
|
-
const
|
|
2324
|
+
const npmx = (packageName) => `https://npmx.dev/package/${packageName}`;
|
|
2187
2325
|
const restricedImports = [
|
|
2188
2326
|
{
|
|
2189
2327
|
name: "assert",
|
|
@@ -2195,11 +2333,11 @@ const restricedImports = [
|
|
|
2195
2333
|
},
|
|
2196
2334
|
{
|
|
2197
2335
|
name: "axios",
|
|
2198
|
-
message:
|
|
2336
|
+
message: npmx("ky")
|
|
2199
2337
|
},
|
|
2200
2338
|
{
|
|
2201
2339
|
name: "clone-deep",
|
|
2202
|
-
message: `${
|
|
2340
|
+
message: `${npmx("rfdc")} for Node.js / ${npmx("klona")} for Browser.`
|
|
2203
2341
|
},
|
|
2204
2342
|
{
|
|
2205
2343
|
name: "date-fns",
|
|
@@ -2211,15 +2349,15 @@ const restricedImports = [
|
|
|
2211
2349
|
},
|
|
2212
2350
|
{
|
|
2213
2351
|
name: "dayjs",
|
|
2214
|
-
message:
|
|
2352
|
+
message: npmx("date-fns")
|
|
2215
2353
|
},
|
|
2216
2354
|
{
|
|
2217
2355
|
name: "deep-copy",
|
|
2218
|
-
message: `${
|
|
2356
|
+
message: `${npmx("rfdc")} for Node.js / ${npmx("klona")} for Browser.`
|
|
2219
2357
|
},
|
|
2220
2358
|
{
|
|
2221
2359
|
name: "fast-copy",
|
|
2222
|
-
message: `${
|
|
2360
|
+
message: `${npmx("rfdc")} for Node.js / ${npmx("klona")} for Browser.`
|
|
2223
2361
|
},
|
|
2224
2362
|
{
|
|
2225
2363
|
name: "idb/with-async-ittr-cjs",
|
|
@@ -2231,7 +2369,7 @@ const restricedImports = [
|
|
|
2231
2369
|
},
|
|
2232
2370
|
{
|
|
2233
2371
|
name: "lodash.clonedeep",
|
|
2234
|
-
message: `${
|
|
2372
|
+
message: `${npmx("rfdc")} for Node.js / ${npmx("klona")} for Browser.`
|
|
2235
2373
|
},
|
|
2236
2374
|
{
|
|
2237
2375
|
name: "lodash-unified",
|
|
@@ -2243,7 +2381,7 @@ const restricedImports = [
|
|
|
2243
2381
|
},
|
|
2244
2382
|
{
|
|
2245
2383
|
name: "node-fetch",
|
|
2246
|
-
message: `${
|
|
2384
|
+
message: `${npmx("undici")} (preferred) or ${npmx("node-fetch-native")}.`
|
|
2247
2385
|
},
|
|
2248
2386
|
{
|
|
2249
2387
|
name: "react-fast-compare",
|
|
@@ -2255,15 +2393,19 @@ const restricedImports = [
|
|
|
2255
2393
|
}
|
|
2256
2394
|
];
|
|
2257
2395
|
const renameNodeRules = (rules, from, to) => Object.fromEntries(Object.entries(rules).map(([key, value]) => [key.startsWith(`${from}/`) ? `${to}/${key.slice(from.length + 1)}` : key, value]));
|
|
2258
|
-
const node = async (options
|
|
2259
|
-
const { lessOpinionated, overrides } = options;
|
|
2396
|
+
const node = async (options) => {
|
|
2397
|
+
const { files, lessOpinionated, overrides } = options;
|
|
2260
2398
|
const [nodePlugin] = await loadPackages(["eslint-plugin-n"]);
|
|
2261
2399
|
return [
|
|
2262
2400
|
{
|
|
2263
|
-
name: "moso/node",
|
|
2264
|
-
plugins: { "node": memoize(nodePlugin, "eslint-plugin-n") }
|
|
2401
|
+
name: "moso/node/setup",
|
|
2402
|
+
plugins: { "node": memoize(nodePlugin, "eslint-plugin-n") }
|
|
2403
|
+
},
|
|
2404
|
+
{
|
|
2405
|
+
name: "moso/node/rules",
|
|
2406
|
+
files,
|
|
2265
2407
|
languageOptions: { globals: { ...globals.node } },
|
|
2266
|
-
settings: { node: { version: "^22.22.
|
|
2408
|
+
settings: { node: { version: "^22.22.3 || >=24" } },
|
|
2267
2409
|
rules: {
|
|
2268
2410
|
...(assert.ok(!Array.isArray(nodePlugin.configs["flat/recommended"])), renameNodeRules(nodePlugin.configs["flat/recommended"].rules ?? {}, "n", "node")),
|
|
2269
2411
|
"node/no-unpublished-import": "warn",
|
|
@@ -2303,33 +2445,9 @@ const node = async (options = {}) => {
|
|
|
2303
2445
|
},
|
|
2304
2446
|
...options.strict ? [{
|
|
2305
2447
|
name: "moso/node/strict",
|
|
2306
|
-
files:
|
|
2448
|
+
files: files ?? (options.module ? ["**/*.cjs"] : ["**/*.cjs", "**/*.?([cm])js"]),
|
|
2307
2449
|
rules: { strict: ["warn", "global"] }
|
|
2308
|
-
}] : []
|
|
2309
|
-
{
|
|
2310
|
-
files: [
|
|
2311
|
-
GLOB_DTS,
|
|
2312
|
-
GLOB_MJS,
|
|
2313
|
-
GLOB_TS,
|
|
2314
|
-
GLOB_TSX
|
|
2315
|
-
],
|
|
2316
|
-
rules: { "node/no-unsupported-features/es-syntax": "off" }
|
|
2317
|
-
},
|
|
2318
|
-
{
|
|
2319
|
-
files: [
|
|
2320
|
-
GLOB_ASTRO,
|
|
2321
|
-
GLOB_DTS,
|
|
2322
|
-
GLOB_JSX,
|
|
2323
|
-
GLOB_TS,
|
|
2324
|
-
GLOB_TSX,
|
|
2325
|
-
GLOB_VUE
|
|
2326
|
-
],
|
|
2327
|
-
rules: {
|
|
2328
|
-
"node/no-extraneous-import": "off",
|
|
2329
|
-
"node/no-missing-import": "off",
|
|
2330
|
-
"node/no-restricted-import": "off"
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2450
|
+
}] : []
|
|
2333
2451
|
];
|
|
2334
2452
|
};
|
|
2335
2453
|
//#endregion
|
|
@@ -2344,228 +2462,183 @@ const commonOptions = {
|
|
|
2344
2462
|
order: "asc",
|
|
2345
2463
|
specialCharacters: "keep",
|
|
2346
2464
|
type: "natural"
|
|
2347
|
-
};
|
|
2348
|
-
const perfectionist = async (options) => {
|
|
2349
|
-
const {
|
|
2350
|
-
const [perfectionistPlugin] = await loadPackages(["eslint-plugin-perfectionist"]);
|
|
2351
|
-
return [{
|
|
2352
|
-
name: "moso/perfectionist",
|
|
2353
|
-
plugins: { "perfectionist": memoize(perfectionistPlugin, "eslint-plugin-perfectionist") },
|
|
2354
|
-
rules: {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
fallbackSort: {
|
|
2359
|
-
order: "asc",
|
|
2360
|
-
type: "natural"
|
|
2361
|
-
},
|
|
2362
|
-
type: "alphabetical"
|
|
2363
|
-
}],
|
|
2364
|
-
"perfectionist/sort-classes": ["error", { ...commonOptions }],
|
|
2365
|
-
"perfectionist/sort-decorators": ["error", { ...commonOptions }],
|
|
2366
|
-
"perfectionist/sort-enums": [
|
|
2367
|
-
"error",
|
|
2368
|
-
{
|
|
2369
|
-
...commonOptions,
|
|
2370
|
-
groups: [
|
|
2371
|
-
"r",
|
|
2372
|
-
"g",
|
|
2373
|
-
"b"
|
|
2374
|
-
],
|
|
2375
|
-
customGroups: [
|
|
2376
|
-
{
|
|
2377
|
-
elementNamePattern: "^r$",
|
|
2378
|
-
groupName: "r"
|
|
2379
|
-
},
|
|
2380
|
-
{
|
|
2381
|
-
elementNamePattern: "^g$",
|
|
2382
|
-
groupName: "g"
|
|
2383
|
-
},
|
|
2384
|
-
{
|
|
2385
|
-
elementNamePattern: "^b$",
|
|
2386
|
-
groupName: "b"
|
|
2387
|
-
}
|
|
2388
|
-
],
|
|
2389
|
-
useConfigurationIf: { allNamesMatchPattern: "^[rgb]$" }
|
|
2390
|
-
},
|
|
2391
|
-
{ ...commonOptions }
|
|
2392
|
-
],
|
|
2393
|
-
"perfectionist/sort-export-attributes": ["error", {
|
|
2394
|
-
...commonOptions,
|
|
2395
|
-
fallbackSort: {
|
|
2396
|
-
order: "asc",
|
|
2397
|
-
type: "natural"
|
|
2398
|
-
},
|
|
2399
|
-
type: "alphabetical"
|
|
2400
|
-
}],
|
|
2401
|
-
"perfectionist/sort-exports": ["error", { ...commonOptions }],
|
|
2402
|
-
"perfectionist/sort-heritage-clauses": ["error", { ...commonOptions }],
|
|
2403
|
-
"perfectionist/sort-import-attributes": ["error", {
|
|
2404
|
-
...commonOptions,
|
|
2405
|
-
fallbackSort: {
|
|
2406
|
-
order: "asc",
|
|
2407
|
-
type: "natural"
|
|
2408
|
-
},
|
|
2409
|
-
type: "alphabetical"
|
|
2410
|
-
}],
|
|
2411
|
-
"perfectionist/sort-imports": ["error", {
|
|
2412
|
-
fallbackSort: {
|
|
2413
|
-
order: "asc",
|
|
2414
|
-
type: "alphabetical"
|
|
2415
|
-
},
|
|
2416
|
-
groups: [
|
|
2417
|
-
"builtin",
|
|
2418
|
-
"external",
|
|
2419
|
-
"internal",
|
|
2420
|
-
[
|
|
2421
|
-
"parent",
|
|
2422
|
-
"sibling",
|
|
2423
|
-
"index"
|
|
2424
|
-
],
|
|
2425
|
-
"side-effect",
|
|
2426
|
-
"unknown",
|
|
2427
|
-
["type-builtin", "type-external"],
|
|
2428
|
-
"type-internal",
|
|
2429
|
-
[
|
|
2430
|
-
"type-parent",
|
|
2431
|
-
"type-sibling",
|
|
2432
|
-
"type-index",
|
|
2433
|
-
"type-import"
|
|
2434
|
-
]
|
|
2435
|
-
],
|
|
2436
|
-
ignoreCase: false,
|
|
2437
|
-
newlinesBetween: "ignore",
|
|
2465
|
+
};
|
|
2466
|
+
const perfectionist = async (options) => {
|
|
2467
|
+
const { overrides } = options;
|
|
2468
|
+
const [perfectionistPlugin] = await loadPackages(["eslint-plugin-perfectionist"]);
|
|
2469
|
+
return [{
|
|
2470
|
+
name: "moso/perfectionist",
|
|
2471
|
+
plugins: { "perfectionist": memoize(perfectionistPlugin, "eslint-plugin-perfectionist") },
|
|
2472
|
+
rules: {
|
|
2473
|
+
"perfectionist/sort-array-includes": ["error", {
|
|
2474
|
+
...commonOptions,
|
|
2475
|
+
fallbackSort: {
|
|
2438
2476
|
order: "asc",
|
|
2439
2477
|
type: "natural"
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2478
|
+
},
|
|
2479
|
+
type: "alphabetical"
|
|
2480
|
+
}],
|
|
2481
|
+
"perfectionist/sort-classes": ["error", { ...commonOptions }],
|
|
2482
|
+
"perfectionist/sort-decorators": ["error", { ...commonOptions }],
|
|
2483
|
+
"perfectionist/sort-enums": [
|
|
2484
|
+
"error",
|
|
2485
|
+
{
|
|
2443
2486
|
...commonOptions,
|
|
2444
|
-
fallbackSort: { type: "unsorted" },
|
|
2445
2487
|
groups: [
|
|
2446
|
-
|
|
2447
|
-
"
|
|
2448
|
-
|
|
2449
|
-
"conditional",
|
|
2450
|
-
"intersection",
|
|
2451
|
-
"union"
|
|
2452
|
-
],
|
|
2453
|
-
"unknown"
|
|
2488
|
+
"r",
|
|
2489
|
+
"g",
|
|
2490
|
+
"b"
|
|
2454
2491
|
],
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
"error",
|
|
2460
|
-
{
|
|
2461
|
-
...commonOptions,
|
|
2462
|
-
type: "unsorted",
|
|
2463
|
-
useConfigurationIf: { tagMatchesPattern: "^[a-z][^.]*$" }
|
|
2464
|
-
},
|
|
2465
|
-
{
|
|
2466
|
-
...commonOptions,
|
|
2467
|
-
customGroups: [
|
|
2468
|
-
{
|
|
2469
|
-
elementNamePattern: ["^role$", "^aria-.+$"],
|
|
2470
|
-
groupName: "a11y"
|
|
2471
|
-
},
|
|
2472
|
-
{
|
|
2473
|
-
elementNamePattern: [
|
|
2474
|
-
"^type$",
|
|
2475
|
-
"^id$",
|
|
2476
|
-
"^className$",
|
|
2477
|
-
"^href$",
|
|
2478
|
-
"^src$",
|
|
2479
|
-
"^srcSet$",
|
|
2480
|
-
"^name$",
|
|
2481
|
-
"^style$"
|
|
2482
|
-
],
|
|
2483
|
-
groupName: "almost-props"
|
|
2484
|
-
},
|
|
2485
|
-
{
|
|
2486
|
-
elementNamePattern: "^on.+",
|
|
2487
|
-
groupName: "callback"
|
|
2488
|
-
},
|
|
2489
|
-
{
|
|
2490
|
-
elementNamePattern: "^(?:class|client|is|server|set|transition):",
|
|
2491
|
-
groupName: "directive"
|
|
2492
|
-
},
|
|
2493
|
-
{
|
|
2494
|
-
elementNamePattern: ["^ref$", "^key$"],
|
|
2495
|
-
groupName: "reserved"
|
|
2496
|
-
}
|
|
2497
|
-
],
|
|
2498
|
-
fallbackSort: {
|
|
2499
|
-
order: "asc",
|
|
2500
|
-
type: "natural"
|
|
2492
|
+
customGroups: [
|
|
2493
|
+
{
|
|
2494
|
+
elementNamePattern: "^r$",
|
|
2495
|
+
groupName: "r"
|
|
2501
2496
|
},
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
"
|
|
2505
|
-
"almost-props",
|
|
2506
|
-
"unknown",
|
|
2507
|
-
"directive",
|
|
2508
|
-
"a11y",
|
|
2509
|
-
"shorthand-prop",
|
|
2510
|
-
"callback",
|
|
2511
|
-
"multiline-prop"
|
|
2512
|
-
],
|
|
2513
|
-
type: "alphabetical"
|
|
2514
|
-
}
|
|
2515
|
-
],
|
|
2516
|
-
"perfectionist/sort-maps": [
|
|
2517
|
-
"error",
|
|
2518
|
-
{
|
|
2519
|
-
...commonOptions,
|
|
2520
|
-
ignoreCase: true,
|
|
2521
|
-
type: "unsorted",
|
|
2522
|
-
useConfigurationIf: { matchesAstSelector: "VariableDeclaration[kind=\"const\"] NewExpression" }
|
|
2523
|
-
},
|
|
2524
|
-
{
|
|
2525
|
-
...commonOptions,
|
|
2526
|
-
fallbackSort: {
|
|
2527
|
-
order: "asc",
|
|
2528
|
-
type: "natural"
|
|
2497
|
+
{
|
|
2498
|
+
elementNamePattern: "^g$",
|
|
2499
|
+
groupName: "g"
|
|
2529
2500
|
},
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2501
|
+
{
|
|
2502
|
+
elementNamePattern: "^b$",
|
|
2503
|
+
groupName: "b"
|
|
2504
|
+
}
|
|
2505
|
+
],
|
|
2506
|
+
useConfigurationIf: { allNamesMatchPattern: "^[rgb]$" }
|
|
2507
|
+
},
|
|
2508
|
+
{ ...commonOptions }
|
|
2509
|
+
],
|
|
2510
|
+
"perfectionist/sort-export-attributes": ["error", {
|
|
2511
|
+
...commonOptions,
|
|
2512
|
+
fallbackSort: {
|
|
2513
|
+
order: "asc",
|
|
2514
|
+
type: "natural"
|
|
2515
|
+
},
|
|
2516
|
+
type: "alphabetical"
|
|
2517
|
+
}],
|
|
2518
|
+
"perfectionist/sort-exports": ["error", { ...commonOptions }],
|
|
2519
|
+
"perfectionist/sort-heritage-clauses": ["error", { ...commonOptions }],
|
|
2520
|
+
"perfectionist/sort-import-attributes": ["error", {
|
|
2521
|
+
...commonOptions,
|
|
2522
|
+
fallbackSort: {
|
|
2523
|
+
order: "asc",
|
|
2524
|
+
type: "natural"
|
|
2525
|
+
},
|
|
2526
|
+
type: "alphabetical"
|
|
2527
|
+
}],
|
|
2528
|
+
"perfectionist/sort-imports": ["error", {
|
|
2529
|
+
fallbackSort: {
|
|
2530
|
+
order: "asc",
|
|
2531
|
+
type: "alphabetical"
|
|
2532
|
+
},
|
|
2533
|
+
groups: [
|
|
2534
|
+
"builtin",
|
|
2535
|
+
"external",
|
|
2536
|
+
"internal",
|
|
2537
|
+
[
|
|
2538
|
+
"parent",
|
|
2539
|
+
"sibling",
|
|
2540
|
+
"index"
|
|
2541
|
+
],
|
|
2542
|
+
"side-effect",
|
|
2543
|
+
"unknown",
|
|
2544
|
+
["type-builtin", "type-external"],
|
|
2545
|
+
"type-internal",
|
|
2546
|
+
[
|
|
2547
|
+
"type-parent",
|
|
2548
|
+
"type-sibling",
|
|
2549
|
+
"type-index",
|
|
2550
|
+
"type-import"
|
|
2551
|
+
]
|
|
2533
2552
|
],
|
|
2534
|
-
|
|
2553
|
+
ignoreCase: false,
|
|
2554
|
+
newlinesBetween: "ignore",
|
|
2555
|
+
order: "asc",
|
|
2556
|
+
type: "natural"
|
|
2557
|
+
}],
|
|
2558
|
+
"perfectionist/sort-interfaces": ["error", { ...commonOptions }],
|
|
2559
|
+
"perfectionist/sort-intersection-types": ["error", {
|
|
2560
|
+
...commonOptions,
|
|
2561
|
+
fallbackSort: { type: "unsorted" },
|
|
2562
|
+
groups: [
|
|
2563
|
+
["keyword", "literal"],
|
|
2564
|
+
"named",
|
|
2565
|
+
[
|
|
2566
|
+
"conditional",
|
|
2567
|
+
"intersection",
|
|
2568
|
+
"union"
|
|
2569
|
+
],
|
|
2570
|
+
"unknown"
|
|
2571
|
+
],
|
|
2572
|
+
ignoreCase: true,
|
|
2573
|
+
type: "alphabetical"
|
|
2574
|
+
}],
|
|
2575
|
+
"perfectionist/sort-jsx-props": [
|
|
2576
|
+
"error",
|
|
2577
|
+
{
|
|
2535
2578
|
...commonOptions,
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
"perfectionist/sort-named-imports": ["error", { ...commonOptions }],
|
|
2541
|
-
"perfectionist/sort-object-types": ["error", { ...commonOptions }],
|
|
2542
|
-
"perfectionist/sort-objects": ["error", { ...commonOptions }],
|
|
2543
|
-
"perfectionist/sort-sets": ["error", { ...commonOptions }],
|
|
2544
|
-
"perfectionist/sort-switch-case": ["error", {
|
|
2579
|
+
type: "unsorted",
|
|
2580
|
+
useConfigurationIf: { tagMatchesPattern: "^[a-z][^.]*$" }
|
|
2581
|
+
},
|
|
2582
|
+
{
|
|
2545
2583
|
...commonOptions,
|
|
2584
|
+
customGroups: [
|
|
2585
|
+
{
|
|
2586
|
+
elementNamePattern: ["^role$", "^aria-.+$"],
|
|
2587
|
+
groupName: "a11y"
|
|
2588
|
+
},
|
|
2589
|
+
{
|
|
2590
|
+
elementNamePattern: [
|
|
2591
|
+
"^type$",
|
|
2592
|
+
"^id$",
|
|
2593
|
+
"^className$",
|
|
2594
|
+
"^href$",
|
|
2595
|
+
"^src$",
|
|
2596
|
+
"^srcSet$",
|
|
2597
|
+
"^name$",
|
|
2598
|
+
"^style$"
|
|
2599
|
+
],
|
|
2600
|
+
groupName: "almost-props"
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
elementNamePattern: "^on.+",
|
|
2604
|
+
groupName: "callback"
|
|
2605
|
+
},
|
|
2606
|
+
{
|
|
2607
|
+
elementNamePattern: "^(?:class|client|is|server|set|transition):",
|
|
2608
|
+
groupName: "directive"
|
|
2609
|
+
},
|
|
2610
|
+
{
|
|
2611
|
+
elementNamePattern: ["^ref$", "^key$"],
|
|
2612
|
+
groupName: "reserved"
|
|
2613
|
+
}
|
|
2614
|
+
],
|
|
2546
2615
|
fallbackSort: {
|
|
2547
2616
|
order: "asc",
|
|
2548
2617
|
type: "natural"
|
|
2549
2618
|
},
|
|
2550
|
-
|
|
2551
|
-
}],
|
|
2552
|
-
"perfectionist/sort-union-types": ["error", {
|
|
2553
|
-
...commonOptions,
|
|
2554
|
-
fallbackSort: { type: "unsorted" },
|
|
2619
|
+
ignoreCase: true,
|
|
2555
2620
|
groups: [
|
|
2556
|
-
|
|
2557
|
-
"
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
"
|
|
2621
|
+
"reserved",
|
|
2622
|
+
"almost-props",
|
|
2623
|
+
"unknown",
|
|
2624
|
+
"directive",
|
|
2625
|
+
"a11y",
|
|
2626
|
+
"shorthand-prop",
|
|
2627
|
+
"callback",
|
|
2628
|
+
"multiline-prop"
|
|
2564
2629
|
],
|
|
2565
|
-
ignoreCase: true,
|
|
2566
2630
|
type: "alphabetical"
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2631
|
+
}
|
|
2632
|
+
],
|
|
2633
|
+
"perfectionist/sort-maps": [
|
|
2634
|
+
"error",
|
|
2635
|
+
{
|
|
2636
|
+
...commonOptions,
|
|
2637
|
+
ignoreCase: true,
|
|
2638
|
+
type: "unsorted",
|
|
2639
|
+
useConfigurationIf: { matchesAstSelector: "VariableDeclaration[kind=\"const\"] NewExpression" }
|
|
2640
|
+
},
|
|
2641
|
+
{
|
|
2569
2642
|
...commonOptions,
|
|
2570
2643
|
fallbackSort: {
|
|
2571
2644
|
order: "asc",
|
|
@@ -2573,24 +2646,62 @@ const perfectionist = async (options) => {
|
|
|
2573
2646
|
},
|
|
2574
2647
|
ignoreCase: true,
|
|
2575
2648
|
type: "alphabetical"
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2649
|
+
}
|
|
2650
|
+
],
|
|
2651
|
+
"perfectionist/sort-modules": ["error", {
|
|
2652
|
+
...commonOptions,
|
|
2653
|
+
fallbackSort: { type: "unsorted" },
|
|
2654
|
+
type: "alphabetical"
|
|
2655
|
+
}],
|
|
2656
|
+
"perfectionist/sort-named-exports": ["error", { ...commonOptions }],
|
|
2657
|
+
"perfectionist/sort-named-imports": ["error", { ...commonOptions }],
|
|
2658
|
+
"perfectionist/sort-object-types": ["error", { ...commonOptions }],
|
|
2659
|
+
"perfectionist/sort-objects": ["error", { ...commonOptions }],
|
|
2660
|
+
"perfectionist/sort-sets": ["error", { ...commonOptions }],
|
|
2661
|
+
"perfectionist/sort-switch-case": ["error", {
|
|
2662
|
+
...commonOptions,
|
|
2663
|
+
fallbackSort: {
|
|
2664
|
+
order: "asc",
|
|
2665
|
+
type: "natural"
|
|
2666
|
+
},
|
|
2667
|
+
type: "alphabetical"
|
|
2668
|
+
}],
|
|
2669
|
+
"perfectionist/sort-union-types": ["error", {
|
|
2670
|
+
...commonOptions,
|
|
2671
|
+
fallbackSort: { type: "unsorted" },
|
|
2672
|
+
groups: [
|
|
2673
|
+
["keyword", "literal"],
|
|
2674
|
+
"named",
|
|
2675
|
+
[
|
|
2676
|
+
"conditional",
|
|
2677
|
+
"intersection",
|
|
2678
|
+
"union"
|
|
2679
|
+
],
|
|
2680
|
+
"unknown"
|
|
2681
|
+
],
|
|
2682
|
+
ignoreCase: true,
|
|
2683
|
+
type: "alphabetical"
|
|
2684
|
+
}],
|
|
2685
|
+
"perfectionist/sort-variable-declarations": ["error", {
|
|
2686
|
+
...commonOptions,
|
|
2687
|
+
fallbackSort: {
|
|
2688
|
+
order: "asc",
|
|
2689
|
+
type: "natural"
|
|
2690
|
+
},
|
|
2691
|
+
ignoreCase: true,
|
|
2692
|
+
type: "alphabetical"
|
|
2693
|
+
}]
|
|
2694
|
+
},
|
|
2695
|
+
...overrides
|
|
2580
2696
|
}];
|
|
2581
2697
|
};
|
|
2582
2698
|
//#endregion
|
|
2583
2699
|
//#region src/configs/promise.ts
|
|
2584
|
-
const promise = async (options
|
|
2700
|
+
const promise = async (options) => {
|
|
2585
2701
|
const { lessOpinionated, overrides, typescript } = options;
|
|
2586
2702
|
const [promisePlugin] = await loadPackages(["eslint-plugin-promise"]);
|
|
2587
2703
|
return [{
|
|
2588
2704
|
name: "moso/promise",
|
|
2589
|
-
files: [
|
|
2590
|
-
GLOB_SRC,
|
|
2591
|
-
GLOB_ASTRO,
|
|
2592
|
-
GLOB_VUE
|
|
2593
|
-
],
|
|
2594
2705
|
plugins: { "promise": memoize(promisePlugin, "eslint-plugin-promise") },
|
|
2595
2706
|
rules: {
|
|
2596
2707
|
"promise/no-callback-in-promise": "error",
|
|
@@ -2634,31 +2745,36 @@ const RemixPackages = [
|
|
|
2634
2745
|
"@remix-run/serve"
|
|
2635
2746
|
];
|
|
2636
2747
|
const react = async (options) => {
|
|
2637
|
-
const { additionalHooks = "useIsomorphicLayoutEffect", files, filesTypeAware, ignoresTypeAware, lessOpinionated, nextjs, overrides, overridesTypeAware, parserOptions, projectRoot, stylistic, typescript } = options;
|
|
2748
|
+
const { a11y, additionalHooks = "useIsomorphicLayoutEffect", files, filesTypeAware, ignoresTypeAware, lessOpinionated, nextjs, overrides, overridesA11y, overridesTypeAware, parserOptions, projectRoot, stylistic, typescript } = options;
|
|
2638
2749
|
const [reactPlugin, reactHooksPlugin, reactRefreshPlugin, reactYouMightNotNeedAnEffect] = await loadPackages([
|
|
2639
2750
|
"@eslint-react/eslint-plugin",
|
|
2640
2751
|
"eslint-plugin-react-hooks",
|
|
2641
2752
|
"eslint-plugin-react-refresh",
|
|
2642
2753
|
"eslint-plugin-react-you-might-not-need-an-effect"
|
|
2643
2754
|
]);
|
|
2644
|
-
const isTypeAware = typeof projectRoot === "string";
|
|
2755
|
+
const isTypeAware = typescript && typeof projectRoot === "string";
|
|
2645
2756
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((x) => isPackageExists(x));
|
|
2646
2757
|
const isUsingNextJS = nextjs !== false;
|
|
2647
2758
|
const isUsingRemix = RemixPackages.some((x) => isPackageExists(x));
|
|
2648
2759
|
const isUsingReactRouter = ReactRouterPackages.some((x) => isPackageExists(x));
|
|
2760
|
+
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
2649
2761
|
const reactHooks = additionalHooks ? additionalHooks.replaceAll(",", "|") : void 0;
|
|
2650
2762
|
const stylisticEnabled = stylistic !== false;
|
|
2651
2763
|
const [typescriptParser] = typescript ? await loadPackages(["@typescript-eslint/parser"]) : [void 0];
|
|
2652
2764
|
return [
|
|
2653
2765
|
{
|
|
2654
|
-
name: "moso/react",
|
|
2655
|
-
files,
|
|
2766
|
+
name: "moso/react/setup",
|
|
2656
2767
|
plugins: {
|
|
2657
2768
|
"@eslint-react": memoize(reactPlugin, "@eslint-react"),
|
|
2658
2769
|
"react-hooks": memoize(reactHooksPlugin, "eslint-plugin-react-hooks"),
|
|
2659
2770
|
"react-refresh": memoize(reactRefreshPlugin, "eslint-plugin-react-refresh"),
|
|
2660
|
-
"react-you-might-not-need-an-effect": memoize(reactYouMightNotNeedAnEffect, "eslint-plugin-react-you-might-not-need-an-effect")
|
|
2661
|
-
|
|
2771
|
+
"react-you-might-not-need-an-effect": memoize(reactYouMightNotNeedAnEffect, "eslint-plugin-react-you-might-not-need-an-effect"),
|
|
2772
|
+
...jsxA11yPlugin && { "jsx-a11y": memoize(jsxA11yPlugin, "eslint-plugin-jsx-a11y") }
|
|
2773
|
+
}
|
|
2774
|
+
},
|
|
2775
|
+
{
|
|
2776
|
+
name: "moso/react/rules",
|
|
2777
|
+
files,
|
|
2662
2778
|
languageOptions: {
|
|
2663
2779
|
parser: typescript ? typescriptParser : void 0,
|
|
2664
2780
|
parserOptions: {
|
|
@@ -2724,12 +2840,15 @@ const react = async (options) => {
|
|
|
2724
2840
|
"dynamicParams",
|
|
2725
2841
|
"experimental_ppr",
|
|
2726
2842
|
"fetchCache",
|
|
2843
|
+
"generateImageMetaData",
|
|
2727
2844
|
"generateMetadata",
|
|
2845
|
+
"generateSitemaps",
|
|
2728
2846
|
"generateStaticParams",
|
|
2729
2847
|
"generateViewport",
|
|
2730
2848
|
"maxDuration",
|
|
2731
2849
|
"metadata",
|
|
2732
2850
|
"preferredRegion",
|
|
2851
|
+
"revalidate",
|
|
2733
2852
|
"runtime",
|
|
2734
2853
|
"viewport"
|
|
2735
2854
|
] : [], ...isUsingReactRouter || isUsingRemix ? [
|
|
@@ -2746,6 +2865,41 @@ const react = async (options) => {
|
|
|
2746
2865
|
"HydrateFallback"
|
|
2747
2866
|
] : []]
|
|
2748
2867
|
}],
|
|
2868
|
+
...jsxA11yPlugin && {
|
|
2869
|
+
"jsx-a11y/alt-text": ["warn", {
|
|
2870
|
+
elements: ["img"],
|
|
2871
|
+
img: ["Image"]
|
|
2872
|
+
}],
|
|
2873
|
+
"jsx-a11y/aria-props": "warn",
|
|
2874
|
+
"jsx-a11y/aria-proptypes": "warn",
|
|
2875
|
+
"jsx-a11y/aria-role": "warn",
|
|
2876
|
+
"jsx-a11y/aria-unsupported-elements": "warn",
|
|
2877
|
+
"jsx-a11y/iframe-has-title": "warn",
|
|
2878
|
+
"jsx-a11y/no-access-key": "warn",
|
|
2879
|
+
"jsx-a11y/no-static-element-interactions": "warn",
|
|
2880
|
+
"jsx-a11y/role-has-required-aria-props": "warn",
|
|
2881
|
+
"jsx-a11y/role-supports-aria-props": "warn",
|
|
2882
|
+
"jsx-a11y/tabindex-no-positive": "warn",
|
|
2883
|
+
"jsx-a11y/anchor-ambiguous-text": "off",
|
|
2884
|
+
"jsx-a11y/interactive-supports-focus": ["error", { tabbable: [
|
|
2885
|
+
"button",
|
|
2886
|
+
"checkbox",
|
|
2887
|
+
"link",
|
|
2888
|
+
"progressbar",
|
|
2889
|
+
"searchbox",
|
|
2890
|
+
"slider",
|
|
2891
|
+
"spinbutton",
|
|
2892
|
+
"switch",
|
|
2893
|
+
"textbox"
|
|
2894
|
+
] }],
|
|
2895
|
+
"jsx-a11y/label-has-for": "off",
|
|
2896
|
+
"jsx-a11y/no-noninteractive-element-interactions": ["error", {
|
|
2897
|
+
body: ["onError", "onLoad"],
|
|
2898
|
+
iframe: ["onError", "onLoad"],
|
|
2899
|
+
img: ["onError", "onLoad"]
|
|
2900
|
+
}],
|
|
2901
|
+
...overridesA11y
|
|
2902
|
+
},
|
|
2749
2903
|
...overrides
|
|
2750
2904
|
}
|
|
2751
2905
|
},
|
|
@@ -2800,11 +2954,6 @@ const regexp = async (options) => {
|
|
|
2800
2954
|
const [regexpPlugin] = await loadPackages(["eslint-plugin-regexp"]);
|
|
2801
2955
|
return [{
|
|
2802
2956
|
name: "moso/regexp",
|
|
2803
|
-
files: [
|
|
2804
|
-
GLOB_SRC,
|
|
2805
|
-
GLOB_ASTRO,
|
|
2806
|
-
GLOB_VUE
|
|
2807
|
-
],
|
|
2808
2957
|
plugins: { "regexp": memoize(regexpPlugin, "eslint-plugin-regexp") },
|
|
2809
2958
|
rules: {
|
|
2810
2959
|
"no-empty-character-class": "off",
|
|
@@ -3057,6 +3206,7 @@ const sortTsconfig = (options = {}) => {
|
|
|
3057
3206
|
//#endregion
|
|
3058
3207
|
//#region src/configs/stylistic.ts
|
|
3059
3208
|
const StylisticConfigDefaults = {
|
|
3209
|
+
braceStyle: "1tbs",
|
|
3060
3210
|
experimental: false,
|
|
3061
3211
|
indent: 4,
|
|
3062
3212
|
jsx: true,
|
|
@@ -3064,12 +3214,13 @@ const StylisticConfigDefaults = {
|
|
|
3064
3214
|
semi: true
|
|
3065
3215
|
};
|
|
3066
3216
|
const stylistic = async (options) => {
|
|
3067
|
-
const { experimental, indent, jsx, lessOpinionated, quotes, overrides, semi, typescript } = {
|
|
3217
|
+
const { braceStyle, experimental, indent, jsx, lessOpinionated, quotes, overrides, semi, typescript } = {
|
|
3068
3218
|
...StylisticConfigDefaults,
|
|
3069
3219
|
...options
|
|
3070
3220
|
};
|
|
3071
3221
|
const [stylisticPlugin] = await loadPackages(["@stylistic/eslint-plugin"]);
|
|
3072
3222
|
const config = stylisticPlugin.configs.customize({
|
|
3223
|
+
braceStyle,
|
|
3073
3224
|
experimental,
|
|
3074
3225
|
indent,
|
|
3075
3226
|
jsx,
|
|
@@ -3103,7 +3254,7 @@ const stylistic = async (options) => {
|
|
|
3103
3254
|
"@stylistic/block-spacing": ["error", "always"],
|
|
3104
3255
|
"@stylistic/brace-style": [
|
|
3105
3256
|
"error",
|
|
3106
|
-
|
|
3257
|
+
braceStyle,
|
|
3107
3258
|
{ allowSingleLine: true }
|
|
3108
3259
|
],
|
|
3109
3260
|
"@stylistic/comma-dangle": ["error", {
|
|
@@ -3305,40 +3456,67 @@ const stylistic = async (options) => {
|
|
|
3305
3456
|
}];
|
|
3306
3457
|
};
|
|
3307
3458
|
//#endregion
|
|
3459
|
+
//#region src/configs/tailwind.ts
|
|
3460
|
+
const tailwind = async (options) => {
|
|
3461
|
+
const { config, entryPoint, overrides, stylistic, version } = options;
|
|
3462
|
+
const [tailwindPlugin] = await loadPackages(["eslint-plugin-better-tailwindcss"]);
|
|
3463
|
+
const stylisticEnabled = stylistic !== false;
|
|
3464
|
+
return [{
|
|
3465
|
+
name: "moso/tailwind",
|
|
3466
|
+
settings: { "better-tailwindcss": version === 4 ? { entryPoint } : version === 3 ? { config } : void 0 },
|
|
3467
|
+
plugins: { "tailwind-better": memoize(tailwindPlugin, "eslint-plugin-better-tailwindcss") },
|
|
3468
|
+
rules: {
|
|
3469
|
+
"tailwind-better/no-conflicting-classes": "error",
|
|
3470
|
+
"tailwind-better/no-restricted-classes": "error",
|
|
3471
|
+
"tailwind-better/no-unknown-classes": ["off", { detectComponentClasses: true }],
|
|
3472
|
+
...stylisticEnabled && {
|
|
3473
|
+
"tailwind-better/enforce-consistent-line-wrapping": ["error", {
|
|
3474
|
+
classesPerLine: 0,
|
|
3475
|
+
group: "newLine",
|
|
3476
|
+
indent: stylistic.indent,
|
|
3477
|
+
lineBreakStyle: "unix",
|
|
3478
|
+
preferSingleLine: false
|
|
3479
|
+
}],
|
|
3480
|
+
"tailwind-better/enforce-consistent-class-order": ["error", {
|
|
3481
|
+
order: "strict",
|
|
3482
|
+
detectComponentClasses: true,
|
|
3483
|
+
componentClassOrder: "preserve",
|
|
3484
|
+
componentClassPosition: "start",
|
|
3485
|
+
unknownClassOrder: "preserve",
|
|
3486
|
+
unknownClassPosition: "start"
|
|
3487
|
+
}],
|
|
3488
|
+
"tailwind-better/enforce-consistent-variable-syntax": ["error", { syntax: "shorthand" }],
|
|
3489
|
+
"tailwind-better/enforce-consistent-important-position": "off",
|
|
3490
|
+
"tailwind-better/enforce-shorthand-classes": "off",
|
|
3491
|
+
"tailwind-better/enforce-canonical-classes": "error",
|
|
3492
|
+
"tailwind-better/no-duplicate-classes": "error",
|
|
3493
|
+
"tailwind-better/no-deprecated-classes": "warn",
|
|
3494
|
+
"tailwind-better/no-unnecessary-whitespace": "warn"
|
|
3495
|
+
},
|
|
3496
|
+
...overrides
|
|
3497
|
+
}
|
|
3498
|
+
}];
|
|
3499
|
+
};
|
|
3500
|
+
//#endregion
|
|
3308
3501
|
//#region src/configs/test.ts
|
|
3309
3502
|
const test = async (options) => {
|
|
3310
|
-
const { isInEditor, files, overrides } = options;
|
|
3311
|
-
const [functionalPlugin
|
|
3503
|
+
const { functionalEnforcement, isInEditor, files, overrides } = options;
|
|
3504
|
+
const [functionalPlugin] = functionalEnforcement === "none" ? [void 0] : await loadPackages(["eslint-plugin-functional"]);
|
|
3505
|
+
const [noOnlyTestsPlugin] = await loadPackages(["eslint-plugin-no-only-tests"]);
|
|
3312
3506
|
const vitestPlugin = await interopDefault(import("@vitest/eslint-plugin"));
|
|
3313
3507
|
return [{
|
|
3314
3508
|
name: "moso/test/setup",
|
|
3509
|
+
languageOptions: { globals: { ...vitestPlugin.environments.env.globals } },
|
|
3510
|
+
settings: { vitest: { typecheck: true } },
|
|
3315
3511
|
plugins: {
|
|
3316
3512
|
"no-only-tests": memoize(noOnlyTestsPlugin, "eslint-plugin-no-only-tests"),
|
|
3317
3513
|
"vitest": memoize(vitestPlugin, "@vitest/eslint-plugin")
|
|
3318
|
-
}
|
|
3319
|
-
settings: { vitest: { typecheck: true } },
|
|
3320
|
-
languageOptions: { globals: { ...vitestPlugin.environments.env.globals } }
|
|
3514
|
+
}
|
|
3321
3515
|
}, {
|
|
3322
3516
|
name: "moso/test/rules",
|
|
3323
3517
|
files,
|
|
3324
3518
|
rules: {
|
|
3325
|
-
...functionalPlugin.configs.off.rules,
|
|
3326
|
-
"@moso/no-top-level-await": "off",
|
|
3327
|
-
"jsdoc/require-jsdoc": "off",
|
|
3328
|
-
"node/no-sync": "off",
|
|
3329
|
-
"node/prefer-global/process": "off",
|
|
3330
|
-
"regexp/no-super-linear-backtracking": "off",
|
|
3331
|
-
"unicorn/consistent-function-scoping": "off",
|
|
3332
|
-
"unicorn/prefer-module": "off",
|
|
3333
|
-
"@typescript-eslint/consistent-type-definitions": "off",
|
|
3334
|
-
"@typescript-eslint/no-unsafe-argument": "off",
|
|
3335
|
-
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
3336
|
-
"@typescript-eslint/no-unsafe-call": "off",
|
|
3337
|
-
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
3338
|
-
"@typescript-eslint/no-unsafe-return": "off",
|
|
3339
|
-
"@typescript-eslint/no-unused-expressions": "off",
|
|
3340
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
3341
|
-
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
3519
|
+
...(assert.ok(!Array.isArray(functionalPlugin?.configs.off)), functionalPlugin?.configs.off.rules),
|
|
3342
3520
|
"no-only-tests/no-only-tests": isInEditor ? "warn" : "error",
|
|
3343
3521
|
...(assert.ok(!Array.isArray(vitestPlugin.configs.recommended)), vitestPlugin.configs.recommended.rules),
|
|
3344
3522
|
"vitest/consistent-test-it": ["error", {
|
|
@@ -3378,9 +3556,15 @@ const toml = async (options) => {
|
|
|
3378
3556
|
"toml/tables-order": "error",
|
|
3379
3557
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
3380
3558
|
...stylisticEnabled && {
|
|
3381
|
-
"toml/array-bracket-newline": "error",
|
|
3382
|
-
|
|
3383
|
-
|
|
3559
|
+
"toml/array-bracket-newline": ["error", {
|
|
3560
|
+
minItems: 4,
|
|
3561
|
+
multiline: true
|
|
3562
|
+
}],
|
|
3563
|
+
"toml/array-bracket-spacing": ["error", "never"],
|
|
3564
|
+
"toml/array-element-newline": ["error", {
|
|
3565
|
+
minItems: 4,
|
|
3566
|
+
multiline: true
|
|
3567
|
+
}],
|
|
3384
3568
|
"toml/indent": ["error", typeof indent === "number" || typeof indent === "string" ? indent : 2],
|
|
3385
3569
|
"toml/inline-table-curly-spacing": "error",
|
|
3386
3570
|
"toml/key-spacing": "error",
|
|
@@ -3954,21 +4138,20 @@ const typescript = async (options) => {
|
|
|
3954
4138
|
//#endregion
|
|
3955
4139
|
//#region src/configs/unicorn.ts
|
|
3956
4140
|
const unicorn = async (options) => {
|
|
3957
|
-
const { lessOpinionated, overrides } = options;
|
|
4141
|
+
const { files, lessOpinionated, overrides } = options;
|
|
3958
4142
|
const [unicornPlugin] = await loadPackages(["eslint-plugin-unicorn"]);
|
|
3959
4143
|
return [{
|
|
3960
|
-
name: "moso/unicorn",
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
],
|
|
3966
|
-
plugins: { "unicorn": memoize(unicornPlugin, "eslint-plugin-unicorn") },
|
|
4144
|
+
name: "moso/unicorn/setup",
|
|
4145
|
+
plugins: { "unicorn": memoize(unicornPlugin, "eslint-plugin-unicorn") }
|
|
4146
|
+
}, {
|
|
4147
|
+
name: "moso/unicorn/rules",
|
|
4148
|
+
files,
|
|
3967
4149
|
rules: {
|
|
3968
4150
|
...(assert.ok(!Array.isArray(unicornPlugin.configs.unopinionated)), unicornPlugin.configs.unopinionated.rules),
|
|
3969
4151
|
...!lessOpinionated && {
|
|
3970
4152
|
...(assert.ok(!Array.isArray(unicornPlugin.configs.recommended)), unicornPlugin.configs.recommended.rules),
|
|
3971
4153
|
"unicorn/custom-error-definition": "error",
|
|
4154
|
+
"unicorn/iteration-fallback-style": ["error", "fallback"],
|
|
3972
4155
|
"unicorn/no-instanceof-builtins": ["error", {
|
|
3973
4156
|
strategy: "strict",
|
|
3974
4157
|
useErrorIsError: true
|
|
@@ -3976,7 +4159,7 @@ const unicorn = async (options) => {
|
|
|
3976
4159
|
"unicorn/no-unsafe-dom-html": "error",
|
|
3977
4160
|
"unicorn/prefer-at": ["error", { checkAllIndexAccess: false }],
|
|
3978
4161
|
"unicorn/prefer-short-arrow-method": "error",
|
|
3979
|
-
"unicorn/try-complexity": "error",
|
|
4162
|
+
"unicorn/try-complexity": ["error", { max: 3 }],
|
|
3980
4163
|
"unicorn/consistent-boolean-name": "off",
|
|
3981
4164
|
"unicorn/consistent-compound-words": "off",
|
|
3982
4165
|
"unicorn/consistent-export-decorator-position": "off",
|
|
@@ -4053,7 +4236,8 @@ const unicorn = async (options) => {
|
|
|
4053
4236
|
"unicorn/require-array-sort-compare": "off",
|
|
4054
4237
|
"unicorn/require-css-escape": "off",
|
|
4055
4238
|
"unicorn/require-module-attributes": "off",
|
|
4056
|
-
"unicorn/require-module-specifiers": "off"
|
|
4239
|
+
"unicorn/require-module-specifiers": "off",
|
|
4240
|
+
"unicorn/single-line-block-comment-style": "off"
|
|
4057
4241
|
},
|
|
4058
4242
|
...overrides
|
|
4059
4243
|
}
|
|
@@ -4063,15 +4247,14 @@ const unicorn = async (options) => {
|
|
|
4063
4247
|
//#region src/configs/vue.ts
|
|
4064
4248
|
const NuxtPackages = ["nuxt"];
|
|
4065
4249
|
const vue = async (options) => {
|
|
4066
|
-
const { a11y, files,
|
|
4067
|
-
const { indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
4250
|
+
const { a11y, files, overrides, overridesA11y, parserOptions, stylistic, typescript } = options;
|
|
4251
|
+
const { braceStyle = "1tbs", indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
4068
4252
|
const [vuePlugin, vueParser, processorVueBlocks, { mergeProcessors }] = await loadPackages([
|
|
4069
4253
|
"eslint-plugin-vue",
|
|
4070
4254
|
"vue-eslint-parser",
|
|
4071
4255
|
"eslint-processor-vue-blocks",
|
|
4072
4256
|
"eslint-merge-processors"
|
|
4073
4257
|
]);
|
|
4074
|
-
const isTypeAware = typeof projectRoot === "string";
|
|
4075
4258
|
const isUsingNuxt = NuxtPackages.some((x) => isPackageExists(x));
|
|
4076
4259
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks;
|
|
4077
4260
|
const stylisticEnabled = stylistic !== false;
|
|
@@ -4096,7 +4279,10 @@ const vue = async (options) => {
|
|
|
4096
4279
|
watch: "readonly",
|
|
4097
4280
|
watchEffect: "readonly"
|
|
4098
4281
|
} },
|
|
4099
|
-
plugins: {
|
|
4282
|
+
plugins: {
|
|
4283
|
+
"vue": memoize(vuePlugin, "eslint-plugin-vue"),
|
|
4284
|
+
...vueA11yPlugin && { "vuejs-accessibility": memoize(vueA11yPlugin, "eslint-plugin-vuejs-accessibility") }
|
|
4285
|
+
}
|
|
4100
4286
|
},
|
|
4101
4287
|
{
|
|
4102
4288
|
name: "moso/vue/rules",
|
|
@@ -4119,10 +4305,7 @@ const vue = async (options) => {
|
|
|
4119
4305
|
}
|
|
4120
4306
|
})]),
|
|
4121
4307
|
rules: {
|
|
4122
|
-
...vuePlugin.configs
|
|
4123
|
-
...vuePlugin.configs["flat/essential"].map((config) => config.rules ?? {}).reduce((acc, rules) => Object.assign(acc, rules), {}),
|
|
4124
|
-
...vuePlugin.configs["flat/strongly-recommended"].map((config) => config.rules ?? {}).reduce((acc, rules) => Object.assign(acc, rules), {}),
|
|
4125
|
-
...vuePlugin.configs["flat/recommended"].map((config) => config.rules ?? {}).reduce((acc, rules) => Object.assign(acc, rules), {}),
|
|
4308
|
+
...flattenRules(vuePlugin.configs["flat/recommended"]),
|
|
4126
4309
|
"node/prefer-global/process": "off",
|
|
4127
4310
|
"vue/block-order": ["error", { order: [
|
|
4128
4311
|
"script",
|
|
@@ -4186,7 +4369,7 @@ const vue = async (options) => {
|
|
|
4186
4369
|
}],
|
|
4187
4370
|
"vue/brace-style": [
|
|
4188
4371
|
"error",
|
|
4189
|
-
|
|
4372
|
+
braceStyle,
|
|
4190
4373
|
{ allowSingleLine: true }
|
|
4191
4374
|
],
|
|
4192
4375
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
@@ -4255,69 +4438,13 @@ const vue = async (options) => {
|
|
|
4255
4438
|
"vue/space-in-parens": ["error", "never"],
|
|
4256
4439
|
"vue/template-curly-spacing": "error"
|
|
4257
4440
|
},
|
|
4258
|
-
...
|
|
4259
|
-
"
|
|
4260
|
-
|
|
4261
|
-
"no-redeclare": "off",
|
|
4262
|
-
"no-unused-vars": "off",
|
|
4263
|
-
"no-array-constructor": "off",
|
|
4264
|
-
"@typescript-eslint/no-array-constructor": "error",
|
|
4265
|
-
"no-unused-expressions": "off",
|
|
4266
|
-
"@typescript-eslint/no-unused-expressions": "error",
|
|
4267
|
-
"no-useless-constructor": "off",
|
|
4268
|
-
"@typescript-eslint/no-useless-constructor": "error",
|
|
4269
|
-
"camelcase": "off",
|
|
4270
|
-
"vue/camelcase": "off",
|
|
4271
|
-
"@typescript-eslint/naming-convention": ["error", {
|
|
4272
|
-
format: [
|
|
4273
|
-
"camelCase",
|
|
4274
|
-
"PascalCase",
|
|
4275
|
-
"UPPER_CASE"
|
|
4276
|
-
],
|
|
4277
|
-
leadingUnderscore: "allow",
|
|
4278
|
-
selector: "variableLike",
|
|
4279
|
-
trailingUnderscore: "allow"
|
|
4280
|
-
}],
|
|
4281
|
-
"no-use-before-define": "off",
|
|
4282
|
-
"@typescript-eslint/no-use-before-define": ["error", {
|
|
4283
|
-
classes: false,
|
|
4284
|
-
enums: false,
|
|
4285
|
-
functions: false,
|
|
4286
|
-
typedefs: false,
|
|
4287
|
-
variables: false
|
|
4288
|
-
}]
|
|
4441
|
+
...vueA11yPlugin && {
|
|
4442
|
+
...flattenRules(vueA11yPlugin.configs["flat/recommended"]),
|
|
4443
|
+
...overridesA11y
|
|
4289
4444
|
},
|
|
4290
4445
|
...overrides
|
|
4291
4446
|
}
|
|
4292
4447
|
},
|
|
4293
|
-
...isTypeAware ? [{
|
|
4294
|
-
name: "moso/vue/rules-type-aware",
|
|
4295
|
-
files: filesTypeAware,
|
|
4296
|
-
rules: {
|
|
4297
|
-
"no-implied-eval": "off",
|
|
4298
|
-
"@typescript-eslint/no-implied-eval": "error",
|
|
4299
|
-
"no-unused-vars": "off",
|
|
4300
|
-
"vue/no-unused-vars": "off",
|
|
4301
|
-
"@typescript-eslint/no-unused-vars": ["error", {
|
|
4302
|
-
argsIgnorePattern: "^_",
|
|
4303
|
-
args: "none",
|
|
4304
|
-
caughtErrors: "none",
|
|
4305
|
-
ignoreRestSiblings: true,
|
|
4306
|
-
vars: "all"
|
|
4307
|
-
}],
|
|
4308
|
-
"prefer-promise-reject-errors": "off",
|
|
4309
|
-
"@typescript-eslint/prefer-promise-reject-errors": "error",
|
|
4310
|
-
...overridesTypeAware
|
|
4311
|
-
}
|
|
4312
|
-
}] : [],
|
|
4313
|
-
...vueA11yPlugin ? [{
|
|
4314
|
-
name: "moso/vue/a11y",
|
|
4315
|
-
plugins: { "vue-a11y": memoize(vueA11yPlugin, "eslint-plugin-vuejs-accessibility") },
|
|
4316
|
-
rules: {
|
|
4317
|
-
...vueA11yPlugin.configs["flat/recommended"].map((config) => ("rules" in config ? config.rules : void 0) ?? {}).reduce((acc, rules) => Object.assign(acc, rules), {}),
|
|
4318
|
-
...overridesA11y
|
|
4319
|
-
}
|
|
4320
|
-
}] : [],
|
|
4321
4448
|
...isUsingNuxt ? [
|
|
4322
4449
|
{
|
|
4323
4450
|
name: "moso/nuxt/ignores",
|
|
@@ -4341,6 +4468,7 @@ const vue = async (options) => {
|
|
|
4341
4468
|
rules: { "vue/multi-word-component-names": "off" }
|
|
4342
4469
|
},
|
|
4343
4470
|
{
|
|
4471
|
+
name: "moso/nuxt/template-rules",
|
|
4344
4472
|
files: [`**/layouts/**/*.{${GLOB_SRC_EXT},vue}`, `**/pages/**/*.{${GLOB_SRC_EXT},vue}`],
|
|
4345
4473
|
rules: { "vue/no-multiple-template-root": "error" }
|
|
4346
4474
|
}
|
|
@@ -4358,10 +4486,10 @@ const yaml = async (options) => {
|
|
|
4358
4486
|
name: "moso/yaml/setup",
|
|
4359
4487
|
plugins: { "yml": memoize(yamlPlugin, "eslint-plugin-yml") }
|
|
4360
4488
|
}, {
|
|
4489
|
+
name: "moso/yaml/rules",
|
|
4361
4490
|
files,
|
|
4362
4491
|
language: "yml/yaml",
|
|
4363
4492
|
languageOptions: { parser: memoize(yamlParser, "yaml-eslint-parser") },
|
|
4364
|
-
name: "moso/yaml/rules",
|
|
4365
4493
|
rules: {
|
|
4366
4494
|
"@stylistic/spaced-comment": "off",
|
|
4367
4495
|
"yml/block-mapping": "error",
|
|
@@ -4438,22 +4566,26 @@ async function moso(options, ...userConfigs) {
|
|
|
4438
4566
|
const astroOptions = options.astro ?? AstroPackages.some((x) => isPackageExists(x));
|
|
4439
4567
|
const nextjsOptions = options.nextjs ?? NextJSPackages.some((x) => isPackageExists(x));
|
|
4440
4568
|
const reactOptions = options.react ?? ReactPackages.some((x) => isPackageExists(x));
|
|
4569
|
+
const tailwindOptions = options.tailwind ?? isPackageExists("tailwindcss");
|
|
4441
4570
|
const vueOptions = options.vue ?? VuePackages.some((x) => isPackageExists(x));
|
|
4442
4571
|
if (vueOptions !== false) componentExts.push("vue");
|
|
4443
4572
|
if ("files" in options) throw new Error("[@moso/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
|
|
4573
|
+
const baselineOptions = options.baseline === false ? false : typeof options.baseline === "object" ? options.baseline : typeof options.baseline === "string" || typeof options.baseline === "number" ? { baseline: options.baseline } : {};
|
|
4444
4574
|
const e18eOptions = options.e18e === false ? false : typeof options.e18e === "object" ? options.e18e : options.e18e === true ? {} : options.lessOpinionated === true ? false : {};
|
|
4445
4575
|
const functionalEnforcement = typeof options.functional === "string" ? options.functional : typeof options.functional === "object" ? options.functional.functionalEnforcement ?? "recommended" : options.functional ? "recommended" : options.functional === false || options.lessOpinionated === true ? "none" : "lite";
|
|
4446
4576
|
const hasTypeScript = Boolean(typescriptOptions);
|
|
4447
4577
|
const ignoreOptions = typeof options.ignores === "object" ? options.ignores : {};
|
|
4448
4578
|
const modeOptions = typeof options.mode === "string" ? options.mode : "none";
|
|
4449
4579
|
const perfectionistOptions = typeof options.perfectionist === "boolean" ? options.perfectionist : options.lessOpinionated !== true;
|
|
4450
|
-
const projectRootOptions = typeof options.projectRoot === "string" ? checkFilePath(options.projectRoot) : typeof options.typescript === "object" && typeof options.typescript.projectRoot === "string" ? checkFilePath(options.typescript.projectRoot) : void 0;
|
|
4451
4580
|
const stylisticOptions = options.stylistic === false ? false : {
|
|
4452
4581
|
...StylisticConfigDefaults,
|
|
4453
4582
|
jsx: typeof jsxOptions === "boolean" ? jsxOptions : true,
|
|
4454
4583
|
...typeof options.stylistic === "object" && options.stylistic
|
|
4455
4584
|
};
|
|
4456
|
-
const { filesTypeAware, ignoresTypeAware, parserOptions, useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
|
|
4585
|
+
const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
|
|
4586
|
+
const deprecatedProjectRoot = options.projectRoot;
|
|
4587
|
+
if (deprecatedProjectRoot !== void 0) console.warn("[@moso/eslint-config] The top-level `projectRoot` option is deprecated. Move it inside the `typescript` options instead: `typescript: { projectRoot: import.meta.dirname }`.");
|
|
4588
|
+
const projectRootOptions = typeof typescriptProjectRoot === "string" ? checkFilePath(typescriptProjectRoot) : typeof deprecatedProjectRoot === "string" ? checkFilePath(deprecatedProjectRoot) : void 0;
|
|
4457
4589
|
const projectServiceUserConfig = {
|
|
4458
4590
|
defaultProject: "./tsconfig.json",
|
|
4459
4591
|
loadTypeScriptPlugins: isInEditor,
|
|
@@ -4497,6 +4629,11 @@ async function moso(options, ...userConfigs) {
|
|
|
4497
4629
|
}),
|
|
4498
4630
|
imports({
|
|
4499
4631
|
...typescriptConfigOptions,
|
|
4632
|
+
files: [
|
|
4633
|
+
GLOB_DTS,
|
|
4634
|
+
GLOB_TS,
|
|
4635
|
+
GLOB_TSX
|
|
4636
|
+
],
|
|
4500
4637
|
overrides: getOverrides(options, "imports"),
|
|
4501
4638
|
stylistic: stylisticOptions,
|
|
4502
4639
|
typescript: hasTypeScript
|
|
@@ -4509,6 +4646,7 @@ async function moso(options, ...userConfigs) {
|
|
|
4509
4646
|
overrides: getOverrides(options, "javascript")
|
|
4510
4647
|
}),
|
|
4511
4648
|
node({
|
|
4649
|
+
files: [GLOB_SRC],
|
|
4512
4650
|
hasReact: Boolean(reactOptions),
|
|
4513
4651
|
lessOpinionated: options.lessOpinionated,
|
|
4514
4652
|
overrides: getOverrides(options, "node"),
|
|
@@ -4522,6 +4660,7 @@ async function moso(options, ...userConfigs) {
|
|
|
4522
4660
|
}),
|
|
4523
4661
|
regexp({ overrides: getOverrides(options, "regexp") }),
|
|
4524
4662
|
unicorn({
|
|
4663
|
+
files: [GLOB_SRC],
|
|
4525
4664
|
lessOpinionated: options.lessOpinionated,
|
|
4526
4665
|
overrides: getOverrides(options, "unicorn")
|
|
4527
4666
|
})
|
|
@@ -4532,12 +4671,26 @@ async function moso(options, ...userConfigs) {
|
|
|
4532
4671
|
overrides: getOverrides(options, "stylistic"),
|
|
4533
4672
|
typescript: hasTypeScript
|
|
4534
4673
|
}));
|
|
4674
|
+
if (baselineOptions !== false) mut_configs.push(baseline({
|
|
4675
|
+
...baselineOptions,
|
|
4676
|
+
...typescriptConfigOptions,
|
|
4677
|
+
files: [
|
|
4678
|
+
GLOB_JS,
|
|
4679
|
+
GLOB_JSX,
|
|
4680
|
+
...astroOptions === false ? [] : [GLOB_ASTRO]
|
|
4681
|
+
],
|
|
4682
|
+
filesTypeAware: [GLOB_TS, GLOB_TSX],
|
|
4683
|
+
overrides: getOverrides(options, "baseline"),
|
|
4684
|
+
projectRoot: projectRootOptions,
|
|
4685
|
+
typescript: hasTypeScript
|
|
4686
|
+
}));
|
|
4535
4687
|
if (astroOptions !== false) mut_configs.push(astro({
|
|
4536
4688
|
...typescriptConfigOptions,
|
|
4537
4689
|
files: [GLOB_ASTRO],
|
|
4538
4690
|
overrides: getOverrides(options, "astro"),
|
|
4539
4691
|
stylistic: stylisticOptions,
|
|
4540
|
-
typescript: hasTypeScript
|
|
4692
|
+
typescript: hasTypeScript,
|
|
4693
|
+
...resolveSubOptions(options, "astro")
|
|
4541
4694
|
}));
|
|
4542
4695
|
if (e18eOptions !== false) mut_configs.push(e18e({
|
|
4543
4696
|
...e18eOptions,
|
|
@@ -4547,14 +4700,14 @@ async function moso(options, ...userConfigs) {
|
|
|
4547
4700
|
overrides: getOverrides(options, "e18e")
|
|
4548
4701
|
}));
|
|
4549
4702
|
if (functionalEnforcement !== "none") mut_configs.push(functional({
|
|
4550
|
-
...typescriptConfigOptions,
|
|
4551
4703
|
...functionalConfigOptions,
|
|
4704
|
+
...typescriptConfigOptions,
|
|
4552
4705
|
mode: modeOptions,
|
|
4553
|
-
projectRoot: projectRootOptions,
|
|
4554
4706
|
overrides: getOverrides(options, "functional"),
|
|
4555
4707
|
stylistic: stylisticOptions
|
|
4556
4708
|
}));
|
|
4557
4709
|
if (jsdocOptions !== false) mut_configs.push(jsdoc({
|
|
4710
|
+
files: [GLOB_SRC],
|
|
4558
4711
|
overrides: getOverrides(options, "jsdoc"),
|
|
4559
4712
|
stylistic: stylisticOptions
|
|
4560
4713
|
}));
|
|
@@ -4579,17 +4732,10 @@ async function moso(options, ...userConfigs) {
|
|
|
4579
4732
|
mode: modeOptions,
|
|
4580
4733
|
overrides: getOverrides(options, "nextjs")
|
|
4581
4734
|
}));
|
|
4582
|
-
if (perfectionistOptions) mut_configs.push(perfectionist({
|
|
4583
|
-
lessOpinionated: options.lessOpinionated,
|
|
4584
|
-
overrides: getOverrides(options, "perfectionist")
|
|
4585
|
-
}));
|
|
4735
|
+
if (perfectionistOptions) mut_configs.push(perfectionist({ overrides: getOverrides(options, "perfectionist") }));
|
|
4586
4736
|
if (reactOptions !== false) mut_configs.push(react({
|
|
4587
4737
|
...typescriptConfigOptions,
|
|
4588
|
-
files: [
|
|
4589
|
-
GLOB_JSX,
|
|
4590
|
-
GLOB_TS,
|
|
4591
|
-
GLOB_TSX
|
|
4592
|
-
],
|
|
4738
|
+
files: [GLOB_SRC],
|
|
4593
4739
|
filesTypeAware: [
|
|
4594
4740
|
GLOB_DTS,
|
|
4595
4741
|
GLOB_JSX,
|
|
@@ -4606,6 +4752,7 @@ async function moso(options, ...userConfigs) {
|
|
|
4606
4752
|
...resolveSubOptions(options, "react")
|
|
4607
4753
|
}));
|
|
4608
4754
|
if (options.test !== false) mut_configs.push(test({
|
|
4755
|
+
...functionalConfigOptions,
|
|
4609
4756
|
files: GLOB_TESTS,
|
|
4610
4757
|
isInEditor,
|
|
4611
4758
|
overrides: getOverrides(options, "test")
|
|
@@ -4629,18 +4776,29 @@ async function moso(options, ...userConfigs) {
|
|
|
4629
4776
|
if (vueOptions !== false) mut_configs.push(vue({
|
|
4630
4777
|
...typescriptConfigOptions,
|
|
4631
4778
|
files: [GLOB_VUE],
|
|
4632
|
-
filesTypeAware: [
|
|
4633
|
-
GLOB_TS,
|
|
4634
|
-
GLOB_TSX,
|
|
4635
|
-
GLOB_VUE
|
|
4636
|
-
],
|
|
4637
4779
|
overrides: getOverrides(options, "vue"),
|
|
4638
|
-
projectRoot: projectRootOptions,
|
|
4639
4780
|
sfcBlocks: true,
|
|
4640
4781
|
stylistic: stylisticOptions,
|
|
4641
4782
|
typescript: hasTypeScript,
|
|
4642
4783
|
...resolveSubOptions(options, "vue")
|
|
4643
4784
|
}));
|
|
4785
|
+
if (tailwindOptions !== false) {
|
|
4786
|
+
const resolvedTailwind = tailwindOptions === true ? {} : tailwindOptions;
|
|
4787
|
+
const tailwindConfigOptions = "entryPoint" in resolvedTailwind ? {
|
|
4788
|
+
config: void 0,
|
|
4789
|
+
entryPoint: resolvedTailwind.entryPoint,
|
|
4790
|
+
version: resolvedTailwind.version ?? 4
|
|
4791
|
+
} : {
|
|
4792
|
+
config: resolvedTailwind.config ?? "tailwind.config.js",
|
|
4793
|
+
entryPoint: void 0,
|
|
4794
|
+
version: resolvedTailwind.version ?? 3
|
|
4795
|
+
};
|
|
4796
|
+
mut_configs.push(tailwind({
|
|
4797
|
+
...tailwindConfigOptions,
|
|
4798
|
+
overrides: getOverrides(options, "tailwind"),
|
|
4799
|
+
stylistic: stylisticOptions
|
|
4800
|
+
}));
|
|
4801
|
+
}
|
|
4644
4802
|
if (options.yaml !== false) mut_configs.push(yaml({
|
|
4645
4803
|
files: [GLOB_YAML],
|
|
4646
4804
|
overrides: getOverrides(options, "yaml"),
|
|
@@ -4658,14 +4816,12 @@ async function moso(options, ...userConfigs) {
|
|
|
4658
4816
|
//#endregion
|
|
4659
4817
|
//#region src/presets.ts
|
|
4660
4818
|
const full = {
|
|
4661
|
-
astro: true,
|
|
4819
|
+
astro: { a11y: true },
|
|
4820
|
+
baseline: true,
|
|
4662
4821
|
comments: true,
|
|
4663
4822
|
e18e: true,
|
|
4664
4823
|
functional: { functionalEnforcement: "lite" },
|
|
4665
|
-
ignores: {
|
|
4666
|
-
gitignore: true,
|
|
4667
|
-
userIgnores: false
|
|
4668
|
-
},
|
|
4824
|
+
ignores: { userIgnores: false },
|
|
4669
4825
|
imports: true,
|
|
4670
4826
|
jsdoc: true,
|
|
4671
4827
|
jsonc: true,
|
|
@@ -4673,14 +4829,20 @@ const full = {
|
|
|
4673
4829
|
nextjs: true,
|
|
4674
4830
|
node: true,
|
|
4675
4831
|
perfectionist: true,
|
|
4676
|
-
projectRoot: path.resolve(import.meta.dirname, ".."),
|
|
4677
4832
|
promise: true,
|
|
4678
|
-
react: {
|
|
4833
|
+
react: {
|
|
4834
|
+
a11y: true,
|
|
4835
|
+
reactRefresh: { allowConstantExport: true }
|
|
4836
|
+
},
|
|
4679
4837
|
regexp: true,
|
|
4680
4838
|
stylistic: true,
|
|
4839
|
+
tailwind: {
|
|
4840
|
+
entryPoint: "src/styles/app.css",
|
|
4841
|
+
version: 4
|
|
4842
|
+
},
|
|
4681
4843
|
test: true,
|
|
4682
4844
|
toml: true,
|
|
4683
|
-
typescript: { projectRoot:
|
|
4845
|
+
typescript: { projectRoot: path.resolve(import.meta.dirname, "..") },
|
|
4684
4846
|
unicorn: true,
|
|
4685
4847
|
vue: {
|
|
4686
4848
|
a11y: true,
|
|
@@ -4690,6 +4852,7 @@ const full = {
|
|
|
4690
4852
|
};
|
|
4691
4853
|
const off = {
|
|
4692
4854
|
astro: false,
|
|
4855
|
+
baseline: false,
|
|
4693
4856
|
comments: false,
|
|
4694
4857
|
e18e: false,
|
|
4695
4858
|
functional: false,
|
|
@@ -4698,6 +4861,7 @@ const off = {
|
|
|
4698
4861
|
jsdoc: false,
|
|
4699
4862
|
jsonc: false,
|
|
4700
4863
|
jsx: false,
|
|
4864
|
+
lessOpinionated: true,
|
|
4701
4865
|
nextjs: false,
|
|
4702
4866
|
node: false,
|
|
4703
4867
|
perfectionist: false,
|
|
@@ -4705,6 +4869,7 @@ const off = {
|
|
|
4705
4869
|
react: false,
|
|
4706
4870
|
regexp: false,
|
|
4707
4871
|
stylistic: false,
|
|
4872
|
+
tailwind: false,
|
|
4708
4873
|
test: false,
|
|
4709
4874
|
toml: false,
|
|
4710
4875
|
typescript: false,
|
|
@@ -4713,4 +4878,4 @@ const off = {
|
|
|
4713
4878
|
yaml: false
|
|
4714
4879
|
};
|
|
4715
4880
|
//#endregion
|
|
4716
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS, GLOB_CTS, GLOB_DTS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_MJS, GLOB_MTS, GLOB_POSTCSS, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, astro, checkFilePath, combine, comments, moso as default, moso, disables, e18e, full, functional, getOverrides, globalIgnores, ignores, imports, interopDefault, isInEditorEnv, javascript, jsdoc, jsonc, jsx,
|
|
4881
|
+
export { GLOB_AI, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS, GLOB_CSS_IN_JS, GLOB_CTS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_MJS, GLOB_MTS, GLOB_NODE_MODULES, GLOB_POSTCSS, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, astro, baseline, checkFilePath, combine, comments, moso as default, moso, disables, e18e, flattenRules, full, functional, getOverrides, globalIgnores, ignores, imports, interopDefault, isInEditorEnv, javascript, jsdoc, jsonc, jsx, memoize, nextjs, node, off, perfectionist, promise, react, regexp, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, tailwind, test, toml, typescript, unicorn, vue, vueInlineElements, yaml };
|