@moso/eslint-config 3.0.4 → 3.2.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 +164 -70
- package/dist/index.d.mts +3994 -663
- package/dist/index.mjs +1154 -965
- package/package.json +59 -51
package/dist/index.mjs
CHANGED
|
@@ -4,8 +4,24 @@ import assert from "node:assert/strict";
|
|
|
4
4
|
import { AST_NODE_TYPES, AST_TOKEN_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
5
5
|
import { isIdentifier } from "@typescript-eslint/utils/ast-utils";
|
|
6
6
|
import globals from "globals";
|
|
7
|
-
import path from "node:path";
|
|
8
7
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
8
|
+
//#region package.json
|
|
9
|
+
var peerDependenciesMeta = {
|
|
10
|
+
"@eslint-react/eslint-plugin": { "optional": true },
|
|
11
|
+
"@next/eslint-plugin-next": { "optional": true },
|
|
12
|
+
"astro-eslint-parser": { "optional": true },
|
|
13
|
+
"eslint-plugin-astro": { "optional": true },
|
|
14
|
+
"eslint-plugin-better-tailwindcss": { "optional": true },
|
|
15
|
+
"eslint-plugin-erasable-syntax-only": { "optional": true },
|
|
16
|
+
"eslint-plugin-jsx-a11y": { "optional": true },
|
|
17
|
+
"eslint-plugin-react-hooks": { "optional": true },
|
|
18
|
+
"eslint-plugin-react-refresh": { "optional": true },
|
|
19
|
+
"eslint-plugin-react-you-might-not-need-an-effect": { "optional": true },
|
|
20
|
+
"eslint-plugin-vue": { "optional": true },
|
|
21
|
+
"eslint-plugin-vuejs-accessibility": { "optional": true },
|
|
22
|
+
"typescript": { "optional": true }
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
9
25
|
//#region src/utils.ts
|
|
10
26
|
/**
|
|
11
27
|
* Resolve and flatten any mix of (awaitable) config items or arrays
|
|
@@ -32,10 +48,23 @@ const checkFilePath = (path) => {
|
|
|
32
48
|
if (path.trim() !== path) throw new Error("FilePath cannot have leading/trailing whitespace");
|
|
33
49
|
return path;
|
|
34
50
|
};
|
|
35
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Merge the `rules` of a shared flat-config array into a single rule map.
|
|
53
|
+
*
|
|
54
|
+
* Plugins ship their presets as an array (a setup item, then one item per rule layer),
|
|
55
|
+
* this keeps only the rules so they can be spread into a config item
|
|
56
|
+
* that declares its own `files`, `plugins`, and parser.
|
|
57
|
+
*
|
|
58
|
+
* @param configs - A plugin's exported flat config array.
|
|
59
|
+
* @returns Every config's rules merged in order.
|
|
60
|
+
*/
|
|
61
|
+
const flattenRules = (configs) => configs.reduce((acc, config) => Object.assign(acc, config.rules), {});
|
|
62
|
+
/**
|
|
63
|
+
* Auto-numbering for unnamed `globalIgnores` items.
|
|
64
|
+
*/
|
|
36
65
|
const nextGlobalIgnoresName = (() => {
|
|
37
|
-
|
|
38
|
-
return () => `globalIgnores ${
|
|
66
|
+
const mut_counter = { count: 0 };
|
|
67
|
+
return () => `globalIgnores ${String(mut_counter.count++)}`;
|
|
39
68
|
})();
|
|
40
69
|
/**
|
|
41
70
|
* Build a global-ignores config item (an item with only `ignores`,
|
|
@@ -57,8 +86,8 @@ const globalIgnores = (ignorePatterns, name) => {
|
|
|
57
86
|
/**
|
|
58
87
|
* Await a value and unwrap its `default` export when present.
|
|
59
88
|
*
|
|
60
|
-
* Smooths over the CJS/ESM interop difference where `import()` of a CJS
|
|
61
|
-
*
|
|
89
|
+
* Smooths over the CJS/ESM interop difference where `import()` of a CJS module
|
|
90
|
+
* yields `{ default: ... }` while an ESM module may not.
|
|
62
91
|
*
|
|
63
92
|
* @param value - A module (or promise of one) whose default export should be unwrapped.
|
|
64
93
|
* @returns The default export when one exists, otherwise the resolved value itself.
|
|
@@ -67,7 +96,9 @@ const interopDefault = async (value) => {
|
|
|
67
96
|
const resolved = await value;
|
|
68
97
|
return resolved.default ?? resolved;
|
|
69
98
|
};
|
|
70
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Whether ESLint is running from a git hook or lint-staged rather than an editor.
|
|
101
|
+
*/
|
|
71
102
|
const isInGitHooksOrLintStaged = () => Boolean(process.env.GIT_PARAMS) || Boolean(process.env.VSCODE_GIT_COMMAND) || Boolean(process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
72
103
|
/**
|
|
73
104
|
* Detect whether ESLint is running inside an editor/IDE integration.
|
|
@@ -84,14 +115,14 @@ const isInEditorEnv = () => {
|
|
|
84
115
|
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
116
|
};
|
|
86
117
|
/**
|
|
87
|
-
* Normalize a factory option that accepts `boolean | string | object`
|
|
118
|
+
* Normalize a factory option that accepts `boolean | string | number | object`
|
|
88
119
|
* down to its object form.
|
|
89
120
|
*
|
|
90
121
|
* @param options - The full factory options object.
|
|
91
122
|
* @param key - The option key to resolve.
|
|
92
|
-
* @returns The option's object form; `{}` when the option was a boolean, string, or absent.
|
|
123
|
+
* @returns The option's object form; `{}` when the option was a boolean, string, number, or absent.
|
|
93
124
|
*/
|
|
94
|
-
const resolveSubOptions = (options, key) => typeof options[key] === "
|
|
125
|
+
const resolveSubOptions = (options, key) => typeof options[key] === "object" ? options[key] : {};
|
|
95
126
|
/**
|
|
96
127
|
* Extract the `overrides` rule map from a factory option, regardless of
|
|
97
128
|
* whether the option was given as a boolean, string, or object.
|
|
@@ -104,46 +135,6 @@ const getOverrides = (options, key) => {
|
|
|
104
135
|
const sub = resolveSubOptions(options, key);
|
|
105
136
|
return ("overrides" in sub ? sub.overrides : {}) ?? {};
|
|
106
137
|
};
|
|
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
138
|
/**
|
|
148
139
|
* Return one shared instance per plugin key, registering `plugin` on first use.
|
|
149
140
|
*
|
|
@@ -153,10 +144,11 @@ const loadPackages = async (packageIds) => {
|
|
|
153
144
|
* with different references. Stored realm-wide on `globalThis` so duplicated
|
|
154
145
|
* copies of this package still share one store.
|
|
155
146
|
*
|
|
147
|
+
* @see https://github.com/SukkaW/eslint-config-sukka/blob/master/packages/shared/src/memoize-eslint-plugin.ts
|
|
148
|
+
*
|
|
156
149
|
* @param plugin - The plugin instance to register when the key is unseen.
|
|
157
150
|
* @param key - Stable identifier; must be identical everywhere the same package is registered.
|
|
158
151
|
* @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
152
|
*/
|
|
161
153
|
const memoize = (plugin, key) => {
|
|
162
154
|
globalThis.__ESLINT_PLUGIN_MEMO__ ??= /* @__PURE__ */ new Map();
|
|
@@ -215,71 +207,151 @@ const vueInlineElements = [
|
|
|
215
207
|
"video"
|
|
216
208
|
];
|
|
217
209
|
//#endregion
|
|
210
|
+
//#region src/tools.ts
|
|
211
|
+
const scopeURL = import.meta.dirname;
|
|
212
|
+
/**
|
|
213
|
+
* The optional peer dependencies in a self-maintained list.
|
|
214
|
+
*/
|
|
215
|
+
const optionalPeers = new Set(Object.keys(peerDependenciesMeta));
|
|
216
|
+
/**
|
|
217
|
+
* Whether `name` resolves from this package's own directory (not the user's cwd).
|
|
218
|
+
*/
|
|
219
|
+
const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeURL] });
|
|
220
|
+
/**
|
|
221
|
+
* Whether an install prompt could ever be shown: a TTY outside CI.
|
|
222
|
+
*/
|
|
223
|
+
const isInteractive = () => {
|
|
224
|
+
if (Boolean(process.env.CI)) return false;
|
|
225
|
+
return process.stdout.isTTY;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Offer to install missing packages through an interactive prompt.
|
|
229
|
+
* Only called from `loadPackages` after it has verified the session is interactive,
|
|
230
|
+
* and the packages are genuinely missing.
|
|
231
|
+
*
|
|
232
|
+
* @param missingPackages - Package names to offer for installation.
|
|
233
|
+
*/
|
|
234
|
+
const ensurePackages = async (missingPackages) => {
|
|
235
|
+
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) {
|
|
236
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
237
|
+
await installPackage([...missingPackages], { dev: true });
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Dynamically import a list of packages, unwrapping default exports.
|
|
242
|
+
*
|
|
243
|
+
* In interactive sessions, missing packages trigger an install prompt first.
|
|
244
|
+
* The package-name literals are mapped to module types through `PackageTypes`,
|
|
245
|
+
* so call sites destructure a fully typed tuple without casts:
|
|
246
|
+
* `const [plugin] = await loadPackages(['pkg'])`.
|
|
247
|
+
*
|
|
248
|
+
* @param packageIds - Package names to import, in order.
|
|
249
|
+
* @returns The imported modules (default exports unwrapped), in input order.
|
|
250
|
+
*/
|
|
251
|
+
const loadPackages = async (packageIds) => {
|
|
252
|
+
if (isInteractive()) {
|
|
253
|
+
const missing = packageIds.filter((id) => optionalPeers.has(id) && !isPackageInScope(id));
|
|
254
|
+
if (missing.length > 0) await ensurePackages(missing);
|
|
255
|
+
}
|
|
256
|
+
return Promise.all(packageIds.map(async (id) => interopDefault(import(id))));
|
|
257
|
+
};
|
|
258
|
+
//#endregion
|
|
218
259
|
//#region src/configs/astro.ts
|
|
219
260
|
const astro = async (options) => {
|
|
220
261
|
const { a11y, files, lessOpinionated, overrides, overridesA11y, parserOptions, stylistic, typescript } = options;
|
|
221
|
-
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
222
262
|
const stylisticEnabled = stylistic !== false;
|
|
223
|
-
const [typescriptParser] = typescript ? await loadPackages(["@typescript-eslint/parser"]) : [void 0];
|
|
224
263
|
const [astroParser, astroPlugin] = await loadPackages(["astro-eslint-parser", "eslint-plugin-astro"]);
|
|
264
|
+
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
265
|
+
const [typescriptParser] = typescript ? await loadPackages(["@typescript-eslint/parser"]) : [void 0];
|
|
225
266
|
const { projectService, ...typeAwareParserOptions } = parserOptions ?? {};
|
|
226
|
-
|
|
267
|
+
return [{
|
|
268
|
+
name: "moso/astro/setup",
|
|
269
|
+
plugins: {
|
|
270
|
+
"astro": memoize(astroPlugin, "eslint-plugin-astro"),
|
|
271
|
+
...jsxA11yPlugin && { "jsx-a11y": memoize(jsxA11yPlugin, "eslint-plugin-jsx-a11y") }
|
|
272
|
+
}
|
|
273
|
+
}, {
|
|
274
|
+
name: "moso/astro/rules",
|
|
275
|
+
files,
|
|
276
|
+
languageOptions: {
|
|
277
|
+
globals: { ...astroPlugin.environments.astro.globals },
|
|
278
|
+
parser: memoize(astroParser, "astro-eslint-parser"),
|
|
279
|
+
parserOptions: {
|
|
280
|
+
extraFileExtensions: [".astro"],
|
|
281
|
+
parser: typescript ? typescriptParser : void 0,
|
|
282
|
+
...typescript && {
|
|
283
|
+
...typeAwareParserOptions,
|
|
284
|
+
...Boolean(projectService) && { project: true }
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
sourceType: "module"
|
|
288
|
+
},
|
|
289
|
+
processor: "astro/client-side-ts",
|
|
290
|
+
rules: {
|
|
291
|
+
"@moso/no-top-level-await": "off",
|
|
292
|
+
"node/no-top-level-await": "off",
|
|
293
|
+
"unicorn/no-await-expression-member": "off",
|
|
294
|
+
...flattenRules(astroPlugin.configs.recommended),
|
|
295
|
+
...!lessOpinionated && {
|
|
296
|
+
"astro/no-set-html-directive": "error",
|
|
297
|
+
"astro/no-set-text-directive": "error",
|
|
298
|
+
"astro/no-unsafe-inline-scripts": "error",
|
|
299
|
+
...stylisticEnabled && {
|
|
300
|
+
"astro/prefer-class-list-directive": "error",
|
|
301
|
+
"astro/prefer-object-class-list": "error",
|
|
302
|
+
"astro/prefer-split-class-list": "error",
|
|
303
|
+
"astro/sort-attributes": "off"
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
...stylisticEnabled && {
|
|
307
|
+
"@stylistic/indent": "off",
|
|
308
|
+
"@stylistic/jsx-closing-tag-location": "off",
|
|
309
|
+
"@stylistic/jsx-one-expression-per-line": "off",
|
|
310
|
+
"@stylistic/no-multiple-empty-lines": "off",
|
|
311
|
+
"astro/semi": ["error", stylistic.semi ? "always" : "never"]
|
|
312
|
+
},
|
|
313
|
+
...jsxA11yPlugin && {
|
|
314
|
+
...flattenRules(astroPlugin.configs[lessOpinionated ? "jsx-a11y-recommended" : "jsx-a11y-strict"]),
|
|
315
|
+
...overridesA11y
|
|
316
|
+
},
|
|
317
|
+
...overrides
|
|
318
|
+
}
|
|
319
|
+
}];
|
|
320
|
+
};
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region src/configs/baseline.ts
|
|
323
|
+
const defaultIgnoreFeatures = ["functions-caller-arguments"];
|
|
324
|
+
const baseline = async (options) => {
|
|
325
|
+
const { baseline, files, filesTypeAware, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
|
|
326
|
+
const isTypeAware = typescript && typeof projectRoot === "string" && parserOptions?.projectService !== false;
|
|
327
|
+
const [baselinePlugin] = await loadPackages(["eslint-plugin-baseline-js"]);
|
|
328
|
+
const baselineRule = (typeAware) => ({ "baseline-js/use-baseline": ["warn", {
|
|
329
|
+
available: baseline ?? "widely",
|
|
330
|
+
ignoreFeatures: [...defaultIgnoreFeatures, ...ignoreFeatures ?? []],
|
|
331
|
+
ignoreNodeTypes,
|
|
332
|
+
includeJsBuiltins: { preset: typeAware ? "type-aware" : "auto" },
|
|
333
|
+
includeWebApis: { preset: typeAware ? "type-aware" : "auto" }
|
|
334
|
+
}] });
|
|
227
335
|
return [
|
|
228
336
|
{
|
|
229
|
-
name: "moso/
|
|
230
|
-
|
|
231
|
-
languageOptions: {
|
|
232
|
-
globals: { ...astroPlugin.environments.astro.globals },
|
|
233
|
-
parser: memoize(astroParser, "astro-eslint-parser"),
|
|
234
|
-
parserOptions: {
|
|
235
|
-
extraFileExtensions: [".astro"],
|
|
236
|
-
parser: typescript ? typescriptParser : void 0,
|
|
237
|
-
...typescript && {
|
|
238
|
-
...typeAwareParserOptions,
|
|
239
|
-
...Boolean(projectService) && { project: true }
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
sourceType: "module"
|
|
243
|
-
},
|
|
244
|
-
processor: "astro/client-side-ts",
|
|
245
|
-
plugins: { "astro": memoize(astroPlugin, "eslint-plugin-astro") }
|
|
337
|
+
name: "moso/baseline/setup",
|
|
338
|
+
plugins: { "baseline-js": memoize(baselinePlugin, "eslint-plugin-baseline-js") }
|
|
246
339
|
},
|
|
247
340
|
{
|
|
248
|
-
name: "moso/
|
|
249
|
-
files,
|
|
341
|
+
name: "moso/baseline/rules",
|
|
342
|
+
files: isTypeAware ? files : [...files, ...filesTypeAware ?? []],
|
|
250
343
|
rules: {
|
|
251
|
-
|
|
252
|
-
"node/no-top-level-await": "off",
|
|
253
|
-
"unicorn/no-await-expression-member": "off",
|
|
254
|
-
...flattenRules(astroPlugin.configs.recommended),
|
|
255
|
-
...!lessOpinionated && {
|
|
256
|
-
"astro/no-set-html-directive": "error",
|
|
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
|
-
},
|
|
266
|
-
...stylisticEnabled && {
|
|
267
|
-
"@stylistic/indent": "off",
|
|
268
|
-
"@stylistic/jsx-closing-tag-location": "off",
|
|
269
|
-
"@stylistic/jsx-one-expression-per-line": "off",
|
|
270
|
-
"@stylistic/no-multiple-empty-lines": "off",
|
|
271
|
-
"astro/semi": ["error", stylistic.semi ? "always" : "never"]
|
|
272
|
-
},
|
|
344
|
+
...baselineRule(false),
|
|
273
345
|
...overrides
|
|
274
346
|
}
|
|
275
347
|
},
|
|
276
|
-
...
|
|
277
|
-
name: "moso/
|
|
278
|
-
files,
|
|
279
|
-
|
|
348
|
+
...isTypeAware ? [{
|
|
349
|
+
name: "moso/baseline/type-aware-rules",
|
|
350
|
+
files: filesTypeAware,
|
|
351
|
+
ignores: ignoresTypeAware ?? [],
|
|
280
352
|
rules: {
|
|
281
|
-
...
|
|
282
|
-
...
|
|
353
|
+
...baselineRule(true),
|
|
354
|
+
...overridesTypeAware
|
|
283
355
|
}
|
|
284
356
|
}] : []
|
|
285
357
|
];
|
|
@@ -293,33 +365,25 @@ const GLOB_JSX = "**/*.?([cm])jsx";
|
|
|
293
365
|
const GLOB_TS = "**/*.?([cm])ts";
|
|
294
366
|
const GLOB_TSX = "**/*.?([cm])tsx";
|
|
295
367
|
const GLOB_DTS = "**/?(.)*.d.?([cm])ts";
|
|
296
|
-
const GLOB_ROOT_JS = "
|
|
297
|
-
const GLOB_ROOT_JSX = "
|
|
298
|
-
const GLOB_ROOT_TS = "
|
|
299
|
-
const GLOB_ROOT_TSX = "
|
|
300
|
-
const GLOB_ROOT_DTS = "
|
|
368
|
+
const GLOB_ROOT_JS = "?(.)*.?([cm])js";
|
|
369
|
+
const GLOB_ROOT_JSX = "?(.)*.?([cm])jsx";
|
|
370
|
+
const GLOB_ROOT_TS = "?(.)*.?([cm])ts";
|
|
371
|
+
const GLOB_ROOT_TSX = "?(.)*.?([cm])tsx";
|
|
372
|
+
const GLOB_ROOT_DTS = "?(.)*.d.?([cm])ts";
|
|
301
373
|
const GLOB_MJS = "**/*.mjs";
|
|
302
|
-
const GLOB_MTS = "**/*.mts";
|
|
303
374
|
const GLOB_CJS = "**/*.cjs";
|
|
304
|
-
const
|
|
305
|
-
const GLOB_STYLE = "**/?(.)*.{c,le,sc,pc,postc}ss";
|
|
306
|
-
const
|
|
307
|
-
const GLOB_POSTCSS = "**/?(.)*.{p,post}css";
|
|
308
|
-
const GLOB_LESS = "**/?(.)*.less";
|
|
309
|
-
const GLOB_SCSS = "**/?(.)*.scss";
|
|
375
|
+
const GLOB_TYPINGS = "typings/**/?(.)*.?([cm])ts";
|
|
376
|
+
const GLOB_STYLE = "**/?(.)*.{c,le,sa,sc,pc,postc}ss";
|
|
377
|
+
const GLOB_CSS_IN_JS = "**/*.css.{j,t}s";
|
|
310
378
|
const GLOB_JSON = "**/*.json";
|
|
311
379
|
const GLOB_JSON5 = "**/*.json5";
|
|
312
380
|
const GLOB_JSONC = "**/*.jsonc";
|
|
313
381
|
const GLOB_ASTRO = "**/*.astro";
|
|
314
382
|
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
315
|
-
const GLOB_HTML = "**/*.htm?(l)";
|
|
316
383
|
const GLOB_MARKDOWN = "**/*.md";
|
|
317
|
-
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
318
|
-
const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
319
384
|
const GLOB_TOML = "**/*.toml";
|
|
320
385
|
const GLOB_VUE = "**/*.vue";
|
|
321
386
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
322
|
-
const GLOB_TYPINGS = "typings/**/?(.)*.?([cm])ts";
|
|
323
387
|
const GLOB_TESTS = [
|
|
324
388
|
`**/__tests__/**/?(.)*.${GLOB_SRC_EXT}`,
|
|
325
389
|
`**/?(.)*.spec.${GLOB_SRC_EXT}`,
|
|
@@ -327,60 +391,72 @@ const GLOB_TESTS = [
|
|
|
327
391
|
`**/?(.)*.bench.${GLOB_SRC_EXT}`,
|
|
328
392
|
`**/?(.)*.benchmark.${GLOB_SRC_EXT}`
|
|
329
393
|
];
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
394
|
+
const GLOB_NODE_MODULES = "**/node_modules";
|
|
395
|
+
const GLOB_DIST = "**/dist";
|
|
396
|
+
const GLOB_LOCKFILE = [
|
|
397
|
+
"**/package-lock.json",
|
|
398
|
+
"**/bun.lock?(b)",
|
|
399
|
+
"**/pnpm-lock.yaml",
|
|
400
|
+
"**/yarn.lock"
|
|
401
|
+
];
|
|
402
|
+
const GLOB_AI = [
|
|
403
|
+
"**/.agents",
|
|
404
|
+
"**/.claude",
|
|
405
|
+
"**/.context",
|
|
406
|
+
"**/.*/skills"
|
|
339
407
|
];
|
|
340
408
|
const GLOB_EXCLUDE = [
|
|
341
|
-
|
|
342
|
-
|
|
409
|
+
GLOB_NODE_MODULES,
|
|
410
|
+
GLOB_DIST,
|
|
411
|
+
...GLOB_LOCKFILE,
|
|
412
|
+
"**/fixtures",
|
|
343
413
|
"**/lib",
|
|
344
|
-
"**/package-lock.json",
|
|
345
|
-
"**/yarn.lock",
|
|
346
|
-
"**/pnpm-lock.yaml",
|
|
347
|
-
"**/bun.lockb",
|
|
348
|
-
"**/bun.lock",
|
|
349
414
|
"**/output",
|
|
350
415
|
"**/coverage",
|
|
351
416
|
"**/temp",
|
|
352
|
-
"**/.temp",
|
|
353
417
|
"**/tmp",
|
|
354
|
-
"**/.
|
|
355
|
-
"**/.history",
|
|
356
|
-
"**/.vitepress/cache",
|
|
357
|
-
"**/.nuxt",
|
|
358
|
-
"**/.next",
|
|
359
|
-
"**/.vercel",
|
|
418
|
+
"**/.cache",
|
|
360
419
|
"**/.changeset",
|
|
420
|
+
"**/.history",
|
|
361
421
|
"**/.idea",
|
|
362
|
-
"**/.
|
|
422
|
+
"**/.next",
|
|
423
|
+
"**/.nitro",
|
|
424
|
+
"**/.nuxt",
|
|
363
425
|
"**/.output",
|
|
426
|
+
"**/.temp",
|
|
427
|
+
"**/.tmp",
|
|
428
|
+
"**/.vercel",
|
|
364
429
|
"**/.vite-inspect",
|
|
430
|
+
"**/.vitepress/cache",
|
|
365
431
|
"**/.yarn",
|
|
366
|
-
"**/vite.config.*.timestamp-*",
|
|
367
432
|
"**/CHANGELOG*.md",
|
|
368
|
-
"
|
|
433
|
+
"**/?(.)*.min.*",
|
|
369
434
|
"**/LICENSE*",
|
|
370
435
|
"**/__snapshots__",
|
|
371
|
-
"**/auto-import?(s).ts",
|
|
372
|
-
"**/
|
|
373
|
-
"**/
|
|
374
|
-
"**/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
"**/*.css.ts"
|
|
436
|
+
"**/auto-import?(s)?(.d).ts",
|
|
437
|
+
"**/components?(.d).ts",
|
|
438
|
+
"**/typegen?(.d).ts",
|
|
439
|
+
"**/vite.config.*.timestamp-*",
|
|
440
|
+
GLOB_CSS_IN_JS,
|
|
441
|
+
...GLOB_AI
|
|
378
442
|
];
|
|
379
443
|
//#endregion
|
|
380
444
|
//#region src/configs/disables.ts
|
|
381
|
-
const disables = async () => {
|
|
382
|
-
const [functionalPlugin] = await loadPackages(["eslint-plugin-functional"]);
|
|
445
|
+
const disables = async (functionalEnabled = false) => {
|
|
446
|
+
const [functionalPlugin] = functionalEnabled ? await loadPackages(["eslint-plugin-functional"]) : [void 0];
|
|
383
447
|
return [
|
|
448
|
+
{
|
|
449
|
+
name: "moso/disables/allow-default-export",
|
|
450
|
+
files: [
|
|
451
|
+
`**/config*.${GLOB_SRC_EXT}`,
|
|
452
|
+
`**/{api,helpers,middleware,modules,pages,plugins,routes,views}/${GLOB_SRC}`,
|
|
453
|
+
`**/{esbuild,farm,index,next,nuxt,rolldown,rollup,rspack,vite,webpack}.${GLOB_SRC_EXT}`,
|
|
454
|
+
`${GLOB_MARKDOWN}/**`,
|
|
455
|
+
"**/*.d.ts",
|
|
456
|
+
"**/.prettierrc"
|
|
457
|
+
],
|
|
458
|
+
rules: { "import-lite/no-default-export": "off" }
|
|
459
|
+
},
|
|
384
460
|
{
|
|
385
461
|
name: "moso/disables/bin",
|
|
386
462
|
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
@@ -399,12 +475,18 @@ const disables = async () => {
|
|
|
399
475
|
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
400
476
|
rules: {
|
|
401
477
|
"@moso/no-top-level-await": "off",
|
|
478
|
+
"baseline-js/use-baseline": "off",
|
|
402
479
|
"no-console": "off"
|
|
403
480
|
}
|
|
404
481
|
},
|
|
482
|
+
{
|
|
483
|
+
name: "moso/disables/components",
|
|
484
|
+
files: [GLOB_JSX, GLOB_TSX],
|
|
485
|
+
rules: { "unicorn/no-anonymous-default-export": "off" }
|
|
486
|
+
},
|
|
405
487
|
{
|
|
406
488
|
name: "moso/disables/config-files",
|
|
407
|
-
files: [`**/*.config.${GLOB_SRC_EXT}`,
|
|
489
|
+
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/{esbuild,farm,index,next,nuxt,rolldown,rollup,rspack,vite,webpack}.${GLOB_SRC_EXT}`],
|
|
408
490
|
rules: {
|
|
409
491
|
"@moso/no-top-level-await": "off",
|
|
410
492
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
@@ -415,17 +497,51 @@ const disables = async () => {
|
|
|
415
497
|
name: "moso/disables/dts",
|
|
416
498
|
files: ["**/*.d.?([cm])ts"],
|
|
417
499
|
rules: {
|
|
500
|
+
"no-restricted-syntax": "off",
|
|
418
501
|
"@eslint-community/eslint-comments/no-unlimited-disable": "off",
|
|
419
502
|
"import-lite/no-duplicates": "off",
|
|
420
|
-
"unused-imports/no-unused-vars": "off"
|
|
421
|
-
|
|
503
|
+
"unused-imports/no-unused-vars": "off"
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
name: "moso/disables/github",
|
|
508
|
+
files: ["**/ISSUE_TEMPLATE/**"],
|
|
509
|
+
rules: { "unicorn/filename-case": "off" }
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
name: "moso/disables/node-frameworks",
|
|
513
|
+
files: [
|
|
514
|
+
GLOB_ASTRO,
|
|
515
|
+
GLOB_ASTRO_TS,
|
|
516
|
+
GLOB_DTS,
|
|
517
|
+
GLOB_JSX,
|
|
518
|
+
GLOB_TS,
|
|
519
|
+
GLOB_TSX,
|
|
520
|
+
GLOB_VUE
|
|
521
|
+
],
|
|
522
|
+
rules: {
|
|
523
|
+
"node/no-extraneous-import": "off",
|
|
524
|
+
"node/no-missing-import": "off",
|
|
525
|
+
"node/no-restricted-import": "off"
|
|
422
526
|
}
|
|
423
527
|
},
|
|
528
|
+
{
|
|
529
|
+
name: "moso/disables/node-typescript",
|
|
530
|
+
files: [
|
|
531
|
+
GLOB_DTS,
|
|
532
|
+
GLOB_MJS,
|
|
533
|
+
GLOB_TS,
|
|
534
|
+
GLOB_TSX
|
|
535
|
+
],
|
|
536
|
+
rules: { "node/no-unsupported-features/es-syntax": "off" }
|
|
537
|
+
},
|
|
424
538
|
{
|
|
425
539
|
name: "moso/disables/scripts",
|
|
426
540
|
files: [`**/scripts/${GLOB_SRC}`],
|
|
427
541
|
rules: {
|
|
428
542
|
"@moso/no-top-level-await": "off",
|
|
543
|
+
"baseline-js/use-baseline": "off",
|
|
544
|
+
"no-console": "off",
|
|
429
545
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
430
546
|
"functional/no-conditional-statements": "off",
|
|
431
547
|
"functional/no-expression-statements": "off",
|
|
@@ -433,15 +549,40 @@ const disables = async () => {
|
|
|
433
549
|
"functional/no-return-void": "off",
|
|
434
550
|
"functional/no-throw-statements": "off",
|
|
435
551
|
"node/no-sync": "off",
|
|
436
|
-
"node/no-unpublished-import": "off"
|
|
437
|
-
|
|
552
|
+
"node/no-unpublished-import": "off"
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
name: "moso/disables/tests",
|
|
557
|
+
files: GLOB_TESTS,
|
|
558
|
+
rules: {
|
|
559
|
+
"@moso/no-top-level-await": "off",
|
|
560
|
+
"baseline-js/use-baseline": "off",
|
|
561
|
+
"e18e/prefer-static-regex": "off",
|
|
562
|
+
"no-unused-expressions": "off",
|
|
563
|
+
"jsdoc/require-jsdoc": "off",
|
|
564
|
+
"node/no-sync": "off",
|
|
565
|
+
"node/prefer-global/process": "off",
|
|
566
|
+
"regexp/no-super-linear-backtracking": "off",
|
|
567
|
+
"unicorn/consistent-function-scoping": "off",
|
|
568
|
+
"unicorn/prefer-module": "off",
|
|
569
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
570
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
571
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
572
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
573
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
574
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
575
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
576
|
+
"@typescript-eslint/no-unused-expressions": "off",
|
|
577
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
578
|
+
"@typescript-eslint/strict-boolean-expressions": "off"
|
|
438
579
|
}
|
|
439
580
|
},
|
|
440
581
|
{
|
|
441
582
|
name: "moso/disables/typings",
|
|
442
583
|
files: [GLOB_TYPINGS],
|
|
443
584
|
rules: {
|
|
444
|
-
...(assert.ok(!Array.isArray(functionalPlugin.configs.off)), functionalPlugin.configs.off.rules),
|
|
585
|
+
...functionalPlugin !== void 0 && (assert.ok(!Array.isArray(functionalPlugin.configs.off)), functionalPlugin.configs.off.rules),
|
|
445
586
|
"jsdoc/check-examples": "off",
|
|
446
587
|
"jsdoc/check-indentation": "off",
|
|
447
588
|
"jsdoc/check-line-alignment": "off",
|
|
@@ -487,20 +628,16 @@ const e18e = async (options) => {
|
|
|
487
628
|
const { isInEditor, lessOpinionated, mode, modernization, moduleReplacements, overrides, performanceImprovements } = options;
|
|
488
629
|
const [e18ePlugin] = await loadPackages(["@e18e/eslint-plugin"]);
|
|
489
630
|
const enableModernization = modernization !== false;
|
|
490
|
-
const enableModuleReplacements = moduleReplacements
|
|
631
|
+
const enableModuleReplacements = moduleReplacements ?? (mode === "library" && isInEditor === true);
|
|
491
632
|
const enablePerformanceImprovements = performanceImprovements !== false;
|
|
492
633
|
return [{
|
|
493
634
|
name: "moso/e18e/rules",
|
|
494
|
-
files: [
|
|
495
|
-
GLOB_SRC,
|
|
496
|
-
GLOB_ASTRO,
|
|
497
|
-
GLOB_VUE
|
|
498
|
-
],
|
|
499
635
|
plugins: { "e18e": memoize(e18ePlugin, "@e18e/eslint-plugin") },
|
|
500
636
|
rules: {
|
|
501
637
|
...enableModernization && { ...(assert.ok(!Array.isArray(e18ePlugin.configs.modernization)), e18ePlugin.configs.modernization.rules) },
|
|
502
638
|
...enableModuleReplacements && { ...(assert.ok(!Array.isArray(e18ePlugin.configs.moduleReplacements)), e18ePlugin.configs.moduleReplacements.rules) },
|
|
503
639
|
...enablePerformanceImprovements && { ...(assert.ok(!Array.isArray(e18ePlugin.configs.performanceImprovements)), e18ePlugin.configs.performanceImprovements.rules) },
|
|
640
|
+
...mode === "library" && { "e18e/prefer-static-regex": "off" },
|
|
504
641
|
...lessOpinionated && {
|
|
505
642
|
"e18e/prefer-array-at": "off",
|
|
506
643
|
"e18e/prefer-array-from-map": "off",
|
|
@@ -511,28 +648,15 @@ const e18e = async (options) => {
|
|
|
511
648
|
},
|
|
512
649
|
...overrides
|
|
513
650
|
}
|
|
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
|
-
}]];
|
|
651
|
+
}];
|
|
523
652
|
};
|
|
524
653
|
//#endregion
|
|
525
654
|
//#region src/configs/eslint-comments.ts
|
|
526
|
-
const comments = async (options
|
|
655
|
+
const comments = async (options) => {
|
|
527
656
|
const { overrides } = options;
|
|
528
657
|
const [eslintComments] = await loadPackages(["@eslint-community/eslint-plugin-eslint-comments"]);
|
|
529
658
|
return [{
|
|
530
659
|
name: "moso/eslint-comments",
|
|
531
|
-
files: [
|
|
532
|
-
GLOB_SRC,
|
|
533
|
-
GLOB_ASTRO,
|
|
534
|
-
GLOB_VUE
|
|
535
|
-
],
|
|
536
660
|
plugins: { "@eslint-community/eslint-comments": memoize(eslintComments, "@eslint-community/eslint-comments") },
|
|
537
661
|
rules: {
|
|
538
662
|
...(assert.ok(!Array.isArray(eslintComments.configs?.recommended)), eslintComments.configs?.recommended.rules),
|
|
@@ -544,10 +668,9 @@ const comments = async (options = {}) => {
|
|
|
544
668
|
//#endregion
|
|
545
669
|
//#region src/configs/functional.ts
|
|
546
670
|
const functional = async (options) => {
|
|
547
|
-
const { functionalEnforcement, ignoreNamePattern, mode, overrides,
|
|
671
|
+
const { filesTypeAware, functionalEnforcement, ignoreNamePattern, mode, overrides, stylistic } = options;
|
|
548
672
|
const [functionalPlugin] = await loadPackages(["eslint-plugin-functional"]);
|
|
549
673
|
const stylisticEnabled = stylistic !== false;
|
|
550
|
-
const isTypeAware = typeof projectRoot === "string";
|
|
551
674
|
const commonRules = {
|
|
552
675
|
"functional/functional-parameters": ["error", {
|
|
553
676
|
allowRestParameter: true,
|
|
@@ -620,12 +743,6 @@ const functional = async (options) => {
|
|
|
620
743
|
};
|
|
621
744
|
return [{
|
|
622
745
|
name: "moso/functional",
|
|
623
|
-
files: [
|
|
624
|
-
GLOB_SRC,
|
|
625
|
-
GLOB_ASTRO,
|
|
626
|
-
GLOB_VUE
|
|
627
|
-
],
|
|
628
|
-
plugins: { "functional": memoize(functionalPlugin, "eslint-plugin-functional") },
|
|
629
746
|
settings: { immutability: { overrides: [
|
|
630
747
|
{
|
|
631
748
|
type: "^Readonly<.+>$",
|
|
@@ -640,18 +757,15 @@ const functional = async (options) => {
|
|
|
640
757
|
to: "Immutable"
|
|
641
758
|
}
|
|
642
759
|
] } },
|
|
760
|
+
plugins: { "functional": memoize(functionalPlugin, "eslint-plugin-functional") },
|
|
643
761
|
rules: {
|
|
644
762
|
...(assert.ok(!Array.isArray(functionalPlugin.configs.off)), functionalPlugin.configs.off.rules),
|
|
645
763
|
...functionalEnforcement === "lite" ? liteRules : functionalEnforcement === "strict" ? strictRules : recommendedRules,
|
|
646
764
|
...overrides
|
|
647
765
|
}
|
|
648
|
-
},
|
|
766
|
+
}, {
|
|
649
767
|
name: "moso/functional/disable-type-aware",
|
|
650
|
-
|
|
651
|
-
GLOB_SRC,
|
|
652
|
-
GLOB_ASTRO,
|
|
653
|
-
GLOB_VUE
|
|
654
|
-
],
|
|
768
|
+
ignores: filesTypeAware,
|
|
655
769
|
rules: {
|
|
656
770
|
...(assert.ok(!Array.isArray(functionalPlugin.configs.disableTypeChecked)), functionalPlugin.configs.disableTypeChecked.rules),
|
|
657
771
|
"functional/no-let": ["error", {
|
|
@@ -659,187 +773,25 @@ const functional = async (options) => {
|
|
|
659
773
|
ignoreIdentifierPattern: ignoreNamePattern
|
|
660
774
|
}]
|
|
661
775
|
}
|
|
662
|
-
}]
|
|
776
|
+
}];
|
|
663
777
|
};
|
|
664
778
|
//#endregion
|
|
665
779
|
//#region src/configs/ignores.ts
|
|
666
780
|
const ignores = async (options) => {
|
|
667
|
-
const { gitignore, ignoreTypeScript, userIgnores } = options;
|
|
781
|
+
const { gitignore = true, ignoreTypeScript, userIgnores } = options;
|
|
668
782
|
const [eslintConfigFlatGitIgnore] = await loadPackages(["eslint-config-flat-gitignore"]);
|
|
669
783
|
const mut_configs = [];
|
|
670
784
|
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];
|
|
671
785
|
if (ignoreTypeScript) mut_ignores.push(GLOB_TS, GLOB_TSX);
|
|
672
786
|
mut_configs.push(globalIgnores(mut_ignores, "moso/ignores/globals"));
|
|
673
|
-
if (
|
|
674
|
-
files: [".gitignore"],
|
|
675
|
-
name: "moso/ignores/gitignore",
|
|
676
|
-
strict: false
|
|
677
|
-
}));
|
|
678
|
-
else if (typeof gitignore === "string" || Array.isArray(gitignore)) mut_configs.push(eslintConfigFlatGitIgnore({
|
|
679
|
-
files: gitignore,
|
|
787
|
+
if (gitignore !== false) mut_configs.push(eslintConfigFlatGitIgnore({
|
|
680
788
|
name: "moso/ignores/gitignore",
|
|
681
|
-
strict: false
|
|
789
|
+
strict: false,
|
|
790
|
+
...typeof gitignore === "string" ? { files: [gitignore] } : typeof gitignore === "object" ? gitignore : { files: [".gitignore"] }
|
|
682
791
|
}));
|
|
683
792
|
return mut_configs;
|
|
684
793
|
};
|
|
685
794
|
//#endregion
|
|
686
|
-
//#region package.json
|
|
687
|
-
var package_default = {
|
|
688
|
-
name: "@moso/eslint-config",
|
|
689
|
-
type: "module",
|
|
690
|
-
version: "3.0.4",
|
|
691
|
-
description: "@moso's sharable ESLint config",
|
|
692
|
-
author: {
|
|
693
|
-
"name": "Morten Sørensen",
|
|
694
|
-
"email": "morten@moso.dev",
|
|
695
|
-
"url": "https://moso.dev"
|
|
696
|
-
},
|
|
697
|
-
license: "BSD-3-Clause",
|
|
698
|
-
homepage: "https://github.com/moso/eslint-config",
|
|
699
|
-
repository: {
|
|
700
|
-
"type": "git",
|
|
701
|
-
"url": "git+https://github.com/moso/eslint-config/eslint-config.git"
|
|
702
|
-
},
|
|
703
|
-
bugs: { "url": "https://github.com/moso/eslint-config/issues" },
|
|
704
|
-
keywords: [
|
|
705
|
-
"config",
|
|
706
|
-
"eslint",
|
|
707
|
-
"eslint-config",
|
|
708
|
-
"eslint-config moso",
|
|
709
|
-
"functional programming",
|
|
710
|
-
"moso",
|
|
711
|
-
"perfectionist",
|
|
712
|
-
"stylistic",
|
|
713
|
-
"typescript",
|
|
714
|
-
"react",
|
|
715
|
-
"vue"
|
|
716
|
-
],
|
|
717
|
-
exports: {
|
|
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" }
|
|
841
|
-
};
|
|
842
|
-
//#endregion
|
|
843
795
|
//#region src/rules/utils.ts
|
|
844
796
|
/**
|
|
845
797
|
* Typed rule factory for every rule in this plugin.
|
|
@@ -853,11 +805,10 @@ const createRule = ESLintUtils.RuleCreator((name) => name);
|
|
|
853
805
|
* (or the node itself) matching a node type.
|
|
854
806
|
* Basically the AST equivalent of `Element#closest`.
|
|
855
807
|
*/
|
|
856
|
-
const closest = (node,
|
|
857
|
-
const predicate = typeof test === "string" ? (node) => node.type === test : test;
|
|
808
|
+
const closest = (node, type) => {
|
|
858
809
|
const findClosest = (current) => {
|
|
859
810
|
if (!current) return void 0;
|
|
860
|
-
return
|
|
811
|
+
return current.type === type ? current : findClosest(current.parent);
|
|
861
812
|
};
|
|
862
813
|
return findClosest(node);
|
|
863
814
|
};
|
|
@@ -893,9 +844,13 @@ const getFixer = (token, pattern) => {
|
|
|
893
844
|
};
|
|
894
845
|
case AST_TOKEN_TYPES.RegularExpression: return (fixer) => {
|
|
895
846
|
const mut_flags = new Set(token.regex.flags);
|
|
896
|
-
mut_flags.add("u");
|
|
897
|
-
|
|
898
|
-
|
|
847
|
+
if (!mut_flags.has("v")) mut_flags.add("u");
|
|
848
|
+
try {
|
|
849
|
+
const re = new RegExp(escape(token.regex.pattern, pattern), [...mut_flags].join(""));
|
|
850
|
+
return fixer.replaceText(token, re.toString());
|
|
851
|
+
} catch {
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
899
854
|
};
|
|
900
855
|
case AST_TOKEN_TYPES.String:
|
|
901
856
|
case AST_TOKEN_TYPES.Template: return (fixer) => {
|
|
@@ -929,24 +884,15 @@ const getReturnExpression = (node) => {
|
|
|
929
884
|
*/
|
|
930
885
|
const getValue = (token) => {
|
|
931
886
|
switch (token.type) {
|
|
932
|
-
case AST_TOKEN_TYPES.Block:
|
|
933
|
-
case AST_TOKEN_TYPES.Boolean: return false;
|
|
934
887
|
case AST_TOKEN_TYPES.Identifier:
|
|
935
|
-
if (token.value.startsWith("#")) return token.value.slice(1);
|
|
936
|
-
return token.value;
|
|
937
888
|
case AST_TOKEN_TYPES.JSXIdentifier:
|
|
938
|
-
case AST_TOKEN_TYPES.JSXText:
|
|
939
|
-
case AST_TOKEN_TYPES.Keyword:
|
|
940
|
-
case AST_TOKEN_TYPES.Line:
|
|
941
|
-
case AST_TOKEN_TYPES.Null:
|
|
942
|
-
case AST_TOKEN_TYPES.Numeric: return false;
|
|
889
|
+
case AST_TOKEN_TYPES.JSXText:
|
|
943
890
|
case AST_TOKEN_TYPES.PrivateIdentifier: return token.value;
|
|
944
|
-
case AST_TOKEN_TYPES.Punctuator: return false;
|
|
945
891
|
case AST_TOKEN_TYPES.RegularExpression: return token.regex.pattern;
|
|
946
892
|
case AST_TOKEN_TYPES.String:
|
|
947
893
|
case AST_TOKEN_TYPES.Template: return token.value.slice(1, -1);
|
|
894
|
+
default: return false;
|
|
948
895
|
}
|
|
949
|
-
return false;
|
|
950
896
|
};
|
|
951
897
|
const functionLikeTypes = /* @__PURE__ */ new Set([
|
|
952
898
|
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
@@ -987,10 +933,9 @@ const isIdentifierFunction = (node) => {
|
|
|
987
933
|
return node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 1 && node.body.body[0].type === AST_NODE_TYPES.ReturnStatement && isSameIdentifier(node.params[0], node.body.body[0].argument);
|
|
988
934
|
};
|
|
989
935
|
const isLiteralValue = (node, value) => {
|
|
990
|
-
if (node
|
|
936
|
+
if (node?.type !== AST_NODE_TYPES.Literal) return false;
|
|
991
937
|
if (typeof value === "string") return node.value === value;
|
|
992
|
-
|
|
993
|
-
return value.includes(node.value);
|
|
938
|
+
return typeof node.value === "string" && value.test(node.value);
|
|
994
939
|
};
|
|
995
940
|
const makeProgramListener = (pattern, onReport) => ({ Program: (program) => {
|
|
996
941
|
const tokens = program.tokens ?? [];
|
|
@@ -1045,9 +990,9 @@ const ruleAvoidBarrelFiles = createRule({
|
|
|
1045
990
|
declarationCount: declarationCount + 1,
|
|
1046
991
|
exportCount
|
|
1047
992
|
};
|
|
1048
|
-
if (statement.type === AST_NODE_TYPES.ExportNamedDeclaration) return {
|
|
993
|
+
if (statement.type === AST_NODE_TYPES.ExportNamedDeclaration && statement.exportKind !== "type") return {
|
|
1049
994
|
declarationCount,
|
|
1050
|
-
exportCount: exportCount + statement.specifiers.length
|
|
995
|
+
exportCount: exportCount + statement.specifiers.filter((specifier) => specifier.exportKind !== "type").length
|
|
1051
996
|
};
|
|
1052
997
|
if (statement.type === AST_NODE_TYPES.ExportAllDeclaration && statement.exportKind !== "type") return {
|
|
1053
998
|
declarationCount,
|
|
@@ -1075,7 +1020,7 @@ const ruleAvoidBarrelFiles = createRule({
|
|
|
1075
1020
|
declarationCount: 0,
|
|
1076
1021
|
exportCount: 0
|
|
1077
1022
|
});
|
|
1078
|
-
if (exportCount > declarationCount && exportCount
|
|
1023
|
+
if (exportCount > declarationCount && exportCount >= amountOfExportsToConsiderModuleAsBarrel) context.report({
|
|
1079
1024
|
node,
|
|
1080
1025
|
messageId: "avoidBarrelFiles"
|
|
1081
1026
|
});
|
|
@@ -1113,7 +1058,7 @@ const ruleNoBidi = createRule({
|
|
|
1113
1058
|
//#endregion
|
|
1114
1059
|
//#region src/rules/no-force-cast-via-top-type/no-force-cast-via-top-type.ts
|
|
1115
1060
|
const isTopType = (node) => node.type === AST_NODE_TYPES.TSAnyKeyword || node.type === AST_NODE_TYPES.TSUnknownKeyword;
|
|
1116
|
-
const
|
|
1061
|
+
const isCastToAnotherType = (node) => node?.type === AST_NODE_TYPES.TSAsExpression && !isTopType(node.typeAnnotation);
|
|
1117
1062
|
const ruleNoForceCastViaTopType = createRule({
|
|
1118
1063
|
name: "no-force-cast-via-top-type",
|
|
1119
1064
|
meta: {
|
|
@@ -1128,7 +1073,7 @@ const ruleNoForceCastViaTopType = createRule({
|
|
|
1128
1073
|
},
|
|
1129
1074
|
create: (context) => ({ TSAsExpression: (node) => {
|
|
1130
1075
|
if (!isTopType(node.typeAnnotation)) return;
|
|
1131
|
-
if (!
|
|
1076
|
+
if (!isCastToAnotherType(node.parent)) return;
|
|
1132
1077
|
const type = node.typeAnnotation.type === AST_NODE_TYPES.TSAnyKeyword ? "any" : "unknown";
|
|
1133
1078
|
context.report({
|
|
1134
1079
|
node,
|
|
@@ -1192,13 +1137,23 @@ const ruleNoImportFromDist = createRule({
|
|
|
1192
1137
|
schema: [],
|
|
1193
1138
|
messages: { noImportFromDist: "Do not import modules from the `dist` folder. Got {{path}}." }
|
|
1194
1139
|
},
|
|
1195
|
-
create: (context) => ({
|
|
1196
|
-
|
|
1197
|
-
node
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1140
|
+
create: (context) => ({
|
|
1141
|
+
"ImportDeclaration": (node) => {
|
|
1142
|
+
if (isDist(node.source.value)) context.report({
|
|
1143
|
+
node,
|
|
1144
|
+
messageId: "noImportFromDist",
|
|
1145
|
+
data: { path: node.source.value }
|
|
1146
|
+
});
|
|
1147
|
+
},
|
|
1148
|
+
"CallExpression[callee.name=\"require\"]": (node) => {
|
|
1149
|
+
const firstArg = node.arguments.at(0);
|
|
1150
|
+
if (firstArg?.type === AST_NODE_TYPES.Literal && typeof firstArg.value === "string" && isDist(firstArg.value)) context.report({
|
|
1151
|
+
node,
|
|
1152
|
+
messageId: "noImportFromDist",
|
|
1153
|
+
data: { path: firstArg.value }
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
})
|
|
1202
1157
|
});
|
|
1203
1158
|
//#endregion
|
|
1204
1159
|
//#region src/rules/no-import-node-modules-by-path/no-import-node-modules-by-path.ts
|
|
@@ -1222,8 +1177,8 @@ const ruleNoImportNodeModulesByPath = createRule({
|
|
|
1222
1177
|
});
|
|
1223
1178
|
},
|
|
1224
1179
|
"CallExpression[callee.name=\"require\"]": (node) => {
|
|
1225
|
-
const firstArg = node.arguments
|
|
1226
|
-
if (firstArg
|
|
1180
|
+
const firstArg = node.arguments.at(0);
|
|
1181
|
+
if (firstArg?.type === AST_NODE_TYPES.Literal && typeof firstArg.value === "string" && firstArg.value.includes("/node_modules/")) context.report({
|
|
1227
1182
|
node,
|
|
1228
1183
|
messageId: "noImportNodeModulesByPath"
|
|
1229
1184
|
});
|
|
@@ -1233,7 +1188,7 @@ const ruleNoImportNodeModulesByPath = createRule({
|
|
|
1233
1188
|
//#endregion
|
|
1234
1189
|
//#region src/rules/no-invisible-characters/no-invisible-characters.ts
|
|
1235
1190
|
const combinePattern = (...patterns) => {
|
|
1236
|
-
const source = patterns.map((pattern) =>
|
|
1191
|
+
const source = patterns.map((pattern) => pattern.source).join("");
|
|
1237
1192
|
return new RegExp(`[${source}]`, "u");
|
|
1238
1193
|
};
|
|
1239
1194
|
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);
|
|
@@ -1263,16 +1218,19 @@ const ruleNoInvisibleCharacters = createRule({
|
|
|
1263
1218
|
//#region src/rules/no-redundant-variable/no-redundant-variable.ts
|
|
1264
1219
|
const isRedundantVariable = (node, exit) => {
|
|
1265
1220
|
if (!node) return false;
|
|
1266
|
-
return node.type === AST_NODE_TYPES.VariableDeclaration && node.declarations.length === 1 && node.declarations.
|
|
1221
|
+
return node.type === AST_NODE_TYPES.VariableDeclaration && node.declarations.length === 1 && node.declarations[0].init !== null && isSameIdentifier(exit.argument, node.declarations[0].id);
|
|
1222
|
+
};
|
|
1223
|
+
const isSelfReferencing = (source, variable) => {
|
|
1224
|
+
const { init } = variable.declarations[0];
|
|
1225
|
+
return source.getDeclaredVariables(variable).some(({ references }) => references.some(({ identifier }) => identifier.range[0] >= init.range[0] && identifier.range[1] <= init.range[1]));
|
|
1267
1226
|
};
|
|
1268
1227
|
const isRedundantVariableFixer = (source, variable, exit) => (fixer) => {
|
|
1269
1228
|
const { init, id } = variable.declarations[0];
|
|
1270
|
-
if (!init || !exit.argument) return null;
|
|
1271
1229
|
const replaced = getReturnExpression(init);
|
|
1272
1230
|
const modified = wrap(source.getText(replaced), (input) => {
|
|
1273
1231
|
if (!id.typeAnnotation) return input;
|
|
1274
1232
|
const annotation = source.getText(id.typeAnnotation.typeAnnotation);
|
|
1275
|
-
return `(${input}) as ${
|
|
1233
|
+
return `(${input}) as ${replaced === init ? annotation : `Promise<${annotation}>`}`;
|
|
1276
1234
|
});
|
|
1277
1235
|
return [fixer.remove(variable), fixer.replaceText(exit.argument, modified)];
|
|
1278
1236
|
};
|
|
@@ -1288,18 +1246,22 @@ const ruleNoRedundantVariables = createRule({
|
|
|
1288
1246
|
},
|
|
1289
1247
|
fixable: "code",
|
|
1290
1248
|
schema: [],
|
|
1291
|
-
messages: { noRedundantVar: "
|
|
1249
|
+
messages: { noRedundantVar: "Return the value directly instead of assigning it to a redundant variable." }
|
|
1292
1250
|
},
|
|
1293
1251
|
create: (context) => ({ BlockStatement: ({ body }) => {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1252
|
+
let mut_previous;
|
|
1253
|
+
for (const statement of body) {
|
|
1254
|
+
if (!isReturnStatement(statement)) {
|
|
1255
|
+
mut_previous = statement;
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1258
|
+
if (isRedundantVariable(mut_previous, statement) && !isSelfReferencing(context.sourceCode, mut_previous)) context.report({
|
|
1259
|
+
node: statement,
|
|
1260
|
+
messageId: "noRedundantVar",
|
|
1261
|
+
fix: isRedundantVariableFixer(context.sourceCode, mut_previous, statement)
|
|
1262
|
+
});
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1303
1265
|
} })
|
|
1304
1266
|
});
|
|
1305
1267
|
//#endregion
|
|
@@ -1310,7 +1272,7 @@ const ruleNoStringInterpolation = createRule({
|
|
|
1310
1272
|
meta: {
|
|
1311
1273
|
type: "suggestion",
|
|
1312
1274
|
docs: {
|
|
1313
|
-
description: "Disallow
|
|
1275
|
+
description: "Disallow multiline expressions in string interpolation.",
|
|
1314
1276
|
recommended: "stylistic",
|
|
1315
1277
|
url: "https://dimensiondev.github.io/eslint-plugin/src/rules/string/no-interpolation"
|
|
1316
1278
|
},
|
|
@@ -1358,6 +1320,18 @@ const ruleNoTopLevelAwait = createRule({
|
|
|
1358
1320
|
node,
|
|
1359
1321
|
messageId: "noTopLevelAwait"
|
|
1360
1322
|
});
|
|
1323
|
+
},
|
|
1324
|
+
"ForOfStatement": (node) => {
|
|
1325
|
+
if (mut_functionDepth === 0 && node.await) context.report({
|
|
1326
|
+
node,
|
|
1327
|
+
messageId: "noTopLevelAwait"
|
|
1328
|
+
});
|
|
1329
|
+
},
|
|
1330
|
+
"VariableDeclaration": (node) => {
|
|
1331
|
+
if (mut_functionDepth === 0 && node.kind === "await using") context.report({
|
|
1332
|
+
node,
|
|
1333
|
+
messageId: "noTopLevelAwait"
|
|
1334
|
+
});
|
|
1361
1335
|
}
|
|
1362
1336
|
};
|
|
1363
1337
|
}
|
|
@@ -1375,7 +1349,7 @@ const ruleNoUnneededArrayFlatMap = createRule({
|
|
|
1375
1349
|
},
|
|
1376
1350
|
fixable: "code",
|
|
1377
1351
|
schema: [],
|
|
1378
|
-
messages: { noUnneededArrayFlatMap: "
|
|
1352
|
+
messages: { noUnneededArrayFlatMap: "Use `Array#flat()` instead of `Array#flatMap()` with an identity callback." }
|
|
1379
1353
|
},
|
|
1380
1354
|
create: (context) => ({ CallExpression: (node) => {
|
|
1381
1355
|
if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
@@ -1384,11 +1358,14 @@ const ruleNoUnneededArrayFlatMap = createRule({
|
|
|
1384
1358
|
context.report({
|
|
1385
1359
|
node,
|
|
1386
1360
|
messageId: "noUnneededArrayFlatMap",
|
|
1387
|
-
fix: (fixer) => [fixer.replaceText(property, "flat"),
|
|
1361
|
+
fix: (fixer) => [fixer.replaceText(property, "flat"), fixer.replaceTextRange([node.arguments[0].range[0], node.range[1] - 1], "")]
|
|
1388
1362
|
});
|
|
1389
1363
|
} })
|
|
1390
1364
|
});
|
|
1391
1365
|
//#endregion
|
|
1366
|
+
//#region src/rules/package.json
|
|
1367
|
+
var version = "3.2.0";
|
|
1368
|
+
//#endregion
|
|
1392
1369
|
//#region src/rules/prefer-early-return/prefer-early-return.ts
|
|
1393
1370
|
const isTriggering = (node, maximumStatements) => {
|
|
1394
1371
|
if (node.type !== AST_NODE_TYPES.IfStatement || node.alternate !== null) return false;
|
|
@@ -1396,7 +1373,6 @@ const isTriggering = (node, maximumStatements) => {
|
|
|
1396
1373
|
return consequent.type === AST_NODE_TYPES.ExpressionStatement && maximumStatements === 0 || consequent.type === AST_NODE_TYPES.BlockStatement && consequent.body.length > maximumStatements;
|
|
1397
1374
|
};
|
|
1398
1375
|
const makeFixer = (context, parent) => (fixer) => {
|
|
1399
|
-
if (parent.type !== AST_NODE_TYPES.IfStatement) return [];
|
|
1400
1376
|
const { test, consequent } = parent;
|
|
1401
1377
|
const bodyText = consequent.type === AST_NODE_TYPES.BlockStatement ? context.sourceCode.getText(consequent).slice(1, -1).trim() : context.sourceCode.getText(consequent);
|
|
1402
1378
|
const negated = test.type === AST_NODE_TYPES.UnaryExpression && test.operator === "!" ? context.sourceCode.getText(test.argument) : `!(${context.sourceCode.getText(test)})`;
|
|
@@ -1429,11 +1405,12 @@ const rulePreferEarlyReturns = createRule({
|
|
|
1429
1405
|
defaultOptions: [{ maximumStatements: 1 }],
|
|
1430
1406
|
create: (context, [{ maximumStatements }]) => ({ BlockStatement: ({ body, parent }) => {
|
|
1431
1407
|
if (!isFunctionLike(parent)) return;
|
|
1432
|
-
|
|
1408
|
+
const statement = body.at(0);
|
|
1409
|
+
if (statement === void 0 || body.length !== 1 || !isTriggering(statement, maximumStatements)) return;
|
|
1433
1410
|
context.report({
|
|
1434
|
-
node:
|
|
1411
|
+
node: statement,
|
|
1435
1412
|
messageId: "preferEarlyReturn",
|
|
1436
|
-
fix: makeFixer(context,
|
|
1413
|
+
fix: makeFixer(context, statement)
|
|
1437
1414
|
});
|
|
1438
1415
|
} })
|
|
1439
1416
|
});
|
|
@@ -1461,7 +1438,7 @@ const rulePreferFetch = createRule({
|
|
|
1461
1438
|
name: "prefer-fetch",
|
|
1462
1439
|
meta: {
|
|
1463
1440
|
docs: {
|
|
1464
|
-
description: "Enforce fetch",
|
|
1441
|
+
description: "Enforce `fetch()` over legacy HTTP request APIs and libraries.",
|
|
1465
1442
|
recommended: "stylistic",
|
|
1466
1443
|
url: "https://dimensiondev.github.io/eslint-plugin/src/rules/prefer-fetch"
|
|
1467
1444
|
},
|
|
@@ -1498,16 +1475,17 @@ const rulePreferFetch = createRule({
|
|
|
1498
1475
|
//#region src/rules/prefer-reduce-over-chaining/prefer-reduce-over-chaining.ts
|
|
1499
1476
|
const arrayHighOrderFunctions = /* @__PURE__ */ new Set([
|
|
1500
1477
|
"filter",
|
|
1478
|
+
"flatMap",
|
|
1501
1479
|
"forEach",
|
|
1502
1480
|
"map",
|
|
1503
1481
|
"reduce",
|
|
1504
1482
|
"reduceRight"
|
|
1505
1483
|
]);
|
|
1506
1484
|
const isArrayHigherOrderFunction = (node) => {
|
|
1507
|
-
if (node
|
|
1485
|
+
if (node?.type !== AST_NODE_TYPES.MemberExpression) return false;
|
|
1508
1486
|
if (node.computed) return false;
|
|
1509
1487
|
if (node.property.type !== AST_NODE_TYPES.Identifier) return false;
|
|
1510
|
-
return arrayHighOrderFunctions.has(node.property.name) && node.parent.type === AST_NODE_TYPES.CallExpression;
|
|
1488
|
+
return arrayHighOrderFunctions.has(node.property.name) && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
|
|
1511
1489
|
};
|
|
1512
1490
|
const rulePreferReduceOverChaining = createRule({
|
|
1513
1491
|
name: "prefer-reduce-over-chaining",
|
|
@@ -1524,7 +1502,6 @@ const rulePreferReduceOverChaining = createRule({
|
|
|
1524
1502
|
create: (context) => ({ MemberExpression: (node) => {
|
|
1525
1503
|
if (!isArrayHigherOrderFunction(node)) return;
|
|
1526
1504
|
const { parent } = node;
|
|
1527
|
-
if (parent.type !== AST_NODE_TYPES.CallExpression) return;
|
|
1528
1505
|
if (!isArrayHigherOrderFunction(parent.parent)) return;
|
|
1529
1506
|
context.report({
|
|
1530
1507
|
node: parent,
|
|
@@ -1534,11 +1511,211 @@ const rulePreferReduceOverChaining = createRule({
|
|
|
1534
1511
|
} })
|
|
1535
1512
|
});
|
|
1536
1513
|
//#endregion
|
|
1514
|
+
//#region src/rules/prefer-strict-number-guards/prefer-strict-number-guards.ts
|
|
1515
|
+
const allGuards = [
|
|
1516
|
+
"check-parse-result",
|
|
1517
|
+
"encode-input-rule",
|
|
1518
|
+
"guard-array-index",
|
|
1519
|
+
"guard-derived-value",
|
|
1520
|
+
"use-direct-operands",
|
|
1521
|
+
"write-explicit-condition"
|
|
1522
|
+
];
|
|
1523
|
+
const defaultGuards = [
|
|
1524
|
+
"check-parse-result",
|
|
1525
|
+
"guard-derived-value",
|
|
1526
|
+
"use-direct-operands",
|
|
1527
|
+
"write-explicit-condition"
|
|
1528
|
+
];
|
|
1529
|
+
const arithmeticOperators = /* @__PURE__ */ new Set([
|
|
1530
|
+
"%",
|
|
1531
|
+
"*",
|
|
1532
|
+
"**",
|
|
1533
|
+
"+",
|
|
1534
|
+
"-",
|
|
1535
|
+
"/"
|
|
1536
|
+
]);
|
|
1537
|
+
const parseFunctions = [
|
|
1538
|
+
"Number",
|
|
1539
|
+
"parseFloat",
|
|
1540
|
+
"parseInt"
|
|
1541
|
+
];
|
|
1542
|
+
const indexNamePattern = /^(?:[ijk]|idx|index)$/iu;
|
|
1543
|
+
const indexSuffixPattern = /(?:Idx|Index)$/u;
|
|
1544
|
+
const isConsoleAssert = (statement) => {
|
|
1545
|
+
if (statement.type !== AST_NODE_TYPES.ExpressionStatement) return false;
|
|
1546
|
+
if (statement.expression.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
1547
|
+
const { callee } = statement.expression;
|
|
1548
|
+
return callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && isIdentifierName(callee.object, "console") && isIdentifierName(callee.property, "assert");
|
|
1549
|
+
};
|
|
1550
|
+
const isConsumedDirectly = (node) => {
|
|
1551
|
+
const { parent } = node;
|
|
1552
|
+
if (parent.type === AST_NODE_TYPES.BinaryExpression) return arithmeticOperators.has(parent.operator);
|
|
1553
|
+
return parent.type === AST_NODE_TYPES.MemberExpression && parent.computed && parent.property === node;
|
|
1554
|
+
};
|
|
1555
|
+
const isGuardedIndex = (node) => {
|
|
1556
|
+
const { parent } = node;
|
|
1557
|
+
if (parent.type === AST_NODE_TYPES.TSNonNullExpression) return true;
|
|
1558
|
+
return parent.type === AST_NODE_TYPES.LogicalExpression && parent.operator === "??" && parent.left === node;
|
|
1559
|
+
};
|
|
1560
|
+
const isMathCall = (node, methods) => {
|
|
1561
|
+
const { callee } = node;
|
|
1562
|
+
return callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && isIdentifierName(callee.object, "Math") && (methods === void 0 || isIdentifierName(callee.property, methods));
|
|
1563
|
+
};
|
|
1564
|
+
const isWriteTarget = (node) => {
|
|
1565
|
+
const { parent } = node;
|
|
1566
|
+
if (parent.type === AST_NODE_TYPES.AssignmentExpression) return parent.left === node;
|
|
1567
|
+
if (parent.type === AST_NODE_TYPES.UpdateExpression) return true;
|
|
1568
|
+
return parent.type === AST_NODE_TYPES.UnaryExpression && parent.operator === "delete";
|
|
1569
|
+
};
|
|
1570
|
+
const assertedNames = (node, sourceCode) => {
|
|
1571
|
+
if (node.body.type !== AST_NODE_TYPES.BlockStatement) return /* @__PURE__ */ new Set();
|
|
1572
|
+
const mut_names = /* @__PURE__ */ new Set();
|
|
1573
|
+
for (const statement of node.body.body) {
|
|
1574
|
+
if (!isConsoleAssert(statement)) break;
|
|
1575
|
+
for (const token of sourceCode.getTokens(statement)) if (token.type === AST_TOKEN_TYPES.Identifier) mut_names.add(token.value);
|
|
1576
|
+
}
|
|
1577
|
+
return mut_names;
|
|
1578
|
+
};
|
|
1579
|
+
const looksLikeIndex = (node) => {
|
|
1580
|
+
if (node.type === AST_NODE_TYPES.BinaryExpression) return arithmeticOperators.has(node.operator);
|
|
1581
|
+
if (node.type === AST_NODE_TYPES.CallExpression) return isMathCall(node);
|
|
1582
|
+
return isIdentifierName(node, (name) => indexNamePattern.test(name) || indexSuffixPattern.test(name));
|
|
1583
|
+
};
|
|
1584
|
+
const numberParameterNames = (node) => {
|
|
1585
|
+
const mut_names = /* @__PURE__ */ new Set();
|
|
1586
|
+
for (const parameter of node.params) {
|
|
1587
|
+
if (parameter.type !== AST_NODE_TYPES.Identifier) continue;
|
|
1588
|
+
if (parameter.typeAnnotation?.typeAnnotation.type !== AST_NODE_TYPES.TSNumberKeyword) continue;
|
|
1589
|
+
mut_names.add(parameter.name);
|
|
1590
|
+
}
|
|
1591
|
+
return mut_names;
|
|
1592
|
+
};
|
|
1593
|
+
const rulePreferStrictNumberGuards = createRule({
|
|
1594
|
+
name: "prefer-strict-number-guards",
|
|
1595
|
+
meta: {
|
|
1596
|
+
type: "problem",
|
|
1597
|
+
docs: {
|
|
1598
|
+
description: "Enforce the syntactic patterns that keep numeric code analyzable.",
|
|
1599
|
+
recommended: "stylistic",
|
|
1600
|
+
url: "https://github.com/chenglou/freerange"
|
|
1601
|
+
},
|
|
1602
|
+
schema: [{
|
|
1603
|
+
type: "object",
|
|
1604
|
+
description: "Which of the Freerange authoring rules to enforce.",
|
|
1605
|
+
properties: { guards: {
|
|
1606
|
+
type: "array",
|
|
1607
|
+
description: "The audit codes to enforce. The heuristic `encode-input-rule` and `guard-array-index` are off by default.",
|
|
1608
|
+
items: {
|
|
1609
|
+
type: "string",
|
|
1610
|
+
enum: [...allGuards]
|
|
1611
|
+
},
|
|
1612
|
+
uniqueItems: true,
|
|
1613
|
+
default: [...defaultGuards]
|
|
1614
|
+
} },
|
|
1615
|
+
additionalProperties: false
|
|
1616
|
+
}],
|
|
1617
|
+
messages: {
|
|
1618
|
+
checkParseResult: "This can produce `NaN` or `±Infinity`. Check the result with `Number.isFinite` or `Number.isNaN` before using it.",
|
|
1619
|
+
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`.",
|
|
1620
|
+
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.",
|
|
1621
|
+
guardDerivedValue: "Dividing by a calculation hides whether that calculation can be zero. Name it in a `const`, check that name for zero, then divide.",
|
|
1622
|
+
useDirectOperands: "A nested division introduces a ratio that can round to zero. Use the direct operands instead - `a / (b / c)` is `(a * c) / b`.",
|
|
1623
|
+
writeExplicitCondition: "`0` is falsy, so a `||` fallback silently replaces a legitimate zero. Write `value === 0 ? fallback : value` instead."
|
|
1624
|
+
}
|
|
1625
|
+
},
|
|
1626
|
+
defaultOptions: [{ guards: [...defaultGuards] }],
|
|
1627
|
+
create: (context, [{ guards }]) => {
|
|
1628
|
+
const enabled = new Set(guards);
|
|
1629
|
+
const mut_scopes = [];
|
|
1630
|
+
const enterFunction = (node) => {
|
|
1631
|
+
mut_scopes.push({
|
|
1632
|
+
asserted: assertedNames(node, context.sourceCode),
|
|
1633
|
+
numberParams: numberParameterNames(node)
|
|
1634
|
+
});
|
|
1635
|
+
};
|
|
1636
|
+
const exitFunction = () => mut_scopes.pop();
|
|
1637
|
+
const reportUnencodedInput = (node) => {
|
|
1638
|
+
if (!enabled.has("encode-input-rule")) return;
|
|
1639
|
+
if (node.type !== AST_NODE_TYPES.Identifier) return;
|
|
1640
|
+
const scope = mut_scopes.at(-1);
|
|
1641
|
+
if (!scope) return;
|
|
1642
|
+
if (!scope.numberParams.has(node.name)) return;
|
|
1643
|
+
if (scope.asserted.has(node.name)) return;
|
|
1644
|
+
context.report({
|
|
1645
|
+
node,
|
|
1646
|
+
messageId: "encodeInputRule",
|
|
1647
|
+
data: { name: node.name }
|
|
1648
|
+
});
|
|
1649
|
+
};
|
|
1650
|
+
return {
|
|
1651
|
+
"ArrowFunctionExpression": enterFunction,
|
|
1652
|
+
"ArrowFunctionExpression:exit": exitFunction,
|
|
1653
|
+
"BinaryExpression": (node) => {
|
|
1654
|
+
if (node.operator !== "/" && node.operator !== "%") return;
|
|
1655
|
+
const divisor = node.right;
|
|
1656
|
+
if (divisor.type === AST_NODE_TYPES.BinaryExpression && arithmeticOperators.has(divisor.operator)) {
|
|
1657
|
+
const nested = divisor.operator === "/";
|
|
1658
|
+
const guard = nested ? "use-direct-operands" : "guard-derived-value";
|
|
1659
|
+
if (!enabled.has(guard)) return;
|
|
1660
|
+
context.report({
|
|
1661
|
+
node: divisor,
|
|
1662
|
+
messageId: nested ? "useDirectOperands" : "guardDerivedValue"
|
|
1663
|
+
});
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
reportUnencodedInput(divisor);
|
|
1667
|
+
},
|
|
1668
|
+
"CallExpression": (node) => {
|
|
1669
|
+
if (!enabled.has("check-parse-result")) return;
|
|
1670
|
+
if (isIdentifierName(node.callee, parseFunctions) && isConsumedDirectly(node)) {
|
|
1671
|
+
context.report({
|
|
1672
|
+
node,
|
|
1673
|
+
messageId: "checkParseResult"
|
|
1674
|
+
});
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
if (!isMathCall(node, ["max", "min"])) return;
|
|
1678
|
+
if (!(node.arguments.length === 0 || node.arguments.some((argument) => argument.type === AST_NODE_TYPES.SpreadElement))) return;
|
|
1679
|
+
context.report({
|
|
1680
|
+
node,
|
|
1681
|
+
messageId: "checkParseResult"
|
|
1682
|
+
});
|
|
1683
|
+
},
|
|
1684
|
+
"FunctionDeclaration": enterFunction,
|
|
1685
|
+
"FunctionDeclaration:exit": exitFunction,
|
|
1686
|
+
"FunctionExpression": enterFunction,
|
|
1687
|
+
"FunctionExpression:exit": exitFunction,
|
|
1688
|
+
"LogicalExpression": (node) => {
|
|
1689
|
+
if (!enabled.has("write-explicit-condition")) return;
|
|
1690
|
+
if (node.operator !== "||") return;
|
|
1691
|
+
if (node.right.type !== AST_NODE_TYPES.Literal) return;
|
|
1692
|
+
if (typeof node.right.value !== "number") return;
|
|
1693
|
+
context.report({
|
|
1694
|
+
node,
|
|
1695
|
+
messageId: "writeExplicitCondition"
|
|
1696
|
+
});
|
|
1697
|
+
},
|
|
1698
|
+
"MemberExpression": (node) => {
|
|
1699
|
+
if (!node.computed) return;
|
|
1700
|
+
if (node.property.type === AST_NODE_TYPES.Literal) return;
|
|
1701
|
+
reportUnencodedInput(node.property);
|
|
1702
|
+
if (!enabled.has("guard-array-index")) return;
|
|
1703
|
+
if (!looksLikeIndex(node.property)) return;
|
|
1704
|
+
if (isGuardedIndex(node) || isWriteTarget(node)) return;
|
|
1705
|
+
context.report({
|
|
1706
|
+
node,
|
|
1707
|
+
messageId: "guardArrayIndex"
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
//#endregion
|
|
1537
1714
|
//#region src/rules/index.ts
|
|
1538
1715
|
const plugin = {
|
|
1539
1716
|
meta: {
|
|
1540
1717
|
name: "@moso/eslint-plugin",
|
|
1541
|
-
version
|
|
1718
|
+
version
|
|
1542
1719
|
},
|
|
1543
1720
|
rules: {
|
|
1544
1721
|
"avoid-barrel-files": ruleAvoidBarrelFiles,
|
|
@@ -1554,7 +1731,8 @@ const plugin = {
|
|
|
1554
1731
|
"no-unneeded-array-flat-map": ruleNoUnneededArrayFlatMap,
|
|
1555
1732
|
"prefer-early-return": rulePreferEarlyReturns,
|
|
1556
1733
|
"prefer-fetch": rulePreferFetch,
|
|
1557
|
-
"prefer-reduce-over-chaining": rulePreferReduceOverChaining
|
|
1734
|
+
"prefer-reduce-over-chaining": rulePreferReduceOverChaining,
|
|
1735
|
+
"prefer-strict-number-guards": rulePreferStrictNumberGuards
|
|
1558
1736
|
}
|
|
1559
1737
|
};
|
|
1560
1738
|
const configs = { recommended: {
|
|
@@ -1578,7 +1756,7 @@ var rules_default = {
|
|
|
1578
1756
|
//#endregion
|
|
1579
1757
|
//#region src/configs/imports.ts
|
|
1580
1758
|
const imports = async (options) => {
|
|
1581
|
-
const { overrides, stylistic, typescript } = options;
|
|
1759
|
+
const { files, overrides, stylistic, typescript } = options;
|
|
1582
1760
|
const [importLite] = await loadPackages(["eslint-plugin-import-lite"]);
|
|
1583
1761
|
const stylisticEnabled = stylistic !== false;
|
|
1584
1762
|
return [{
|
|
@@ -1601,11 +1779,7 @@ const imports = async (options) => {
|
|
|
1601
1779
|
}
|
|
1602
1780
|
}, ...typescript ? [{
|
|
1603
1781
|
name: "moso/imports/typescript",
|
|
1604
|
-
files
|
|
1605
|
-
GLOB_DTS,
|
|
1606
|
-
GLOB_TS,
|
|
1607
|
-
GLOB_TSX
|
|
1608
|
-
],
|
|
1782
|
+
files,
|
|
1609
1783
|
rules: {
|
|
1610
1784
|
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
1611
1785
|
"@typescript-eslint/consistent-type-imports": [stylisticEnabled ? "error" : "off", {
|
|
@@ -1648,10 +1822,7 @@ const javascript = async (options) => {
|
|
|
1648
1822
|
sourceType: "module"
|
|
1649
1823
|
},
|
|
1650
1824
|
linterOptions: { reportUnusedDisableDirectives: true },
|
|
1651
|
-
plugins: {
|
|
1652
|
-
"@eslint/js": memoize(eslintJs, "@eslint/js"),
|
|
1653
|
-
"unused-imports": memoize(unusedImportsPlugin, "eslint-plugin-unused-imports")
|
|
1654
|
-
},
|
|
1825
|
+
plugins: { "unused-imports": memoize(unusedImportsPlugin, "eslint-plugin-unused-imports") },
|
|
1655
1826
|
rules: {
|
|
1656
1827
|
...(assert.ok(!Array.isArray(eslintJs.configs.recommended)), eslintJs.configs.recommended.rules),
|
|
1657
1828
|
"array-callback-return": ["error", { allowImplicit: true }],
|
|
@@ -1809,16 +1980,12 @@ const javascript = async (options) => {
|
|
|
1809
1980
|
message: "Labeled statements are not allowed.",
|
|
1810
1981
|
selector: "LabeledStatement"
|
|
1811
1982
|
},
|
|
1812
|
-
{
|
|
1813
|
-
message: "Const enums are forbidden to increase interoperability. Use regular enums instead.",
|
|
1814
|
-
selector: "TSEnumDeclaration[const=true]"
|
|
1815
|
-
},
|
|
1816
1983
|
{
|
|
1817
1984
|
message: "TypeScript's own parser uses `ExportAssignment` for both `export default` and `export =`.",
|
|
1818
1985
|
selector: "TSExportAssignment"
|
|
1819
1986
|
},
|
|
1820
1987
|
{
|
|
1821
|
-
message: "`with` is disallowed in strict mode because it makes code
|
|
1988
|
+
message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
|
1822
1989
|
selector: "WithStatement"
|
|
1823
1990
|
}
|
|
1824
1991
|
],
|
|
@@ -1934,6 +2101,7 @@ const javascript = async (options) => {
|
|
|
1934
2101
|
"@moso/prefer-early-return": ["error", { maximumStatements: 1 }],
|
|
1935
2102
|
"@moso/prefer-fetch": "error",
|
|
1936
2103
|
"@moso/prefer-reduce-over-chaining": "error",
|
|
2104
|
+
"@moso/prefer-strict-number-guards": "error",
|
|
1937
2105
|
"de-morgan/no-negated-conjunction": "error",
|
|
1938
2106
|
"de-morgan/no-negated-disjunction": "error"
|
|
1939
2107
|
}
|
|
@@ -1942,12 +2110,15 @@ const javascript = async (options) => {
|
|
|
1942
2110
|
//#endregion
|
|
1943
2111
|
//#region src/configs/jsdoc.ts
|
|
1944
2112
|
const jsdoc = async (options) => {
|
|
1945
|
-
const { lessOpinionated, overrides, stylistic } = options;
|
|
2113
|
+
const { files, lessOpinionated, overrides, stylistic, typescript } = options;
|
|
1946
2114
|
const [jsdocPlugin] = await loadPackages(["eslint-plugin-jsdoc"]);
|
|
1947
2115
|
const stylisticEnabled = stylistic === false ? "off" : "error";
|
|
1948
2116
|
return [{
|
|
1949
|
-
name: "moso/jsdoc",
|
|
1950
|
-
plugins: { "jsdoc": memoize(jsdocPlugin, "eslint-plugin-jsdoc") }
|
|
2117
|
+
name: "moso/jsdoc/setup",
|
|
2118
|
+
plugins: { "jsdoc": memoize(jsdocPlugin, "eslint-plugin-jsdoc") }
|
|
2119
|
+
}, {
|
|
2120
|
+
name: "moso/jsdoc/rules",
|
|
2121
|
+
files,
|
|
1951
2122
|
rules: {
|
|
1952
2123
|
"jsdoc/check-access": "warn",
|
|
1953
2124
|
"jsdoc/check-alignment": stylisticEnabled,
|
|
@@ -2008,7 +2179,7 @@ const jsdoc = async (options) => {
|
|
|
2008
2179
|
"ts-nocheck",
|
|
2009
2180
|
"vue-ignore"
|
|
2010
2181
|
] }],
|
|
2011
|
-
"jsdoc/no-types": "warn",
|
|
2182
|
+
"jsdoc/no-types": typescript ? "off" : "warn",
|
|
2012
2183
|
"jsdoc/require-asterisk-prefix": "warn",
|
|
2013
2184
|
"jsdoc/require-description": "warn",
|
|
2014
2185
|
"jsdoc/require-hyphen-before-param-description": "warn",
|
|
@@ -2029,9 +2200,11 @@ const jsonc = async (options) => {
|
|
|
2029
2200
|
const [jsoncPlugin, jsoncParser] = await loadPackages(["eslint-plugin-jsonc", "jsonc-eslint-parser"]);
|
|
2030
2201
|
const stylisticEnabled = stylistic === false ? "off" : "error";
|
|
2031
2202
|
return [{
|
|
2032
|
-
name: "moso/jsonc",
|
|
2203
|
+
name: "moso/jsonc/setup",
|
|
2204
|
+
plugins: { "jsonc": memoize(jsoncPlugin, "eslint-plugin-jsonc") }
|
|
2205
|
+
}, {
|
|
2206
|
+
name: "moso/jsonc/rules",
|
|
2033
2207
|
files,
|
|
2034
|
-
plugins: { "jsonc": memoize(jsoncPlugin, "eslint-plugin-jsonc") },
|
|
2035
2208
|
languageOptions: { parser: memoize(jsoncParser, "jsonc-eslint-parser") },
|
|
2036
2209
|
rules: {
|
|
2037
2210
|
"jsonc/no-bigint-literals": "error",
|
|
@@ -2063,7 +2236,7 @@ const jsonc = async (options) => {
|
|
|
2063
2236
|
"jsonc/array-bracket-spacing": [stylisticEnabled, "never"],
|
|
2064
2237
|
"jsonc/comma-dangle": [stylisticEnabled, "never"],
|
|
2065
2238
|
"jsonc/comma-style": [stylisticEnabled, "last"],
|
|
2066
|
-
"jsonc/indent": [stylisticEnabled,
|
|
2239
|
+
"jsonc/indent": [stylisticEnabled, indent],
|
|
2067
2240
|
"jsonc/key-spacing": [stylisticEnabled, {
|
|
2068
2241
|
afterColon: true,
|
|
2069
2242
|
beforeColon: false
|
|
@@ -2085,33 +2258,25 @@ const jsonc = async (options) => {
|
|
|
2085
2258
|
const jsx = async (options) => {
|
|
2086
2259
|
const { a11y, files, lessOpinionated, overrides, overridesA11y, stylistic } = options;
|
|
2087
2260
|
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: {
|
|
2261
|
+
const stylisticEnabled = stylistic !== false;
|
|
2262
|
+
return [{
|
|
2263
|
+
name: "moso/jsx/setup",
|
|
2264
|
+
plugins: { ...jsxA11yPlugin && { "jsx-a11y": memoize(jsxA11yPlugin, "eslint-plugin-jsx-a11y") } }
|
|
2265
|
+
}, {
|
|
2266
|
+
name: "moso/jsx/rules",
|
|
2267
|
+
files,
|
|
2268
|
+
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
|
2269
|
+
rules: {
|
|
2270
|
+
...stylisticEnabled && {
|
|
2271
|
+
"@stylistic/jsx-curly-spacing": ["error", {
|
|
2272
|
+
"when": "always",
|
|
2273
|
+
"allowMultiline": false,
|
|
2274
|
+
"children": false,
|
|
2275
|
+
"spacing": { "objectLiterals": "never" }
|
|
2276
|
+
}],
|
|
2277
|
+
"@stylistic/jsx-one-expression-per-line": "off"
|
|
2278
|
+
},
|
|
2279
|
+
...jsxA11yPlugin && {
|
|
2115
2280
|
...lessOpinionated ? { ...(assert.ok(!Array.isArray(jsxA11yPlugin.flatConfigs.recommended)), jsxA11yPlugin.flatConfigs.recommended.rules) } : {
|
|
2116
2281
|
"jsx-a11y/alt-text": ["warn", {
|
|
2117
2282
|
elements: ["img"],
|
|
@@ -2147,43 +2312,41 @@ const jsx = async (options) => {
|
|
|
2147
2312
|
}]
|
|
2148
2313
|
},
|
|
2149
2314
|
...overridesA11y
|
|
2150
|
-
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2315
|
+
},
|
|
2316
|
+
...overrides
|
|
2317
|
+
}
|
|
2318
|
+
}];
|
|
2153
2319
|
};
|
|
2154
2320
|
//#endregion
|
|
2155
2321
|
//#region src/configs/nextjs.ts
|
|
2156
2322
|
const nextjs = async (options) => {
|
|
2157
|
-
const { files, mode, overrides } = options;
|
|
2323
|
+
const { files, mode, overrides, rootDir } = options;
|
|
2158
2324
|
const [nextjsPlugin] = await loadPackages(["@next/eslint-plugin-next"]);
|
|
2159
|
-
return [
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2325
|
+
return [{
|
|
2326
|
+
name: "moso/nextjs/setup",
|
|
2327
|
+
plugins: { "@next/next": memoize(nextjsPlugin, "@next/eslint-plugin-next") }
|
|
2328
|
+
}, {
|
|
2329
|
+
name: "moso/nextjs/rules",
|
|
2330
|
+
files,
|
|
2331
|
+
languageOptions: {
|
|
2332
|
+
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
2333
|
+
sourceType: "module"
|
|
2168
2334
|
},
|
|
2169
|
-
{
|
|
2170
|
-
|
|
2171
|
-
|
|
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
|
-
}
|
|
2335
|
+
settings: {
|
|
2336
|
+
react: { version: "detect" },
|
|
2337
|
+
...rootDir !== void 0 && { next: { rootDir } }
|
|
2177
2338
|
},
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2339
|
+
rules: {
|
|
2340
|
+
...(assert.ok(!Array.isArray(nextjsPlugin.configs.recommended)), nextjsPlugin.configs.recommended.rules),
|
|
2341
|
+
...(assert.ok(!Array.isArray(nextjsPlugin.configs["core-web-vitals"])), nextjsPlugin.configs["core-web-vitals"].rules),
|
|
2342
|
+
...mode === "library" && { "@next/next/no-html-link-for-pages": "off" },
|
|
2343
|
+
...overrides
|
|
2344
|
+
}
|
|
2345
|
+
}];
|
|
2183
2346
|
};
|
|
2184
2347
|
//#endregion
|
|
2185
2348
|
//#region src/configs/node.ts
|
|
2186
|
-
const
|
|
2349
|
+
const npmx = (packageName) => `https://npmx.dev/package/${packageName}`;
|
|
2187
2350
|
const restricedImports = [
|
|
2188
2351
|
{
|
|
2189
2352
|
name: "assert",
|
|
@@ -2195,11 +2358,11 @@ const restricedImports = [
|
|
|
2195
2358
|
},
|
|
2196
2359
|
{
|
|
2197
2360
|
name: "axios",
|
|
2198
|
-
message:
|
|
2361
|
+
message: npmx("ky")
|
|
2199
2362
|
},
|
|
2200
2363
|
{
|
|
2201
2364
|
name: "clone-deep",
|
|
2202
|
-
message: `${
|
|
2365
|
+
message: `${npmx("rfdc")} for Node.js / ${npmx("klona")} for Browser.`
|
|
2203
2366
|
},
|
|
2204
2367
|
{
|
|
2205
2368
|
name: "date-fns",
|
|
@@ -2211,15 +2374,15 @@ const restricedImports = [
|
|
|
2211
2374
|
},
|
|
2212
2375
|
{
|
|
2213
2376
|
name: "dayjs",
|
|
2214
|
-
message:
|
|
2377
|
+
message: npmx("date-fns")
|
|
2215
2378
|
},
|
|
2216
2379
|
{
|
|
2217
2380
|
name: "deep-copy",
|
|
2218
|
-
message: `${
|
|
2381
|
+
message: `${npmx("rfdc")} for Node.js / ${npmx("klona")} for Browser.`
|
|
2219
2382
|
},
|
|
2220
2383
|
{
|
|
2221
2384
|
name: "fast-copy",
|
|
2222
|
-
message: `${
|
|
2385
|
+
message: `${npmx("rfdc")} for Node.js / ${npmx("klona")} for Browser.`
|
|
2223
2386
|
},
|
|
2224
2387
|
{
|
|
2225
2388
|
name: "idb/with-async-ittr-cjs",
|
|
@@ -2231,7 +2394,7 @@ const restricedImports = [
|
|
|
2231
2394
|
},
|
|
2232
2395
|
{
|
|
2233
2396
|
name: "lodash.clonedeep",
|
|
2234
|
-
message: `${
|
|
2397
|
+
message: `${npmx("rfdc")} for Node.js / ${npmx("klona")} for Browser.`
|
|
2235
2398
|
},
|
|
2236
2399
|
{
|
|
2237
2400
|
name: "lodash-unified",
|
|
@@ -2243,7 +2406,7 @@ const restricedImports = [
|
|
|
2243
2406
|
},
|
|
2244
2407
|
{
|
|
2245
2408
|
name: "node-fetch",
|
|
2246
|
-
message: `${
|
|
2409
|
+
message: `${npmx("undici")} (preferred) or ${npmx("node-fetch-native")}.`
|
|
2247
2410
|
},
|
|
2248
2411
|
{
|
|
2249
2412
|
name: "react-fast-compare",
|
|
@@ -2255,15 +2418,19 @@ const restricedImports = [
|
|
|
2255
2418
|
}
|
|
2256
2419
|
];
|
|
2257
2420
|
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;
|
|
2421
|
+
const node = async (options) => {
|
|
2422
|
+
const { files, lessOpinionated, overrides } = options;
|
|
2260
2423
|
const [nodePlugin] = await loadPackages(["eslint-plugin-n"]);
|
|
2261
2424
|
return [
|
|
2262
2425
|
{
|
|
2263
|
-
name: "moso/node",
|
|
2264
|
-
plugins: { "node": memoize(nodePlugin, "eslint-plugin-n") }
|
|
2426
|
+
name: "moso/node/setup",
|
|
2427
|
+
plugins: { "node": memoize(nodePlugin, "eslint-plugin-n") }
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
name: "moso/node/rules",
|
|
2431
|
+
files: files ?? ["**/*.?([cm])[jt]s?(x)"],
|
|
2265
2432
|
languageOptions: { globals: { ...globals.node } },
|
|
2266
|
-
settings: { node: { version: "^22.22.
|
|
2433
|
+
settings: { node: { version: "^22.22.3 || >=24" } },
|
|
2267
2434
|
rules: {
|
|
2268
2435
|
...(assert.ok(!Array.isArray(nodePlugin.configs["flat/recommended"])), renameNodeRules(nodePlugin.configs["flat/recommended"].rules ?? {}, "n", "node")),
|
|
2269
2436
|
"node/no-unpublished-import": "warn",
|
|
@@ -2303,33 +2470,9 @@ const node = async (options = {}) => {
|
|
|
2303
2470
|
},
|
|
2304
2471
|
...options.strict ? [{
|
|
2305
2472
|
name: "moso/node/strict",
|
|
2306
|
-
files: options.
|
|
2473
|
+
files: options.module ? [GLOB_CJS] : [GLOB_CJS, GLOB_JS],
|
|
2307
2474
|
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
|
-
}
|
|
2475
|
+
}] : []
|
|
2333
2476
|
];
|
|
2334
2477
|
};
|
|
2335
2478
|
//#endregion
|
|
@@ -2346,226 +2489,181 @@ const commonOptions = {
|
|
|
2346
2489
|
type: "natural"
|
|
2347
2490
|
};
|
|
2348
2491
|
const perfectionist = async (options) => {
|
|
2349
|
-
const {
|
|
2492
|
+
const { overrides } = options;
|
|
2350
2493
|
const [perfectionistPlugin] = await loadPackages(["eslint-plugin-perfectionist"]);
|
|
2351
2494
|
return [{
|
|
2352
2495
|
name: "moso/perfectionist",
|
|
2353
2496
|
plugins: { "perfectionist": memoize(perfectionistPlugin, "eslint-plugin-perfectionist") },
|
|
2354
2497
|
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",
|
|
2498
|
+
"perfectionist/sort-array-includes": ["error", {
|
|
2499
|
+
...commonOptions,
|
|
2500
|
+
fallbackSort: {
|
|
2438
2501
|
order: "asc",
|
|
2439
2502
|
type: "natural"
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2503
|
+
},
|
|
2504
|
+
type: "alphabetical"
|
|
2505
|
+
}],
|
|
2506
|
+
"perfectionist/sort-classes": ["error", { ...commonOptions }],
|
|
2507
|
+
"perfectionist/sort-decorators": ["error", { ...commonOptions }],
|
|
2508
|
+
"perfectionist/sort-enums": [
|
|
2509
|
+
"error",
|
|
2510
|
+
{
|
|
2443
2511
|
...commonOptions,
|
|
2444
|
-
fallbackSort: { type: "unsorted" },
|
|
2445
2512
|
groups: [
|
|
2446
|
-
|
|
2447
|
-
"
|
|
2448
|
-
|
|
2449
|
-
"conditional",
|
|
2450
|
-
"intersection",
|
|
2451
|
-
"union"
|
|
2452
|
-
],
|
|
2453
|
-
"unknown"
|
|
2513
|
+
"r",
|
|
2514
|
+
"g",
|
|
2515
|
+
"b"
|
|
2454
2516
|
],
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
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"
|
|
2517
|
+
customGroups: [
|
|
2518
|
+
{
|
|
2519
|
+
elementNamePattern: "^r$",
|
|
2520
|
+
groupName: "r"
|
|
2521
|
+
},
|
|
2522
|
+
{
|
|
2523
|
+
elementNamePattern: "^g$",
|
|
2524
|
+
groupName: "g"
|
|
2501
2525
|
},
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
"
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2526
|
+
{
|
|
2527
|
+
elementNamePattern: "^b$",
|
|
2528
|
+
groupName: "b"
|
|
2529
|
+
}
|
|
2530
|
+
],
|
|
2531
|
+
useConfigurationIf: { allNamesMatchPattern: "^[rgb]$" }
|
|
2532
|
+
},
|
|
2533
|
+
{ ...commonOptions }
|
|
2534
|
+
],
|
|
2535
|
+
"perfectionist/sort-export-attributes": ["error", {
|
|
2536
|
+
...commonOptions,
|
|
2537
|
+
fallbackSort: {
|
|
2538
|
+
order: "asc",
|
|
2539
|
+
type: "natural"
|
|
2540
|
+
},
|
|
2541
|
+
type: "alphabetical"
|
|
2542
|
+
}],
|
|
2543
|
+
"perfectionist/sort-exports": ["error", { ...commonOptions }],
|
|
2544
|
+
"perfectionist/sort-heritage-clauses": ["error", { ...commonOptions }],
|
|
2545
|
+
"perfectionist/sort-import-attributes": ["error", {
|
|
2546
|
+
...commonOptions,
|
|
2547
|
+
fallbackSort: {
|
|
2548
|
+
order: "asc",
|
|
2549
|
+
type: "natural"
|
|
2550
|
+
},
|
|
2551
|
+
type: "alphabetical"
|
|
2552
|
+
}],
|
|
2553
|
+
"perfectionist/sort-imports": ["error", {
|
|
2554
|
+
fallbackSort: {
|
|
2555
|
+
order: "asc",
|
|
2556
|
+
type: "alphabetical"
|
|
2557
|
+
},
|
|
2558
|
+
groups: [
|
|
2559
|
+
"builtin",
|
|
2560
|
+
"external",
|
|
2561
|
+
"internal",
|
|
2562
|
+
[
|
|
2563
|
+
"parent",
|
|
2564
|
+
"sibling",
|
|
2565
|
+
"index"
|
|
2566
|
+
],
|
|
2567
|
+
"side-effect",
|
|
2568
|
+
"unknown",
|
|
2569
|
+
["type-builtin", "type-external"],
|
|
2570
|
+
"type-internal",
|
|
2571
|
+
[
|
|
2572
|
+
"type-parent",
|
|
2573
|
+
"type-sibling",
|
|
2574
|
+
"type-index",
|
|
2575
|
+
"type-import"
|
|
2576
|
+
]
|
|
2515
2577
|
],
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2578
|
+
ignoreCase: false,
|
|
2579
|
+
newlinesBetween: "ignore",
|
|
2580
|
+
order: "asc",
|
|
2581
|
+
type: "natural"
|
|
2582
|
+
}],
|
|
2583
|
+
"perfectionist/sort-interfaces": ["error", { ...commonOptions }],
|
|
2584
|
+
"perfectionist/sort-intersection-types": ["error", {
|
|
2585
|
+
...commonOptions,
|
|
2586
|
+
fallbackSort: { type: "unsorted" },
|
|
2587
|
+
groups: [
|
|
2588
|
+
["keyword", "literal"],
|
|
2589
|
+
"named",
|
|
2590
|
+
[
|
|
2591
|
+
"conditional",
|
|
2592
|
+
"intersection",
|
|
2593
|
+
"union"
|
|
2594
|
+
],
|
|
2595
|
+
"unknown"
|
|
2533
2596
|
],
|
|
2534
|
-
|
|
2597
|
+
ignoreCase: true,
|
|
2598
|
+
type: "alphabetical"
|
|
2599
|
+
}],
|
|
2600
|
+
"perfectionist/sort-jsx-props": [
|
|
2601
|
+
"error",
|
|
2602
|
+
{
|
|
2535
2603
|
...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", {
|
|
2604
|
+
type: "unsorted",
|
|
2605
|
+
useConfigurationIf: { tagMatchesPattern: "^[a-z][^.]*$" }
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2545
2608
|
...commonOptions,
|
|
2609
|
+
customGroups: [
|
|
2610
|
+
{
|
|
2611
|
+
elementNamePattern: ["^role$", "^aria-.+$"],
|
|
2612
|
+
groupName: "a11y"
|
|
2613
|
+
},
|
|
2614
|
+
{
|
|
2615
|
+
elementNamePattern: [
|
|
2616
|
+
"^type$",
|
|
2617
|
+
"^id$",
|
|
2618
|
+
"^className$",
|
|
2619
|
+
"^href$",
|
|
2620
|
+
"^src$",
|
|
2621
|
+
"^srcSet$",
|
|
2622
|
+
"^name$",
|
|
2623
|
+
"^style$"
|
|
2624
|
+
],
|
|
2625
|
+
groupName: "almost-props"
|
|
2626
|
+
},
|
|
2627
|
+
{
|
|
2628
|
+
elementNamePattern: "^on.+",
|
|
2629
|
+
groupName: "callback"
|
|
2630
|
+
},
|
|
2631
|
+
{
|
|
2632
|
+
elementNamePattern: "^(?:class|client|is|server|set|transition):",
|
|
2633
|
+
groupName: "directive"
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
elementNamePattern: ["^ref$", "^key$"],
|
|
2637
|
+
groupName: "reserved"
|
|
2638
|
+
}
|
|
2639
|
+
],
|
|
2546
2640
|
fallbackSort: {
|
|
2547
2641
|
order: "asc",
|
|
2548
2642
|
type: "natural"
|
|
2549
2643
|
},
|
|
2550
|
-
|
|
2551
|
-
}],
|
|
2552
|
-
"perfectionist/sort-union-types": ["error", {
|
|
2553
|
-
...commonOptions,
|
|
2554
|
-
fallbackSort: { type: "unsorted" },
|
|
2644
|
+
ignoreCase: true,
|
|
2555
2645
|
groups: [
|
|
2556
|
-
|
|
2557
|
-
"
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
"
|
|
2646
|
+
"reserved",
|
|
2647
|
+
"almost-props",
|
|
2648
|
+
"unknown",
|
|
2649
|
+
"directive",
|
|
2650
|
+
"a11y",
|
|
2651
|
+
"shorthand-prop",
|
|
2652
|
+
"callback",
|
|
2653
|
+
"multiline-prop"
|
|
2564
2654
|
],
|
|
2565
|
-
ignoreCase: true,
|
|
2566
2655
|
type: "alphabetical"
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2656
|
+
}
|
|
2657
|
+
],
|
|
2658
|
+
"perfectionist/sort-maps": [
|
|
2659
|
+
"error",
|
|
2660
|
+
{
|
|
2661
|
+
...commonOptions,
|
|
2662
|
+
ignoreCase: true,
|
|
2663
|
+
type: "unsorted",
|
|
2664
|
+
useConfigurationIf: { matchesAstSelector: "VariableDeclaration[kind=\"const\"] NewExpression" }
|
|
2665
|
+
},
|
|
2666
|
+
{
|
|
2569
2667
|
...commonOptions,
|
|
2570
2668
|
fallbackSort: {
|
|
2571
2669
|
order: "asc",
|
|
@@ -2573,24 +2671,62 @@ const perfectionist = async (options) => {
|
|
|
2573
2671
|
},
|
|
2574
2672
|
ignoreCase: true,
|
|
2575
2673
|
type: "alphabetical"
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2674
|
+
}
|
|
2675
|
+
],
|
|
2676
|
+
"perfectionist/sort-modules": ["error", {
|
|
2677
|
+
...commonOptions,
|
|
2678
|
+
fallbackSort: { type: "unsorted" },
|
|
2679
|
+
type: "alphabetical"
|
|
2680
|
+
}],
|
|
2681
|
+
"perfectionist/sort-named-exports": ["error", { ...commonOptions }],
|
|
2682
|
+
"perfectionist/sort-named-imports": ["error", { ...commonOptions }],
|
|
2683
|
+
"perfectionist/sort-object-types": ["error", { ...commonOptions }],
|
|
2684
|
+
"perfectionist/sort-objects": ["error", { ...commonOptions }],
|
|
2685
|
+
"perfectionist/sort-sets": ["error", { ...commonOptions }],
|
|
2686
|
+
"perfectionist/sort-switch-case": ["error", {
|
|
2687
|
+
...commonOptions,
|
|
2688
|
+
fallbackSort: {
|
|
2689
|
+
order: "asc",
|
|
2690
|
+
type: "natural"
|
|
2691
|
+
},
|
|
2692
|
+
type: "alphabetical"
|
|
2693
|
+
}],
|
|
2694
|
+
"perfectionist/sort-union-types": ["error", {
|
|
2695
|
+
...commonOptions,
|
|
2696
|
+
fallbackSort: { type: "unsorted" },
|
|
2697
|
+
groups: [
|
|
2698
|
+
["keyword", "literal"],
|
|
2699
|
+
"named",
|
|
2700
|
+
[
|
|
2701
|
+
"conditional",
|
|
2702
|
+
"intersection",
|
|
2703
|
+
"union"
|
|
2704
|
+
],
|
|
2705
|
+
"unknown"
|
|
2706
|
+
],
|
|
2707
|
+
ignoreCase: true,
|
|
2708
|
+
type: "alphabetical"
|
|
2709
|
+
}],
|
|
2710
|
+
"perfectionist/sort-variable-declarations": ["error", {
|
|
2711
|
+
...commonOptions,
|
|
2712
|
+
fallbackSort: {
|
|
2713
|
+
order: "asc",
|
|
2714
|
+
type: "natural"
|
|
2715
|
+
},
|
|
2716
|
+
ignoreCase: true,
|
|
2717
|
+
type: "alphabetical"
|
|
2718
|
+
}],
|
|
2578
2719
|
...overrides
|
|
2579
2720
|
}
|
|
2580
2721
|
}];
|
|
2581
2722
|
};
|
|
2582
2723
|
//#endregion
|
|
2583
2724
|
//#region src/configs/promise.ts
|
|
2584
|
-
const promise = async (options
|
|
2725
|
+
const promise = async (options) => {
|
|
2585
2726
|
const { lessOpinionated, overrides, typescript } = options;
|
|
2586
2727
|
const [promisePlugin] = await loadPackages(["eslint-plugin-promise"]);
|
|
2587
2728
|
return [{
|
|
2588
2729
|
name: "moso/promise",
|
|
2589
|
-
files: [
|
|
2590
|
-
GLOB_SRC,
|
|
2591
|
-
GLOB_ASTRO,
|
|
2592
|
-
GLOB_VUE
|
|
2593
|
-
],
|
|
2594
2730
|
plugins: { "promise": memoize(promisePlugin, "eslint-plugin-promise") },
|
|
2595
2731
|
rules: {
|
|
2596
2732
|
"promise/no-callback-in-promise": "error",
|
|
@@ -2634,31 +2770,36 @@ const RemixPackages = [
|
|
|
2634
2770
|
"@remix-run/serve"
|
|
2635
2771
|
];
|
|
2636
2772
|
const react = async (options) => {
|
|
2637
|
-
const { additionalHooks = "useIsomorphicLayoutEffect", files, filesTypeAware, ignoresTypeAware, lessOpinionated, nextjs, overrides, overridesTypeAware, parserOptions, projectRoot, stylistic, typescript } = options;
|
|
2773
|
+
const { a11y, additionalHooks = "useIsomorphicLayoutEffect", files, filesTypeAware, ignoresTypeAware, lessOpinionated, nextjs, overrides, overridesA11y, overridesTypeAware, parserOptions, projectRoot, reactRefresh, stylistic, typescript } = options;
|
|
2638
2774
|
const [reactPlugin, reactHooksPlugin, reactRefreshPlugin, reactYouMightNotNeedAnEffect] = await loadPackages([
|
|
2639
2775
|
"@eslint-react/eslint-plugin",
|
|
2640
2776
|
"eslint-plugin-react-hooks",
|
|
2641
2777
|
"eslint-plugin-react-refresh",
|
|
2642
2778
|
"eslint-plugin-react-you-might-not-need-an-effect"
|
|
2643
2779
|
]);
|
|
2644
|
-
const isTypeAware = typeof projectRoot === "string";
|
|
2645
|
-
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((x) => isPackageExists(x));
|
|
2780
|
+
const isTypeAware = typescript && typeof projectRoot === "string" && parserOptions?.projectService !== false;
|
|
2781
|
+
const isAllowConstantExport = reactRefresh?.allowConstantExport ?? ReactRefreshAllowConstantExportPackages.some((x) => isPackageExists(x));
|
|
2646
2782
|
const isUsingNextJS = nextjs !== false;
|
|
2647
2783
|
const isUsingRemix = RemixPackages.some((x) => isPackageExists(x));
|
|
2648
2784
|
const isUsingReactRouter = ReactRouterPackages.some((x) => isPackageExists(x));
|
|
2785
|
+
const [jsxA11yPlugin] = a11y ? await loadPackages(["eslint-plugin-jsx-a11y"]) : [void 0];
|
|
2649
2786
|
const reactHooks = additionalHooks ? additionalHooks.replaceAll(",", "|") : void 0;
|
|
2650
2787
|
const stylisticEnabled = stylistic !== false;
|
|
2651
2788
|
const [typescriptParser] = typescript ? await loadPackages(["@typescript-eslint/parser"]) : [void 0];
|
|
2652
2789
|
return [
|
|
2653
2790
|
{
|
|
2654
|
-
name: "moso/react",
|
|
2655
|
-
files,
|
|
2791
|
+
name: "moso/react/setup",
|
|
2656
2792
|
plugins: {
|
|
2657
2793
|
"@eslint-react": memoize(reactPlugin, "@eslint-react"),
|
|
2658
2794
|
"react-hooks": memoize(reactHooksPlugin, "eslint-plugin-react-hooks"),
|
|
2659
2795
|
"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
|
-
|
|
2796
|
+
"react-you-might-not-need-an-effect": memoize(reactYouMightNotNeedAnEffect, "eslint-plugin-react-you-might-not-need-an-effect"),
|
|
2797
|
+
...jsxA11yPlugin && { "jsx-a11y": memoize(jsxA11yPlugin, "eslint-plugin-jsx-a11y") }
|
|
2798
|
+
}
|
|
2799
|
+
},
|
|
2800
|
+
{
|
|
2801
|
+
name: "moso/react/rules",
|
|
2802
|
+
files,
|
|
2662
2803
|
languageOptions: {
|
|
2663
2804
|
parser: typescript ? typescriptParser : void 0,
|
|
2664
2805
|
parserOptions: {
|
|
@@ -2724,12 +2865,15 @@ const react = async (options) => {
|
|
|
2724
2865
|
"dynamicParams",
|
|
2725
2866
|
"experimental_ppr",
|
|
2726
2867
|
"fetchCache",
|
|
2868
|
+
"generateImageMetaData",
|
|
2727
2869
|
"generateMetadata",
|
|
2870
|
+
"generateSitemaps",
|
|
2728
2871
|
"generateStaticParams",
|
|
2729
2872
|
"generateViewport",
|
|
2730
2873
|
"maxDuration",
|
|
2731
2874
|
"metadata",
|
|
2732
2875
|
"preferredRegion",
|
|
2876
|
+
"revalidate",
|
|
2733
2877
|
"runtime",
|
|
2734
2878
|
"viewport"
|
|
2735
2879
|
] : [], ...isUsingReactRouter || isUsingRemix ? [
|
|
@@ -2746,6 +2890,41 @@ const react = async (options) => {
|
|
|
2746
2890
|
"HydrateFallback"
|
|
2747
2891
|
] : []]
|
|
2748
2892
|
}],
|
|
2893
|
+
...jsxA11yPlugin && {
|
|
2894
|
+
"jsx-a11y/alt-text": ["warn", {
|
|
2895
|
+
elements: ["img"],
|
|
2896
|
+
img: ["Image"]
|
|
2897
|
+
}],
|
|
2898
|
+
"jsx-a11y/aria-props": "warn",
|
|
2899
|
+
"jsx-a11y/aria-proptypes": "warn",
|
|
2900
|
+
"jsx-a11y/aria-role": "warn",
|
|
2901
|
+
"jsx-a11y/aria-unsupported-elements": "warn",
|
|
2902
|
+
"jsx-a11y/iframe-has-title": "warn",
|
|
2903
|
+
"jsx-a11y/no-access-key": "warn",
|
|
2904
|
+
"jsx-a11y/no-static-element-interactions": "warn",
|
|
2905
|
+
"jsx-a11y/role-has-required-aria-props": "warn",
|
|
2906
|
+
"jsx-a11y/role-supports-aria-props": "warn",
|
|
2907
|
+
"jsx-a11y/tabindex-no-positive": "warn",
|
|
2908
|
+
"jsx-a11y/anchor-ambiguous-text": "off",
|
|
2909
|
+
"jsx-a11y/interactive-supports-focus": ["error", { tabbable: [
|
|
2910
|
+
"button",
|
|
2911
|
+
"checkbox",
|
|
2912
|
+
"link",
|
|
2913
|
+
"progressbar",
|
|
2914
|
+
"searchbox",
|
|
2915
|
+
"slider",
|
|
2916
|
+
"spinbutton",
|
|
2917
|
+
"switch",
|
|
2918
|
+
"textbox"
|
|
2919
|
+
] }],
|
|
2920
|
+
"jsx-a11y/label-has-for": "off",
|
|
2921
|
+
"jsx-a11y/no-noninteractive-element-interactions": ["error", {
|
|
2922
|
+
body: ["onError", "onLoad"],
|
|
2923
|
+
iframe: ["onError", "onLoad"],
|
|
2924
|
+
img: ["onError", "onLoad"]
|
|
2925
|
+
}],
|
|
2926
|
+
...overridesA11y
|
|
2927
|
+
},
|
|
2749
2928
|
...overrides
|
|
2750
2929
|
}
|
|
2751
2930
|
},
|
|
@@ -2800,11 +2979,6 @@ const regexp = async (options) => {
|
|
|
2800
2979
|
const [regexpPlugin] = await loadPackages(["eslint-plugin-regexp"]);
|
|
2801
2980
|
return [{
|
|
2802
2981
|
name: "moso/regexp",
|
|
2803
|
-
files: [
|
|
2804
|
-
GLOB_SRC,
|
|
2805
|
-
GLOB_ASTRO,
|
|
2806
|
-
GLOB_VUE
|
|
2807
|
-
],
|
|
2808
2982
|
plugins: { "regexp": memoize(regexpPlugin, "eslint-plugin-regexp") },
|
|
2809
2983
|
rules: {
|
|
2810
2984
|
"no-empty-character-class": "off",
|
|
@@ -3057,6 +3231,7 @@ const sortTsconfig = (options = {}) => {
|
|
|
3057
3231
|
//#endregion
|
|
3058
3232
|
//#region src/configs/stylistic.ts
|
|
3059
3233
|
const StylisticConfigDefaults = {
|
|
3234
|
+
braceStyle: "1tbs",
|
|
3060
3235
|
experimental: false,
|
|
3061
3236
|
indent: 4,
|
|
3062
3237
|
jsx: true,
|
|
@@ -3064,12 +3239,13 @@ const StylisticConfigDefaults = {
|
|
|
3064
3239
|
semi: true
|
|
3065
3240
|
};
|
|
3066
3241
|
const stylistic = async (options) => {
|
|
3067
|
-
const { experimental, indent, jsx, lessOpinionated, quotes, overrides, semi, typescript } = {
|
|
3242
|
+
const { braceStyle, experimental, indent, jsx, lessOpinionated, quotes, overrides, semi, typescript } = {
|
|
3068
3243
|
...StylisticConfigDefaults,
|
|
3069
3244
|
...options
|
|
3070
3245
|
};
|
|
3071
3246
|
const [stylisticPlugin] = await loadPackages(["@stylistic/eslint-plugin"]);
|
|
3072
3247
|
const config = stylisticPlugin.configs.customize({
|
|
3248
|
+
braceStyle,
|
|
3073
3249
|
experimental,
|
|
3074
3250
|
indent,
|
|
3075
3251
|
jsx,
|
|
@@ -3103,7 +3279,7 @@ const stylistic = async (options) => {
|
|
|
3103
3279
|
"@stylistic/block-spacing": ["error", "always"],
|
|
3104
3280
|
"@stylistic/brace-style": [
|
|
3105
3281
|
"error",
|
|
3106
|
-
|
|
3282
|
+
braceStyle,
|
|
3107
3283
|
{ allowSingleLine: true }
|
|
3108
3284
|
],
|
|
3109
3285
|
"@stylistic/comma-dangle": ["error", {
|
|
@@ -3305,40 +3481,68 @@ const stylistic = async (options) => {
|
|
|
3305
3481
|
}];
|
|
3306
3482
|
};
|
|
3307
3483
|
//#endregion
|
|
3484
|
+
//#region src/configs/tailwind.ts
|
|
3485
|
+
const tailwind = async (options) => {
|
|
3486
|
+
const { config, entryPoint, overrides, stylistic, version } = options;
|
|
3487
|
+
const [tailwindPlugin] = await loadPackages(["eslint-plugin-better-tailwindcss"]);
|
|
3488
|
+
const stylisticEnabled = stylistic !== false;
|
|
3489
|
+
return [{
|
|
3490
|
+
name: "moso/tailwind",
|
|
3491
|
+
settings: { "better-tailwindcss": version === 4 ? { entryPoint } : { config } },
|
|
3492
|
+
plugins: { "tailwind-better": memoize(tailwindPlugin, "eslint-plugin-better-tailwindcss") },
|
|
3493
|
+
rules: {
|
|
3494
|
+
"tailwind-better/no-conflicting-classes": "error",
|
|
3495
|
+
"tailwind-better/no-restricted-classes": "error",
|
|
3496
|
+
"tailwind-better/no-unknown-classes": ["off", { detectComponentClasses: true }],
|
|
3497
|
+
...stylisticEnabled && {
|
|
3498
|
+
"tailwind-better/enforce-consistent-line-wrapping": ["error", {
|
|
3499
|
+
classesPerLine: 0,
|
|
3500
|
+
group: "newLine",
|
|
3501
|
+
indent: stylistic.indent,
|
|
3502
|
+
lineBreakStyle: "unix",
|
|
3503
|
+
preferSingleLine: false,
|
|
3504
|
+
printWidth: 0
|
|
3505
|
+
}],
|
|
3506
|
+
"tailwind-better/enforce-consistent-class-order": ["error", {
|
|
3507
|
+
order: "strict",
|
|
3508
|
+
detectComponentClasses: true,
|
|
3509
|
+
componentClassOrder: "preserve",
|
|
3510
|
+
componentClassPosition: "start",
|
|
3511
|
+
unknownClassOrder: "preserve",
|
|
3512
|
+
unknownClassPosition: "start"
|
|
3513
|
+
}],
|
|
3514
|
+
"tailwind-better/enforce-consistent-variable-syntax": ["error", { syntax: "shorthand" }],
|
|
3515
|
+
"tailwind-better/enforce-consistent-important-position": "off",
|
|
3516
|
+
"tailwind-better/enforce-shorthand-classes": "off",
|
|
3517
|
+
"tailwind-better/enforce-canonical-classes": "error",
|
|
3518
|
+
"tailwind-better/no-duplicate-classes": "error",
|
|
3519
|
+
"tailwind-better/no-deprecated-classes": "warn",
|
|
3520
|
+
"tailwind-better/no-unnecessary-whitespace": "warn"
|
|
3521
|
+
},
|
|
3522
|
+
...overrides
|
|
3523
|
+
}
|
|
3524
|
+
}];
|
|
3525
|
+
};
|
|
3526
|
+
//#endregion
|
|
3308
3527
|
//#region src/configs/test.ts
|
|
3309
3528
|
const test = async (options) => {
|
|
3310
|
-
const { isInEditor, files, overrides } = options;
|
|
3311
|
-
const [functionalPlugin
|
|
3529
|
+
const { functionalEnforcement, isInEditor, files, overrides } = options;
|
|
3530
|
+
const [functionalPlugin] = functionalEnforcement === "none" ? [void 0] : await loadPackages(["eslint-plugin-functional"]);
|
|
3531
|
+
const [noOnlyTestsPlugin] = await loadPackages(["eslint-plugin-no-only-tests"]);
|
|
3312
3532
|
const vitestPlugin = await interopDefault(import("@vitest/eslint-plugin"));
|
|
3313
3533
|
return [{
|
|
3314
3534
|
name: "moso/test/setup",
|
|
3535
|
+
languageOptions: { globals: { ...vitestPlugin.environments.env.globals } },
|
|
3536
|
+
settings: { vitest: { typecheck: true } },
|
|
3315
3537
|
plugins: {
|
|
3316
3538
|
"no-only-tests": memoize(noOnlyTestsPlugin, "eslint-plugin-no-only-tests"),
|
|
3317
3539
|
"vitest": memoize(vitestPlugin, "@vitest/eslint-plugin")
|
|
3318
|
-
}
|
|
3319
|
-
settings: { vitest: { typecheck: true } },
|
|
3320
|
-
languageOptions: { globals: { ...vitestPlugin.environments.env.globals } }
|
|
3540
|
+
}
|
|
3321
3541
|
}, {
|
|
3322
3542
|
name: "moso/test/rules",
|
|
3323
3543
|
files,
|
|
3324
3544
|
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",
|
|
3545
|
+
...(assert.ok(!Array.isArray(functionalPlugin?.configs.off)), functionalPlugin?.configs.off.rules),
|
|
3342
3546
|
"no-only-tests/no-only-tests": isInEditor ? "warn" : "error",
|
|
3343
3547
|
...(assert.ok(!Array.isArray(vitestPlugin.configs.recommended)), vitestPlugin.configs.recommended.rules),
|
|
3344
3548
|
"vitest/consistent-test-it": ["error", {
|
|
@@ -3378,10 +3582,16 @@ const toml = async (options) => {
|
|
|
3378
3582
|
"toml/tables-order": "error",
|
|
3379
3583
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
3380
3584
|
...stylisticEnabled && {
|
|
3381
|
-
"toml/array-bracket-newline": "error",
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3585
|
+
"toml/array-bracket-newline": ["error", {
|
|
3586
|
+
minItems: 4,
|
|
3587
|
+
multiline: true
|
|
3588
|
+
}],
|
|
3589
|
+
"toml/array-bracket-spacing": ["error", "never"],
|
|
3590
|
+
"toml/array-element-newline": ["error", {
|
|
3591
|
+
minItems: 4,
|
|
3592
|
+
multiline: true
|
|
3593
|
+
}],
|
|
3594
|
+
"toml/indent": ["error", indent],
|
|
3385
3595
|
"toml/inline-table-curly-spacing": "error",
|
|
3386
3596
|
"toml/key-spacing": "error",
|
|
3387
3597
|
"toml/padding-line-between-pairs": "error",
|
|
@@ -3400,7 +3610,7 @@ const typescript = async (options) => {
|
|
|
3400
3610
|
const { componentExts, disableTypeAwareRules, erasableOnly, files, filesTypeAware, functionalEnforcement, lessOpinionated, mode, overrides, overridesTypeAware, parserOptions, projectRoot, stylistic, unsafe } = options;
|
|
3401
3611
|
const [tsEslintPlugin, tsEslintParser] = await loadPackages(["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"]);
|
|
3402
3612
|
const [erasableSyntaxPlugin] = erasableOnly !== false && !lessOpinionated ? await loadPackages(["eslint-plugin-erasable-syntax-only"]) : [void 0];
|
|
3403
|
-
const isTypeAware = typeof projectRoot === "string";
|
|
3613
|
+
const isTypeAware = typeof projectRoot === "string" && parserOptions.projectService !== false;
|
|
3404
3614
|
const stylisticEnabled = stylistic !== false;
|
|
3405
3615
|
return [
|
|
3406
3616
|
{
|
|
@@ -3411,7 +3621,7 @@ const typescript = async (options) => {
|
|
|
3411
3621
|
parserOptions: {
|
|
3412
3622
|
ecmaFeatures: { jsx: true },
|
|
3413
3623
|
ecmaVersion: "latest",
|
|
3414
|
-
extraFileExtensions: componentExts.map((ext) =>
|
|
3624
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
3415
3625
|
jsxPragma: void 0,
|
|
3416
3626
|
sourceType: "module",
|
|
3417
3627
|
warnOnUnsupportedTypeScriptVersion: true,
|
|
@@ -3708,7 +3918,7 @@ const typescript = async (options) => {
|
|
|
3708
3918
|
parserOptions: {
|
|
3709
3919
|
ecmaFeatures: { jsx: true },
|
|
3710
3920
|
ecmaVersion: "latest",
|
|
3711
|
-
extraFileExtensions: componentExts.map((ext) =>
|
|
3921
|
+
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
3712
3922
|
jsxPragma: void 0,
|
|
3713
3923
|
projectService: true,
|
|
3714
3924
|
sourceType: "module",
|
|
@@ -3720,7 +3930,7 @@ const typescript = async (options) => {
|
|
|
3720
3930
|
rules: {
|
|
3721
3931
|
...(assert.ok(!Array.isArray(tsEslintPlugin.configs?.["recommended-type-checked-only"])), tsEslintPlugin.configs?.["recommended-type-checked-only"]?.rules),
|
|
3722
3932
|
"no-implied-eval": "off",
|
|
3723
|
-
"
|
|
3933
|
+
"no-throw-literal": "off",
|
|
3724
3934
|
"prefer-destructuring": "off",
|
|
3725
3935
|
"prefer-promise-reject-errors": "off",
|
|
3726
3936
|
"require-await": "off",
|
|
@@ -3954,21 +4164,20 @@ const typescript = async (options) => {
|
|
|
3954
4164
|
//#endregion
|
|
3955
4165
|
//#region src/configs/unicorn.ts
|
|
3956
4166
|
const unicorn = async (options) => {
|
|
3957
|
-
const { lessOpinionated, overrides } = options;
|
|
4167
|
+
const { files, lessOpinionated, overrides } = options;
|
|
3958
4168
|
const [unicornPlugin] = await loadPackages(["eslint-plugin-unicorn"]);
|
|
3959
4169
|
return [{
|
|
3960
|
-
name: "moso/unicorn",
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
],
|
|
3966
|
-
plugins: { "unicorn": memoize(unicornPlugin, "eslint-plugin-unicorn") },
|
|
4170
|
+
name: "moso/unicorn/setup",
|
|
4171
|
+
plugins: { "unicorn": memoize(unicornPlugin, "eslint-plugin-unicorn") }
|
|
4172
|
+
}, {
|
|
4173
|
+
name: "moso/unicorn/rules",
|
|
4174
|
+
files,
|
|
3967
4175
|
rules: {
|
|
3968
4176
|
...(assert.ok(!Array.isArray(unicornPlugin.configs.unopinionated)), unicornPlugin.configs.unopinionated.rules),
|
|
3969
4177
|
...!lessOpinionated && {
|
|
3970
4178
|
...(assert.ok(!Array.isArray(unicornPlugin.configs.recommended)), unicornPlugin.configs.recommended.rules),
|
|
3971
4179
|
"unicorn/custom-error-definition": "error",
|
|
4180
|
+
"unicorn/iteration-fallback-style": ["error", "fallback"],
|
|
3972
4181
|
"unicorn/no-instanceof-builtins": ["error", {
|
|
3973
4182
|
strategy: "strict",
|
|
3974
4183
|
useErrorIsError: true
|
|
@@ -3976,7 +4185,7 @@ const unicorn = async (options) => {
|
|
|
3976
4185
|
"unicorn/no-unsafe-dom-html": "error",
|
|
3977
4186
|
"unicorn/prefer-at": ["error", { checkAllIndexAccess: false }],
|
|
3978
4187
|
"unicorn/prefer-short-arrow-method": "error",
|
|
3979
|
-
"unicorn/try-complexity": "error",
|
|
4188
|
+
"unicorn/try-complexity": ["error", { max: 3 }],
|
|
3980
4189
|
"unicorn/consistent-boolean-name": "off",
|
|
3981
4190
|
"unicorn/consistent-compound-words": "off",
|
|
3982
4191
|
"unicorn/consistent-export-decorator-position": "off",
|
|
@@ -4053,7 +4262,8 @@ const unicorn = async (options) => {
|
|
|
4053
4262
|
"unicorn/require-array-sort-compare": "off",
|
|
4054
4263
|
"unicorn/require-css-escape": "off",
|
|
4055
4264
|
"unicorn/require-module-attributes": "off",
|
|
4056
|
-
"unicorn/require-module-specifiers": "off"
|
|
4265
|
+
"unicorn/require-module-specifiers": "off",
|
|
4266
|
+
"unicorn/single-line-block-comment-style": "off"
|
|
4057
4267
|
},
|
|
4058
4268
|
...overrides
|
|
4059
4269
|
}
|
|
@@ -4063,15 +4273,14 @@ const unicorn = async (options) => {
|
|
|
4063
4273
|
//#region src/configs/vue.ts
|
|
4064
4274
|
const NuxtPackages = ["nuxt"];
|
|
4065
4275
|
const vue = async (options) => {
|
|
4066
|
-
const { a11y, files,
|
|
4067
|
-
const { indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
4276
|
+
const { a11y, files, overrides, overridesA11y, parserOptions, stylistic, typescript } = options;
|
|
4277
|
+
const { braceStyle = "1tbs", indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
4068
4278
|
const [vuePlugin, vueParser, processorVueBlocks, { mergeProcessors }] = await loadPackages([
|
|
4069
4279
|
"eslint-plugin-vue",
|
|
4070
4280
|
"vue-eslint-parser",
|
|
4071
4281
|
"eslint-processor-vue-blocks",
|
|
4072
4282
|
"eslint-merge-processors"
|
|
4073
4283
|
]);
|
|
4074
|
-
const isTypeAware = typeof projectRoot === "string";
|
|
4075
4284
|
const isUsingNuxt = NuxtPackages.some((x) => isPackageExists(x));
|
|
4076
4285
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks;
|
|
4077
4286
|
const stylisticEnabled = stylistic !== false;
|
|
@@ -4096,7 +4305,10 @@ const vue = async (options) => {
|
|
|
4096
4305
|
watch: "readonly",
|
|
4097
4306
|
watchEffect: "readonly"
|
|
4098
4307
|
} },
|
|
4099
|
-
plugins: {
|
|
4308
|
+
plugins: {
|
|
4309
|
+
"vue": memoize(vuePlugin, "eslint-plugin-vue"),
|
|
4310
|
+
...vueA11yPlugin && { "vuejs-accessibility": memoize(vueA11yPlugin, "eslint-plugin-vuejs-accessibility") }
|
|
4311
|
+
}
|
|
4100
4312
|
},
|
|
4101
4313
|
{
|
|
4102
4314
|
name: "moso/vue/rules",
|
|
@@ -4119,10 +4331,7 @@ const vue = async (options) => {
|
|
|
4119
4331
|
}
|
|
4120
4332
|
})]),
|
|
4121
4333
|
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), {}),
|
|
4334
|
+
...flattenRules(vuePlugin.configs["flat/recommended"]),
|
|
4126
4335
|
"node/prefer-global/process": "off",
|
|
4127
4336
|
"vue/block-order": ["error", { order: [
|
|
4128
4337
|
"script",
|
|
@@ -4186,7 +4395,7 @@ const vue = async (options) => {
|
|
|
4186
4395
|
}],
|
|
4187
4396
|
"vue/brace-style": [
|
|
4188
4397
|
"error",
|
|
4189
|
-
|
|
4398
|
+
braceStyle,
|
|
4190
4399
|
{ allowSingleLine: true }
|
|
4191
4400
|
],
|
|
4192
4401
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
@@ -4255,69 +4464,13 @@ const vue = async (options) => {
|
|
|
4255
4464
|
"vue/space-in-parens": ["error", "never"],
|
|
4256
4465
|
"vue/template-curly-spacing": "error"
|
|
4257
4466
|
},
|
|
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
|
-
}]
|
|
4467
|
+
...vueA11yPlugin && {
|
|
4468
|
+
...flattenRules(vueA11yPlugin.configs["flat/recommended"]),
|
|
4469
|
+
...overridesA11y
|
|
4289
4470
|
},
|
|
4290
4471
|
...overrides
|
|
4291
4472
|
}
|
|
4292
4473
|
},
|
|
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
4474
|
...isUsingNuxt ? [
|
|
4322
4475
|
{
|
|
4323
4476
|
name: "moso/nuxt/ignores",
|
|
@@ -4333,7 +4486,7 @@ const vue = async (options) => {
|
|
|
4333
4486
|
name: "moso/nuxt/rules",
|
|
4334
4487
|
files: [
|
|
4335
4488
|
`**/app.{${GLOB_SRC_EXT},vue}`,
|
|
4336
|
-
`**/components
|
|
4489
|
+
`**/components/**/*.{${GLOB_SRC_EXT},vue}`,
|
|
4337
4490
|
`**/error.{${GLOB_SRC_EXT},vue}`,
|
|
4338
4491
|
`**/layouts/**/*.{${GLOB_SRC_EXT},vue}`,
|
|
4339
4492
|
`**/pages/**/*.{${GLOB_SRC_EXT},vue}`
|
|
@@ -4341,6 +4494,7 @@ const vue = async (options) => {
|
|
|
4341
4494
|
rules: { "vue/multi-word-component-names": "off" }
|
|
4342
4495
|
},
|
|
4343
4496
|
{
|
|
4497
|
+
name: "moso/nuxt/template-rules",
|
|
4344
4498
|
files: [`**/layouts/**/*.{${GLOB_SRC_EXT},vue}`, `**/pages/**/*.{${GLOB_SRC_EXT},vue}`],
|
|
4345
4499
|
rules: { "vue/no-multiple-template-root": "error" }
|
|
4346
4500
|
}
|
|
@@ -4358,10 +4512,10 @@ const yaml = async (options) => {
|
|
|
4358
4512
|
name: "moso/yaml/setup",
|
|
4359
4513
|
plugins: { "yml": memoize(yamlPlugin, "eslint-plugin-yml") }
|
|
4360
4514
|
}, {
|
|
4515
|
+
name: "moso/yaml/rules",
|
|
4361
4516
|
files,
|
|
4362
4517
|
language: "yml/yaml",
|
|
4363
4518
|
languageOptions: { parser: memoize(yamlParser, "yaml-eslint-parser") },
|
|
4364
|
-
name: "moso/yaml/rules",
|
|
4365
4519
|
rules: {
|
|
4366
4520
|
"@stylistic/spaced-comment": "off",
|
|
4367
4521
|
"yml/block-mapping": "error",
|
|
@@ -4416,44 +4570,53 @@ const VuePackages = [
|
|
|
4416
4570
|
/**
|
|
4417
4571
|
* Construct an array of ESLint flat config items.
|
|
4418
4572
|
*
|
|
4419
|
-
* @param {OptionsConfig & TypedFlatConfigItem} options - Options for generating the ESLint configurations.
|
|
4573
|
+
* @param {OptionsConfig & TypedFlatConfigItem} [options={}] - Options for generating the ESLint configurations.
|
|
4420
4574
|
* @param {Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]} userConfigs - User configurations to be merged with the generated configurations
|
|
4421
4575
|
* @returns {Promise<TypedFlatConfigItem[]>} - The merged ESLint configurations
|
|
4422
4576
|
*/
|
|
4423
|
-
async function moso(options, ...userConfigs) {
|
|
4424
|
-
const { componentExts = [], isInEditor = isInEditorEnv(), jsdoc: jsdocOptions = false, jsonc: jsoncOptions = false, jsx: jsxOptions = true } = options;
|
|
4425
|
-
|
|
4577
|
+
async function moso(options = {}, ...userConfigs) {
|
|
4578
|
+
const { componentExts: componentExtsOption = [], isInEditor = isInEditorEnv(), jsdoc: jsdocOptions = false, jsonc: jsoncOptions = false, jsx: jsxOptions = true } = options;
|
|
4579
|
+
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.");
|
|
4580
|
+
const mut_packageExistsCache = /* @__PURE__ */ new Map();
|
|
4581
|
+
const packageExists = (name) => {
|
|
4582
|
+
const cached = mut_packageExistsCache.get(name);
|
|
4583
|
+
if (cached !== void 0) return cached;
|
|
4584
|
+
const found = isPackageExists(name);
|
|
4585
|
+
mut_packageExistsCache.set(name, found);
|
|
4586
|
+
return found;
|
|
4587
|
+
};
|
|
4588
|
+
const anyPackageExists = (names) => names.some((x) => packageExists(x));
|
|
4589
|
+
const typescriptRequested = options.typescript ?? packageExists("typescript");
|
|
4426
4590
|
const typescriptVersion = (typescriptRequested === false ? void 0 : await getPackageInfo("typescript"))?.version;
|
|
4427
4591
|
const typescriptUnsupported = typescriptVersion !== void 0 && Number(typescriptVersion.split(".")[0]) >= 7;
|
|
4428
4592
|
if (typescriptUnsupported) {
|
|
4429
|
-
const message = `[@moso/eslint-config] TypeScript ${typescriptVersion} was detected, but TypeScript 7 does not ship a programmatic API, so @typescript-eslint (and therefore all TypeScript linting) cannot run against it.\n\n
|
|
4430
|
-
Install the TypeScript 6 compatibility package side-by-side via an npm alias:\n\n
|
|
4431
|
-
npm install -D typescript@npm:@typescript/typescript6\n\n
|
|
4432
|
-
Optionally keep TypeScript 7's own tsc available as "@typescript/native": "npm:typescript@^7.0.2".\n
|
|
4433
|
-
See https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0`;
|
|
4593
|
+
const message = `[@moso/eslint-config] TypeScript ${typescriptVersion} was detected, but TypeScript 7 does not ship a programmatic API, so @typescript-eslint (and therefore all TypeScript linting) cannot run against it.\n\nInstall the TypeScript 6 compatibility package side-by-side via an npm alias:\n\n npm install -D typescript@npm:@typescript/typescript6\n\nOptionally keep TypeScript 7's own tsc available as "@typescript/native": "npm:typescript@^7.0.2".\nSee https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0`;
|
|
4434
4594
|
if (options.typescript !== void 0) throw new Error(message);
|
|
4435
4595
|
console.warn(message);
|
|
4436
4596
|
}
|
|
4437
4597
|
const typescriptOptions = typescriptUnsupported ? false : typescriptRequested;
|
|
4438
|
-
const astroOptions = options.astro ?? AstroPackages
|
|
4439
|
-
const nextjsOptions = options.nextjs ?? NextJSPackages
|
|
4440
|
-
const reactOptions = options.react ?? ReactPackages
|
|
4441
|
-
const
|
|
4442
|
-
|
|
4443
|
-
|
|
4598
|
+
const astroOptions = options.astro ?? anyPackageExists(AstroPackages);
|
|
4599
|
+
const nextjsOptions = options.nextjs ?? anyPackageExists(NextJSPackages);
|
|
4600
|
+
const reactOptions = options.react ?? anyPackageExists(ReactPackages);
|
|
4601
|
+
const tailwindOptions = options.tailwind ?? packageExists("tailwindcss");
|
|
4602
|
+
const vueOptions = options.vue ?? anyPackageExists(VuePackages);
|
|
4603
|
+
const componentExts = vueOptions === false ? [...componentExtsOption] : [.../* @__PURE__ */ new Set([...componentExtsOption, "vue"])];
|
|
4604
|
+
const baselineOptions = options.baseline === false ? false : typeof options.baseline === "object" ? options.baseline : typeof options.baseline === "string" || typeof options.baseline === "number" ? { baseline: options.baseline } : {};
|
|
4444
4605
|
const e18eOptions = options.e18e === false ? false : typeof options.e18e === "object" ? options.e18e : options.e18e === true ? {} : options.lessOpinionated === true ? false : {};
|
|
4445
|
-
const functionalEnforcement = typeof options.functional === "string" ? options.functional : typeof options.functional === "object" ? options.functional.functionalEnforcement ?? "
|
|
4606
|
+
const functionalEnforcement = typeof options.functional === "string" ? options.functional : typeof options.functional === "object" ? options.functional.functionalEnforcement ?? "lite" : options.functional ? "recommended" : options.functional === false || options.lessOpinionated === true ? "none" : "lite";
|
|
4446
4607
|
const hasTypeScript = Boolean(typescriptOptions);
|
|
4447
4608
|
const ignoreOptions = typeof options.ignores === "object" ? options.ignores : {};
|
|
4448
4609
|
const modeOptions = typeof options.mode === "string" ? options.mode : "none";
|
|
4449
4610
|
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
4611
|
const stylisticOptions = options.stylistic === false ? false : {
|
|
4452
4612
|
...StylisticConfigDefaults,
|
|
4453
4613
|
jsx: typeof jsxOptions === "boolean" ? jsxOptions : true,
|
|
4454
4614
|
...typeof options.stylistic === "object" && options.stylistic
|
|
4455
4615
|
};
|
|
4456
|
-
const { filesTypeAware, ignoresTypeAware, parserOptions, useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
|
|
4616
|
+
const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, unsafe: typescriptUnsafe, useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
|
|
4617
|
+
const deprecatedProjectRoot = options.projectRoot;
|
|
4618
|
+
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 }`.");
|
|
4619
|
+
const projectRootOptions = typeof typescriptProjectRoot === "string" ? checkFilePath(typescriptProjectRoot) : typeof deprecatedProjectRoot === "string" ? checkFilePath(deprecatedProjectRoot) : void 0;
|
|
4457
4620
|
const projectServiceUserConfig = {
|
|
4458
4621
|
defaultProject: "./tsconfig.json",
|
|
4459
4622
|
loadTypeScriptPlugins: isInEditor,
|
|
@@ -4464,7 +4627,6 @@ async function moso(options, ...userConfigs) {
|
|
|
4464
4627
|
GLOB_TS,
|
|
4465
4628
|
GLOB_TSX
|
|
4466
4629
|
];
|
|
4467
|
-
const withRoot = (glob) => projectRootOptions === void 0 ? glob : path.join(projectRootOptions, glob);
|
|
4468
4630
|
const typescriptConfigOptions = {
|
|
4469
4631
|
...typescriptSubOptions,
|
|
4470
4632
|
filesTypeAware: filesTypeAware ?? defaultFilesTypesAware,
|
|
@@ -4473,13 +4635,7 @@ async function moso(options, ...userConfigs) {
|
|
|
4473
4635
|
tsconfigRootDir: projectRootOptions,
|
|
4474
4636
|
...parserOptions,
|
|
4475
4637
|
projectService: projectRootOptions === void 0 || parserOptions?.projectService === false ? false : useDefaultDefaultProject === false ? projectServiceUserConfig : {
|
|
4476
|
-
allowDefaultProject: [
|
|
4477
|
-
withRoot(GLOB_ROOT_DTS),
|
|
4478
|
-
withRoot(GLOB_ROOT_JS),
|
|
4479
|
-
withRoot(GLOB_ROOT_JSX),
|
|
4480
|
-
withRoot(GLOB_ROOT_TS),
|
|
4481
|
-
withRoot(GLOB_ROOT_TSX)
|
|
4482
|
-
],
|
|
4638
|
+
allowDefaultProject: [GLOB_ROOT_JS, GLOB_ROOT_JSX],
|
|
4483
4639
|
...projectServiceUserConfig
|
|
4484
4640
|
}
|
|
4485
4641
|
}
|
|
@@ -4489,55 +4645,76 @@ async function moso(options, ...userConfigs) {
|
|
|
4489
4645
|
ignoreNamePattern: ["^[mM]ut_"],
|
|
4490
4646
|
...resolveSubOptions(options, "functional")
|
|
4491
4647
|
};
|
|
4492
|
-
const mut_configs = [
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4648
|
+
const mut_configs = [];
|
|
4649
|
+
if (options.comments !== false) mut_configs.push(comments({ overrides: getOverrides(options, "comments") }));
|
|
4650
|
+
if (options.ignores !== false) mut_configs.push(ignores({
|
|
4651
|
+
...ignoreOptions,
|
|
4652
|
+
...resolveSubOptions(options, "ignores")
|
|
4653
|
+
}));
|
|
4654
|
+
if (options.imports !== false) mut_configs.push(imports({
|
|
4655
|
+
...typescriptConfigOptions,
|
|
4656
|
+
files: [
|
|
4657
|
+
GLOB_DTS,
|
|
4658
|
+
GLOB_TS,
|
|
4659
|
+
GLOB_TSX
|
|
4660
|
+
],
|
|
4661
|
+
overrides: getOverrides(options, "imports"),
|
|
4662
|
+
stylistic: stylisticOptions,
|
|
4663
|
+
typescript: hasTypeScript
|
|
4664
|
+
}));
|
|
4665
|
+
mut_configs.push(javascript({
|
|
4666
|
+
...functionalConfigOptions,
|
|
4667
|
+
isInEditor,
|
|
4668
|
+
lessOpinionated: options.lessOpinionated,
|
|
4669
|
+
perfectionist: perfectionistOptions,
|
|
4670
|
+
overrides: getOverrides(options, "javascript")
|
|
4671
|
+
}));
|
|
4672
|
+
if (options.node !== false) mut_configs.push(node({
|
|
4673
|
+
files: [GLOB_SRC],
|
|
4674
|
+
hasReact: Boolean(reactOptions),
|
|
4675
|
+
lessOpinionated: options.lessOpinionated,
|
|
4676
|
+
overrides: getOverrides(options, "node"),
|
|
4677
|
+
typescript: hasTypeScript,
|
|
4678
|
+
...resolveSubOptions(options, "node")
|
|
4679
|
+
}));
|
|
4680
|
+
if (options.promise !== false) mut_configs.push(promise({
|
|
4681
|
+
lessOpinionated: options.lessOpinionated,
|
|
4682
|
+
overrides: getOverrides(options, "promise"),
|
|
4683
|
+
typescript: hasTypeScript
|
|
4684
|
+
}));
|
|
4685
|
+
if (options.regexp !== false) mut_configs.push(regexp({ overrides: getOverrides(options, "regexp") }));
|
|
4686
|
+
if (options.unicorn !== false) mut_configs.push(unicorn({
|
|
4687
|
+
files: [GLOB_SRC],
|
|
4688
|
+
lessOpinionated: options.lessOpinionated,
|
|
4689
|
+
overrides: getOverrides(options, "unicorn")
|
|
4690
|
+
}));
|
|
4529
4691
|
if (stylisticOptions !== false) mut_configs.push(stylistic({
|
|
4530
4692
|
...stylisticOptions,
|
|
4531
4693
|
lessOpinionated: options.lessOpinionated,
|
|
4532
4694
|
overrides: getOverrides(options, "stylistic"),
|
|
4533
4695
|
typescript: hasTypeScript
|
|
4534
4696
|
}));
|
|
4697
|
+
if (baselineOptions !== false) mut_configs.push(baseline({
|
|
4698
|
+
...baselineOptions,
|
|
4699
|
+
...typescriptConfigOptions,
|
|
4700
|
+
files: [
|
|
4701
|
+
GLOB_JS,
|
|
4702
|
+
GLOB_JSX,
|
|
4703
|
+
...astroOptions === false ? [] : [GLOB_ASTRO]
|
|
4704
|
+
],
|
|
4705
|
+
filesTypeAware: [GLOB_TS, GLOB_TSX],
|
|
4706
|
+
overrides: getOverrides(options, "baseline"),
|
|
4707
|
+
projectRoot: projectRootOptions,
|
|
4708
|
+
typescript: hasTypeScript
|
|
4709
|
+
}));
|
|
4535
4710
|
if (astroOptions !== false) mut_configs.push(astro({
|
|
4536
4711
|
...typescriptConfigOptions,
|
|
4537
4712
|
files: [GLOB_ASTRO],
|
|
4713
|
+
lessOpinionated: options.lessOpinionated,
|
|
4538
4714
|
overrides: getOverrides(options, "astro"),
|
|
4539
4715
|
stylistic: stylisticOptions,
|
|
4540
|
-
typescript: hasTypeScript
|
|
4716
|
+
typescript: hasTypeScript,
|
|
4717
|
+
...resolveSubOptions(options, "astro")
|
|
4541
4718
|
}));
|
|
4542
4719
|
if (e18eOptions !== false) mut_configs.push(e18e({
|
|
4543
4720
|
...e18eOptions,
|
|
@@ -4547,16 +4724,19 @@ async function moso(options, ...userConfigs) {
|
|
|
4547
4724
|
overrides: getOverrides(options, "e18e")
|
|
4548
4725
|
}));
|
|
4549
4726
|
if (functionalEnforcement !== "none") mut_configs.push(functional({
|
|
4550
|
-
...typescriptConfigOptions,
|
|
4551
4727
|
...functionalConfigOptions,
|
|
4728
|
+
...typescriptConfigOptions,
|
|
4552
4729
|
mode: modeOptions,
|
|
4553
|
-
projectRoot: projectRootOptions,
|
|
4554
4730
|
overrides: getOverrides(options, "functional"),
|
|
4555
4731
|
stylistic: stylisticOptions
|
|
4556
4732
|
}));
|
|
4557
4733
|
if (jsdocOptions !== false) mut_configs.push(jsdoc({
|
|
4734
|
+
files: [GLOB_SRC],
|
|
4735
|
+
lessOpinionated: options.lessOpinionated,
|
|
4558
4736
|
overrides: getOverrides(options, "jsdoc"),
|
|
4559
|
-
stylistic: stylisticOptions
|
|
4737
|
+
stylistic: stylisticOptions,
|
|
4738
|
+
typescript: hasTypeScript,
|
|
4739
|
+
...resolveSubOptions(options, "jsdoc")
|
|
4560
4740
|
}));
|
|
4561
4741
|
if (jsoncOptions !== false) mut_configs.push(jsonc({
|
|
4562
4742
|
files: [
|
|
@@ -4577,25 +4757,14 @@ async function moso(options, ...userConfigs) {
|
|
|
4577
4757
|
if (nextjsOptions !== false) mut_configs.push(nextjs({
|
|
4578
4758
|
files: [GLOB_SRC],
|
|
4579
4759
|
mode: modeOptions,
|
|
4580
|
-
overrides: getOverrides(options, "nextjs")
|
|
4581
|
-
|
|
4582
|
-
if (perfectionistOptions) mut_configs.push(perfectionist({
|
|
4583
|
-
lessOpinionated: options.lessOpinionated,
|
|
4584
|
-
overrides: getOverrides(options, "perfectionist")
|
|
4760
|
+
overrides: getOverrides(options, "nextjs"),
|
|
4761
|
+
...resolveSubOptions(options, "nextjs")
|
|
4585
4762
|
}));
|
|
4763
|
+
if (perfectionistOptions) mut_configs.push(perfectionist({ overrides: getOverrides(options, "perfectionist") }));
|
|
4586
4764
|
if (reactOptions !== false) mut_configs.push(react({
|
|
4587
4765
|
...typescriptConfigOptions,
|
|
4588
|
-
files: [
|
|
4589
|
-
|
|
4590
|
-
GLOB_TS,
|
|
4591
|
-
GLOB_TSX
|
|
4592
|
-
],
|
|
4593
|
-
filesTypeAware: [
|
|
4594
|
-
GLOB_DTS,
|
|
4595
|
-
GLOB_JSX,
|
|
4596
|
-
GLOB_TS,
|
|
4597
|
-
GLOB_TSX
|
|
4598
|
-
],
|
|
4766
|
+
files: [GLOB_SRC],
|
|
4767
|
+
filesTypeAware: defaultFilesTypesAware,
|
|
4599
4768
|
ignoresTypeAware: [GLOB_ASTRO_TS, `${GLOB_MARKDOWN}/**`],
|
|
4600
4769
|
lessOpinionated: options.lessOpinionated,
|
|
4601
4770
|
nextjs: Boolean(nextjsOptions),
|
|
@@ -4606,6 +4775,7 @@ async function moso(options, ...userConfigs) {
|
|
|
4606
4775
|
...resolveSubOptions(options, "react")
|
|
4607
4776
|
}));
|
|
4608
4777
|
if (options.test !== false) mut_configs.push(test({
|
|
4778
|
+
...functionalConfigOptions,
|
|
4609
4779
|
files: GLOB_TESTS,
|
|
4610
4780
|
isInEditor,
|
|
4611
4781
|
overrides: getOverrides(options, "test")
|
|
@@ -4624,29 +4794,41 @@ async function moso(options, ...userConfigs) {
|
|
|
4624
4794
|
mode: modeOptions,
|
|
4625
4795
|
overrides: getOverrides(options, "typescript"),
|
|
4626
4796
|
projectRoot: projectRootOptions,
|
|
4627
|
-
|
|
4797
|
+
stylistic: stylisticOptions,
|
|
4798
|
+
unsafe: typescriptUnsafe ?? "warn"
|
|
4628
4799
|
}));
|
|
4629
4800
|
if (vueOptions !== false) mut_configs.push(vue({
|
|
4630
4801
|
...typescriptConfigOptions,
|
|
4631
4802
|
files: [GLOB_VUE],
|
|
4632
|
-
filesTypeAware: [
|
|
4633
|
-
GLOB_TS,
|
|
4634
|
-
GLOB_TSX,
|
|
4635
|
-
GLOB_VUE
|
|
4636
|
-
],
|
|
4637
4803
|
overrides: getOverrides(options, "vue"),
|
|
4638
|
-
projectRoot: projectRootOptions,
|
|
4639
4804
|
sfcBlocks: true,
|
|
4640
4805
|
stylistic: stylisticOptions,
|
|
4641
4806
|
typescript: hasTypeScript,
|
|
4642
4807
|
...resolveSubOptions(options, "vue")
|
|
4643
4808
|
}));
|
|
4809
|
+
if (tailwindOptions !== false) {
|
|
4810
|
+
const resolvedTailwind = tailwindOptions === true ? {} : tailwindOptions;
|
|
4811
|
+
const tailwindConfigOptions = "entryPoint" in resolvedTailwind ? {
|
|
4812
|
+
config: void 0,
|
|
4813
|
+
entryPoint: resolvedTailwind.entryPoint,
|
|
4814
|
+
version: resolvedTailwind.version ?? 4
|
|
4815
|
+
} : {
|
|
4816
|
+
config: resolvedTailwind.config ?? "tailwind.config.js",
|
|
4817
|
+
entryPoint: void 0,
|
|
4818
|
+
version: resolvedTailwind.version ?? 3
|
|
4819
|
+
};
|
|
4820
|
+
mut_configs.push(tailwind({
|
|
4821
|
+
...tailwindConfigOptions,
|
|
4822
|
+
overrides: getOverrides(options, "tailwind"),
|
|
4823
|
+
stylistic: stylisticOptions
|
|
4824
|
+
}));
|
|
4825
|
+
}
|
|
4644
4826
|
if (options.yaml !== false) mut_configs.push(yaml({
|
|
4645
4827
|
files: [GLOB_YAML],
|
|
4646
4828
|
overrides: getOverrides(options, "yaml"),
|
|
4647
4829
|
stylistic: stylisticOptions
|
|
4648
4830
|
}));
|
|
4649
|
-
mut_configs.push(disables());
|
|
4831
|
+
mut_configs.push(disables(functionalEnforcement !== "none"));
|
|
4650
4832
|
let mut_composer = new FlatConfigComposer().append(...mut_configs, ...userConfigs);
|
|
4651
4833
|
if (isInEditor) mut_composer = mut_composer.disableRulesFix([
|
|
4652
4834
|
"unused-imports/no-unused-imports",
|
|
@@ -4658,14 +4840,12 @@ async function moso(options, ...userConfigs) {
|
|
|
4658
4840
|
//#endregion
|
|
4659
4841
|
//#region src/presets.ts
|
|
4660
4842
|
const full = {
|
|
4661
|
-
astro: true,
|
|
4843
|
+
astro: { a11y: true },
|
|
4844
|
+
baseline: true,
|
|
4662
4845
|
comments: true,
|
|
4663
4846
|
e18e: true,
|
|
4664
4847
|
functional: { functionalEnforcement: "lite" },
|
|
4665
|
-
ignores: {
|
|
4666
|
-
gitignore: true,
|
|
4667
|
-
userIgnores: false
|
|
4668
|
-
},
|
|
4848
|
+
ignores: { userIgnores: false },
|
|
4669
4849
|
imports: true,
|
|
4670
4850
|
jsdoc: true,
|
|
4671
4851
|
jsonc: true,
|
|
@@ -4673,14 +4853,20 @@ const full = {
|
|
|
4673
4853
|
nextjs: true,
|
|
4674
4854
|
node: true,
|
|
4675
4855
|
perfectionist: true,
|
|
4676
|
-
projectRoot: path.resolve(import.meta.dirname, ".."),
|
|
4677
4856
|
promise: true,
|
|
4678
|
-
react: {
|
|
4857
|
+
react: {
|
|
4858
|
+
a11y: true,
|
|
4859
|
+
reactRefresh: { allowConstantExport: true }
|
|
4860
|
+
},
|
|
4679
4861
|
regexp: true,
|
|
4680
4862
|
stylistic: true,
|
|
4863
|
+
tailwind: {
|
|
4864
|
+
entryPoint: "src/styles/app.css",
|
|
4865
|
+
version: 4
|
|
4866
|
+
},
|
|
4681
4867
|
test: true,
|
|
4682
4868
|
toml: true,
|
|
4683
|
-
typescript: { projectRoot:
|
|
4869
|
+
typescript: { projectRoot: process.cwd() },
|
|
4684
4870
|
unicorn: true,
|
|
4685
4871
|
vue: {
|
|
4686
4872
|
a11y: true,
|
|
@@ -4690,6 +4876,7 @@ const full = {
|
|
|
4690
4876
|
};
|
|
4691
4877
|
const off = {
|
|
4692
4878
|
astro: false,
|
|
4879
|
+
baseline: false,
|
|
4693
4880
|
comments: false,
|
|
4694
4881
|
e18e: false,
|
|
4695
4882
|
functional: false,
|
|
@@ -4698,6 +4885,7 @@ const off = {
|
|
|
4698
4885
|
jsdoc: false,
|
|
4699
4886
|
jsonc: false,
|
|
4700
4887
|
jsx: false,
|
|
4888
|
+
lessOpinionated: true,
|
|
4701
4889
|
nextjs: false,
|
|
4702
4890
|
node: false,
|
|
4703
4891
|
perfectionist: false,
|
|
@@ -4705,6 +4893,7 @@ const off = {
|
|
|
4705
4893
|
react: false,
|
|
4706
4894
|
regexp: false,
|
|
4707
4895
|
stylistic: false,
|
|
4896
|
+
tailwind: false,
|
|
4708
4897
|
test: false,
|
|
4709
4898
|
toml: false,
|
|
4710
4899
|
typescript: false,
|
|
@@ -4713,4 +4902,4 @@ const off = {
|
|
|
4713
4902
|
yaml: false
|
|
4714
4903
|
};
|
|
4715
4904
|
//#endregion
|
|
4716
|
-
export {
|
|
4905
|
+
export { GLOB_AI, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS_IN_JS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MJS, GLOB_NODE_MODULES, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, 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 };
|