@luxass/eslint-config 4.18.0 → 4.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2687 +1,2205 @@
1
- // src/factory.ts
2
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
3
- import { isPackageExists as isPackageExists3 } from "local-pkg";
2
+ import { isPackageExists } from "local-pkg";
3
+ import process from "node:process";
4
+ import { fileURLToPath } from "node:url";
5
+ import eslintCommentsPlugin from "@eslint-community/eslint-plugin-eslint-comments";
6
+ import pluginAntfu from "eslint-plugin-antfu";
7
+ import pluginUnusedImports from "eslint-plugin-unused-imports";
8
+ import globals from "globals";
9
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
10
+ import pluginNode from "eslint-plugin-n";
11
+ import pluginPerfectionist from "eslint-plugin-perfectionist";
12
+ import { configs } from "eslint-plugin-regexp";
13
+ import pluginUnicorn from "eslint-plugin-unicorn";
4
14
 
5
- // src/globs.ts
6
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
7
- var GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
8
- var GLOB_JS = "**/*.?([cm])js";
9
- var GLOB_JSX = "**/*.?([cm])jsx";
10
- var GLOB_TS = "**/*.?([cm])ts";
11
- var GLOB_TSX = "**/*.?([cm])tsx";
12
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
13
- var GLOB_CSS = "**/*.css";
14
- var GLOB_POSTCSS = "**/*.{p,post}css";
15
- var GLOB_LESS = "**/*.less";
16
- var GLOB_SCSS = "**/*.scss";
17
- var GLOB_JSON = "**/*.json";
18
- var GLOB_JSON5 = "**/*.json5";
19
- var GLOB_JSONC = "**/*.jsonc";
20
- var GLOB_MARKDOWN = "**/*.md";
21
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
22
- var GLOB_SVELTE = "**/*.svelte";
23
- var GLOB_VUE = "**/*.vue";
24
- var GLOB_YAML = "**/*.y?(a)ml";
25
- var GLOB_TOML = "**/*.toml";
26
- var GLOB_HTML = "**/*.htm?(l)";
27
- var GLOB_ASTRO = "**/*.astro";
28
- var GLOB_ASTRO_TS = "**/*.astro/*.ts";
29
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
30
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
31
- var GLOB_TESTS = [
32
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
33
- `**/*.spec.${GLOB_SRC_EXT}`,
34
- `**/*.test.${GLOB_SRC_EXT}`,
35
- `**/*.bench.${GLOB_SRC_EXT}`,
36
- `**/*.benchmark.${GLOB_SRC_EXT}`
15
+ //#region src/globs.ts
16
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
17
+ const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
18
+ const GLOB_JS = "**/*.?([cm])js";
19
+ const GLOB_JSX = "**/*.?([cm])jsx";
20
+ const GLOB_TS = "**/*.?([cm])ts";
21
+ const GLOB_TSX = "**/*.?([cm])tsx";
22
+ const GLOB_STYLE = "**/*.{c,le,sc}ss";
23
+ const GLOB_CSS = "**/*.css";
24
+ const GLOB_POSTCSS = "**/*.{p,post}css";
25
+ const GLOB_LESS = "**/*.less";
26
+ const GLOB_SCSS = "**/*.scss";
27
+ const GLOB_JSON = "**/*.json";
28
+ const GLOB_JSON5 = "**/*.json5";
29
+ const GLOB_JSONC = "**/*.jsonc";
30
+ const GLOB_MARKDOWN = "**/*.md";
31
+ const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
32
+ const GLOB_SVELTE = "**/*.svelte";
33
+ const GLOB_VUE = "**/*.vue";
34
+ const GLOB_YAML = "**/*.y?(a)ml";
35
+ const GLOB_TOML = "**/*.toml";
36
+ const GLOB_HTML = "**/*.htm?(l)";
37
+ const GLOB_ASTRO = "**/*.astro";
38
+ const GLOB_ASTRO_TS = "**/*.astro/*.ts";
39
+ const GLOB_GRAPHQL = "**/*.{g,graph}ql";
40
+ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
41
+ const GLOB_TESTS = [
42
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
43
+ `**/*.spec.${GLOB_SRC_EXT}`,
44
+ `**/*.test.${GLOB_SRC_EXT}`,
45
+ `**/*.bench.${GLOB_SRC_EXT}`,
46
+ `**/*.benchmark.${GLOB_SRC_EXT}`
37
47
  ];
38
- var GLOB_NEXTJS_OG = [
39
- `**/app/**/opengraph-image.[jt]s?(x)`,
40
- `**/app/**/twitter-image.[jt]s?(x)`,
41
- `**/app/**/route.[jt]s?(x)`
48
+ const GLOB_NEXTJS_OG = [
49
+ `**/app/**/opengraph-image.[jt]s?(x)`,
50
+ `**/app/**/twitter-image.[jt]s?(x)`,
51
+ `**/app/**/route.[jt]s?(x)`
42
52
  ];
43
- var GLOB_NEXTJS_ROUTES = [
44
- `**/app/**/page.${GLOB_SRC_EXT}`,
45
- `**/app/**/layout.${GLOB_SRC_EXT}`,
46
- `**/app/**/error.${GLOB_SRC_EXT}`,
47
- `**/app/**/template.${GLOB_SRC_EXT}`,
48
- `**/app/**/not-found.${GLOB_SRC_EXT}`,
49
- `**/app/**/loading.${GLOB_SRC_EXT}`,
50
- `**/app/**/robots.${GLOB_SRC_EXT}`,
51
- `**/app/**/sitemap.${GLOB_SRC_EXT}`,
52
- `**/pages/**/*.${GLOB_SRC_EXT}`
53
+ const GLOB_NEXTJS_ROUTES = [
54
+ `**/app/**/page.${GLOB_SRC_EXT}`,
55
+ `**/app/**/layout.${GLOB_SRC_EXT}`,
56
+ `**/app/**/error.${GLOB_SRC_EXT}`,
57
+ `**/app/**/template.${GLOB_SRC_EXT}`,
58
+ `**/app/**/not-found.${GLOB_SRC_EXT}`,
59
+ `**/app/**/loading.${GLOB_SRC_EXT}`,
60
+ `**/app/**/robots.${GLOB_SRC_EXT}`,
61
+ `**/app/**/sitemap.${GLOB_SRC_EXT}`,
62
+ `**/pages/**/*.${GLOB_SRC_EXT}`
53
63
  ];
54
- var GLOB_EXCLUDE = [
55
- "**/node_modules",
56
- "**/dist",
57
- "**/out",
58
- "**/build",
59
- "**/package-lock.json",
60
- "**/yarn.lock",
61
- "**/pnpm-lock.yaml",
62
- "**/bun.lockb",
63
- "**/output",
64
- "**/coverage",
65
- "**/temp",
66
- "**/.temp",
67
- "**/tmp",
68
- "**/.tmp",
69
- "**/.history",
70
- "**/.vitepress/cache",
71
- "**/.nuxt",
72
- "**/.next",
73
- "**/.vercel",
74
- "**/.netlify",
75
- "**/.changeset",
76
- "**/.idea",
77
- "**/.cache",
78
- "**/.output",
79
- "**/.vite-inspect",
80
- "**/.astro",
81
- "**/CHANGELOG*.md",
82
- "**/*.min.*",
83
- "**/LICENSE*",
84
- "**/__snapshots__",
85
- "**/auto-import?(s).d.ts",
86
- "**/components.d.ts"
64
+ const GLOB_EXCLUDE = [
65
+ "**/node_modules",
66
+ "**/dist",
67
+ "**/out",
68
+ "**/build",
69
+ "**/package-lock.json",
70
+ "**/yarn.lock",
71
+ "**/pnpm-lock.yaml",
72
+ "**/bun.lockb",
73
+ "**/output",
74
+ "**/coverage",
75
+ "**/temp",
76
+ "**/.temp",
77
+ "**/tmp",
78
+ "**/.tmp",
79
+ "**/.history",
80
+ "**/.vitepress/cache",
81
+ "**/.nuxt",
82
+ "**/.next",
83
+ "**/.vercel",
84
+ "**/.netlify",
85
+ "**/.changeset",
86
+ "**/.idea",
87
+ "**/.cache",
88
+ "**/.output",
89
+ "**/.vite-inspect",
90
+ "**/.astro",
91
+ "**/CHANGELOG*.md",
92
+ "**/*.min.*",
93
+ "**/LICENSE*",
94
+ "**/__snapshots__",
95
+ "**/auto-import?(s).d.ts",
96
+ "**/components.d.ts"
87
97
  ];
88
98
 
89
- // src/utils.ts
90
- import process from "node:process";
91
- import { fileURLToPath } from "node:url";
92
- import { isPackageExists } from "local-pkg";
93
- var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
94
- var isCwdInScope = isPackageExists("@luxass/eslint-config");
95
- var parserPlain = {
96
- meta: {
97
- name: "parser-plain"
98
- },
99
- parseForESLint: (code) => ({
100
- ast: {
101
- body: [],
102
- comments: [],
103
- loc: { end: code.length, start: 0 },
104
- range: [0, code.length],
105
- tokens: [],
106
- type: "Program"
107
- },
108
- scopeManager: null,
109
- services: { isPlain: true },
110
- visitorKeys: {
111
- Program: []
112
- }
113
- })
99
+ //#endregion
100
+ //#region src/utils.ts
101
+ const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
102
+ const isCwdInScope = isPackageExists("@luxass/eslint-config");
103
+ const parserPlain = {
104
+ meta: { name: "parser-plain" },
105
+ parseForESLint: (code) => ({
106
+ ast: {
107
+ body: [],
108
+ comments: [],
109
+ loc: {
110
+ end: code.length,
111
+ start: 0
112
+ },
113
+ range: [0, code.length],
114
+ tokens: [],
115
+ type: "Program"
116
+ },
117
+ scopeManager: null,
118
+ services: { isPlain: true },
119
+ visitorKeys: { Program: [] }
120
+ })
114
121
  };
115
- async function combine(...configs2) {
116
- const resolved = await Promise.all(configs2);
117
- return resolved.flat();
122
+ /**
123
+ * Combine array and non-array configs into a single array.
124
+ */
125
+ async function combine(...configs$1) {
126
+ const resolved = await Promise.all(configs$1);
127
+ return resolved.flat();
118
128
  }
129
+ /**
130
+ * Rename plugin prefixes in a rule object.
131
+ * Accepts a map of prefixes to rename.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * import { renameRules } from "@luxass/eslint-config";
136
+ *
137
+ * export default [{
138
+ * rules: renameRules(
139
+ * {
140
+ * "@typescript-eslint/indent": "error"
141
+ * },
142
+ * { "@typescript-eslint": "ts" }
143
+ * )
144
+ * }]
145
+ * ```
146
+ */
119
147
  function renameRules(rules, map) {
120
- return Object.fromEntries(
121
- Object.entries(rules).map(([key, value]) => {
122
- for (const [from, to] of Object.entries(map)) {
123
- if (key.startsWith(`${from}/`)) {
124
- return [to + key.slice(from.length), value];
125
- }
126
- }
127
- return [key, value];
128
- })
129
- );
148
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
149
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
150
+ return [key, value];
151
+ }));
130
152
  }
131
- function renamePluginInConfigs(configs2, map) {
132
- return configs2.map((i) => {
133
- const clone = { ...i };
134
- if (clone.rules) {
135
- clone.rules = renameRules(clone.rules, map);
136
- }
137
- if (clone.plugins) {
138
- clone.plugins = Object.fromEntries(
139
- Object.entries(clone.plugins).map(([key, value]) => {
140
- if (key in map) {
141
- return [map[key], value];
142
- }
143
- return [key, value];
144
- })
145
- );
146
- }
147
- return clone;
148
- });
153
+ /**
154
+ * Rename plugin names a flat configs array
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * import { renamePluginInConfigs } from "@luxass/eslint-config";
159
+ * import someConfigs from "./some-configs";
160
+ *
161
+ * export default renamePluginInConfigs(someConfigs, {
162
+ * "@typescript-eslint": "ts",
163
+ * "@stylistic": "style",
164
+ * })
165
+ * ```
166
+ */
167
+ function renamePluginInConfigs(configs$1, map) {
168
+ return configs$1.map((i) => {
169
+ const clone = { ...i };
170
+ if (clone.rules) clone.rules = renameRules(clone.rules, map);
171
+ if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
172
+ if (key in map) return [map[key], value];
173
+ return [key, value];
174
+ }));
175
+ return clone;
176
+ });
149
177
  }
178
+ /**
179
+ * Convert a value to an array.
180
+ * If the value is an array, return it as is.
181
+ * Otherwise, return the value as the only element in an array.
182
+ *
183
+ * @param {T | T[]} value - Value to convert to an array.
184
+ * @returns {T[]} - The value as an array.
185
+ *
186
+ * @example
187
+ * ```ts
188
+ * import { toArray } from "@luxass/eslint-config";
189
+ *
190
+ * toArray("foo") // ["foo"]
191
+ * toArray(["foo"]) // ["foo"]
192
+ * ```
193
+ */
150
194
  function toArray(value) {
151
- return Array.isArray(value) ? value : [value];
195
+ return Array.isArray(value) ? value : [value];
152
196
  }
197
+ /**
198
+ * Import a module and return the default export.
199
+ * If the module does not have a default export, return the module itself.
200
+ *
201
+ * @param {Promise<T>} m - Module to import.
202
+ * @returns {Promise<T extends { default: infer U } ? U : T>} - The default export or the module itself.
203
+ * @template T
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * import { interop } from "@luxass/eslint-config";
208
+ *
209
+ * const module = await interop(import("module"));
210
+ * ```
211
+ */
153
212
  async function interop(m) {
154
- const resolved = await m;
155
- return resolved.default || resolved;
213
+ const resolved = await m;
214
+ return resolved.default || resolved;
156
215
  }
216
+ /**
217
+ * Ensure that packages are installed.
218
+ * If the packages are not installed, prompt the user to install them.
219
+ *
220
+ * @param {string[]} packages - Packages to ensure are installed.
221
+ * @returns {Promise<void>} - A promise that resolves when the packages are installed.
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * import { ensure } from "@luxass/eslint-config";
226
+ *
227
+ * await ensure(["eslint-plugin-jsdoc"]);
228
+ * ```
229
+ */
157
230
  async function ensure(packages) {
158
- if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) {
159
- return;
160
- }
161
- ;
162
- const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
163
- if (nonExistingPackages.length === 0) {
164
- return;
165
- }
166
- const p = await import("@clack/prompts");
167
- const result = await p.confirm({
168
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
169
- });
170
- if (result) {
171
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
172
- }
231
+ if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) return;
232
+ const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
233
+ if (nonExistingPackages.length === 0) return;
234
+ const p = await import("@clack/prompts");
235
+ const result = await p.confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
236
+ if (result) await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
173
237
  }
238
+ /**
239
+ * Resolve sub-options from a config options object.
240
+ *
241
+ * @param {ConfigOptions} options - The config options object.
242
+ * @template K - The key of the sub-options to resolve.
243
+ * @param {K} key - The key of the sub-options to resolve.
244
+ * @returns {ResolvedOptions<ConfigOptions[K]>} - The resolved sub-options.
245
+ *
246
+ * @example
247
+ * ```ts
248
+ * import { resolveSubOptions } from "@luxass/eslint-config";
249
+ *
250
+ * const options = {
251
+ * foo: {
252
+ * bar: true,
253
+ * },
254
+ * };
255
+ *
256
+ * const subOptions = resolveSubOptions(options, "foo");
257
+ * ```
258
+ */
174
259
  function resolveSubOptions(options, key) {
175
- return typeof options[key] === "boolean" ? {} : options[key] || {};
260
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
176
261
  }
262
+ /**
263
+ * Get overrides from a config options object.
264
+ * @param {ConfigOptions} options The config options object.
265
+ * @template K The key of the sub-options to resolve.
266
+ * @param {K} key The key of the sub-options to resolve.
267
+ * @returns {Partial<Linter.RulesRecord & RuleOptions>} The overrides.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * import { getOverrides } from "@luxass/eslint-config";
272
+ *
273
+ * const options = {
274
+ * overrides: {
275
+ * rules: {
276
+ * "no-console": "off",
277
+ * },
278
+ * },
279
+ * };
280
+ *
281
+ * const overrides = getOverrides(options, "overrides");
282
+ * ```
283
+ */
177
284
  function getOverrides(options, key) {
178
- const sub = resolveSubOptions(options, key);
179
- return {
180
- ..."overrides" in sub ? sub.overrides : {}
181
- };
285
+ const sub = resolveSubOptions(options, key);
286
+ return { ..."overrides" in sub ? sub.overrides : {} };
182
287
  }
183
288
  function isPackageInScope(name) {
184
- return isPackageExists(name, { paths: [scopeUrl] });
289
+ return isPackageExists(name, { paths: [scopeUrl] });
185
290
  }
186
291
  function isInEditorEnv() {
187
- if (process.env.CI) {
188
- return false;
189
- }
190
- if (isInGitHooksOrLintStaged()) {
191
- return false;
192
- }
193
- return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
292
+ if (process.env.CI) return false;
293
+ if (isInGitHooksOrLintStaged()) return false;
294
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
194
295
  }
195
296
  function isInGitHooksOrLintStaged() {
196
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
297
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
197
298
  }
198
299
 
199
- // src/configs/astro.ts
300
+ //#endregion
301
+ //#region src/configs/astro.ts
200
302
  async function astro(options = {}) {
201
- const {
202
- files = [GLOB_ASTRO],
203
- overrides = {},
204
- stylistic: stylistic2 = true
205
- } = options;
206
- await ensure([
207
- "eslint-plugin-astro",
208
- "astro-eslint-parser"
209
- ]);
210
- const [
211
- pluginAstro,
212
- parserAstro,
213
- parserTs
214
- ] = await Promise.all([
215
- interop(import("eslint-plugin-astro")),
216
- interop(import("astro-eslint-parser")),
217
- interop(import("@typescript-eslint/parser"))
218
- ]);
219
- return [
220
- {
221
- name: "luxass/astro/setup",
222
- plugins: {
223
- astro: pluginAstro
224
- }
225
- },
226
- {
227
- files,
228
- languageOptions: {
229
- globals: pluginAstro.environments.astro.globals,
230
- parser: parserAstro,
231
- parserOptions: {
232
- extraFileExtensions: [".astro"],
233
- parser: parserTs
234
- },
235
- sourceType: "module"
236
- },
237
- name: "luxass/astro/rules",
238
- processor: "astro/client-side-ts",
239
- rules: {
240
- // Astro uses top level await for e.g. data fetching
241
- // https://docs.astro.build/en/guides/data-fetching/#fetch-in-astro
242
- "antfu/no-top-level-await": "off",
243
- // use recommended rules
244
- "astro/missing-client-only-directive-value": "error",
245
- "astro/no-conflict-set-directives": "error",
246
- "astro/no-deprecated-astro-canonicalurl": "error",
247
- "astro/no-deprecated-astro-fetchcontent": "error",
248
- "astro/no-deprecated-astro-resolve": "error",
249
- "astro/no-deprecated-getentrybyslug": "error",
250
- "astro/no-set-html-directive": "off",
251
- "astro/no-unused-define-vars-in-style": "error",
252
- "astro/semi": "off",
253
- "astro/valid-compile": "error",
254
- ...stylistic2 ? {
255
- "style/indent": "off",
256
- "style/jsx-closing-tag-location": "off",
257
- "style/jsx-one-expression-per-line": "off",
258
- "style/no-multiple-empty-lines": "off"
259
- } : {},
260
- ...overrides
261
- }
262
- }
263
- ];
303
+ const { files = [GLOB_ASTRO], overrides = {}, stylistic: stylistic$1 = true } = options;
304
+ await ensure(["eslint-plugin-astro", "astro-eslint-parser"]);
305
+ const [pluginAstro, parserAstro, parserTs] = await Promise.all([
306
+ interop(import("eslint-plugin-astro")),
307
+ interop(import("astro-eslint-parser")),
308
+ interop(import("@typescript-eslint/parser"))
309
+ ]);
310
+ return [{
311
+ name: "luxass/astro/setup",
312
+ plugins: { astro: pluginAstro }
313
+ }, {
314
+ files,
315
+ languageOptions: {
316
+ globals: pluginAstro.environments.astro.globals,
317
+ parser: parserAstro,
318
+ parserOptions: {
319
+ extraFileExtensions: [".astro"],
320
+ parser: parserTs
321
+ },
322
+ sourceType: "module"
323
+ },
324
+ name: "luxass/astro/rules",
325
+ processor: "astro/client-side-ts",
326
+ rules: {
327
+ "antfu/no-top-level-await": "off",
328
+ "astro/missing-client-only-directive-value": "error",
329
+ "astro/no-conflict-set-directives": "error",
330
+ "astro/no-deprecated-astro-canonicalurl": "error",
331
+ "astro/no-deprecated-astro-fetchcontent": "error",
332
+ "astro/no-deprecated-astro-resolve": "error",
333
+ "astro/no-deprecated-getentrybyslug": "error",
334
+ "astro/no-set-html-directive": "off",
335
+ "astro/no-unused-define-vars-in-style": "error",
336
+ "astro/semi": "off",
337
+ "astro/valid-compile": "error",
338
+ ...stylistic$1 ? {
339
+ "style/indent": "off",
340
+ "style/jsx-closing-tag-location": "off",
341
+ "style/jsx-one-expression-per-line": "off",
342
+ "style/no-multiple-empty-lines": "off"
343
+ } : {},
344
+ ...overrides
345
+ }
346
+ }];
264
347
  }
265
348
 
266
- // src/configs/comments.ts
267
- import eslintCommentsPlugin from "@eslint-community/eslint-plugin-eslint-comments";
349
+ //#endregion
350
+ //#region src/configs/comments.ts
268
351
  async function comments() {
269
- return [
270
- {
271
- name: "luxass/eslint-comments",
272
- plugins: {
273
- "eslint-comments": eslintCommentsPlugin
274
- },
275
- rules: {
276
- // https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-aggregating-enable.md
277
- "eslint-comments/no-aggregating-enable": "error",
278
- // https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-duplicate-disable.md
279
- "eslint-comments/no-duplicate-disable": "error",
280
- // https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-unlimited-disable.md
281
- "eslint-comments/no-unlimited-disable": "error",
282
- // https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-unused-enable.md
283
- "eslint-comments/no-unused-enable": "error"
284
- }
285
- }
286
- ];
352
+ return [{
353
+ name: "luxass/eslint-comments",
354
+ plugins: { "eslint-comments": eslintCommentsPlugin },
355
+ rules: {
356
+ "eslint-comments/no-aggregating-enable": "error",
357
+ "eslint-comments/no-duplicate-disable": "error",
358
+ "eslint-comments/no-unlimited-disable": "error",
359
+ "eslint-comments/no-unused-enable": "error"
360
+ }
361
+ }];
287
362
  }
288
363
 
289
- // src/configs/disables.ts
364
+ //#endregion
365
+ //#region src/configs/disables.ts
290
366
  async function disables() {
291
- return [
292
- {
293
- files: [`**/scripts/${GLOB_SRC}`],
294
- name: "luxass/disables/scripts",
295
- rules: {
296
- "antfu/no-top-level-await": "off",
297
- "no-console": "off",
298
- "ts/explicit-function-return-type": "off"
299
- }
300
- },
301
- {
302
- files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
303
- name: "luxass/disables/cli",
304
- rules: {
305
- "antfu/no-top-level-await": "off",
306
- "no-console": "off"
307
- }
308
- },
309
- {
310
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
311
- name: "luxass/disables/bin",
312
- rules: {
313
- "antfu/no-import-dist": "off",
314
- "antfu/no-import-node-modules-by-path": "off"
315
- }
316
- },
317
- {
318
- files: ["**/*.d.?([cm])ts"],
319
- name: "luxass/disables/dts",
320
- rules: {
321
- "eslint-comments/no-unlimited-disable": "off",
322
- "import/no-duplicates": "off",
323
- "no-restricted-syntax": "off",
324
- "unused-imports/no-unused-vars": "off"
325
- }
326
- },
327
- {
328
- files: ["**/*.js", "**/*.cjs"],
329
- name: "luxass/disables/cjs",
330
- rules: {
331
- "ts/no-require-imports": "off"
332
- }
333
- },
334
- {
335
- files: ["**/.github/workflows/*.{yml,yaml}"],
336
- name: "luxass/disables/github-actions",
337
- rules: {
338
- // GitHub Actions supports empty values to enable features
339
- "yaml/no-empty-mapping-value": "off"
340
- }
341
- },
342
- {
343
- files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
344
- name: "luxass/disables/config-files",
345
- rules: {
346
- "antfu/no-top-level-await": "off",
347
- "no-console": "off",
348
- "ts/explicit-function-return-type": "off"
349
- }
350
- }
351
- ];
367
+ return [
368
+ {
369
+ files: [`**/scripts/${GLOB_SRC}`],
370
+ name: "luxass/disables/scripts",
371
+ rules: {
372
+ "antfu/no-top-level-await": "off",
373
+ "no-console": "off",
374
+ "ts/explicit-function-return-type": "off"
375
+ }
376
+ },
377
+ {
378
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
379
+ name: "luxass/disables/cli",
380
+ rules: {
381
+ "antfu/no-top-level-await": "off",
382
+ "no-console": "off"
383
+ }
384
+ },
385
+ {
386
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
387
+ name: "luxass/disables/bin",
388
+ rules: {
389
+ "antfu/no-import-dist": "off",
390
+ "antfu/no-import-node-modules-by-path": "off"
391
+ }
392
+ },
393
+ {
394
+ files: ["**/*.d.?([cm])ts"],
395
+ name: "luxass/disables/dts",
396
+ rules: {
397
+ "eslint-comments/no-unlimited-disable": "off",
398
+ "no-restricted-syntax": "off",
399
+ "unused-imports/no-unused-vars": "off"
400
+ }
401
+ },
402
+ {
403
+ files: ["**/*.js", "**/*.cjs"],
404
+ name: "luxass/disables/cjs",
405
+ rules: { "ts/no-require-imports": "off" }
406
+ },
407
+ {
408
+ files: ["**/.github/workflows/*.{yml,yaml}"],
409
+ name: "luxass/disables/github-actions",
410
+ rules: { "yaml/no-empty-mapping-value": "off" }
411
+ },
412
+ {
413
+ files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
414
+ name: "luxass/disables/config-files",
415
+ rules: {
416
+ "antfu/no-top-level-await": "off",
417
+ "no-console": "off",
418
+ "ts/explicit-function-return-type": "off"
419
+ }
420
+ }
421
+ ];
352
422
  }
353
423
 
354
- // src/configs/stylistic.ts
355
- import pluginAntfu from "eslint-plugin-antfu";
356
- var StylisticConfigDefaults = {
357
- indent: 2,
358
- jsx: true,
359
- quotes: "double",
360
- semi: true
424
+ //#endregion
425
+ //#region src/configs/stylistic.ts
426
+ const StylisticConfigDefaults = {
427
+ indent: 2,
428
+ jsx: true,
429
+ quotes: "double",
430
+ semi: true
361
431
  };
362
432
  async function stylistic(options = {}) {
363
- const {
364
- indent,
365
- jsx: jsx2,
366
- overrides = {},
367
- quotes,
368
- semi
369
- } = {
370
- ...StylisticConfigDefaults,
371
- ...options
372
- };
373
- const pluginStylistic = await interop(import("@stylistic/eslint-plugin"));
374
- const config = pluginStylistic.configs.customize({
375
- indent,
376
- jsx: jsx2,
377
- pluginName: "style",
378
- quotes,
379
- semi
380
- });
381
- return [
382
- {
383
- name: "luxass/stylistic",
384
- plugins: {
385
- antfu: pluginAntfu,
386
- style: pluginStylistic
387
- },
388
- rules: {
389
- ...config.rules,
390
- "antfu/consistent-list-newline": "error",
391
- "antfu/if-newline": "off",
392
- "antfu/top-level-function": "error",
393
- "curly": ["error", "multi-line", "consistent"],
394
- "style/arrow-parens": ["error", "always", { requireForBlockBody: true }],
395
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
396
- "style/generator-star-spacing": ["error", { after: true, before: false }],
397
- "style/yield-star-spacing": ["error", { after: true, before: false }],
398
- ...overrides
399
- }
400
- }
401
- ];
433
+ const { indent, jsx: jsx$1, overrides = {}, quotes, semi } = {
434
+ ...StylisticConfigDefaults,
435
+ ...options
436
+ };
437
+ const pluginStylistic = await interop(import("@stylistic/eslint-plugin"));
438
+ const config = pluginStylistic.configs.customize({
439
+ indent,
440
+ jsx: jsx$1,
441
+ pluginName: "style",
442
+ quotes,
443
+ semi
444
+ });
445
+ return [{
446
+ name: "luxass/stylistic",
447
+ plugins: {
448
+ antfu: pluginAntfu,
449
+ style: pluginStylistic
450
+ },
451
+ rules: {
452
+ ...config.rules,
453
+ "antfu/consistent-list-newline": "error",
454
+ "antfu/if-newline": "off",
455
+ "antfu/top-level-function": "error",
456
+ "curly": [
457
+ "error",
458
+ "multi-line",
459
+ "consistent"
460
+ ],
461
+ "style/arrow-parens": [
462
+ "error",
463
+ "always",
464
+ { requireForBlockBody: true }
465
+ ],
466
+ "style/brace-style": [
467
+ "error",
468
+ "1tbs",
469
+ { allowSingleLine: true }
470
+ ],
471
+ "style/generator-star-spacing": ["error", {
472
+ after: true,
473
+ before: false
474
+ }],
475
+ "style/padding-line-between-statements": [
476
+ "error",
477
+ {
478
+ blankLine: "always",
479
+ next: "*",
480
+ prev: "import"
481
+ },
482
+ {
483
+ blankLine: "any",
484
+ next: "import",
485
+ prev: "import"
486
+ }
487
+ ],
488
+ "style/yield-star-spacing": ["error", {
489
+ after: true,
490
+ before: false
491
+ }],
492
+ ...overrides
493
+ }
494
+ }];
402
495
  }
403
496
 
404
- // src/configs/formatters.ts
497
+ //#endregion
498
+ //#region src/configs/formatters.ts
405
499
  function mergePrettierOptions(options, overrides = {}) {
406
- return {
407
- ...options,
408
- ...overrides,
409
- plugins: [
410
- ...overrides.plugins || [],
411
- ...options.plugins || []
412
- ]
413
- };
500
+ return {
501
+ ...options,
502
+ ...overrides,
503
+ plugins: [...overrides.plugins || [], ...options.plugins || []]
504
+ };
414
505
  }
415
- async function formatters(options = {}, stylistic2 = {}) {
416
- if (options === true) {
417
- options = {
418
- astro: isPackageInScope("astro"),
419
- css: true,
420
- graphql: true,
421
- html: true,
422
- markdown: true
423
- };
424
- }
425
- await ensure([
426
- "eslint-plugin-format",
427
- options.astro ? "prettier-plugin-astro" : void 0
428
- ]);
429
- const {
430
- indent,
431
- quotes,
432
- semi
433
- } = {
434
- ...StylisticConfigDefaults,
435
- ...stylistic2
436
- };
437
- const prettierOptions = Object.assign(
438
- {
439
- endOfLine: "auto",
440
- printWidth: 120,
441
- semi,
442
- singleQuote: quotes === "single",
443
- tabWidth: typeof indent === "number" ? indent : 2,
444
- trailingComma: "all",
445
- useTabs: indent === "tab"
446
- },
447
- options.prettierOptions || {}
448
- );
449
- const dprintOptions = Object.assign(
450
- {
451
- indentWidth: typeof indent === "number" ? indent : 2,
452
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
453
- useTabs: indent === "tab"
454
- },
455
- options.dprintOptions || {}
456
- );
457
- const pluginFormat = await interop(import("eslint-plugin-format"));
458
- const configs2 = [
459
- {
460
- name: "luxass/formatter/setup",
461
- plugins: {
462
- format: pluginFormat
463
- }
464
- }
465
- ];
466
- if (options.css) {
467
- configs2.push(
468
- {
469
- files: [GLOB_CSS, GLOB_POSTCSS],
470
- languageOptions: {
471
- parser: parserPlain
472
- },
473
- name: "luxass/formatter/css",
474
- rules: {
475
- "format/prettier": [
476
- "error",
477
- mergePrettierOptions(prettierOptions, {
478
- parser: "css"
479
- })
480
- ]
481
- }
482
- },
483
- {
484
- files: [GLOB_SCSS],
485
- languageOptions: {
486
- parser: parserPlain
487
- },
488
- name: "luxass/formatter/scss",
489
- rules: {
490
- "format/prettier": [
491
- "error",
492
- mergePrettierOptions(prettierOptions, {
493
- parser: "scss"
494
- })
495
- ]
496
- }
497
- },
498
- {
499
- files: [GLOB_LESS],
500
- languageOptions: {
501
- parser: parserPlain
502
- },
503
- name: "luxass/formatter/less",
504
- rules: {
505
- "format/prettier": [
506
- "error",
507
- mergePrettierOptions(prettierOptions, {
508
- parser: "less"
509
- })
510
- ]
511
- }
512
- }
513
- );
514
- }
515
- if (options.html) {
516
- configs2.push({
517
- files: [GLOB_HTML],
518
- languageOptions: {
519
- parser: parserPlain
520
- },
521
- name: "luxass/formatter/html",
522
- rules: {
523
- "format/prettier": [
524
- "error",
525
- mergePrettierOptions(prettierOptions, {
526
- parser: "html"
527
- })
528
- ]
529
- }
530
- });
531
- }
532
- if (options.markdown) {
533
- const formatter = options.markdown === true ? "prettier" : options.markdown;
534
- configs2.push({
535
- files: [GLOB_MARKDOWN],
536
- languageOptions: {
537
- parser: parserPlain
538
- },
539
- name: "luxass/formatter/markdown",
540
- rules: {
541
- [`format/${formatter}`]: [
542
- "error",
543
- formatter === "prettier" ? mergePrettierOptions(prettierOptions, {
544
- embeddedLanguageFormatting: "off",
545
- parser: "markdown"
546
- }) : {
547
- ...dprintOptions,
548
- language: "markdown"
549
- }
550
- ]
551
- }
552
- });
553
- }
554
- if (options.astro) {
555
- configs2.push({
556
- files: [GLOB_ASTRO],
557
- languageOptions: {
558
- parser: parserPlain
559
- },
560
- name: "luxass/formatter/astro",
561
- rules: {
562
- "format/prettier": [
563
- "error",
564
- mergePrettierOptions(prettierOptions, {
565
- parser: "astro",
566
- plugins: [
567
- "prettier-plugin-astro"
568
- ]
569
- })
570
- ]
571
- }
572
- });
573
- }
574
- if (options.graphql) {
575
- configs2.push({
576
- files: [GLOB_GRAPHQL],
577
- languageOptions: {
578
- parser: parserPlain
579
- },
580
- name: "luxass/formatter/graphql",
581
- rules: {
582
- "format/prettier": [
583
- "error",
584
- mergePrettierOptions(prettierOptions, {
585
- parser: "graphql"
586
- })
587
- ]
588
- }
589
- });
590
- }
591
- return configs2;
506
+ async function formatters(options = {}, stylistic$1 = {}) {
507
+ if (options === true) options = {
508
+ astro: isPackageInScope("astro"),
509
+ css: true,
510
+ graphql: true,
511
+ html: true,
512
+ markdown: true
513
+ };
514
+ await ensure(["eslint-plugin-format", options.astro ? "prettier-plugin-astro" : void 0]);
515
+ const { indent, quotes, semi } = {
516
+ ...StylisticConfigDefaults,
517
+ ...stylistic$1
518
+ };
519
+ const prettierOptions = Object.assign({
520
+ endOfLine: "auto",
521
+ printWidth: 120,
522
+ semi,
523
+ singleQuote: quotes === "single",
524
+ tabWidth: typeof indent === "number" ? indent : 2,
525
+ trailingComma: "all",
526
+ useTabs: indent === "tab"
527
+ }, options.prettierOptions || {});
528
+ const dprintOptions = Object.assign({
529
+ indentWidth: typeof indent === "number" ? indent : 2,
530
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
531
+ useTabs: indent === "tab"
532
+ }, options.dprintOptions || {});
533
+ const pluginFormat = await interop(import("eslint-plugin-format"));
534
+ const configs$1 = [{
535
+ name: "luxass/formatter/setup",
536
+ plugins: { format: pluginFormat }
537
+ }];
538
+ if (options.css) configs$1.push({
539
+ files: [GLOB_CSS, GLOB_POSTCSS],
540
+ languageOptions: { parser: parserPlain },
541
+ name: "luxass/formatter/css",
542
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "css" })] }
543
+ }, {
544
+ files: [GLOB_SCSS],
545
+ languageOptions: { parser: parserPlain },
546
+ name: "luxass/formatter/scss",
547
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "scss" })] }
548
+ }, {
549
+ files: [GLOB_LESS],
550
+ languageOptions: { parser: parserPlain },
551
+ name: "luxass/formatter/less",
552
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
553
+ });
554
+ if (options.html) configs$1.push({
555
+ files: [GLOB_HTML],
556
+ languageOptions: { parser: parserPlain },
557
+ name: "luxass/formatter/html",
558
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
559
+ });
560
+ if (options.markdown) {
561
+ const formatter = options.markdown === true ? "prettier" : options.markdown;
562
+ configs$1.push({
563
+ files: [GLOB_MARKDOWN],
564
+ languageOptions: { parser: parserPlain },
565
+ name: "luxass/formatter/markdown",
566
+ rules: { [`format/${formatter}`]: ["error", formatter === "prettier" ? mergePrettierOptions(prettierOptions, {
567
+ embeddedLanguageFormatting: "off",
568
+ parser: "markdown"
569
+ }) : {
570
+ ...dprintOptions,
571
+ language: "markdown"
572
+ }] }
573
+ });
574
+ }
575
+ if (options.astro) configs$1.push({
576
+ files: [GLOB_ASTRO],
577
+ languageOptions: { parser: parserPlain },
578
+ name: "luxass/formatter/astro",
579
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
580
+ parser: "astro",
581
+ plugins: ["prettier-plugin-astro"]
582
+ })] }
583
+ });
584
+ if (options.graphql) configs$1.push({
585
+ files: [GLOB_GRAPHQL],
586
+ languageOptions: { parser: parserPlain },
587
+ name: "luxass/formatter/graphql",
588
+ rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
589
+ });
590
+ return configs$1;
592
591
  }
593
592
 
594
- // src/configs/ignores.ts
593
+ //#endregion
594
+ //#region src/configs/ignores.ts
595
595
  async function ignores(userIgnores = []) {
596
- return [
597
- {
598
- ignores: [
599
- ...GLOB_EXCLUDE,
600
- ...userIgnores
601
- ],
602
- name: "luxass/ignores"
603
- }
604
- ];
596
+ return [{
597
+ ignores: [...GLOB_EXCLUDE, ...userIgnores],
598
+ name: "luxass/ignores"
599
+ }];
605
600
  }
606
601
 
607
- // src/configs/imports.ts
608
- import pluginAntfu2 from "eslint-plugin-antfu";
609
- import pluginImport from "eslint-plugin-import-x";
610
- async function imports(options = {}) {
611
- const {
612
- stylistic: stylistic2 = true
613
- } = options;
614
- return [
615
- {
616
- name: "luxass/imports",
617
- plugins: {
618
- antfu: pluginAntfu2,
619
- import: pluginImport
620
- },
621
- rules: {
622
- "antfu/import-dedupe": "error",
623
- "antfu/no-import-dist": "error",
624
- "antfu/no-import-node-modules-by-path": "error",
625
- "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
626
- "import/first": "error",
627
- "import/no-duplicates": "error",
628
- "import/no-mutable-exports": "error",
629
- "import/no-named-default": "error",
630
- "import/no-self-import": "error",
631
- "import/no-webpack-loader-syntax": "error",
632
- ...stylistic2 ? {
633
- "import/newline-after-import": ["error", { count: 1 }]
634
- } : {}
635
- }
636
- }
637
- ];
602
+ //#endregion
603
+ //#region src/configs/imports.ts
604
+ async function imports(_options = {}) {
605
+ return [{
606
+ name: "luxass/imports",
607
+ plugins: { antfu: pluginAntfu },
608
+ rules: {
609
+ "antfu/import-dedupe": "error",
610
+ "antfu/no-import-dist": "error",
611
+ "antfu/no-import-node-modules-by-path": "error"
612
+ }
613
+ }];
638
614
  }
639
615
 
640
- // src/configs/javascript.ts
641
- import pluginAntfu3 from "eslint-plugin-antfu";
642
- import pluginUnusedImports from "eslint-plugin-unused-imports";
643
- import globals from "globals";
616
+ //#endregion
617
+ //#region src/configs/javascript.ts
644
618
  async function javascript(options = {}) {
645
- const {
646
- isInEditor = false,
647
- overrides = {}
648
- } = options;
649
- return [
650
- {
651
- languageOptions: {
652
- ecmaVersion: 2022,
653
- globals: {
654
- ...globals.browser,
655
- ...globals.es2021,
656
- ...globals.node,
657
- document: "readonly",
658
- navigator: "readonly",
659
- window: "readonly"
660
- },
661
- parserOptions: {
662
- ecmaFeatures: {
663
- jsx: true
664
- },
665
- ecmaVersion: 2022,
666
- sourceType: "module"
667
- },
668
- sourceType: "module"
669
- },
670
- linterOptions: {
671
- reportUnusedDisableDirectives: true
672
- },
673
- name: "luxass/javascript/setup"
674
- },
675
- {
676
- name: "luxass/javascript/rules",
677
- plugins: {
678
- "antfu": pluginAntfu3,
679
- "unused-imports": pluginUnusedImports
680
- },
681
- rules: {
682
- "accessor-pairs": [
683
- "error",
684
- { enforceForClassMembers: true, setWithoutGet: true }
685
- ],
686
- "antfu/no-top-level-await": "error",
687
- "array-callback-return": "error",
688
- "block-scoped-var": "error",
689
- "constructor-super": "error",
690
- "default-case-last": "error",
691
- "dot-notation": ["error", { allowKeywords: true }],
692
- "eqeqeq": ["error", "smart"],
693
- "new-cap": [
694
- "error",
695
- { capIsNew: false, newIsCap: true, properties: true }
696
- ],
697
- "no-alert": "error",
698
- "no-array-constructor": "error",
699
- "no-async-promise-executor": "error",
700
- "no-caller": "error",
701
- "no-case-declarations": "error",
702
- "no-class-assign": "error",
703
- "no-compare-neg-zero": "error",
704
- "no-cond-assign": ["error", "always"],
705
- "no-console": ["error", { allow: ["warn", "error"] }],
706
- "no-const-assign": "error",
707
- "no-control-regex": "error",
708
- "no-debugger": "error",
709
- "no-delete-var": "error",
710
- "no-dupe-args": "error",
711
- "no-dupe-class-members": "error",
712
- "no-dupe-keys": "error",
713
- "no-duplicate-case": "error",
714
- "no-empty": ["error", { allowEmptyCatch: true }],
715
- "no-empty-character-class": "error",
716
- "no-empty-pattern": "error",
717
- "no-eval": "error",
718
- "no-ex-assign": "error",
719
- "no-extend-native": "error",
720
- "no-extra-bind": "error",
721
- "no-extra-boolean-cast": "error",
722
- "no-fallthrough": "error",
723
- "no-func-assign": "error",
724
- "no-global-assign": "error",
725
- "no-implied-eval": "error",
726
- "no-import-assign": "error",
727
- "no-invalid-regexp": "error",
728
- "no-invalid-this": "error",
729
- "no-irregular-whitespace": "error",
730
- "no-iterator": "error",
731
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
732
- "no-lone-blocks": "error",
733
- "no-loss-of-precision": "error",
734
- "no-misleading-character-class": "error",
735
- "no-multi-str": "error",
736
- "no-new": "error",
737
- "no-new-func": "error",
738
- "no-new-native-nonconstructor": "error",
739
- "no-new-wrappers": "error",
740
- "no-obj-calls": "error",
741
- "no-octal": "error",
742
- "no-octal-escape": "error",
743
- "no-proto": "error",
744
- "no-prototype-builtins": "error",
745
- "no-redeclare": ["error", { builtinGlobals: false }],
746
- "no-regex-spaces": "error",
747
- "no-restricted-globals": [
748
- "error",
749
- { message: "Use `globalThis` instead.", name: "global" },
750
- { message: "Use `globalThis` instead.", name: "self" }
751
- ],
752
- "no-restricted-properties": [
753
- "error",
754
- {
755
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
756
- property: "__proto__"
757
- },
758
- {
759
- message: "Use `Object.defineProperty` instead.",
760
- property: "__defineGetter__"
761
- },
762
- {
763
- message: "Use `Object.defineProperty` instead.",
764
- property: "__defineSetter__"
765
- },
766
- {
767
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
768
- property: "__lookupGetter__"
769
- },
770
- {
771
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
772
- property: "__lookupSetter__"
773
- }
774
- ],
775
- "no-restricted-syntax": [
776
- "error",
777
- "DebuggerStatement",
778
- "LabeledStatement",
779
- "WithStatement",
780
- "TSEnumDeclaration[const=true]",
781
- "TSExportAssignment"
782
- ],
783
- "no-self-assign": ["error", { props: true }],
784
- "no-self-compare": "error",
785
- "no-sequences": "error",
786
- "no-shadow-restricted-names": "error",
787
- "no-sparse-arrays": "error",
788
- "no-template-curly-in-string": "error",
789
- "no-this-before-super": "error",
790
- "no-throw-literal": "error",
791
- "no-undef": "error",
792
- "no-undef-init": "error",
793
- "no-unexpected-multiline": "error",
794
- "no-unmodified-loop-condition": "error",
795
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
796
- "no-unreachable": "error",
797
- "no-unreachable-loop": "error",
798
- "no-unsafe-finally": "error",
799
- "no-unsafe-negation": "error",
800
- "no-unused-expressions": [
801
- "error",
802
- {
803
- allowShortCircuit: true,
804
- allowTaggedTemplates: true,
805
- allowTernary: true
806
- }
807
- ],
808
- "no-unused-vars": [
809
- "error",
810
- {
811
- args: "none",
812
- caughtErrors: "none",
813
- ignoreRestSiblings: true,
814
- vars: "all"
815
- }
816
- ],
817
- "no-use-before-define": [
818
- "error",
819
- { classes: false, functions: false, variables: true }
820
- ],
821
- "no-useless-backreference": "error",
822
- "no-useless-call": "error",
823
- "no-useless-catch": "error",
824
- "no-useless-computed-key": "error",
825
- "no-useless-constructor": "error",
826
- "no-useless-rename": "error",
827
- "no-useless-return": "error",
828
- "no-var": "error",
829
- "no-with": "error",
830
- "object-shorthand": [
831
- "error",
832
- "always",
833
- {
834
- avoidQuotes: true,
835
- ignoreConstructors: false
836
- }
837
- ],
838
- "one-var": ["error", { initialized: "never" }],
839
- "prefer-arrow-callback": [
840
- "error",
841
- {
842
- allowNamedFunctions: false,
843
- allowUnboundThis: true
844
- }
845
- ],
846
- "prefer-const": [
847
- "error",
848
- {
849
- destructuring: "all",
850
- ignoreReadBeforeAssign: true
851
- }
852
- ],
853
- "prefer-exponentiation-operator": "error",
854
- "prefer-promise-reject-errors": "error",
855
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
856
- "prefer-rest-params": "error",
857
- "prefer-spread": "error",
858
- "prefer-template": "error",
859
- "symbol-description": "error",
860
- "unicode-bom": ["error", "never"],
861
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
862
- "unused-imports/no-unused-vars": [
863
- "error",
864
- {
865
- args: "after-used",
866
- argsIgnorePattern: "^_",
867
- vars: "all",
868
- varsIgnorePattern: "^_"
869
- }
870
- ],
871
- "use-isnan": [
872
- "error",
873
- { enforceForIndexOf: true, enforceForSwitchCase: true }
874
- ],
875
- "valid-typeof": ["error", { requireStringLiterals: true }],
876
- "vars-on-top": "error",
877
- "yoda": ["error", "never"],
878
- ...overrides
879
- }
880
- },
881
- {
882
- files: [
883
- `scripts/${GLOB_SRC}`,
884
- `cli.${GLOB_SRC_EXT}`,
885
- `**/playground.${GLOB_SRC_EXT}`
886
- ],
887
- name: "luxass/disables/cli",
888
- rules: {
889
- "no-console": "off"
890
- }
891
- }
892
- ];
619
+ const { isInEditor = false, overrides = {} } = options;
620
+ return [
621
+ {
622
+ languageOptions: {
623
+ ecmaVersion: 2022,
624
+ globals: {
625
+ ...globals.browser,
626
+ ...globals.es2021,
627
+ ...globals.node,
628
+ document: "readonly",
629
+ navigator: "readonly",
630
+ window: "readonly"
631
+ },
632
+ parserOptions: {
633
+ ecmaFeatures: { jsx: true },
634
+ ecmaVersion: 2022,
635
+ sourceType: "module"
636
+ },
637
+ sourceType: "module"
638
+ },
639
+ linterOptions: { reportUnusedDisableDirectives: true },
640
+ name: "luxass/javascript/setup"
641
+ },
642
+ {
643
+ name: "luxass/javascript/rules",
644
+ plugins: {
645
+ "antfu": pluginAntfu,
646
+ "unused-imports": pluginUnusedImports
647
+ },
648
+ rules: {
649
+ "accessor-pairs": ["error", {
650
+ enforceForClassMembers: true,
651
+ setWithoutGet: true
652
+ }],
653
+ "antfu/no-top-level-await": "error",
654
+ "array-callback-return": "error",
655
+ "block-scoped-var": "error",
656
+ "constructor-super": "error",
657
+ "default-case-last": "error",
658
+ "dot-notation": ["error", { allowKeywords: true }],
659
+ "eqeqeq": ["error", "smart"],
660
+ "new-cap": ["error", {
661
+ capIsNew: false,
662
+ newIsCap: true,
663
+ properties: true
664
+ }],
665
+ "no-alert": "error",
666
+ "no-array-constructor": "error",
667
+ "no-async-promise-executor": "error",
668
+ "no-caller": "error",
669
+ "no-case-declarations": "error",
670
+ "no-class-assign": "error",
671
+ "no-compare-neg-zero": "error",
672
+ "no-cond-assign": ["error", "always"],
673
+ "no-console": ["error", { allow: ["warn", "error"] }],
674
+ "no-const-assign": "error",
675
+ "no-control-regex": "error",
676
+ "no-debugger": "error",
677
+ "no-delete-var": "error",
678
+ "no-dupe-args": "error",
679
+ "no-dupe-class-members": "error",
680
+ "no-dupe-keys": "error",
681
+ "no-duplicate-case": "error",
682
+ "no-empty": ["error", { allowEmptyCatch: true }],
683
+ "no-empty-character-class": "error",
684
+ "no-empty-pattern": "error",
685
+ "no-eval": "error",
686
+ "no-ex-assign": "error",
687
+ "no-extend-native": "error",
688
+ "no-extra-bind": "error",
689
+ "no-extra-boolean-cast": "error",
690
+ "no-fallthrough": "error",
691
+ "no-func-assign": "error",
692
+ "no-global-assign": "error",
693
+ "no-implied-eval": "error",
694
+ "no-import-assign": "error",
695
+ "no-invalid-regexp": "error",
696
+ "no-invalid-this": "error",
697
+ "no-irregular-whitespace": "error",
698
+ "no-iterator": "error",
699
+ "no-labels": ["error", {
700
+ allowLoop: false,
701
+ allowSwitch: false
702
+ }],
703
+ "no-lone-blocks": "error",
704
+ "no-loss-of-precision": "error",
705
+ "no-misleading-character-class": "error",
706
+ "no-multi-str": "error",
707
+ "no-new": "error",
708
+ "no-new-func": "error",
709
+ "no-new-native-nonconstructor": "error",
710
+ "no-new-wrappers": "error",
711
+ "no-obj-calls": "error",
712
+ "no-octal": "error",
713
+ "no-octal-escape": "error",
714
+ "no-proto": "error",
715
+ "no-prototype-builtins": "error",
716
+ "no-redeclare": ["error", { builtinGlobals: false }],
717
+ "no-regex-spaces": "error",
718
+ "no-restricted-globals": [
719
+ "error",
720
+ {
721
+ message: "Use `globalThis` instead.",
722
+ name: "global"
723
+ },
724
+ {
725
+ message: "Use `globalThis` instead.",
726
+ name: "self"
727
+ }
728
+ ],
729
+ "no-restricted-properties": [
730
+ "error",
731
+ {
732
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
733
+ property: "__proto__"
734
+ },
735
+ {
736
+ message: "Use `Object.defineProperty` instead.",
737
+ property: "__defineGetter__"
738
+ },
739
+ {
740
+ message: "Use `Object.defineProperty` instead.",
741
+ property: "__defineSetter__"
742
+ },
743
+ {
744
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
745
+ property: "__lookupGetter__"
746
+ },
747
+ {
748
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
749
+ property: "__lookupSetter__"
750
+ }
751
+ ],
752
+ "no-restricted-syntax": [
753
+ "error",
754
+ "DebuggerStatement",
755
+ "LabeledStatement",
756
+ "WithStatement",
757
+ "TSEnumDeclaration[const=true]",
758
+ "TSExportAssignment"
759
+ ],
760
+ "no-self-assign": ["error", { props: true }],
761
+ "no-self-compare": "error",
762
+ "no-sequences": "error",
763
+ "no-shadow-restricted-names": "error",
764
+ "no-sparse-arrays": "error",
765
+ "no-template-curly-in-string": "error",
766
+ "no-this-before-super": "error",
767
+ "no-throw-literal": "error",
768
+ "no-undef": "error",
769
+ "no-undef-init": "error",
770
+ "no-unexpected-multiline": "error",
771
+ "no-unmodified-loop-condition": "error",
772
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
773
+ "no-unreachable": "error",
774
+ "no-unreachable-loop": "error",
775
+ "no-unsafe-finally": "error",
776
+ "no-unsafe-negation": "error",
777
+ "no-unused-expressions": ["error", {
778
+ allowShortCircuit: true,
779
+ allowTaggedTemplates: true,
780
+ allowTernary: true
781
+ }],
782
+ "no-unused-vars": ["error", {
783
+ args: "none",
784
+ caughtErrors: "none",
785
+ ignoreRestSiblings: true,
786
+ vars: "all"
787
+ }],
788
+ "no-use-before-define": ["error", {
789
+ classes: false,
790
+ functions: false,
791
+ variables: true
792
+ }],
793
+ "no-useless-backreference": "error",
794
+ "no-useless-call": "error",
795
+ "no-useless-catch": "error",
796
+ "no-useless-computed-key": "error",
797
+ "no-useless-constructor": "error",
798
+ "no-useless-rename": "error",
799
+ "no-useless-return": "error",
800
+ "no-var": "error",
801
+ "no-with": "error",
802
+ "object-shorthand": [
803
+ "error",
804
+ "always",
805
+ {
806
+ avoidQuotes: true,
807
+ ignoreConstructors: false
808
+ }
809
+ ],
810
+ "one-var": ["error", { initialized: "never" }],
811
+ "prefer-arrow-callback": ["error", {
812
+ allowNamedFunctions: false,
813
+ allowUnboundThis: true
814
+ }],
815
+ "prefer-const": ["error", {
816
+ destructuring: "all",
817
+ ignoreReadBeforeAssign: true
818
+ }],
819
+ "prefer-exponentiation-operator": "error",
820
+ "prefer-promise-reject-errors": "error",
821
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
822
+ "prefer-rest-params": "error",
823
+ "prefer-spread": "error",
824
+ "prefer-template": "error",
825
+ "symbol-description": "error",
826
+ "unicode-bom": ["error", "never"],
827
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
828
+ "unused-imports/no-unused-vars": ["error", {
829
+ args: "after-used",
830
+ argsIgnorePattern: "^_",
831
+ vars: "all",
832
+ varsIgnorePattern: "^_"
833
+ }],
834
+ "use-isnan": ["error", {
835
+ enforceForIndexOf: true,
836
+ enforceForSwitchCase: true
837
+ }],
838
+ "valid-typeof": ["error", { requireStringLiterals: true }],
839
+ "vars-on-top": "error",
840
+ "yoda": ["error", "never"],
841
+ ...overrides
842
+ }
843
+ },
844
+ {
845
+ files: [
846
+ `scripts/${GLOB_SRC}`,
847
+ `cli.${GLOB_SRC_EXT}`,
848
+ `**/playground.${GLOB_SRC_EXT}`
849
+ ],
850
+ name: "luxass/disables/cli",
851
+ rules: { "no-console": "off" }
852
+ }
853
+ ];
893
854
  }
894
855
 
895
- // src/configs/jsdoc.ts
856
+ //#endregion
857
+ //#region src/configs/jsdoc.ts
896
858
  async function jsdoc(options = {}) {
897
- const {
898
- overrides,
899
- stylistic: stylistic2 = true
900
- } = options;
901
- return [
902
- {
903
- name: "luxass/jsdoc/rules",
904
- plugins: {
905
- jsdoc: await interop(import("eslint-plugin-jsdoc"))
906
- },
907
- rules: {
908
- "jsdoc/check-access": "warn",
909
- "jsdoc/check-param-names": "warn",
910
- "jsdoc/check-property-names": "warn",
911
- "jsdoc/check-types": "warn",
912
- "jsdoc/empty-tags": "warn",
913
- "jsdoc/implements-on-classes": "warn",
914
- "jsdoc/no-defaults": "warn",
915
- "jsdoc/no-multi-asterisks": "warn",
916
- "jsdoc/require-param-name": "warn",
917
- "jsdoc/require-property": "warn",
918
- "jsdoc/require-property-description": "warn",
919
- "jsdoc/require-property-name": "warn",
920
- "jsdoc/require-returns-check": "warn",
921
- "jsdoc/require-returns-description": "warn",
922
- "jsdoc/require-yields-check": "warn",
923
- ...stylistic2 ? {
924
- "jsdoc/check-alignment": "warn",
925
- "jsdoc/multiline-blocks": "warn"
926
- } : {},
927
- ...overrides
928
- }
929
- }
930
- ];
859
+ const { overrides, stylistic: stylistic$1 = true } = options;
860
+ return [{
861
+ name: "luxass/jsdoc/rules",
862
+ plugins: { jsdoc: await interop(import("eslint-plugin-jsdoc")) },
863
+ rules: {
864
+ "jsdoc/check-access": "warn",
865
+ "jsdoc/check-param-names": "warn",
866
+ "jsdoc/check-property-names": "warn",
867
+ "jsdoc/check-types": "warn",
868
+ "jsdoc/empty-tags": "warn",
869
+ "jsdoc/implements-on-classes": "warn",
870
+ "jsdoc/no-defaults": "warn",
871
+ "jsdoc/no-multi-asterisks": "warn",
872
+ "jsdoc/require-param-name": "warn",
873
+ "jsdoc/require-property": "warn",
874
+ "jsdoc/require-property-description": "warn",
875
+ "jsdoc/require-property-name": "warn",
876
+ "jsdoc/require-returns-check": "warn",
877
+ "jsdoc/require-returns-description": "warn",
878
+ "jsdoc/require-yields-check": "warn",
879
+ ...stylistic$1 ? {
880
+ "jsdoc/check-alignment": "warn",
881
+ "jsdoc/multiline-blocks": "warn"
882
+ } : {},
883
+ ...overrides
884
+ }
885
+ }];
931
886
  }
932
887
 
933
- // src/configs/json.ts
888
+ //#endregion
889
+ //#region src/configs/json.ts
934
890
  async function jsonc(options = {}) {
935
- const {
936
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
937
- overrides = {},
938
- stylistic: stylistic2 = true
939
- } = options;
940
- const {
941
- indent = 2
942
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
943
- const [
944
- pluginJsonc,
945
- parserJsonc
946
- ] = await Promise.all([
947
- interop(import("eslint-plugin-jsonc")),
948
- interop(import("jsonc-eslint-parser"))
949
- ]);
950
- return [
951
- {
952
- name: "luxass/jsonc/setup",
953
- plugins: {
954
- jsonc: pluginJsonc
955
- }
956
- },
957
- {
958
- files,
959
- languageOptions: {
960
- parser: parserJsonc
961
- },
962
- name: "luxass/jsonc/rules",
963
- rules: {
964
- "jsonc/no-bigint-literals": "error",
965
- "jsonc/no-binary-expression": "error",
966
- "jsonc/no-binary-numeric-literals": "error",
967
- "jsonc/no-dupe-keys": "error",
968
- "jsonc/no-escape-sequence-in-identifier": "error",
969
- "jsonc/no-floating-decimal": "error",
970
- "jsonc/no-hexadecimal-numeric-literals": "error",
971
- "jsonc/no-infinity": "error",
972
- "jsonc/no-multi-str": "error",
973
- "jsonc/no-nan": "error",
974
- "jsonc/no-number-props": "error",
975
- "jsonc/no-numeric-separators": "error",
976
- "jsonc/no-octal": "error",
977
- "jsonc/no-octal-escape": "error",
978
- "jsonc/no-octal-numeric-literals": "error",
979
- "jsonc/no-parenthesized": "error",
980
- "jsonc/no-plus-sign": "error",
981
- "jsonc/no-regexp-literals": "error",
982
- "jsonc/no-sparse-arrays": "error",
983
- "jsonc/no-template-literals": "error",
984
- "jsonc/no-undefined-value": "error",
985
- "jsonc/no-unicode-codepoint-escapes": "error",
986
- "jsonc/no-useless-escape": "error",
987
- "jsonc/space-unary-ops": "error",
988
- "jsonc/valid-json-number": "error",
989
- "jsonc/vue-custom-block/no-parsing-error": "error",
990
- ...stylistic2 ? {
991
- "jsonc/array-bracket-spacing": ["error", "never"],
992
- "jsonc/comma-dangle": ["error", "never"],
993
- "jsonc/comma-style": ["error", "last"],
994
- "jsonc/indent": ["error", indent],
995
- "jsonc/key-spacing": [
996
- "error",
997
- { afterColon: true, beforeColon: false }
998
- ],
999
- "jsonc/object-curly-newline": [
1000
- "error",
1001
- { consistent: true, multiline: true }
1002
- ],
1003
- "jsonc/object-curly-spacing": ["error", "always"],
1004
- "jsonc/object-property-newline": [
1005
- "error",
1006
- { allowMultiplePropertiesPerLine: true }
1007
- ],
1008
- "jsonc/quote-props": "error",
1009
- "jsonc/quotes": "error"
1010
- } : {},
1011
- ...overrides
1012
- }
1013
- }
1014
- ];
891
+ const { files = [
892
+ GLOB_JSON,
893
+ GLOB_JSON5,
894
+ GLOB_JSONC
895
+ ], overrides = {}, stylistic: stylistic$1 = true } = options;
896
+ const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
897
+ const [pluginJsonc, parserJsonc] = await Promise.all([interop(import("eslint-plugin-jsonc")), interop(import("jsonc-eslint-parser"))]);
898
+ return [{
899
+ name: "luxass/jsonc/setup",
900
+ plugins: { jsonc: pluginJsonc }
901
+ }, {
902
+ files,
903
+ languageOptions: { parser: parserJsonc },
904
+ name: "luxass/jsonc/rules",
905
+ rules: {
906
+ "jsonc/no-bigint-literals": "error",
907
+ "jsonc/no-binary-expression": "error",
908
+ "jsonc/no-binary-numeric-literals": "error",
909
+ "jsonc/no-dupe-keys": "error",
910
+ "jsonc/no-escape-sequence-in-identifier": "error",
911
+ "jsonc/no-floating-decimal": "error",
912
+ "jsonc/no-hexadecimal-numeric-literals": "error",
913
+ "jsonc/no-infinity": "error",
914
+ "jsonc/no-multi-str": "error",
915
+ "jsonc/no-nan": "error",
916
+ "jsonc/no-number-props": "error",
917
+ "jsonc/no-numeric-separators": "error",
918
+ "jsonc/no-octal": "error",
919
+ "jsonc/no-octal-escape": "error",
920
+ "jsonc/no-octal-numeric-literals": "error",
921
+ "jsonc/no-parenthesized": "error",
922
+ "jsonc/no-plus-sign": "error",
923
+ "jsonc/no-regexp-literals": "error",
924
+ "jsonc/no-sparse-arrays": "error",
925
+ "jsonc/no-template-literals": "error",
926
+ "jsonc/no-undefined-value": "error",
927
+ "jsonc/no-unicode-codepoint-escapes": "error",
928
+ "jsonc/no-useless-escape": "error",
929
+ "jsonc/space-unary-ops": "error",
930
+ "jsonc/valid-json-number": "error",
931
+ "jsonc/vue-custom-block/no-parsing-error": "error",
932
+ ...stylistic$1 ? {
933
+ "jsonc/array-bracket-spacing": ["error", "never"],
934
+ "jsonc/comma-dangle": ["error", "never"],
935
+ "jsonc/comma-style": ["error", "last"],
936
+ "jsonc/indent": ["error", indent],
937
+ "jsonc/key-spacing": ["error", {
938
+ afterColon: true,
939
+ beforeColon: false
940
+ }],
941
+ "jsonc/object-curly-newline": ["error", {
942
+ consistent: true,
943
+ multiline: true
944
+ }],
945
+ "jsonc/object-curly-spacing": ["error", "always"],
946
+ "jsonc/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
947
+ "jsonc/quote-props": "error",
948
+ "jsonc/quotes": "error"
949
+ } : {},
950
+ ...overrides
951
+ }
952
+ }];
1015
953
  }
1016
954
 
1017
- // src/configs/jsx.ts
955
+ //#endregion
956
+ //#region src/configs/jsx.ts
1018
957
  async function jsx() {
1019
- return [
1020
- {
1021
- files: [GLOB_JSX, GLOB_TSX],
1022
- languageOptions: {
1023
- parserOptions: {
1024
- ecmaFeatures: {
1025
- jsx: true
1026
- }
1027
- }
1028
- },
1029
- name: "luxass/jsx/setup"
1030
- }
1031
- ];
958
+ return [{
959
+ files: [GLOB_JSX, GLOB_TSX],
960
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
961
+ name: "luxass/jsx/setup"
962
+ }];
1032
963
  }
1033
964
 
1034
- // src/configs/markdown.ts
1035
- import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
965
+ //#endregion
966
+ //#region src/configs/markdown.ts
1036
967
  async function markdown(options = {}) {
1037
- const {
1038
- exts = [],
1039
- files = [GLOB_MARKDOWN],
1040
- overrides = {}
1041
- } = options;
1042
- const markdown2 = await interop(import("@eslint/markdown"));
1043
- return [
1044
- {
1045
- name: "luxass/markdown/setup",
1046
- plugins: {
1047
- markdown: markdown2
1048
- }
1049
- },
1050
- {
1051
- files,
1052
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1053
- name: "luxass/markdown/processor",
1054
- // `eslint-plugin-markdown` only creates virtual files for code blocks,
1055
- // but not the markdown file itself. We use `eslint-merge-processors` to
1056
- // add a pass-through processor for the markdown file itself.
1057
- processor: mergeProcessors([
1058
- markdown2.processors.markdown,
1059
- processorPassThrough
1060
- ])
1061
- },
1062
- {
1063
- files,
1064
- languageOptions: {
1065
- parser: parserPlain
1066
- },
1067
- name: "luxass/markdown/parser"
1068
- },
1069
- {
1070
- files: [
1071
- GLOB_MARKDOWN_CODE,
1072
- ...exts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
1073
- ],
1074
- languageOptions: {
1075
- parserOptions: {
1076
- ecmaFeatures: {
1077
- impliedStrict: true
1078
- }
1079
- }
1080
- },
1081
- name: "luxass/markdown/disables",
1082
- rules: {
1083
- "antfu/no-top-level-await": "off",
1084
- "import/newline-after-import": "off",
1085
- "no-alert": "off",
1086
- "no-console": "off",
1087
- "no-labels": "off",
1088
- "no-lone-blocks": "off",
1089
- "no-restricted-syntax": "off",
1090
- "no-undef": "off",
1091
- "no-unused-expressions": "off",
1092
- "no-unused-labels": "off",
1093
- "no-unused-vars": "off",
1094
- "node/prefer-global/process": "off",
1095
- "style/comma-dangle": "off",
1096
- "style/eol-last": "off",
1097
- "ts/consistent-type-imports": "off",
1098
- "ts/explicit-function-return-type": "off",
1099
- "ts/no-namespace": "off",
1100
- "ts/no-redeclare": "off",
1101
- "ts/no-require-imports": "off",
1102
- "ts/no-unused-expressions": "off",
1103
- "ts/no-unused-vars": "off",
1104
- "ts/no-use-before-define": "off",
1105
- "ts/no-var-requires": "off",
1106
- "unicode-bom": "off",
1107
- "unused-imports/no-unused-imports": "off",
1108
- "unused-imports/no-unused-vars": "off",
1109
- ...overrides
1110
- }
1111
- }
1112
- ];
968
+ const { exts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
969
+ const markdown$1 = await interop(import("@eslint/markdown"));
970
+ return [
971
+ {
972
+ name: "luxass/markdown/setup",
973
+ plugins: { markdown: markdown$1 }
974
+ },
975
+ {
976
+ files,
977
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
978
+ name: "luxass/markdown/processor",
979
+ processor: mergeProcessors([markdown$1.processors.markdown, processorPassThrough])
980
+ },
981
+ {
982
+ files,
983
+ languageOptions: { parser: parserPlain },
984
+ name: "luxass/markdown/parser"
985
+ },
986
+ {
987
+ files: [GLOB_MARKDOWN_CODE, ...exts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
988
+ languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
989
+ name: "luxass/markdown/disables",
990
+ rules: {
991
+ "antfu/no-top-level-await": "off",
992
+ "no-alert": "off",
993
+ "no-console": "off",
994
+ "no-labels": "off",
995
+ "no-lone-blocks": "off",
996
+ "no-restricted-syntax": "off",
997
+ "no-undef": "off",
998
+ "no-unused-expressions": "off",
999
+ "no-unused-labels": "off",
1000
+ "no-unused-vars": "off",
1001
+ "node/prefer-global/process": "off",
1002
+ "style/comma-dangle": "off",
1003
+ "style/eol-last": "off",
1004
+ "style/padding-line-between-statements": "off",
1005
+ "ts/consistent-type-imports": "off",
1006
+ "ts/explicit-function-return-type": "off",
1007
+ "ts/no-namespace": "off",
1008
+ "ts/no-redeclare": "off",
1009
+ "ts/no-require-imports": "off",
1010
+ "ts/no-unused-expressions": "off",
1011
+ "ts/no-unused-vars": "off",
1012
+ "ts/no-use-before-define": "off",
1013
+ "ts/no-var-requires": "off",
1014
+ "unicode-bom": "off",
1015
+ "unused-imports/no-unused-imports": "off",
1016
+ "unused-imports/no-unused-vars": "off",
1017
+ ...overrides
1018
+ }
1019
+ }
1020
+ ];
1113
1021
  }
1114
1022
 
1115
- // src/configs/node.ts
1116
- import pluginNode from "eslint-plugin-n";
1023
+ //#endregion
1024
+ //#region src/configs/node.ts
1117
1025
  function node() {
1118
- return [
1119
- {
1120
- name: "luxass/node",
1121
- plugins: {
1122
- node: pluginNode
1123
- },
1124
- rules: {
1125
- "node/handle-callback-err": ["error", "^(err|error)$"],
1126
- "node/no-deprecated-api": "error",
1127
- "node/no-exports-assign": "error",
1128
- "node/no-new-require": "error",
1129
- "node/no-path-concat": "error",
1130
- "node/prefer-global/buffer": ["error", "never"],
1131
- "node/prefer-global/process": ["error", "never"],
1132
- "node/process-exit-as-throw": "error"
1133
- }
1134
- }
1135
- ];
1026
+ return [{
1027
+ name: "luxass/node",
1028
+ plugins: { node: pluginNode },
1029
+ rules: {
1030
+ "node/handle-callback-err": ["error", "^(err|error)$"],
1031
+ "node/no-deprecated-api": "error",
1032
+ "node/no-exports-assign": "error",
1033
+ "node/no-new-require": "error",
1034
+ "node/no-path-concat": "error",
1035
+ "node/prefer-global/buffer": ["error", "never"],
1036
+ "node/prefer-global/process": ["error", "never"],
1037
+ "node/process-exit-as-throw": "error"
1038
+ }
1039
+ }];
1136
1040
  }
1137
1041
 
1138
- // src/configs/perfectionist.ts
1139
- import pluginPerfectionist from "eslint-plugin-perfectionist";
1042
+ //#endregion
1043
+ //#region src/configs/perfectionist.ts
1044
+ /**
1045
+ * Perfectionist plugin for props and items sorting.
1046
+ *
1047
+ * @see https://github.com/azat-io/eslint-plugin-perfectionist
1048
+ */
1140
1049
  async function perfectionist() {
1141
- return [
1142
- {
1143
- name: "luxass/perfectionist/setup",
1144
- plugins: {
1145
- perfectionist: pluginPerfectionist
1146
- },
1147
- rules: {
1148
- "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
1149
- "perfectionist/sort-imports": ["error", {
1150
- groups: [
1151
- "type",
1152
- ["parent-type", "sibling-type", "index-type", "internal-type"],
1153
- "builtin",
1154
- "external",
1155
- "internal",
1156
- ["parent", "sibling", "index"],
1157
- "side-effect",
1158
- "object",
1159
- "unknown"
1160
- ],
1161
- newlinesBetween: "ignore",
1162
- order: "asc",
1163
- type: "natural"
1164
- }],
1165
- "perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
1166
- "perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
1167
- }
1168
- }
1169
- ];
1050
+ return [{
1051
+ name: "luxass/perfectionist/setup",
1052
+ plugins: { perfectionist: pluginPerfectionist },
1053
+ rules: {
1054
+ "perfectionist/sort-exports": ["error", {
1055
+ order: "asc",
1056
+ type: "natural"
1057
+ }],
1058
+ "perfectionist/sort-imports": ["error", {
1059
+ groups: [
1060
+ "type",
1061
+ [
1062
+ "parent-type",
1063
+ "sibling-type",
1064
+ "index-type",
1065
+ "internal-type"
1066
+ ],
1067
+ "builtin",
1068
+ "external",
1069
+ "internal",
1070
+ [
1071
+ "parent",
1072
+ "sibling",
1073
+ "index"
1074
+ ],
1075
+ "side-effect",
1076
+ "object",
1077
+ "unknown"
1078
+ ],
1079
+ newlinesBetween: "ignore",
1080
+ order: "asc",
1081
+ type: "natural"
1082
+ }],
1083
+ "perfectionist/sort-named-exports": ["error", {
1084
+ order: "asc",
1085
+ type: "natural"
1086
+ }],
1087
+ "perfectionist/sort-named-imports": ["error", {
1088
+ order: "asc",
1089
+ type: "natural"
1090
+ }]
1091
+ }
1092
+ }];
1170
1093
  }
1171
1094
 
1172
- // src/configs/pnpm.ts
1095
+ //#endregion
1096
+ //#region src/configs/pnpm.ts
1173
1097
  async function pnpm() {
1174
- const [
1175
- pluginPnpm,
1176
- yamlParser,
1177
- jsoncParser
1178
- ] = await Promise.all([
1179
- interop(import("eslint-plugin-pnpm")),
1180
- interop(import("yaml-eslint-parser")),
1181
- interop(import("jsonc-eslint-parser"))
1182
- ]);
1183
- return [
1184
- {
1185
- files: [
1186
- "package.json",
1187
- "**/package.json"
1188
- ],
1189
- languageOptions: {
1190
- parser: jsoncParser
1191
- },
1192
- name: "luxass/pnpm/package-json",
1193
- plugins: {
1194
- pnpm: pluginPnpm
1195
- },
1196
- rules: {
1197
- "pnpm/json-enforce-catalog": "error",
1198
- "pnpm/json-prefer-workspace-settings": "error",
1199
- "pnpm/json-valid-catalog": "error"
1200
- }
1201
- },
1202
- {
1203
- files: ["pnpm-workspace.yaml"],
1204
- languageOptions: {
1205
- parser: yamlParser
1206
- },
1207
- name: "luxass/pnpm/pnpm-workspace-yaml",
1208
- plugins: {
1209
- pnpm: pluginPnpm
1210
- },
1211
- rules: {
1212
- "pnpm/yaml-no-duplicate-catalog-item": "error",
1213
- "pnpm/yaml-no-unused-catalog-item": "error"
1214
- }
1215
- }
1216
- ];
1098
+ const [pluginPnpm, yamlParser, jsoncParser] = await Promise.all([
1099
+ interop(import("eslint-plugin-pnpm")),
1100
+ interop(import("yaml-eslint-parser")),
1101
+ interop(import("jsonc-eslint-parser"))
1102
+ ]);
1103
+ return [{
1104
+ files: ["package.json", "**/package.json"],
1105
+ languageOptions: { parser: jsoncParser },
1106
+ name: "luxass/pnpm/package-json",
1107
+ plugins: { pnpm: pluginPnpm },
1108
+ rules: {
1109
+ "pnpm/json-enforce-catalog": "error",
1110
+ "pnpm/json-prefer-workspace-settings": "error",
1111
+ "pnpm/json-valid-catalog": "error"
1112
+ }
1113
+ }, {
1114
+ files: ["pnpm-workspace.yaml"],
1115
+ languageOptions: { parser: yamlParser },
1116
+ name: "luxass/pnpm/pnpm-workspace-yaml",
1117
+ plugins: { pnpm: pluginPnpm },
1118
+ rules: {
1119
+ "pnpm/yaml-no-duplicate-catalog-item": "error",
1120
+ "pnpm/yaml-no-unused-catalog-item": "error"
1121
+ }
1122
+ }];
1217
1123
  }
1218
1124
 
1219
- // src/configs/react.ts
1220
- import { isPackageExists as isPackageExists2 } from "local-pkg";
1221
- var ReactRefreshAllowConstantExportPackages = [
1222
- "vite"
1223
- ];
1224
- var RemixPackages = [
1225
- "@remix-run/node",
1226
- "@remix-run/react",
1227
- "@remix-run/serve",
1228
- "@remix-run/dev"
1125
+ //#endregion
1126
+ //#region src/configs/react.ts
1127
+ const ReactRefreshAllowConstantExportPackages = ["vite"];
1128
+ const RemixPackages = [
1129
+ "@remix-run/node",
1130
+ "@remix-run/react",
1131
+ "@remix-run/serve",
1132
+ "@remix-run/dev"
1229
1133
  ];
1230
- var ReactRouterPackages = [
1231
- "@react-router/node",
1232
- "@react-router/react",
1233
- "@react-router/serve",
1234
- "@react-router/dev"
1235
- ];
1236
- var NextJsPackages = [
1237
- "next"
1134
+ const ReactRouterPackages = [
1135
+ "@react-router/node",
1136
+ "@react-router/react",
1137
+ "@react-router/serve",
1138
+ "@react-router/dev"
1238
1139
  ];
1140
+ const NextJsPackages = ["next"];
1239
1141
  async function react(options = {}) {
1240
- const {
1241
- files = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
1242
- filesTypeAware = [GLOB_TS, GLOB_TSX],
1243
- ignoresTypeAware = [
1244
- `${GLOB_MARKDOWN}/**`,
1245
- GLOB_ASTRO_TS
1246
- ],
1247
- overrides = {},
1248
- tsconfigPath
1249
- } = options;
1250
- await ensure([
1251
- "@eslint-react/eslint-plugin",
1252
- "eslint-plugin-react-hooks",
1253
- "eslint-plugin-react-refresh"
1254
- ]);
1255
- const isTypeAware = !!tsconfigPath;
1256
- const typeAwareRules = {
1257
- "react/no-leaked-conditional-rendering": "warn"
1258
- };
1259
- const [
1260
- pluginReact,
1261
- pluginReactHooks,
1262
- pluginReactRefresh
1263
- ] = await Promise.all([
1264
- interop(import("@eslint-react/eslint-plugin")),
1265
- interop(import("eslint-plugin-react-hooks")),
1266
- interop(import("eslint-plugin-react-refresh"))
1267
- ]);
1268
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists2(i));
1269
- const isUsingRemix = RemixPackages.some((i) => isPackageExists2(i));
1270
- const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists2(i));
1271
- const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
1272
- const plugins = pluginReact.configs.all.plugins;
1273
- return [
1274
- {
1275
- name: "luxass/react/setup",
1276
- plugins: {
1277
- "react": plugins["@eslint-react"],
1278
- "react-dom": plugins["@eslint-react/dom"],
1279
- "react-hooks": pluginReactHooks,
1280
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1281
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
1282
- "react-refresh": pluginReactRefresh,
1283
- "react-web-api": plugins["@eslint-react/web-api"]
1284
- }
1285
- },
1286
- {
1287
- files,
1288
- languageOptions: {
1289
- parserOptions: {
1290
- ecmaFeatures: {
1291
- jsx: true
1292
- }
1293
- },
1294
- sourceType: "module"
1295
- },
1296
- name: "luxass/react/rules",
1297
- rules: {
1298
- // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
1299
- "react-dom/no-dangerously-set-innerhtml": "warn",
1300
- "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1301
- "react-dom/no-find-dom-node": "error",
1302
- "react-dom/no-flush-sync": "error",
1303
- "react-dom/no-hydrate": "error",
1304
- "react-dom/no-missing-button-type": "warn",
1305
- "react-dom/no-missing-iframe-sandbox": "warn",
1306
- "react-dom/no-namespace": "error",
1307
- "react-dom/no-render": "error",
1308
- "react-dom/no-render-return-value": "error",
1309
- "react-dom/no-script-url": "warn",
1310
- "react-dom/no-unsafe-iframe-sandbox": "warn",
1311
- "react-dom/no-unsafe-target-blank": "warn",
1312
- "react-dom/no-use-form-state": "error",
1313
- "react-dom/no-void-elements-with-children": "error",
1314
- // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
1315
- "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1316
- "react-hooks-extra/no-unnecessary-use-prefix": "warn",
1317
- "react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
1318
- // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
1319
- "react-hooks/exhaustive-deps": "warn",
1320
- "react-hooks/rules-of-hooks": "error",
1321
- // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
1322
- "react-refresh/only-export-components": [
1323
- "warn",
1324
- {
1325
- allowConstantExport: isAllowConstantExport,
1326
- allowExportNames: [
1327
- ...isUsingNext ? [
1328
- "dynamic",
1329
- "dynamicParams",
1330
- "revalidate",
1331
- "fetchCache",
1332
- "runtime",
1333
- "preferredRegion",
1334
- "maxDuration",
1335
- "config",
1336
- "generateStaticParams",
1337
- "metadata",
1338
- "generateMetadata",
1339
- "viewport",
1340
- "generateViewport"
1341
- ] : [],
1342
- ...isUsingRemix || isUsingReactRouter ? [
1343
- "meta",
1344
- "links",
1345
- "headers",
1346
- "loader",
1347
- "action"
1348
- ] : []
1349
- ]
1350
- }
1351
- ],
1352
- // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
1353
- "react-web-api/no-leaked-event-listener": "warn",
1354
- "react-web-api/no-leaked-interval": "warn",
1355
- "react-web-api/no-leaked-resize-observer": "warn",
1356
- "react-web-api/no-leaked-timeout": "warn",
1357
- // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
1358
- "react/jsx-no-duplicate-props": "warn",
1359
- "react/jsx-uses-vars": "warn",
1360
- "react/no-access-state-in-setstate": "error",
1361
- "react/no-array-index-key": "warn",
1362
- "react/no-children-count": "warn",
1363
- "react/no-children-for-each": "warn",
1364
- "react/no-children-map": "warn",
1365
- "react/no-children-only": "warn",
1366
- "react/no-children-to-array": "warn",
1367
- "react/no-clone-element": "warn",
1368
- "react/no-comment-textnodes": "warn",
1369
- "react/no-component-will-mount": "error",
1370
- "react/no-component-will-receive-props": "error",
1371
- "react/no-component-will-update": "error",
1372
- "react/no-context-provider": "warn",
1373
- "react/no-create-ref": "error",
1374
- "react/no-default-props": "error",
1375
- "react/no-direct-mutation-state": "error",
1376
- "react/no-duplicate-key": "warn",
1377
- "react/no-forward-ref": "warn",
1378
- "react/no-implicit-key": "warn",
1379
- "react/no-missing-key": "error",
1380
- "react/no-nested-component-definitions": "error",
1381
- "react/no-prop-types": "error",
1382
- "react/no-redundant-should-component-update": "error",
1383
- "react/no-set-state-in-component-did-mount": "warn",
1384
- "react/no-set-state-in-component-did-update": "warn",
1385
- "react/no-set-state-in-component-will-update": "warn",
1386
- "react/no-string-refs": "error",
1387
- "react/no-unsafe-component-will-mount": "warn",
1388
- "react/no-unsafe-component-will-receive-props": "warn",
1389
- "react/no-unsafe-component-will-update": "warn",
1390
- "react/no-unstable-context-value": "warn",
1391
- "react/no-unstable-default-props": "warn",
1392
- "react/no-unused-class-component-members": "warn",
1393
- "react/no-unused-state": "warn",
1394
- "react/no-use-context": "warn",
1395
- "react/no-useless-forward-ref": "warn",
1396
- // overrides
1397
- ...overrides
1398
- }
1399
- },
1400
- ...isTypeAware ? [{
1401
- files: filesTypeAware,
1402
- ignores: ignoresTypeAware,
1403
- name: "luxass/react/type-aware-rules",
1404
- rules: {
1405
- ...typeAwareRules
1406
- }
1407
- }] : []
1408
- ];
1142
+ const { files = [
1143
+ GLOB_JS,
1144
+ GLOB_JSX,
1145
+ GLOB_TS,
1146
+ GLOB_TSX
1147
+ ], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides = {}, tsconfigPath } = options;
1148
+ await ensure([
1149
+ "@eslint-react/eslint-plugin",
1150
+ "eslint-plugin-react-hooks",
1151
+ "eslint-plugin-react-refresh"
1152
+ ]);
1153
+ const isTypeAware = !!tsconfigPath;
1154
+ const typeAwareRules = { "react/no-leaked-conditional-rendering": "warn" };
1155
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
1156
+ interop(import("@eslint-react/eslint-plugin")),
1157
+ interop(import("eslint-plugin-react-hooks")),
1158
+ interop(import("eslint-plugin-react-refresh"))
1159
+ ]);
1160
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
1161
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
1162
+ const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
1163
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
1164
+ const plugins = pluginReact.configs.all.plugins;
1165
+ return [
1166
+ {
1167
+ name: "luxass/react/setup",
1168
+ plugins: {
1169
+ "react": plugins["@eslint-react"],
1170
+ "react-dom": plugins["@eslint-react/dom"],
1171
+ "react-hooks": pluginReactHooks,
1172
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1173
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
1174
+ "react-refresh": pluginReactRefresh,
1175
+ "react-web-api": plugins["@eslint-react/web-api"]
1176
+ }
1177
+ },
1178
+ {
1179
+ files,
1180
+ languageOptions: {
1181
+ parserOptions: { ecmaFeatures: { jsx: true } },
1182
+ sourceType: "module"
1183
+ },
1184
+ name: "luxass/react/rules",
1185
+ rules: {
1186
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1187
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1188
+ "react-dom/no-find-dom-node": "error",
1189
+ "react-dom/no-flush-sync": "error",
1190
+ "react-dom/no-hydrate": "error",
1191
+ "react-dom/no-missing-button-type": "warn",
1192
+ "react-dom/no-missing-iframe-sandbox": "warn",
1193
+ "react-dom/no-namespace": "error",
1194
+ "react-dom/no-render": "error",
1195
+ "react-dom/no-render-return-value": "error",
1196
+ "react-dom/no-script-url": "warn",
1197
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1198
+ "react-dom/no-unsafe-target-blank": "warn",
1199
+ "react-dom/no-use-form-state": "error",
1200
+ "react-dom/no-void-elements-with-children": "error",
1201
+ "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1202
+ "react-hooks-extra/no-unnecessary-use-prefix": "warn",
1203
+ "react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
1204
+ "react-hooks/exhaustive-deps": "warn",
1205
+ "react-hooks/rules-of-hooks": "error",
1206
+ "react-refresh/only-export-components": ["warn", {
1207
+ allowConstantExport: isAllowConstantExport,
1208
+ allowExportNames: [...isUsingNext ? [
1209
+ "dynamic",
1210
+ "dynamicParams",
1211
+ "revalidate",
1212
+ "fetchCache",
1213
+ "runtime",
1214
+ "preferredRegion",
1215
+ "maxDuration",
1216
+ "config",
1217
+ "generateStaticParams",
1218
+ "metadata",
1219
+ "generateMetadata",
1220
+ "viewport",
1221
+ "generateViewport"
1222
+ ] : [], ...isUsingRemix || isUsingReactRouter ? [
1223
+ "meta",
1224
+ "links",
1225
+ "headers",
1226
+ "loader",
1227
+ "action"
1228
+ ] : []]
1229
+ }],
1230
+ "react-web-api/no-leaked-event-listener": "warn",
1231
+ "react-web-api/no-leaked-interval": "warn",
1232
+ "react-web-api/no-leaked-resize-observer": "warn",
1233
+ "react-web-api/no-leaked-timeout": "warn",
1234
+ "react/jsx-no-duplicate-props": "warn",
1235
+ "react/jsx-uses-vars": "warn",
1236
+ "react/no-access-state-in-setstate": "error",
1237
+ "react/no-array-index-key": "warn",
1238
+ "react/no-children-count": "warn",
1239
+ "react/no-children-for-each": "warn",
1240
+ "react/no-children-map": "warn",
1241
+ "react/no-children-only": "warn",
1242
+ "react/no-children-to-array": "warn",
1243
+ "react/no-clone-element": "warn",
1244
+ "react/no-comment-textnodes": "warn",
1245
+ "react/no-component-will-mount": "error",
1246
+ "react/no-component-will-receive-props": "error",
1247
+ "react/no-component-will-update": "error",
1248
+ "react/no-context-provider": "warn",
1249
+ "react/no-create-ref": "error",
1250
+ "react/no-default-props": "error",
1251
+ "react/no-direct-mutation-state": "error",
1252
+ "react/no-duplicate-key": "warn",
1253
+ "react/no-forward-ref": "warn",
1254
+ "react/no-implicit-key": "warn",
1255
+ "react/no-missing-key": "error",
1256
+ "react/no-nested-component-definitions": "error",
1257
+ "react/no-prop-types": "error",
1258
+ "react/no-redundant-should-component-update": "error",
1259
+ "react/no-set-state-in-component-did-mount": "warn",
1260
+ "react/no-set-state-in-component-did-update": "warn",
1261
+ "react/no-set-state-in-component-will-update": "warn",
1262
+ "react/no-string-refs": "error",
1263
+ "react/no-unsafe-component-will-mount": "warn",
1264
+ "react/no-unsafe-component-will-receive-props": "warn",
1265
+ "react/no-unsafe-component-will-update": "warn",
1266
+ "react/no-unstable-context-value": "warn",
1267
+ "react/no-unstable-default-props": "warn",
1268
+ "react/no-unused-class-component-members": "warn",
1269
+ "react/no-unused-state": "warn",
1270
+ "react/no-use-context": "warn",
1271
+ "react/no-useless-forward-ref": "warn",
1272
+ ...overrides
1273
+ }
1274
+ },
1275
+ ...isTypeAware ? [{
1276
+ files: filesTypeAware,
1277
+ ignores: ignoresTypeAware,
1278
+ name: "luxass/react/type-aware-rules",
1279
+ rules: { ...typeAwareRules }
1280
+ }] : []
1281
+ ];
1409
1282
  }
1410
1283
 
1411
- // src/configs/regexp.ts
1412
- import { configs } from "eslint-plugin-regexp";
1284
+ //#endregion
1285
+ //#region src/configs/regexp.ts
1413
1286
  async function regexp(options = {}) {
1414
- const config = configs["flat/recommended"];
1415
- const rules = {
1416
- ...config.rules
1417
- };
1418
- if (options.level === "warn") {
1419
- for (const key in rules) {
1420
- if (rules[key] === "error") {
1421
- rules[key] = "warn";
1422
- }
1423
- }
1424
- }
1425
- return [
1426
- {
1427
- ...config,
1428
- name: "luxass/regexp/rules",
1429
- rules: {
1430
- ...rules,
1431
- ...options.overrides
1432
- }
1433
- }
1434
- ];
1287
+ const config = configs["flat/recommended"];
1288
+ const rules = { ...config.rules };
1289
+ if (options.level === "warn") {
1290
+ for (const key in rules) if (rules[key] === "error") rules[key] = "warn";
1291
+ }
1292
+ return [{
1293
+ ...config,
1294
+ name: "luxass/regexp/rules",
1295
+ rules: {
1296
+ ...rules,
1297
+ ...options.overrides
1298
+ }
1299
+ }];
1435
1300
  }
1436
1301
 
1437
- // src/configs/sort.ts
1302
+ //#endregion
1303
+ //#region src/configs/sort.ts
1304
+ /**
1305
+ * Sort package.json
1306
+ *
1307
+ * Requires `jsonc` config
1308
+ */
1438
1309
  function sortPackageJson() {
1439
- return [
1440
- {
1441
- files: ["**/package.json"],
1442
- name: "luxass/sort/package-json",
1443
- rules: {
1444
- "jsonc/sort-array-values": [
1445
- "error",
1446
- {
1447
- order: { type: "asc" },
1448
- pathPattern: "^files$"
1449
- }
1450
- ],
1451
- "jsonc/sort-keys": [
1452
- "error",
1453
- {
1454
- order: [
1455
- "name",
1456
- "displayName",
1457
- "version",
1458
- "description",
1459
- "type",
1460
- "private",
1461
- "author",
1462
- "contributors",
1463
- "publisher",
1464
- "packageManager",
1465
- "license",
1466
- "funding",
1467
- "homepage",
1468
- "repository",
1469
- "bugs",
1470
- "keywords",
1471
- "categories",
1472
- "sideEffects",
1473
- "exports",
1474
- "main",
1475
- "module",
1476
- "unpkg",
1477
- "jsdelivr",
1478
- "types",
1479
- "typesVersions",
1480
- "bin",
1481
- "icon",
1482
- "files",
1483
- "engines",
1484
- "activationEvents",
1485
- "contributes",
1486
- "scripts",
1487
- "peerDependencies",
1488
- "peerDependenciesMeta",
1489
- "dependencies",
1490
- "optionalDependencies",
1491
- "devDependencies",
1492
- "pnpm",
1493
- "overrides",
1494
- "resolutions",
1495
- "husky",
1496
- "simple-git-hooks",
1497
- "lint-staged",
1498
- "eslintConfig"
1499
- ],
1500
- pathPattern: "^$"
1501
- },
1502
- {
1503
- order: { type: "asc" },
1504
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1505
- },
1506
- {
1507
- order: { type: "asc" },
1508
- pathPattern: "^resolutions$"
1509
- },
1510
- {
1511
- order: { type: "asc" },
1512
- pathPattern: "^pnpm.overrides$"
1513
- },
1514
- {
1515
- order: ["types", "import", "require", "default"],
1516
- pathPattern: "^exports.*$"
1517
- },
1518
- {
1519
- order: [
1520
- // client hooks only
1521
- "pre-commit",
1522
- "prepare-commit-msg",
1523
- "commit-msg",
1524
- "post-commit",
1525
- "pre-rebase",
1526
- "post-rewrite",
1527
- "post-checkout",
1528
- "post-merge",
1529
- "pre-push",
1530
- "pre-auto-gc"
1531
- ],
1532
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1533
- }
1534
- ]
1535
- }
1536
- }
1537
- ];
1310
+ return [{
1311
+ files: ["**/package.json"],
1312
+ name: "luxass/sort/package-json",
1313
+ rules: {
1314
+ "jsonc/sort-array-values": ["error", {
1315
+ order: { type: "asc" },
1316
+ pathPattern: "^files$"
1317
+ }],
1318
+ "jsonc/sort-keys": [
1319
+ "error",
1320
+ {
1321
+ order: [
1322
+ "name",
1323
+ "displayName",
1324
+ "version",
1325
+ "description",
1326
+ "type",
1327
+ "private",
1328
+ "author",
1329
+ "contributors",
1330
+ "publisher",
1331
+ "packageManager",
1332
+ "license",
1333
+ "funding",
1334
+ "homepage",
1335
+ "repository",
1336
+ "bugs",
1337
+ "keywords",
1338
+ "categories",
1339
+ "sideEffects",
1340
+ "imports",
1341
+ "exports",
1342
+ "main",
1343
+ "module",
1344
+ "unpkg",
1345
+ "jsdelivr",
1346
+ "types",
1347
+ "typesVersions",
1348
+ "bin",
1349
+ "icon",
1350
+ "files",
1351
+ "engines",
1352
+ "activationEvents",
1353
+ "contributes",
1354
+ "scripts",
1355
+ "peerDependencies",
1356
+ "peerDependenciesMeta",
1357
+ "dependencies",
1358
+ "optionalDependencies",
1359
+ "devDependencies",
1360
+ "pnpm",
1361
+ "overrides",
1362
+ "resolutions",
1363
+ "husky",
1364
+ "simple-git-hooks",
1365
+ "lint-staged",
1366
+ "eslintConfig"
1367
+ ],
1368
+ pathPattern: "^$"
1369
+ },
1370
+ {
1371
+ order: { type: "asc" },
1372
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
1373
+ },
1374
+ {
1375
+ order: { type: "asc" },
1376
+ pathPattern: "^resolutions$"
1377
+ },
1378
+ {
1379
+ order: { type: "asc" },
1380
+ pathPattern: "^pnpm.overrides$"
1381
+ },
1382
+ {
1383
+ order: [
1384
+ "types",
1385
+ "import",
1386
+ "require",
1387
+ "default"
1388
+ ],
1389
+ pathPattern: "^exports.*$"
1390
+ },
1391
+ {
1392
+ order: [
1393
+ "pre-commit",
1394
+ "prepare-commit-msg",
1395
+ "commit-msg",
1396
+ "post-commit",
1397
+ "pre-rebase",
1398
+ "post-rewrite",
1399
+ "post-checkout",
1400
+ "post-merge",
1401
+ "pre-push",
1402
+ "pre-auto-gc"
1403
+ ],
1404
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1405
+ }
1406
+ ]
1407
+ }
1408
+ }];
1538
1409
  }
1410
+ /**
1411
+ * Sort tsconfig.json
1412
+ *
1413
+ * Requires `jsonc` config
1414
+ */
1539
1415
  function sortTsconfig() {
1540
- return [
1541
- {
1542
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1543
- name: "luxass/sort/tsconfig",
1544
- rules: {
1545
- "jsonc/sort-keys": [
1546
- "error",
1547
- {
1548
- order: [
1549
- "extends",
1550
- "compilerOptions",
1551
- "references",
1552
- "files",
1553
- "include",
1554
- "exclude"
1555
- ],
1556
- pathPattern: "^$"
1557
- },
1558
- {
1559
- order: [
1560
- /* Projects */
1561
- "incremental",
1562
- "composite",
1563
- "tsBuildInfoFile",
1564
- "disableSourceOfProjectReferenceRedirect",
1565
- "disableSolutionSearching",
1566
- "disableReferencedProjectLoad",
1567
- /* Language and Environment */
1568
- "target",
1569
- "jsx",
1570
- "jsxFactory",
1571
- "jsxFragmentFactory",
1572
- "jsxImportSource",
1573
- "lib",
1574
- "moduleDetection",
1575
- "noLib",
1576
- "reactNamespace",
1577
- "useDefineForClassFields",
1578
- "emitDecoratorMetadata",
1579
- "experimentalDecorators",
1580
- "libReplacement",
1581
- /* Modules */
1582
- "baseUrl",
1583
- "rootDir",
1584
- "rootDirs",
1585
- "customConditions",
1586
- "module",
1587
- "moduleResolution",
1588
- "moduleSuffixes",
1589
- "noResolve",
1590
- "paths",
1591
- "resolveJsonModule",
1592
- "resolvePackageJsonExports",
1593
- "resolvePackageJsonImports",
1594
- "typeRoots",
1595
- "types",
1596
- "allowArbitraryExtensions",
1597
- "allowImportingTsExtensions",
1598
- "allowUmdGlobalAccess",
1599
- /* JavaScript Support */
1600
- "allowJs",
1601
- "checkJs",
1602
- "maxNodeModuleJsDepth",
1603
- /* Type Checking */
1604
- "strict",
1605
- "strictBindCallApply",
1606
- "strictFunctionTypes",
1607
- "strictNullChecks",
1608
- "strictPropertyInitialization",
1609
- "allowUnreachableCode",
1610
- "allowUnusedLabels",
1611
- "alwaysStrict",
1612
- "exactOptionalPropertyTypes",
1613
- "noFallthroughCasesInSwitch",
1614
- "noImplicitAny",
1615
- "noImplicitOverride",
1616
- "noImplicitReturns",
1617
- "noImplicitThis",
1618
- "noPropertyAccessFromIndexSignature",
1619
- "noUncheckedIndexedAccess",
1620
- "noUnusedLocals",
1621
- "noUnusedParameters",
1622
- "useUnknownInCatchVariables",
1623
- /* Emit */
1624
- "declaration",
1625
- "declarationDir",
1626
- "declarationMap",
1627
- "downlevelIteration",
1628
- "emitBOM",
1629
- "emitDeclarationOnly",
1630
- "importHelpers",
1631
- "importsNotUsedAsValues",
1632
- "inlineSourceMap",
1633
- "inlineSources",
1634
- "mapRoot",
1635
- "newLine",
1636
- "noEmit",
1637
- "noEmitHelpers",
1638
- "noEmitOnError",
1639
- "outDir",
1640
- "outFile",
1641
- "preserveConstEnums",
1642
- "preserveValueImports",
1643
- "removeComments",
1644
- "sourceMap",
1645
- "sourceRoot",
1646
- "stripInternal",
1647
- /* Interop Constraints */
1648
- "allowSyntheticDefaultImports",
1649
- "esModuleInterop",
1650
- "forceConsistentCasingInFileNames",
1651
- "isolatedDeclarations",
1652
- "isolatedModules",
1653
- "preserveSymlinks",
1654
- "verbatimModuleSyntax",
1655
- "erasableSyntaxOnly",
1656
- /* Completeness */
1657
- "skipDefaultLibCheck",
1658
- "skipLibCheck"
1659
- ],
1660
- pathPattern: "^compilerOptions$"
1661
- }
1662
- ]
1663
- }
1664
- }
1665
- ];
1416
+ return [{
1417
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1418
+ name: "luxass/sort/tsconfig",
1419
+ rules: { "jsonc/sort-keys": [
1420
+ "error",
1421
+ {
1422
+ order: [
1423
+ "extends",
1424
+ "compilerOptions",
1425
+ "references",
1426
+ "files",
1427
+ "include",
1428
+ "exclude"
1429
+ ],
1430
+ pathPattern: "^$"
1431
+ },
1432
+ {
1433
+ order: [
1434
+ "incremental",
1435
+ "composite",
1436
+ "tsBuildInfoFile",
1437
+ "disableSourceOfProjectReferenceRedirect",
1438
+ "disableSolutionSearching",
1439
+ "disableReferencedProjectLoad",
1440
+ "target",
1441
+ "jsx",
1442
+ "jsxFactory",
1443
+ "jsxFragmentFactory",
1444
+ "jsxImportSource",
1445
+ "lib",
1446
+ "moduleDetection",
1447
+ "noLib",
1448
+ "reactNamespace",
1449
+ "useDefineForClassFields",
1450
+ "emitDecoratorMetadata",
1451
+ "experimentalDecorators",
1452
+ "libReplacement",
1453
+ "baseUrl",
1454
+ "rootDir",
1455
+ "rootDirs",
1456
+ "customConditions",
1457
+ "module",
1458
+ "moduleResolution",
1459
+ "moduleSuffixes",
1460
+ "noResolve",
1461
+ "paths",
1462
+ "resolveJsonModule",
1463
+ "resolvePackageJsonExports",
1464
+ "resolvePackageJsonImports",
1465
+ "typeRoots",
1466
+ "types",
1467
+ "allowArbitraryExtensions",
1468
+ "allowImportingTsExtensions",
1469
+ "allowUmdGlobalAccess",
1470
+ "allowJs",
1471
+ "checkJs",
1472
+ "maxNodeModuleJsDepth",
1473
+ "strict",
1474
+ "strictBindCallApply",
1475
+ "strictFunctionTypes",
1476
+ "strictNullChecks",
1477
+ "strictPropertyInitialization",
1478
+ "allowUnreachableCode",
1479
+ "allowUnusedLabels",
1480
+ "alwaysStrict",
1481
+ "exactOptionalPropertyTypes",
1482
+ "noFallthroughCasesInSwitch",
1483
+ "noImplicitAny",
1484
+ "noImplicitOverride",
1485
+ "noImplicitReturns",
1486
+ "noImplicitThis",
1487
+ "noPropertyAccessFromIndexSignature",
1488
+ "noUncheckedIndexedAccess",
1489
+ "noUnusedLocals",
1490
+ "noUnusedParameters",
1491
+ "useUnknownInCatchVariables",
1492
+ "declaration",
1493
+ "declarationDir",
1494
+ "declarationMap",
1495
+ "downlevelIteration",
1496
+ "emitBOM",
1497
+ "emitDeclarationOnly",
1498
+ "importHelpers",
1499
+ "importsNotUsedAsValues",
1500
+ "inlineSourceMap",
1501
+ "inlineSources",
1502
+ "mapRoot",
1503
+ "newLine",
1504
+ "noEmit",
1505
+ "noEmitHelpers",
1506
+ "noEmitOnError",
1507
+ "outDir",
1508
+ "outFile",
1509
+ "preserveConstEnums",
1510
+ "preserveValueImports",
1511
+ "removeComments",
1512
+ "sourceMap",
1513
+ "sourceRoot",
1514
+ "stripInternal",
1515
+ "allowSyntheticDefaultImports",
1516
+ "esModuleInterop",
1517
+ "forceConsistentCasingInFileNames",
1518
+ "isolatedDeclarations",
1519
+ "isolatedModules",
1520
+ "preserveSymlinks",
1521
+ "verbatimModuleSyntax",
1522
+ "erasableSyntaxOnly",
1523
+ "skipDefaultLibCheck",
1524
+ "skipLibCheck"
1525
+ ],
1526
+ pathPattern: "^compilerOptions$"
1527
+ }
1528
+ ] }
1529
+ }];
1666
1530
  }
1667
1531
 
1668
- // src/configs/tailwindcss.ts
1532
+ //#endregion
1533
+ //#region src/configs/tailwindcss.ts
1669
1534
  async function tailwindcss(options = {}) {
1670
- const {
1671
- configPath,
1672
- overrides
1673
- } = options;
1674
- await ensure([
1675
- "eslint-plugin-tailwindcss"
1676
- ]);
1677
- const [
1678
- pluginTailwindCSS
1679
- ] = await Promise.all([
1680
- interop(import("eslint-plugin-tailwindcss"))
1681
- ]);
1682
- return [
1683
- {
1684
- languageOptions: {
1685
- parserOptions: {
1686
- ecmaFeatures: {
1687
- jsx: true
1688
- }
1689
- }
1690
- },
1691
- name: "luxass/tailwindcss",
1692
- plugins: {
1693
- tailwindcss: pluginTailwindCSS
1694
- },
1695
- rules: {
1696
- // https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/docs/rules/classnames-order.md
1697
- "tailwindcss/classnames-order": "warn",
1698
- // https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/docs/rules/enforces-negative-arbitrary-values.md
1699
- "tailwindcss/enforces-negative-arbitrary-values": "warn",
1700
- // https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/docs/rules/enforces-shorthand.md
1701
- "tailwindcss/enforces-shorthand": "warn",
1702
- // https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/docs/rules/migration-from-tailwind-2.md
1703
- "tailwindcss/migration-from-tailwind-2": "warn",
1704
- // https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/docs/rules/no-arbitrary-value.md
1705
- "tailwindcss/no-arbitrary-value": "off",
1706
- // https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/docs/rules/no-contradicting-classname.md
1707
- "tailwindcss/no-contradicting-classname": "error",
1708
- // https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/docs/rules/no-custom-classname.md
1709
- "tailwindcss/no-custom-classname": "warn",
1710
- ...overrides
1711
- },
1712
- settings: {
1713
- ...configPath != null ? {
1714
- tailwindcss: {
1715
- config: configPath
1716
- }
1717
- } : {}
1718
- }
1719
- }
1720
- ];
1535
+ const { configPath, overrides } = options;
1536
+ await ensure(["eslint-plugin-tailwindcss"]);
1537
+ const [pluginTailwindCSS] = await Promise.all([interop(import("eslint-plugin-tailwindcss"))]);
1538
+ return [{
1539
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
1540
+ name: "luxass/tailwindcss",
1541
+ plugins: { tailwindcss: pluginTailwindCSS },
1542
+ rules: {
1543
+ "tailwindcss/classnames-order": "warn",
1544
+ "tailwindcss/enforces-negative-arbitrary-values": "warn",
1545
+ "tailwindcss/enforces-shorthand": "warn",
1546
+ "tailwindcss/migration-from-tailwind-2": "warn",
1547
+ "tailwindcss/no-arbitrary-value": "off",
1548
+ "tailwindcss/no-contradicting-classname": "error",
1549
+ "tailwindcss/no-custom-classname": "warn",
1550
+ ...overrides
1551
+ },
1552
+ settings: { ...configPath != null ? { tailwindcss: { config: configPath } } : {} }
1553
+ }];
1721
1554
  }
1722
1555
 
1723
- // src/configs/test.ts
1724
- var _pluginTest;
1556
+ //#endregion
1557
+ //#region src/configs/test.ts
1558
+ let _pluginTest;
1725
1559
  async function test(options = {}) {
1726
- const {
1727
- files = GLOB_TESTS,
1728
- isInEditor = false,
1729
- overrides = {}
1730
- } = options;
1731
- const [
1732
- pluginVitest
1733
- ] = await Promise.all([
1734
- interop(import("@vitest/eslint-plugin"))
1735
- ]);
1736
- _pluginTest = _pluginTest || pluginVitest;
1737
- return [
1738
- {
1739
- name: "luxass/test/setup",
1740
- plugins: {
1741
- test: _pluginTest
1742
- }
1743
- },
1744
- {
1745
- files,
1746
- name: "luxass/test/rules",
1747
- rules: {
1748
- "test/consistent-test-it": [
1749
- "error",
1750
- { fn: "it", withinDescribe: "it" }
1751
- ],
1752
- "test/no-focused-tests": isInEditor ? "off" : ["error", { fixable: true }],
1753
- "test/no-identical-title": "error",
1754
- "test/no-import-node-test": "error",
1755
- "test/prefer-hooks-in-order": "error",
1756
- "test/prefer-lowercase-title": "error",
1757
- // Disables
1758
- ...{
1759
- "antfu/no-top-level-await": "off",
1760
- "no-unused-expressions": "off",
1761
- "node/prefer-global/process": "off",
1762
- "ts/explicit-function-return-type": "off"
1763
- },
1764
- ...overrides
1765
- }
1766
- }
1767
- ];
1560
+ const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
1561
+ const [pluginVitest] = await Promise.all([interop(import("@vitest/eslint-plugin"))]);
1562
+ _pluginTest = _pluginTest || pluginVitest;
1563
+ return [{
1564
+ name: "luxass/test/setup",
1565
+ plugins: { test: _pluginTest }
1566
+ }, {
1567
+ files,
1568
+ name: "luxass/test/rules",
1569
+ rules: {
1570
+ "test/consistent-test-it": ["error", {
1571
+ fn: "it",
1572
+ withinDescribe: "it"
1573
+ }],
1574
+ "test/no-focused-tests": isInEditor ? "off" : ["error", { fixable: true }],
1575
+ "test/no-identical-title": "error",
1576
+ "test/no-import-node-test": "error",
1577
+ "test/prefer-hooks-in-order": "error",
1578
+ "test/prefer-lowercase-title": "error",
1579
+ "antfu/no-top-level-await": "off",
1580
+ "no-unused-expressions": "off",
1581
+ "node/prefer-global/process": "off",
1582
+ "ts/explicit-function-return-type": "off",
1583
+ ...overrides
1584
+ }
1585
+ }];
1768
1586
  }
1769
1587
 
1770
- // src/configs/toml.ts
1588
+ //#endregion
1589
+ //#region src/configs/toml.ts
1771
1590
  async function toml(options = {}) {
1772
- const {
1773
- files = [GLOB_TOML],
1774
- overrides = {},
1775
- stylistic: stylistic2 = true
1776
- } = options;
1777
- const {
1778
- indent = 2
1779
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1780
- const [
1781
- pluginToml,
1782
- parserToml
1783
- ] = await Promise.all([
1784
- interop(import("eslint-plugin-toml")),
1785
- interop(import("toml-eslint-parser"))
1786
- ]);
1787
- return [
1788
- {
1789
- name: "luxass/toml/setup",
1790
- plugins: {
1791
- toml: pluginToml
1792
- }
1793
- },
1794
- {
1795
- files,
1796
- languageOptions: {
1797
- parser: parserToml
1798
- },
1799
- name: "luxass/toml/rules",
1800
- rules: {
1801
- "style/spaced-comment": "off",
1802
- "toml/comma-style": "error",
1803
- "toml/keys-order": "error",
1804
- "toml/no-space-dots": "error",
1805
- "toml/no-unreadable-number-separator": "error",
1806
- "toml/precision-of-fractional-seconds": "error",
1807
- "toml/precision-of-integer": "error",
1808
- "toml/tables-order": "error",
1809
- "toml/vue-custom-block/no-parsing-error": "error",
1810
- ...stylistic2 ? {
1811
- "toml/array-bracket-newline": "error",
1812
- "toml/array-bracket-spacing": "error",
1813
- "toml/array-element-newline": "error",
1814
- "toml/indent": ["error", indent === "tab" ? 2 : indent],
1815
- "toml/inline-table-curly-spacing": "error",
1816
- "toml/key-spacing": "error",
1817
- "toml/padding-line-between-pairs": "error",
1818
- "toml/padding-line-between-tables": "error",
1819
- "toml/quoted-keys": "error",
1820
- "toml/spaced-comment": "error",
1821
- "toml/table-bracket-spacing": "error"
1822
- } : {},
1823
- ...overrides
1824
- }
1825
- }
1826
- ];
1591
+ const { files = [GLOB_TOML], overrides = {}, stylistic: stylistic$1 = true } = options;
1592
+ const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1593
+ const [pluginToml, parserToml] = await Promise.all([interop(import("eslint-plugin-toml")), interop(import("toml-eslint-parser"))]);
1594
+ return [{
1595
+ name: "luxass/toml/setup",
1596
+ plugins: { toml: pluginToml }
1597
+ }, {
1598
+ files,
1599
+ languageOptions: { parser: parserToml },
1600
+ name: "luxass/toml/rules",
1601
+ rules: {
1602
+ "style/spaced-comment": "off",
1603
+ "toml/comma-style": "error",
1604
+ "toml/keys-order": "error",
1605
+ "toml/no-space-dots": "error",
1606
+ "toml/no-unreadable-number-separator": "error",
1607
+ "toml/precision-of-fractional-seconds": "error",
1608
+ "toml/precision-of-integer": "error",
1609
+ "toml/tables-order": "error",
1610
+ "toml/vue-custom-block/no-parsing-error": "error",
1611
+ ...stylistic$1 ? {
1612
+ "toml/array-bracket-newline": "error",
1613
+ "toml/array-bracket-spacing": "error",
1614
+ "toml/array-element-newline": "error",
1615
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1616
+ "toml/inline-table-curly-spacing": "error",
1617
+ "toml/key-spacing": "error",
1618
+ "toml/padding-line-between-pairs": "error",
1619
+ "toml/padding-line-between-tables": "error",
1620
+ "toml/quoted-keys": "error",
1621
+ "toml/spaced-comment": "error",
1622
+ "toml/table-bracket-spacing": "error"
1623
+ } : {},
1624
+ ...overrides
1625
+ }
1626
+ }];
1827
1627
  }
1828
1628
 
1829
- // src/configs/typescript.ts
1830
- import process2 from "node:process";
1831
- import pluginAntfu4 from "eslint-plugin-antfu";
1629
+ //#endregion
1630
+ //#region src/configs/typescript.ts
1832
1631
  async function typescript(options = {}) {
1833
- const {
1834
- exts = [],
1835
- overrides = {},
1836
- overridesTypeAware = {},
1837
- parserOptions = {},
1838
- type = "app"
1839
- } = options ?? {};
1840
- const files = options.files ?? [
1841
- GLOB_TS,
1842
- GLOB_TSX,
1843
- ...exts.map((ext) => `**/*.${ext}`)
1844
- ];
1845
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1846
- const ignoresTypeAware = options.ignoresTypeAware ?? [
1847
- `${GLOB_MARKDOWN}/**`,
1848
- GLOB_ASTRO_TS
1849
- ];
1850
- const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1851
- const isTypeAware = !!tsconfigPath;
1852
- const typeAwareRules = {
1853
- "dot-notation": "off",
1854
- "no-implied-eval": "off",
1855
- "ts/await-thenable": "error",
1856
- "ts/dot-notation": ["error", { allowKeywords: true }],
1857
- "ts/no-floating-promises": "error",
1858
- "ts/no-for-in-array": "error",
1859
- "ts/no-implied-eval": "error",
1860
- "ts/no-misused-promises": "error",
1861
- "ts/no-unnecessary-type-assertion": "error",
1862
- "ts/no-unsafe-argument": "error",
1863
- "ts/no-unsafe-assignment": "error",
1864
- "ts/no-unsafe-call": "error",
1865
- "ts/no-unsafe-member-access": "error",
1866
- "ts/no-unsafe-return": "error",
1867
- "ts/promise-function-async": "error",
1868
- "ts/restrict-plus-operands": "error",
1869
- "ts/restrict-template-expressions": "error",
1870
- "ts/return-await": ["error", "in-try-catch"],
1871
- "ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
1872
- "ts/switch-exhaustiveness-check": "error",
1873
- "ts/unbound-method": "error"
1874
- };
1875
- const [
1876
- pluginTs,
1877
- parserTs
1878
- ] = await Promise.all([
1879
- interop(import("@typescript-eslint/eslint-plugin")),
1880
- interop(import("@typescript-eslint/parser"))
1881
- ]);
1882
- function makeParser(typeAware, files2, ignores2) {
1883
- return {
1884
- files: files2,
1885
- ...ignores2 ? { ignores: ignores2 } : {},
1886
- languageOptions: {
1887
- parser: parserTs,
1888
- parserOptions: {
1889
- extraFileExtensions: exts.map((ext) => `.${ext}`),
1890
- sourceType: "module",
1891
- ...typeAware ? {
1892
- projectService: {
1893
- allowDefaultProject: ["./*.js"],
1894
- defaultProject: tsconfigPath
1895
- },
1896
- tsconfigRootDir: process2.cwd()
1897
- } : {},
1898
- ...parserOptions
1899
- }
1900
- },
1901
- name: `luxass/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1902
- };
1903
- }
1904
- return [
1905
- {
1906
- // Install the plugins without globs, so they can be configured separately.
1907
- name: "luxass/typescript/setup",
1908
- plugins: {
1909
- antfu: pluginAntfu4,
1910
- ts: pluginTs
1911
- }
1912
- },
1913
- ...isTypeAware ? [
1914
- makeParser(true, filesTypeAware, ignoresTypeAware),
1915
- makeParser(false, files, filesTypeAware)
1916
- ] : [makeParser(false, files)],
1917
- {
1918
- files,
1919
- name: "luxass/typescript/rules",
1920
- rules: {
1921
- ...renameRules(
1922
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
1923
- {
1924
- "@typescript-eslint": "ts"
1925
- }
1926
- ),
1927
- ...renameRules(
1928
- pluginTs.configs.strict.rules,
1929
- {
1930
- "@typescript-eslint": "ts"
1931
- }
1932
- ),
1933
- "no-dupe-class-members": "off",
1934
- "no-invalid-this": "off",
1935
- "no-loss-of-precision": "error",
1936
- "no-redeclare": "off",
1937
- "no-use-before-define": "off",
1938
- "no-useless-constructor": "off",
1939
- "ts/ban-ts-comment": [
1940
- "error",
1941
- {
1942
- "ts-expect-error": "allow-with-description",
1943
- "ts-ignore": "allow-with-description"
1944
- }
1945
- ],
1946
- "ts/consistent-type-definitions": ["error", "interface"],
1947
- "ts/consistent-type-imports": [
1948
- "error",
1949
- {
1950
- disallowTypeAnnotations: false,
1951
- fixStyle: "separate-type-imports",
1952
- prefer: "type-imports"
1953
- }
1954
- ],
1955
- "ts/method-signature-style": ["error", "property"],
1956
- // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1957
- "ts/no-dupe-class-members": "error",
1958
- "ts/no-dynamic-delete": "off",
1959
- "ts/no-empty-object-type": "error",
1960
- "ts/no-explicit-any": "off",
1961
- "ts/no-extraneous-class": "off",
1962
- "ts/no-import-type-side-effects": "error",
1963
- "ts/no-invalid-this": "error",
1964
- "ts/no-invalid-void-type": "off",
1965
- "ts/no-non-null-assertion": "off",
1966
- "ts/no-redeclare": ["error", { builtinGlobals: false }],
1967
- "ts/no-require-imports": "error",
1968
- "ts/no-unused-expressions": ["error", {
1969
- allowShortCircuit: true,
1970
- allowTaggedTemplates: true,
1971
- allowTernary: true
1972
- }],
1973
- "ts/no-unused-vars": "off",
1974
- "ts/no-use-before-define": [
1975
- "error",
1976
- { classes: false, functions: false, variables: true }
1977
- ],
1978
- "ts/no-useless-constructor": "off",
1979
- "ts/no-wrapper-object-types": "error",
1980
- "ts/triple-slash-reference": "off",
1981
- "ts/unified-signatures": "off",
1982
- ...type === "lib" ? {
1983
- "ts/explicit-function-return-type": ["error", {
1984
- allowExpressions: true,
1985
- allowHigherOrderFunctions: true,
1986
- allowIIFEs: true
1987
- }]
1988
- } : {},
1989
- ...overrides
1990
- }
1991
- },
1992
- ...isTypeAware ? [{
1993
- files: filesTypeAware,
1994
- ignores: ignoresTypeAware,
1995
- name: "luxass/typescript/rules-type-aware",
1996
- rules: {
1997
- ...typeAwareRules,
1998
- ...overridesTypeAware
1999
- }
2000
- }] : []
2001
- ];
1632
+ const { exts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options ?? {};
1633
+ const files = options.files ?? [
1634
+ GLOB_TS,
1635
+ GLOB_TSX,
1636
+ ...exts.map((ext) => `**/*.${ext}`)
1637
+ ];
1638
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1639
+ const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
1640
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1641
+ const isTypeAware = !!tsconfigPath;
1642
+ const typeAwareRules = {
1643
+ "dot-notation": "off",
1644
+ "no-implied-eval": "off",
1645
+ "ts/await-thenable": "error",
1646
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1647
+ "ts/no-floating-promises": "error",
1648
+ "ts/no-for-in-array": "error",
1649
+ "ts/no-implied-eval": "error",
1650
+ "ts/no-misused-promises": "error",
1651
+ "ts/no-unnecessary-type-assertion": "error",
1652
+ "ts/no-unsafe-argument": "error",
1653
+ "ts/no-unsafe-assignment": "error",
1654
+ "ts/no-unsafe-call": "error",
1655
+ "ts/no-unsafe-member-access": "error",
1656
+ "ts/no-unsafe-return": "error",
1657
+ "ts/promise-function-async": "error",
1658
+ "ts/restrict-plus-operands": "error",
1659
+ "ts/restrict-template-expressions": "error",
1660
+ "ts/return-await": ["error", "in-try-catch"],
1661
+ "ts/strict-boolean-expressions": ["error", {
1662
+ allowNullableBoolean: true,
1663
+ allowNullableObject: true
1664
+ }],
1665
+ "ts/switch-exhaustiveness-check": "error",
1666
+ "ts/unbound-method": "error"
1667
+ };
1668
+ const [pluginTs, parserTs] = await Promise.all([interop(import("@typescript-eslint/eslint-plugin")), interop(import("@typescript-eslint/parser"))]);
1669
+ function makeParser(typeAware, files$1, ignores$1) {
1670
+ return {
1671
+ files: files$1,
1672
+ ...ignores$1 ? { ignores: ignores$1 } : {},
1673
+ languageOptions: {
1674
+ parser: parserTs,
1675
+ parserOptions: {
1676
+ extraFileExtensions: exts.map((ext) => `.${ext}`),
1677
+ sourceType: "module",
1678
+ ...typeAware ? {
1679
+ projectService: {
1680
+ allowDefaultProject: ["./*.js"],
1681
+ defaultProject: tsconfigPath
1682
+ },
1683
+ tsconfigRootDir: process.cwd()
1684
+ } : {},
1685
+ ...parserOptions
1686
+ }
1687
+ },
1688
+ name: `luxass/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1689
+ };
1690
+ }
1691
+ return [
1692
+ {
1693
+ name: "luxass/typescript/setup",
1694
+ plugins: {
1695
+ antfu: pluginAntfu,
1696
+ ts: pluginTs
1697
+ }
1698
+ },
1699
+ ...isTypeAware ? [makeParser(true, filesTypeAware, ignoresTypeAware), makeParser(false, files, filesTypeAware)] : [makeParser(false, files)],
1700
+ {
1701
+ files,
1702
+ name: "luxass/typescript/rules",
1703
+ rules: {
1704
+ ...renameRules(pluginTs.configs["eslint-recommended"].overrides[0].rules, { "@typescript-eslint": "ts" }),
1705
+ ...renameRules(pluginTs.configs.strict.rules, { "@typescript-eslint": "ts" }),
1706
+ "no-dupe-class-members": "off",
1707
+ "no-invalid-this": "off",
1708
+ "no-loss-of-precision": "error",
1709
+ "no-redeclare": "off",
1710
+ "no-use-before-define": "off",
1711
+ "no-useless-constructor": "off",
1712
+ "ts/ban-ts-comment": ["error", {
1713
+ "ts-expect-error": "allow-with-description",
1714
+ "ts-ignore": "allow-with-description"
1715
+ }],
1716
+ "ts/consistent-type-definitions": ["error", "interface"],
1717
+ "ts/consistent-type-imports": ["error", {
1718
+ disallowTypeAnnotations: false,
1719
+ fixStyle: "separate-type-imports",
1720
+ prefer: "type-imports"
1721
+ }],
1722
+ "ts/method-signature-style": ["error", "property"],
1723
+ "ts/no-dupe-class-members": "error",
1724
+ "ts/no-dynamic-delete": "off",
1725
+ "ts/no-empty-object-type": "error",
1726
+ "ts/no-explicit-any": "off",
1727
+ "ts/no-extraneous-class": "off",
1728
+ "ts/no-import-type-side-effects": "error",
1729
+ "ts/no-invalid-this": "error",
1730
+ "ts/no-invalid-void-type": "off",
1731
+ "ts/no-non-null-assertion": "off",
1732
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
1733
+ "ts/no-require-imports": "error",
1734
+ "ts/no-unused-expressions": ["error", {
1735
+ allowShortCircuit: true,
1736
+ allowTaggedTemplates: true,
1737
+ allowTernary: true
1738
+ }],
1739
+ "ts/no-unused-vars": "off",
1740
+ "ts/no-use-before-define": ["error", {
1741
+ classes: false,
1742
+ functions: false,
1743
+ variables: true
1744
+ }],
1745
+ "ts/no-useless-constructor": "off",
1746
+ "ts/no-wrapper-object-types": "error",
1747
+ "ts/triple-slash-reference": "off",
1748
+ "ts/unified-signatures": "off",
1749
+ ...type === "lib" ? { "ts/explicit-function-return-type": ["error", {
1750
+ allowExpressions: true,
1751
+ allowHigherOrderFunctions: true,
1752
+ allowIIFEs: true
1753
+ }] } : {},
1754
+ ...overrides
1755
+ }
1756
+ },
1757
+ ...isTypeAware ? [{
1758
+ files: filesTypeAware,
1759
+ ignores: ignoresTypeAware,
1760
+ name: "luxass/typescript/rules-type-aware",
1761
+ rules: {
1762
+ ...typeAwareRules,
1763
+ ...overridesTypeAware
1764
+ }
1765
+ }] : []
1766
+ ];
2002
1767
  }
2003
1768
 
2004
- // src/configs/unicorn.ts
2005
- import pluginUnicorn from "eslint-plugin-unicorn";
1769
+ //#endregion
1770
+ //#region src/configs/unicorn.ts
2006
1771
  async function unicorn(options = {}) {
2007
- return [
2008
- {
2009
- name: "luxass/unicorn/rules",
2010
- plugins: {
2011
- unicorn: pluginUnicorn
2012
- },
2013
- rules: {
2014
- ...options.allRecommended ? pluginUnicorn.configs.recommended.rules : {
2015
- // Pass error message when throwing errors
2016
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/error-message.md
2017
- "unicorn/error-message": "error",
2018
- // Uppercase regex escapes
2019
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/escape-case.md
2020
- "unicorn/escape-case": "error",
2021
- // Array.isArray instead of instanceof
2022
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-instanceof-builtins.md
2023
- "unicorn/no-instanceof-builtins": "error",
2024
- // Ban `new Array` as `Array` constructor's params are ambiguous
2025
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-array.md
2026
- "unicorn/no-new-array": "error",
2027
- // Prevent deprecated `new Buffer()`
2028
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-buffer.md
2029
- "unicorn/no-new-buffer": "error",
2030
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
2031
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/number-literal-case.md
2032
- "unicorn/number-literal-case": "error",
2033
- // textContent instead of innerText
2034
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-text-content.md
2035
- "unicorn/prefer-dom-node-text-content": "error",
2036
- // includes over indexOf when checking for existence
2037
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes.md
2038
- "unicorn/prefer-includes": "error",
2039
- // Prefer using the node: protocol
2040
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
2041
- "unicorn/prefer-node-protocol": "error",
2042
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
2043
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-number-properties.md
2044
- "unicorn/prefer-number-properties": "error",
2045
- // String methods startsWith/endsWith instead of more complicated stuff
2046
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-starts-ends-with.md
2047
- "unicorn/prefer-string-starts-ends-with": "error",
2048
- // Enforce throwing type error when throwing error while checking typeof
2049
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-type-error.md
2050
- "unicorn/prefer-type-error": "error",
2051
- // Use new when throwing error
2052
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md
2053
- "unicorn/throw-new-error": "error"
2054
- }
2055
- }
2056
- }
2057
- ];
1772
+ return [{
1773
+ name: "luxass/unicorn/rules",
1774
+ plugins: { unicorn: pluginUnicorn },
1775
+ rules: { ...options.allRecommended ? pluginUnicorn.configs.recommended.rules : {
1776
+ "unicorn/error-message": "error",
1777
+ "unicorn/escape-case": "error",
1778
+ "unicorn/no-instanceof-builtins": "error",
1779
+ "unicorn/no-new-array": "error",
1780
+ "unicorn/no-new-buffer": "error",
1781
+ "unicorn/number-literal-case": "error",
1782
+ "unicorn/prefer-dom-node-text-content": "error",
1783
+ "unicorn/prefer-includes": "error",
1784
+ "unicorn/prefer-node-protocol": "error",
1785
+ "unicorn/prefer-number-properties": "error",
1786
+ "unicorn/prefer-string-starts-ends-with": "error",
1787
+ "unicorn/prefer-type-error": "error",
1788
+ "unicorn/throw-new-error": "error"
1789
+ } }
1790
+ }];
2058
1791
  }
2059
1792
 
2060
- // src/configs/unocss.ts
1793
+ //#endregion
1794
+ //#region src/configs/unocss.ts
2061
1795
  async function unocss(options = {}) {
2062
- const {
2063
- attributify = true,
2064
- configPath,
2065
- overrides,
2066
- strict = false
2067
- } = options;
2068
- await ensure([
2069
- "@unocss/eslint-plugin"
2070
- ]);
2071
- const [
2072
- pluginUnoCSS
2073
- ] = await Promise.all([
2074
- interop(import("@unocss/eslint-plugin"))
2075
- ]);
2076
- return [
2077
- {
2078
- name: "luxass/unocss",
2079
- plugins: {
2080
- unocss: pluginUnoCSS
2081
- },
2082
- rules: {
2083
- "unocss/order": "warn",
2084
- ...attributify ? {
2085
- "unocss/order-attributify": "warn"
2086
- } : {},
2087
- ...strict ? {
2088
- "unocss/blocklist": "error"
2089
- } : {},
2090
- ...overrides
2091
- },
2092
- settings: {
2093
- ...configPath != null ? {
2094
- unocss: {
2095
- configPath
2096
- }
2097
- } : {}
2098
- }
2099
- }
2100
- ];
1796
+ const { attributify = true, configPath, overrides, strict = false } = options;
1797
+ await ensure(["@unocss/eslint-plugin"]);
1798
+ const [pluginUnoCSS] = await Promise.all([interop(import("@unocss/eslint-plugin"))]);
1799
+ return [{
1800
+ name: "luxass/unocss",
1801
+ plugins: { unocss: pluginUnoCSS },
1802
+ rules: {
1803
+ "unocss/order": "warn",
1804
+ ...attributify ? { "unocss/order-attributify": "warn" } : {},
1805
+ ...strict ? { "unocss/blocklist": "error" } : {},
1806
+ ...overrides
1807
+ },
1808
+ settings: { ...configPath != null ? { unocss: { configPath } } : {} }
1809
+ }];
2101
1810
  }
2102
1811
 
2103
- // src/configs/vue.ts
2104
- import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
1812
+ //#endregion
1813
+ //#region src/configs/vue.ts
2105
1814
  async function vue(options = {}) {
2106
- const {
2107
- files = [GLOB_VUE],
2108
- overrides = {},
2109
- stylistic: stylistic2 = true
2110
- } = options;
2111
- const [
2112
- pluginVue,
2113
- parserVue,
2114
- processorVueBlocks
2115
- ] = await Promise.all([
2116
- interop(import("eslint-plugin-vue")),
2117
- interop(import("vue-eslint-parser")),
2118
- interop(import("eslint-processor-vue-blocks"))
2119
- ]);
2120
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
2121
- const {
2122
- indent = 2
2123
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2124
- return [
2125
- {
2126
- // This allows Vue plugin to work with auto imports
2127
- // https://github.com/vuejs/eslint-plugin-vue/pull/2422
2128
- languageOptions: {
2129
- globals: {
2130
- computed: "readonly",
2131
- defineEmits: "readonly",
2132
- defineExpose: "readonly",
2133
- defineProps: "readonly",
2134
- onMounted: "readonly",
2135
- onUnmounted: "readonly",
2136
- reactive: "readonly",
2137
- ref: "readonly",
2138
- shallowReactive: "readonly",
2139
- shallowRef: "readonly",
2140
- toRef: "readonly",
2141
- toRefs: "readonly",
2142
- watch: "readonly",
2143
- watchEffect: "readonly"
2144
- }
2145
- },
2146
- name: "luxass/vue/setup",
2147
- plugins: {
2148
- vue: pluginVue
2149
- }
2150
- },
2151
- {
2152
- files,
2153
- languageOptions: {
2154
- parser: parserVue,
2155
- parserOptions: {
2156
- ecmaFeatures: {
2157
- jsx: true
2158
- },
2159
- extraFileExtensions: [".vue"],
2160
- parser: options.typescript ? await interop(import("@typescript-eslint/parser")) : null,
2161
- sourceType: "module"
2162
- }
2163
- },
2164
- name: "luxass/vue/rules",
2165
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
2166
- pluginVue.processors[".vue"],
2167
- processorVueBlocks({
2168
- ...sfcBlocks,
2169
- blocks: {
2170
- styles: true,
2171
- ...sfcBlocks.blocks
2172
- }
2173
- })
2174
- ]),
2175
- rules: {
2176
- ...pluginVue.configs.base.rules,
2177
- ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
2178
- ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
2179
- ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({ ...acc, ...c }), {}),
2180
- "antfu/no-top-level-await": "off",
2181
- "node/prefer-global/process": "off",
2182
- "ts/explicit-function-return-type": "off",
2183
- "vue/block-order": [
2184
- "error",
2185
- {
2186
- order: ["script", "template", "style"]
2187
- }
2188
- ],
2189
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
2190
- "vue/component-options-name-casing": ["error", "PascalCase"],
2191
- // this is deprecated
2192
- "vue/component-tags-order": "off",
2193
- "vue/custom-event-name-casing": ["error", "camelCase"],
2194
- "vue/define-macros-order": [
2195
- "error",
2196
- {
2197
- order: [
2198
- "defineOptions",
2199
- "defineProps",
2200
- "defineEmits",
2201
- "defineSlots"
2202
- ]
2203
- }
2204
- ],
2205
- "vue/dot-location": ["error", "property"],
2206
- "vue/dot-notation": ["error", { allowKeywords: true }],
2207
- "vue/eqeqeq": ["error", "smart"],
2208
- "vue/html-indent": ["error", indent],
2209
- "vue/html-quotes": ["error", "double"],
2210
- "vue/max-attributes-per-line": "off",
2211
- "vue/multi-word-component-names": "off",
2212
- "vue/no-dupe-keys": "off",
2213
- "vue/no-empty-pattern": "error",
2214
- "vue/no-irregular-whitespace": "error",
2215
- "vue/no-loss-of-precision": "error",
2216
- "vue/no-restricted-syntax": [
2217
- "error",
2218
- "DebuggerStatement",
2219
- "LabeledStatement",
2220
- "WithStatement"
2221
- ],
2222
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
2223
- "vue/no-setup-props-reactivity-loss": "off",
2224
- "vue/no-sparse-arrays": "error",
2225
- "vue/no-unused-refs": "error",
2226
- "vue/no-useless-v-bind": "error",
2227
- "vue/no-v-html": "off",
2228
- "vue/object-shorthand": [
2229
- "error",
2230
- "always",
2231
- {
2232
- avoidQuotes: true,
2233
- ignoreConstructors: false
2234
- }
2235
- ],
2236
- "vue/prefer-separate-static-class": "error",
2237
- "vue/prefer-template": "error",
2238
- "vue/prop-name-casing": ["error", "camelCase"],
2239
- "vue/require-default-prop": "off",
2240
- "vue/require-prop-types": "off",
2241
- "vue/space-infix-ops": "error",
2242
- "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
2243
- ...stylistic2 ? {
2244
- "vue/array-bracket-spacing": ["error", "never"],
2245
- "vue/arrow-spacing": ["error", { after: true, before: true }],
2246
- "vue/block-spacing": ["error", "always"],
2247
- "vue/block-tag-newline": [
2248
- "error",
2249
- {
2250
- multiline: "always",
2251
- singleline: "always"
2252
- }
2253
- ],
2254
- "vue/brace-style": [
2255
- "error",
2256
- "stroustrup",
2257
- { allowSingleLine: true }
2258
- ],
2259
- "vue/comma-dangle": ["error", "always-multiline"],
2260
- "vue/comma-spacing": ["error", { after: true, before: false }],
2261
- "vue/comma-style": ["error", "last"],
2262
- "vue/html-comment-content-spacing": [
2263
- "error",
2264
- "always",
2265
- {
2266
- exceptions: ["-"]
2267
- }
2268
- ],
2269
- "vue/key-spacing": [
2270
- "error",
2271
- { afterColon: true, beforeColon: false }
2272
- ],
2273
- "vue/keyword-spacing": ["error", { after: true, before: true }],
2274
- "vue/object-curly-newline": "off",
2275
- "vue/object-curly-spacing": ["error", "always"],
2276
- "vue/object-property-newline": [
2277
- "error",
2278
- { allowMultiplePropertiesPerLine: true }
2279
- ],
2280
- "vue/operator-linebreak": ["error", "before"],
2281
- "vue/padding-line-between-blocks": ["error", "always"],
2282
- "vue/quote-props": ["error", "consistent-as-needed"],
2283
- "vue/space-in-parens": ["error", "never"],
2284
- "vue/template-curly-spacing": "error"
2285
- } : {},
2286
- ...overrides
2287
- }
2288
- }
2289
- ];
1815
+ const { files = [GLOB_VUE], overrides = {}, stylistic: stylistic$1 = true } = options;
1816
+ const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1817
+ interop(import("eslint-plugin-vue")),
1818
+ interop(import("vue-eslint-parser")),
1819
+ interop(import("eslint-processor-vue-blocks"))
1820
+ ]);
1821
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
1822
+ const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1823
+ return [{
1824
+ languageOptions: { globals: {
1825
+ computed: "readonly",
1826
+ defineEmits: "readonly",
1827
+ defineExpose: "readonly",
1828
+ defineProps: "readonly",
1829
+ onMounted: "readonly",
1830
+ onUnmounted: "readonly",
1831
+ reactive: "readonly",
1832
+ ref: "readonly",
1833
+ shallowReactive: "readonly",
1834
+ shallowRef: "readonly",
1835
+ toRef: "readonly",
1836
+ toRefs: "readonly",
1837
+ watch: "readonly",
1838
+ watchEffect: "readonly"
1839
+ } },
1840
+ name: "luxass/vue/setup",
1841
+ plugins: { vue: pluginVue }
1842
+ }, {
1843
+ files,
1844
+ languageOptions: {
1845
+ parser: parserVue,
1846
+ parserOptions: {
1847
+ ecmaFeatures: { jsx: true },
1848
+ extraFileExtensions: [".vue"],
1849
+ parser: options.typescript ? await interop(import("@typescript-eslint/parser")) : null,
1850
+ sourceType: "module"
1851
+ }
1852
+ },
1853
+ name: "luxass/vue/rules",
1854
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([pluginVue.processors[".vue"], processorVueBlocks({
1855
+ ...sfcBlocks,
1856
+ blocks: {
1857
+ styles: true,
1858
+ ...sfcBlocks.blocks
1859
+ }
1860
+ })]),
1861
+ rules: {
1862
+ ...pluginVue.configs.base.rules,
1863
+ ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, c) => ({
1864
+ ...acc,
1865
+ ...c
1866
+ }), {}),
1867
+ ...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((acc, c) => ({
1868
+ ...acc,
1869
+ ...c
1870
+ }), {}),
1871
+ ...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((acc, c) => ({
1872
+ ...acc,
1873
+ ...c
1874
+ }), {}),
1875
+ "antfu/no-top-level-await": "off",
1876
+ "node/prefer-global/process": "off",
1877
+ "ts/explicit-function-return-type": "off",
1878
+ "vue/block-order": ["error", { order: [
1879
+ "script",
1880
+ "template",
1881
+ "style"
1882
+ ] }],
1883
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1884
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1885
+ "vue/component-tags-order": "off",
1886
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1887
+ "vue/define-macros-order": ["error", { order: [
1888
+ "defineOptions",
1889
+ "defineProps",
1890
+ "defineEmits",
1891
+ "defineSlots"
1892
+ ] }],
1893
+ "vue/dot-location": ["error", "property"],
1894
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1895
+ "vue/eqeqeq": ["error", "smart"],
1896
+ "vue/html-indent": ["error", indent],
1897
+ "vue/html-quotes": ["error", "double"],
1898
+ "vue/max-attributes-per-line": "off",
1899
+ "vue/multi-word-component-names": "off",
1900
+ "vue/no-dupe-keys": "off",
1901
+ "vue/no-empty-pattern": "error",
1902
+ "vue/no-irregular-whitespace": "error",
1903
+ "vue/no-loss-of-precision": "error",
1904
+ "vue/no-restricted-syntax": [
1905
+ "error",
1906
+ "DebuggerStatement",
1907
+ "LabeledStatement",
1908
+ "WithStatement"
1909
+ ],
1910
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1911
+ "vue/no-setup-props-reactivity-loss": "off",
1912
+ "vue/no-sparse-arrays": "error",
1913
+ "vue/no-unused-refs": "error",
1914
+ "vue/no-useless-v-bind": "error",
1915
+ "vue/no-v-html": "off",
1916
+ "vue/object-shorthand": [
1917
+ "error",
1918
+ "always",
1919
+ {
1920
+ avoidQuotes: true,
1921
+ ignoreConstructors: false
1922
+ }
1923
+ ],
1924
+ "vue/prefer-separate-static-class": "error",
1925
+ "vue/prefer-template": "error",
1926
+ "vue/prop-name-casing": ["error", "camelCase"],
1927
+ "vue/require-default-prop": "off",
1928
+ "vue/require-prop-types": "off",
1929
+ "vue/space-infix-ops": "error",
1930
+ "vue/space-unary-ops": ["error", {
1931
+ nonwords: false,
1932
+ words: true
1933
+ }],
1934
+ ...stylistic$1 ? {
1935
+ "vue/array-bracket-spacing": ["error", "never"],
1936
+ "vue/arrow-spacing": ["error", {
1937
+ after: true,
1938
+ before: true
1939
+ }],
1940
+ "vue/block-spacing": ["error", "always"],
1941
+ "vue/block-tag-newline": ["error", {
1942
+ multiline: "always",
1943
+ singleline: "always"
1944
+ }],
1945
+ "vue/brace-style": [
1946
+ "error",
1947
+ "stroustrup",
1948
+ { allowSingleLine: true }
1949
+ ],
1950
+ "vue/comma-dangle": ["error", "always-multiline"],
1951
+ "vue/comma-spacing": ["error", {
1952
+ after: true,
1953
+ before: false
1954
+ }],
1955
+ "vue/comma-style": ["error", "last"],
1956
+ "vue/html-comment-content-spacing": [
1957
+ "error",
1958
+ "always",
1959
+ { exceptions: ["-"] }
1960
+ ],
1961
+ "vue/key-spacing": ["error", {
1962
+ afterColon: true,
1963
+ beforeColon: false
1964
+ }],
1965
+ "vue/keyword-spacing": ["error", {
1966
+ after: true,
1967
+ before: true
1968
+ }],
1969
+ "vue/object-curly-newline": "off",
1970
+ "vue/object-curly-spacing": ["error", "always"],
1971
+ "vue/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
1972
+ "vue/operator-linebreak": ["error", "before"],
1973
+ "vue/padding-line-between-blocks": ["error", "always"],
1974
+ "vue/quote-props": ["error", "consistent-as-needed"],
1975
+ "vue/space-in-parens": ["error", "never"],
1976
+ "vue/template-curly-spacing": "error"
1977
+ } : {},
1978
+ ...overrides
1979
+ }
1980
+ }];
2290
1981
  }
2291
1982
 
2292
- // src/configs/yaml.ts
1983
+ //#endregion
1984
+ //#region src/configs/yaml.ts
2293
1985
  async function yaml(options = {}) {
2294
- const {
2295
- files = [GLOB_YAML],
2296
- overrides = {},
2297
- stylistic: stylistic2 = true
2298
- } = options;
2299
- const [
2300
- pluginYaml,
2301
- parserYaml
2302
- ] = await Promise.all([
2303
- interop(import("eslint-plugin-yml")),
2304
- interop(import("yaml-eslint-parser"))
2305
- ]);
2306
- const {
2307
- indent = 2,
2308
- quotes = "double"
2309
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2310
- return [
2311
- {
2312
- name: "luxass/yaml/setup",
2313
- plugins: {
2314
- yaml: pluginYaml
2315
- }
2316
- },
2317
- {
2318
- files,
2319
- languageOptions: {
2320
- parser: parserYaml
2321
- },
2322
- name: "luxass/yaml/rules",
2323
- rules: {
2324
- "style/spaced-comment": "off",
2325
- "yaml/block-mapping": "error",
2326
- "yaml/block-sequence": "error",
2327
- "yaml/no-empty-key": "error",
2328
- "yaml/no-empty-mapping-value": "error",
2329
- "yaml/no-empty-sequence-entry": "error",
2330
- "yaml/no-irregular-whitespace": "error",
2331
- "yaml/plain-scalar": "error",
2332
- "yaml/vue-custom-block/no-parsing-error": "error",
2333
- ...stylistic2 ? {
2334
- "yaml/block-mapping-question-indicator-newline": "error",
2335
- "yaml/block-sequence-hyphen-indicator-newline": "error",
2336
- "yaml/flow-mapping-curly-newline": "error",
2337
- "yaml/flow-mapping-curly-spacing": "error",
2338
- "yaml/flow-sequence-bracket-newline": "error",
2339
- "yaml/flow-sequence-bracket-spacing": "error",
2340
- "yaml/indent": ["error", indent === "tab" ? 2 : indent],
2341
- "yaml/key-spacing": "error",
2342
- "yaml/no-tab-indent": "error",
2343
- "yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
2344
- "yaml/spaced-comment": "error"
2345
- } : {},
2346
- ...overrides
2347
- }
2348
- },
2349
- {
2350
- files: ["pnpm-workspace.yaml"],
2351
- name: "luxass/yaml/pnpm-workspace",
2352
- rules: {
2353
- "yaml/sort-keys": [
2354
- "error",
2355
- {
2356
- order: [
2357
- "packages",
2358
- "overrides",
2359
- "patchedDependencies",
2360
- "hoistPattern",
2361
- "catalog",
2362
- "catalogs",
2363
- "allowedDeprecatedVersions",
2364
- "allowNonAppliedPatches",
2365
- "configDependencies",
2366
- "ignoredBuiltDependencies",
2367
- "ignoredOptionalDependencies",
2368
- "neverBuiltDependencies",
2369
- "onlyBuiltDependencies",
2370
- "onlyBuiltDependenciesFile",
2371
- "packageExtensions",
2372
- "peerDependencyRules",
2373
- "supportedArchitectures"
2374
- ],
2375
- pathPattern: "^$"
2376
- },
2377
- {
2378
- order: { type: "asc" },
2379
- pathPattern: ".*"
2380
- }
2381
- ]
2382
- }
2383
- }
2384
- ];
1986
+ const { files = [GLOB_YAML], overrides = {}, stylistic: stylistic$1 = true } = options;
1987
+ const [pluginYaml, parserYaml] = await Promise.all([interop(import("eslint-plugin-yml")), interop(import("yaml-eslint-parser"))]);
1988
+ const { indent = 2, quotes = "double" } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
1989
+ return [
1990
+ {
1991
+ name: "luxass/yaml/setup",
1992
+ plugins: { yaml: pluginYaml }
1993
+ },
1994
+ {
1995
+ files,
1996
+ languageOptions: { parser: parserYaml },
1997
+ name: "luxass/yaml/rules",
1998
+ rules: {
1999
+ "style/spaced-comment": "off",
2000
+ "yaml/block-mapping": "error",
2001
+ "yaml/block-sequence": "error",
2002
+ "yaml/no-empty-key": "error",
2003
+ "yaml/no-empty-mapping-value": "error",
2004
+ "yaml/no-empty-sequence-entry": "error",
2005
+ "yaml/no-irregular-whitespace": "error",
2006
+ "yaml/plain-scalar": "error",
2007
+ "yaml/vue-custom-block/no-parsing-error": "error",
2008
+ ...stylistic$1 ? {
2009
+ "yaml/block-mapping-question-indicator-newline": "error",
2010
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
2011
+ "yaml/flow-mapping-curly-newline": "error",
2012
+ "yaml/flow-mapping-curly-spacing": "error",
2013
+ "yaml/flow-sequence-bracket-newline": "error",
2014
+ "yaml/flow-sequence-bracket-spacing": "error",
2015
+ "yaml/indent": ["error", indent === "tab" ? 2 : indent],
2016
+ "yaml/key-spacing": "error",
2017
+ "yaml/no-tab-indent": "error",
2018
+ "yaml/quotes": ["error", {
2019
+ avoidEscape: true,
2020
+ prefer: quotes === "backtick" ? "single" : quotes
2021
+ }],
2022
+ "yaml/spaced-comment": "error"
2023
+ } : {},
2024
+ ...overrides
2025
+ }
2026
+ },
2027
+ {
2028
+ files: ["pnpm-workspace.yaml"],
2029
+ name: "luxass/yaml/pnpm-workspace",
2030
+ rules: { "yaml/sort-keys": [
2031
+ "error",
2032
+ {
2033
+ order: [
2034
+ "packages",
2035
+ "overrides",
2036
+ "patchedDependencies",
2037
+ "hoistPattern",
2038
+ "catalog",
2039
+ "catalogs",
2040
+ "allowedDeprecatedVersions",
2041
+ "allowNonAppliedPatches",
2042
+ "configDependencies",
2043
+ "ignoredBuiltDependencies",
2044
+ "ignoredOptionalDependencies",
2045
+ "neverBuiltDependencies",
2046
+ "onlyBuiltDependencies",
2047
+ "onlyBuiltDependenciesFile",
2048
+ "packageExtensions",
2049
+ "peerDependencyRules",
2050
+ "supportedArchitectures"
2051
+ ],
2052
+ pathPattern: "^$"
2053
+ },
2054
+ {
2055
+ order: { type: "asc" },
2056
+ pathPattern: ".*"
2057
+ }
2058
+ ] }
2059
+ }
2060
+ ];
2385
2061
  }
2386
2062
 
2387
- // src/factory.ts
2388
- var FLAT_CONFIG_PROPS = [
2389
- "name",
2390
- "languageOptions",
2391
- "linterOptions",
2392
- "processor",
2393
- "plugins",
2394
- "rules",
2395
- "settings"
2063
+ //#endregion
2064
+ //#region src/factory.ts
2065
+ const FLAT_CONFIG_PROPS = [
2066
+ "name",
2067
+ "languageOptions",
2068
+ "linterOptions",
2069
+ "processor",
2070
+ "plugins",
2071
+ "rules",
2072
+ "settings"
2396
2073
  ];
2397
- var VuePackages = [
2398
- "vue",
2399
- "nuxt",
2400
- "vitepress",
2401
- "@slidev/cli"
2074
+ const VuePackages = [
2075
+ "vue",
2076
+ "nuxt",
2077
+ "vitepress",
2078
+ "@slidev/cli"
2402
2079
  ];
2403
- var defaultPluginRenaming = {
2404
- "@eslint-react": "react",
2405
- "@eslint-react/dom": "react-dom",
2406
- "@eslint-react/hooks-extra": "react-hooks-extra",
2407
- "@eslint-react/naming-convention": "react-naming-convention",
2408
- "@stylistic": "style",
2409
- "@typescript-eslint": "ts",
2410
- "import-x": "import",
2411
- "n": "node",
2412
- "vitest": "test",
2413
- "yml": "yaml"
2080
+ const defaultPluginRenaming = {
2081
+ "@eslint-react": "react",
2082
+ "@eslint-react/dom": "react-dom",
2083
+ "@eslint-react/hooks-extra": "react-hooks-extra",
2084
+ "@eslint-react/naming-convention": "react-naming-convention",
2085
+ "@stylistic": "style",
2086
+ "@typescript-eslint": "ts",
2087
+ "n": "node",
2088
+ "vitest": "test",
2089
+ "yml": "yaml"
2414
2090
  };
2091
+ /**
2092
+ * Construct an array of ESLint flat config items.
2093
+ *
2094
+ * @param {OptionsConfig & TypedFlatConfigItem} options
2095
+ * The options for generating the ESLint configurations.
2096
+ * @param {Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]} userConfigs
2097
+ * The user configurations to be merged with the generated configurations.
2098
+ * @returns {Promise<TypedFlatConfigItem[]>}
2099
+ * The merged ESLint configurations.
2100
+ */
2415
2101
  function luxass(options = {}, ...userConfigs) {
2416
- const {
2417
- astro: enableAstro = false,
2418
- autoRenamePlugins = true,
2419
- exts = [],
2420
- gitignore: enableGitignore = true,
2421
- jsx: enableJsx = true,
2422
- pnpm: enableCatalogs = false,
2423
- react: enableReact = false,
2424
- regexp: enableRegexp = true,
2425
- tailwindcss: enableTailwindCSS = false,
2426
- type: projectType = "app",
2427
- typescript: enableTypeScript = isPackageExists3("typescript"),
2428
- unicorn: enableUnicorn = true,
2429
- unocss: enableUnoCSS = false,
2430
- vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
2431
- } = options;
2432
- let isInEditor = options.isInEditor;
2433
- if (isInEditor == null) {
2434
- isInEditor = isInEditorEnv();
2435
- if (isInEditor) {
2436
- console.log("[@luxass/eslint-config] Detected running in editor, some rules are disabled.");
2437
- }
2438
- }
2439
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2440
- if (stylisticOptions && !("jsx" in stylisticOptions)) {
2441
- stylisticOptions.jsx = enableJsx;
2442
- }
2443
- const configs2 = [];
2444
- if (enableGitignore) {
2445
- if (typeof enableGitignore !== "boolean") {
2446
- configs2.push(interop(import("eslint-config-flat-gitignore")).then((r) => [r({
2447
- name: "luxass/gitignore",
2448
- ...enableGitignore
2449
- })]));
2450
- } else {
2451
- configs2.push(interop(import("eslint-config-flat-gitignore")).then((r) => [r({
2452
- name: "luxass/gitignore",
2453
- strict: false
2454
- })]));
2455
- }
2456
- }
2457
- const typescriptOptions = resolveSubOptions(options, "typescript");
2458
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2459
- configs2.push(
2460
- ignores(),
2461
- javascript({
2462
- isInEditor,
2463
- overrides: getOverrides(options, "javascript")
2464
- }),
2465
- comments(),
2466
- node(),
2467
- jsdoc({
2468
- stylistic: stylisticOptions
2469
- }),
2470
- imports({
2471
- stylistic: stylisticOptions
2472
- }),
2473
- perfectionist()
2474
- );
2475
- if (enableUnicorn) {
2476
- configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2477
- }
2478
- if (enableVue) {
2479
- exts.push("vue");
2480
- }
2481
- if (enableJsx) {
2482
- configs2.push(jsx());
2483
- }
2484
- if (enableTypeScript) {
2485
- configs2.push(typescript({
2486
- ...typescriptOptions,
2487
- exts,
2488
- overrides: getOverrides(options, "typescript"),
2489
- type: projectType
2490
- }));
2491
- }
2492
- if (stylisticOptions) {
2493
- configs2.push(stylistic({
2494
- ...stylisticOptions,
2495
- overrides: getOverrides(options, "stylistic")
2496
- }));
2497
- }
2498
- if (enableRegexp) {
2499
- configs2.push(regexp({
2500
- ...resolveSubOptions(options, "regexp"),
2501
- overrides: getOverrides(options, "regexp")
2502
- }));
2503
- }
2504
- if (options.test ?? true) {
2505
- configs2.push(test({
2506
- isInEditor,
2507
- overrides: getOverrides(options, "test")
2508
- }));
2509
- }
2510
- if (enableReact) {
2511
- configs2.push(react({
2512
- ...resolveSubOptions(options, "react"),
2513
- overrides: getOverrides(options, "react"),
2514
- tsconfigPath
2515
- }));
2516
- }
2517
- if (enableVue) {
2518
- configs2.push(
2519
- vue({
2520
- ...resolveSubOptions(options, "vue"),
2521
- overrides: getOverrides(options, "vue"),
2522
- stylistic: stylisticOptions,
2523
- typescript: !!enableTypeScript
2524
- })
2525
- );
2526
- }
2527
- if (enableAstro) {
2528
- configs2.push(
2529
- astro({
2530
- ...resolveSubOptions(options, "astro"),
2531
- overrides: getOverrides(options, "astro")
2532
- })
2533
- );
2534
- }
2535
- if (enableUnoCSS) {
2536
- configs2.push(unocss({
2537
- ...resolveSubOptions(options, "unocss"),
2538
- overrides: getOverrides(options, "unocss")
2539
- }));
2540
- }
2541
- if (enableTailwindCSS) {
2542
- configs2.push(tailwindcss({
2543
- ...resolveSubOptions(options, "tailwindcss"),
2544
- overrides: getOverrides(options, "tailwindcss")
2545
- }));
2546
- }
2547
- if (options.jsonc ?? true) {
2548
- configs2.push(
2549
- jsonc({
2550
- overrides: getOverrides(options, "jsonc"),
2551
- stylistic: stylisticOptions
2552
- }),
2553
- sortPackageJson(),
2554
- sortTsconfig()
2555
- );
2556
- }
2557
- if (enableCatalogs) {
2558
- configs2.push(
2559
- pnpm()
2560
- );
2561
- }
2562
- if (options.yaml ?? true) {
2563
- configs2.push(yaml({
2564
- overrides: getOverrides(options, "yaml"),
2565
- stylistic: stylisticOptions
2566
- }));
2567
- }
2568
- if (options.toml ?? true) {
2569
- configs2.push(toml({
2570
- overrides: getOverrides(options, "toml"),
2571
- stylistic: stylisticOptions
2572
- }));
2573
- }
2574
- if (options.markdown ?? true) {
2575
- configs2.push(
2576
- markdown({
2577
- exts,
2578
- overrides: getOverrides(options, "markdown")
2579
- })
2580
- );
2581
- }
2582
- if (options.formatters) {
2583
- configs2.push(formatters(
2584
- options.formatters,
2585
- typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2586
- ));
2587
- }
2588
- configs2.push(
2589
- disables()
2590
- );
2591
- if ("files" in options) {
2592
- throw new Error('[@luxass/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.');
2593
- }
2594
- const fusedConfig = FLAT_CONFIG_PROPS.reduce((acc, key) => {
2595
- if (key in options) {
2596
- acc[key] = options[key];
2597
- }
2598
- return acc;
2599
- }, {});
2600
- if (Object.keys(fusedConfig).length) {
2601
- configs2.push([fusedConfig]);
2602
- }
2603
- let composer = new FlatConfigComposer();
2604
- composer = composer.append(
2605
- ...configs2,
2606
- ...userConfigs
2607
- );
2608
- if (autoRenamePlugins) {
2609
- composer = composer.renamePlugins(defaultPluginRenaming);
2610
- }
2611
- return composer;
2102
+ const { astro: enableAstro = false, autoRenamePlugins = true, exts = [], gitignore: enableGitignore = true, jsx: enableJsx = true, pnpm: enableCatalogs = false, react: enableReact = false, regexp: enableRegexp = true, tailwindcss: enableTailwindCSS = false, type: projectType = "app", typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
2103
+ let isInEditor = options.isInEditor;
2104
+ if (isInEditor == null) {
2105
+ isInEditor = isInEditorEnv();
2106
+ if (isInEditor) console.log("[@luxass/eslint-config] Detected running in editor, some rules are disabled.");
2107
+ }
2108
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2109
+ if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
2110
+ const configs$1 = [];
2111
+ if (enableGitignore) if (typeof enableGitignore !== "boolean") configs$1.push(interop(import("eslint-config-flat-gitignore")).then((r) => [r({
2112
+ name: "luxass/gitignore",
2113
+ ...enableGitignore
2114
+ })]));
2115
+ else configs$1.push(interop(import("eslint-config-flat-gitignore")).then((r) => [r({
2116
+ name: "luxass/gitignore",
2117
+ strict: false
2118
+ })]));
2119
+ const typescriptOptions = resolveSubOptions(options, "typescript");
2120
+ const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2121
+ configs$1.push(ignores(), javascript({
2122
+ isInEditor,
2123
+ overrides: getOverrides(options, "javascript")
2124
+ }), comments(), node(), jsdoc({ stylistic: stylisticOptions }), imports({ stylistic: stylisticOptions }), perfectionist());
2125
+ if (enableUnicorn) configs$1.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2126
+ if (enableVue) exts.push("vue");
2127
+ if (enableJsx) configs$1.push(jsx());
2128
+ if (enableTypeScript) configs$1.push(typescript({
2129
+ ...typescriptOptions,
2130
+ exts,
2131
+ overrides: getOverrides(options, "typescript"),
2132
+ type: projectType
2133
+ }));
2134
+ if (stylisticOptions) configs$1.push(stylistic({
2135
+ ...stylisticOptions,
2136
+ overrides: getOverrides(options, "stylistic")
2137
+ }));
2138
+ if (enableRegexp) configs$1.push(regexp({
2139
+ ...resolveSubOptions(options, "regexp"),
2140
+ overrides: getOverrides(options, "regexp")
2141
+ }));
2142
+ if (options.test ?? true) configs$1.push(test({
2143
+ isInEditor,
2144
+ overrides: getOverrides(options, "test")
2145
+ }));
2146
+ if (enableReact) configs$1.push(react({
2147
+ ...resolveSubOptions(options, "react"),
2148
+ overrides: getOverrides(options, "react"),
2149
+ tsconfigPath
2150
+ }));
2151
+ if (enableVue) configs$1.push(vue({
2152
+ ...resolveSubOptions(options, "vue"),
2153
+ overrides: getOverrides(options, "vue"),
2154
+ stylistic: stylisticOptions,
2155
+ typescript: !!enableTypeScript
2156
+ }));
2157
+ if (enableAstro) configs$1.push(astro({
2158
+ ...resolveSubOptions(options, "astro"),
2159
+ overrides: getOverrides(options, "astro")
2160
+ }));
2161
+ if (enableUnoCSS) configs$1.push(unocss({
2162
+ ...resolveSubOptions(options, "unocss"),
2163
+ overrides: getOverrides(options, "unocss")
2164
+ }));
2165
+ if (enableTailwindCSS) configs$1.push(tailwindcss({
2166
+ ...resolveSubOptions(options, "tailwindcss"),
2167
+ overrides: getOverrides(options, "tailwindcss")
2168
+ }));
2169
+ if (options.jsonc ?? true) configs$1.push(jsonc({
2170
+ overrides: getOverrides(options, "jsonc"),
2171
+ stylistic: stylisticOptions
2172
+ }), sortPackageJson(), sortTsconfig());
2173
+ if (enableCatalogs) configs$1.push(pnpm());
2174
+ if (options.yaml ?? true) configs$1.push(yaml({
2175
+ overrides: getOverrides(options, "yaml"),
2176
+ stylistic: stylisticOptions
2177
+ }));
2178
+ if (options.toml ?? true) configs$1.push(toml({
2179
+ overrides: getOverrides(options, "toml"),
2180
+ stylistic: stylisticOptions
2181
+ }));
2182
+ if (options.markdown ?? true) configs$1.push(markdown({
2183
+ exts,
2184
+ overrides: getOverrides(options, "markdown")
2185
+ }));
2186
+ if (options.formatters) configs$1.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
2187
+ configs$1.push(disables());
2188
+ if ("files" in options) throw new Error("[@luxass/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.");
2189
+ const fusedConfig = FLAT_CONFIG_PROPS.reduce((acc, key) => {
2190
+ if (key in options) acc[key] = options[key];
2191
+ return acc;
2192
+ }, {});
2193
+ if (Object.keys(fusedConfig).length) configs$1.push([fusedConfig]);
2194
+ let composer = new FlatConfigComposer();
2195
+ composer = composer.append(...configs$1, ...userConfigs);
2196
+ if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
2197
+ return composer;
2612
2198
  }
2613
2199
 
2614
- // src/index.ts
2615
- var index_default = luxass;
2616
- export {
2617
- GLOB_ASTRO,
2618
- GLOB_ASTRO_TS,
2619
- GLOB_CSS,
2620
- GLOB_EXCLUDE,
2621
- GLOB_GRAPHQL,
2622
- GLOB_HTML,
2623
- GLOB_JS,
2624
- GLOB_JSON,
2625
- GLOB_JSON5,
2626
- GLOB_JSONC,
2627
- GLOB_JSX,
2628
- GLOB_LESS,
2629
- GLOB_MARKDOWN,
2630
- GLOB_MARKDOWN_CODE,
2631
- GLOB_MARKDOWN_IN_MARKDOWN,
2632
- GLOB_NEXTJS_OG,
2633
- GLOB_NEXTJS_ROUTES,
2634
- GLOB_POSTCSS,
2635
- GLOB_SCSS,
2636
- GLOB_SRC,
2637
- GLOB_SRC_EXT,
2638
- GLOB_STYLE,
2639
- GLOB_SVELTE,
2640
- GLOB_TESTS,
2641
- GLOB_TOML,
2642
- GLOB_TS,
2643
- GLOB_TSX,
2644
- GLOB_VUE,
2645
- GLOB_YAML,
2646
- astro,
2647
- combine,
2648
- comments,
2649
- index_default as default,
2650
- disables,
2651
- ensure,
2652
- formatters,
2653
- getOverrides,
2654
- ignores,
2655
- imports,
2656
- interop,
2657
- isInEditorEnv,
2658
- isInGitHooksOrLintStaged,
2659
- isPackageInScope,
2660
- javascript,
2661
- jsdoc,
2662
- jsonc,
2663
- jsx,
2664
- luxass,
2665
- markdown,
2666
- node,
2667
- parserPlain,
2668
- perfectionist,
2669
- pnpm,
2670
- react,
2671
- regexp,
2672
- renamePluginInConfigs,
2673
- renameRules,
2674
- resolveSubOptions,
2675
- sortPackageJson,
2676
- sortTsconfig,
2677
- stylistic,
2678
- tailwindcss,
2679
- test,
2680
- toArray,
2681
- toml,
2682
- typescript,
2683
- unicorn,
2684
- unocss,
2685
- vue,
2686
- yaml
2687
- };
2200
+ //#endregion
2201
+ //#region src/index.ts
2202
+ var src_default = luxass;
2203
+
2204
+ //#endregion
2205
+ export { GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_NEXTJS_OG, GLOB_NEXTJS_ROUTES, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, astro, combine, comments, src_default as default, disables, ensure, formatters, getOverrides, ignores, imports, interop, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, luxass, markdown, node, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };