@zayne-labs/eslint-config 0.8.2 → 0.9.1

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,2060 +1,1915 @@
1
- import { defineEnum, assert } from '@zayne-labs/toolkit-type-helpers';
2
- import { fileURLToPath } from 'node:url';
3
- import { isPackageExists } from 'local-pkg';
4
- import { globalIgnores } from 'eslint/config';
5
- import globals from 'globals';
6
- import { fixupPluginRules } from '@eslint/compat';
7
- import { mergeProcessors } from 'eslint-merge-processors';
8
- import { FlatConfigComposer } from 'eslint-flat-config-utils';
1
+ import { assert, defineEnum } from "@zayne-labs/toolkit-type-helpers";
2
+ import { fileURLToPath } from "node:url";
3
+ import { isPackageExists } from "local-pkg";
4
+ import { globalIgnores } from "eslint/config";
5
+ import globals from "globals";
6
+ import { fixupPluginRules } from "@eslint/compat";
7
+ import { mergeProcessors } from "eslint-merge-processors";
8
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
9
9
 
10
- // src/globs.ts
11
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
12
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
13
- var GLOB_JS = "**/*.?([cm])js";
14
- var GLOB_JSX = "**/*.?([cm])jsx";
15
- var GLOB_TS = "**/*.?([cm])ts";
16
- var GLOB_TSX = "**/*.?([cm])tsx";
17
- var GLOB_STYLES = "**/*.{c,le,sc}ss";
18
- var GLOB_CSS = "**/*.css";
19
- var GLOB_POSTCSS = "**/*.{p,post}css";
20
- var GLOB_LESS = "**/*.less";
21
- var GLOB_SCSS = "**/*.scss";
22
- var GLOB_JSON = "**/*.json";
23
- var GLOB_JSON5 = "**/*.json5";
24
- var GLOB_JSONC = "**/*.jsonc";
25
- var GLOB_MARKDOWN = "**/*.md";
26
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
27
- var GLOB_SVELTE = "**/*.svelte";
28
- var GLOB_VUE = "**/*.vue";
29
- var GLOB_YAML = "**/*.y?(a)ml";
30
- var GLOB_TOML = "**/*.toml";
31
- var GLOB_XML = "**/*.xml";
32
- var GLOB_SVG = "**/*.svg";
33
- var GLOB_HTML = "**/*.htm?(l)";
34
- var GLOB_ASTRO = "**/*.astro";
35
- var GLOB_ASTRO_TS = "**/*.astro/*.ts";
36
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
37
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
38
- var GLOB_TESTS = defineEnum([
39
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
40
- `**/*.spec.${GLOB_SRC_EXT}`,
41
- `**/*.test.${GLOB_SRC_EXT}`,
42
- `**/*.bench.${GLOB_SRC_EXT}`,
43
- `**/*.benchmark.${GLOB_SRC_EXT}`
10
+ //#region src/globs.ts
11
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
12
+ const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
13
+ const GLOB_JS = "**/*.?([cm])js";
14
+ const GLOB_JSX = "**/*.?([cm])jsx";
15
+ const GLOB_TS = "**/*.?([cm])ts";
16
+ const GLOB_TSX = "**/*.?([cm])tsx";
17
+ const GLOB_STYLES = "**/*.{c,le,sc}ss";
18
+ const GLOB_CSS = "**/*.css";
19
+ const GLOB_POSTCSS = "**/*.{p,post}css";
20
+ const GLOB_LESS = "**/*.less";
21
+ const GLOB_SCSS = "**/*.scss";
22
+ const GLOB_JSON = "**/*.json";
23
+ const GLOB_JSON5 = "**/*.json5";
24
+ const GLOB_JSONC = "**/*.jsonc";
25
+ const GLOB_MARKDOWN = "**/*.md";
26
+ const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
27
+ const GLOB_SVELTE = "**/*.svelte";
28
+ const GLOB_VUE = "**/*.vue";
29
+ const GLOB_YAML = "**/*.y?(a)ml";
30
+ const GLOB_TOML = "**/*.toml";
31
+ const GLOB_XML = "**/*.xml";
32
+ const GLOB_SVG = "**/*.svg";
33
+ const GLOB_HTML = "**/*.htm?(l)";
34
+ const GLOB_ASTRO = "**/*.astro";
35
+ const GLOB_ASTRO_TS = "**/*.astro/*.ts";
36
+ const GLOB_GRAPHQL = "**/*.{g,graph}ql";
37
+ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
38
+ const GLOB_TESTS = defineEnum([
39
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
40
+ `**/*.spec.${GLOB_SRC_EXT}`,
41
+ `**/*.test.${GLOB_SRC_EXT}`,
42
+ `**/*.bench.${GLOB_SRC_EXT}`,
43
+ `**/*.benchmark.${GLOB_SRC_EXT}`
44
44
  ]);
45
- var GLOB_ALL_SRC = [
46
- GLOB_SRC,
47
- GLOB_STYLES,
48
- GLOB_JSON,
49
- GLOB_JSON5,
50
- GLOB_MARKDOWN,
51
- GLOB_SVELTE,
52
- GLOB_VUE,
53
- GLOB_YAML,
54
- GLOB_XML,
55
- GLOB_HTML
45
+ const GLOB_ALL_SRC = [
46
+ GLOB_SRC,
47
+ GLOB_STYLES,
48
+ GLOB_JSON,
49
+ GLOB_JSON5,
50
+ GLOB_MARKDOWN,
51
+ GLOB_SVELTE,
52
+ GLOB_VUE,
53
+ GLOB_YAML,
54
+ GLOB_XML,
55
+ GLOB_HTML
56
56
  ];
57
- var GLOB_EXCLUDE = defineEnum([
58
- "**/node_modules",
59
- "**/dist",
60
- "**/package-lock.json",
61
- "**/yarn.lock",
62
- "**/pnpm-lock.yaml",
63
- "**/bun.lockb",
64
- "**/output",
65
- "**/coverage",
66
- "**/temp",
67
- "**/.temp",
68
- "**/tmp",
69
- "**/.tmp",
70
- "**/.history",
71
- "**/.vitepress/cache",
72
- "**/.nuxt",
73
- "**/.next",
74
- "**/.svelte-kit",
75
- "**/.vercel",
76
- "**/.changeset",
77
- "**/.idea",
78
- "**/.cache",
79
- "**/.output",
80
- "**/.vite-inspect",
81
- "**/.yarn",
82
- "**/vite.config.*.timestamp-*",
83
- "**/CHANGELOG*.md",
84
- "**/*.min.*",
85
- "**/LICENSE*",
86
- "**/__snapshots__",
87
- "**/auto-import?(s).d.ts",
88
- "**/components.d.ts"
57
+ const GLOB_EXCLUDE = defineEnum([
58
+ "**/node_modules",
59
+ "**/dist",
60
+ "**/package-lock.json",
61
+ "**/yarn.lock",
62
+ "**/pnpm-lock.yaml",
63
+ "**/bun.lockb",
64
+ "**/output",
65
+ "**/coverage",
66
+ "**/temp",
67
+ "**/.temp",
68
+ "**/tmp",
69
+ "**/.tmp",
70
+ "**/.history",
71
+ "**/.vitepress/cache",
72
+ "**/.nuxt",
73
+ "**/.next",
74
+ "**/.svelte-kit",
75
+ "**/.vercel",
76
+ "**/.changeset",
77
+ "**/.idea",
78
+ "**/.cache",
79
+ "**/.output",
80
+ "**/.vite-inspect",
81
+ "**/.yarn",
82
+ "**/vite.config.*.timestamp-*",
83
+ "**/CHANGELOG*.md",
84
+ "**/*.min.*",
85
+ "**/LICENSE*",
86
+ "**/__snapshots__",
87
+ "**/auto-import?(s).d.ts",
88
+ "**/components.d.ts"
89
89
  ]);
90
- var isObject = (value) => {
91
- return typeof value === "object" && value !== null && !Array.isArray(value);
90
+
91
+ //#endregion
92
+ //#region src/utils.ts
93
+ const isObject = (value) => {
94
+ return typeof value === "object" && value !== null && !Array.isArray(value);
95
+ };
96
+ /**
97
+ * @description - Combine array and non-array configs into a single array.
98
+ */
99
+ const combine = async (...configs) => {
100
+ const resolved = await Promise.all(configs);
101
+ return resolved.flat();
92
102
  };
93
- var combine = async (...configs) => {
94
- const resolved = await Promise.all(configs);
95
- return resolved.flat();
103
+ const interopDefault = async (module) => {
104
+ const resolved = await module;
105
+ return resolved.default ?? resolved;
96
106
  };
97
- var interopDefault = async (module) => {
98
- const resolved = await module;
99
- return resolved.default ?? resolved;
107
+ /**
108
+ * @description - Rename plugin prefixes in a rule object.
109
+ * Accepts a map of prefixes to rename.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { renameRules } from '@zayne-labs/eslint-config'
114
+ *
115
+ * export default [{
116
+ * rules: renameRules(
117
+ * {
118
+ * '@typescript-eslint/indent': 'error'
119
+ * },
120
+ * { '@typescript-eslint': 'ts' }
121
+ * )
122
+ * }]
123
+ * ```
124
+ */
125
+ const renameRules = (rules, renameMap) => {
126
+ if (!rules) return;
127
+ const renamedRulesEntries = Object.entries(rules).map(([ruleKey, ruleValue]) => {
128
+ for (const [oldRuleName, newRuleName] of Object.entries(renameMap)) if (ruleKey.startsWith(`${oldRuleName}/`)) return [`${newRuleName}${ruleKey.slice(oldRuleName.length)}`, ruleValue];
129
+ return [ruleKey, ruleValue];
130
+ });
131
+ return Object.fromEntries(renamedRulesEntries);
100
132
  };
101
- var renameRules = (rules, renameMap) => {
102
- if (!rules) return;
103
- const renamedRulesEntries = Object.entries(rules).map(([ruleKey, ruleValue]) => {
104
- for (const [oldRuleName, newRuleName] of Object.entries(renameMap)) {
105
- if (ruleKey.startsWith(`${oldRuleName}/`)) {
106
- return [`${newRuleName}${ruleKey.slice(oldRuleName.length)}`, ruleValue];
107
- }
108
- }
109
- return [ruleKey, ruleValue];
110
- });
111
- return Object.fromEntries(renamedRulesEntries);
133
+ const renamePlugins = (plugins, renameMap) => {
134
+ if (!plugins) return;
135
+ const renamedPluginEntries = Object.entries(plugins).map(([pluginKey, pluginValue]) => {
136
+ if (pluginKey in renameMap) return [renameMap[pluginKey], pluginValue];
137
+ return [pluginKey, pluginValue];
138
+ });
139
+ return Object.fromEntries(renamedPluginEntries);
112
140
  };
113
- var renamePlugins = (plugins, renameMap) => {
114
- if (!plugins) return;
115
- const renamedPluginEntries = Object.entries(plugins).map(([pluginKey, pluginValue]) => {
116
- if (pluginKey in renameMap) {
117
- return [renameMap[pluginKey], pluginValue];
118
- }
119
- return [pluginKey, pluginValue];
120
- });
121
- return Object.fromEntries(renamedPluginEntries);
141
+ /**
142
+ * @description - Rename plugin names a flat configs array
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * import { renamePluginInConfigs } from '@zayne-labs/eslint-config'
147
+ * import someConfigs from './some-configs'
148
+ *
149
+ * export default renamePluginInConfigs(someConfigs, {
150
+ * '@typescript-eslint': 'ts',
151
+ * 'import-x': 'import',
152
+ * })
153
+ * ```
154
+ */
155
+ const renamePluginInConfigs = (options) => {
156
+ const { configs, overrides, renameMap } = options;
157
+ const renamedConfigs = configs.map((config) => ({
158
+ ...config,
159
+ ...overrides,
160
+ ...isObject(config.plugins) && { plugins: renamePlugins(config.plugins, renameMap) },
161
+ ...isObject(config.rules) && { rules: renameRules(config.rules, renameMap) }
162
+ }));
163
+ return renamedConfigs;
122
164
  };
123
- var renamePluginInConfigs = (options) => {
124
- const { configs, overrides, renameMap } = options;
125
- const renamedConfigs = configs.map((config) => ({
126
- ...config,
127
- ...overrides,
128
- ...isObject(config.plugins) && {
129
- plugins: renamePlugins(config.plugins, renameMap)
130
- },
131
- ...isObject(config.rules) && {
132
- rules: renameRules(config.rules, renameMap)
133
- }
134
- }));
135
- return renamedConfigs;
165
+ const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
166
+ const isCwdInScope = isPackageExists("@zayne-labs/eslint-config");
167
+ const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeUrl] });
168
+ /**
169
+ * @description
170
+ * - Ensures that packages are installed in the current scope.
171
+ * - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,
172
+ * and the user is in the same scope as this package, then prompt the user to
173
+ * install the packages.
174
+ *
175
+ * @param packages - The packages to ensure are installed.
176
+ */
177
+ const ensurePackages = async (packages) => {
178
+ if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
179
+ const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
180
+ if (nonExistingPackages.length === 0) return;
181
+ const clackPrompt = await import("@clack/prompts");
182
+ const result = await clackPrompt.confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
183
+ if (result) {
184
+ const antfuPkg = await import("@antfu/install-pkg");
185
+ await antfuPkg.installPackage(nonExistingPackages, { dev: true });
186
+ }
136
187
  };
137
- var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
138
- var isCwdInScope = isPackageExists("@zayne-labs/eslint-config");
139
- var isPackageInScope = (name) => isPackageExists(name, { paths: [scopeUrl] });
140
- var ensurePackages = async (packages) => {
141
- if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
142
- const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
143
- if (nonExistingPackages.length === 0) return;
144
- const clackPrompt = await import('@clack/prompts');
145
- const result = await clackPrompt.confirm({
146
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
147
- });
148
- if (result) {
149
- const antfuPkg = await import('@antfu/install-pkg');
150
- await antfuPkg.installPackage(nonExistingPackages, { dev: true });
151
- }
188
+ const resolveOptions = (option) => isObject(option) ? option : {};
189
+
190
+ //#endregion
191
+ //#region src/configs/astro.ts
192
+ const astro = async (options = {}) => {
193
+ const { files = [GLOB_ASTRO], overrides, typescript: typescript$1 = true } = options;
194
+ const [pluginAstro, parserAstro] = await Promise.all([interopDefault(import("eslint-plugin-astro")), interopDefault(import("astro-eslint-parser"))]);
195
+ return [
196
+ {
197
+ name: "zayne/astro/setup",
198
+ plugins: { astro: pluginAstro }
199
+ },
200
+ {
201
+ files,
202
+ languageOptions: {
203
+ globals: pluginAstro.environments.astro.globals,
204
+ parser: parserAstro,
205
+ parserOptions: {
206
+ extraFileExtensions: [".astro"],
207
+ ...typescript$1 && { parser: (await interopDefault(import("typescript-eslint"))).parser }
208
+ },
209
+ sourceType: "module"
210
+ },
211
+ name: "zayne/astro/recommended",
212
+ processor: typescript$1 ? "astro/client-side-ts" : "astro/astro",
213
+ rules: pluginAstro.configs.recommended.at(-1)?.rules
214
+ },
215
+ {
216
+ files,
217
+ name: "zayne/astro/rules",
218
+ rules: { ...overrides }
219
+ }
220
+ ];
152
221
  };
153
- var resolveOptions = (option) => isObject(option) ? option : {};
154
222
 
155
- // src/configs/astro.ts
156
- var astro = async (options = {}) => {
157
- const { files = [GLOB_ASTRO], overrides, typescript: typescript2 = true } = options;
158
- const [pluginAstro, parserAstro] = await Promise.all([
159
- interopDefault(import('eslint-plugin-astro')),
160
- interopDefault(import('astro-eslint-parser'))
161
- ]);
162
- return [
163
- {
164
- name: "zayne/astro/setup",
165
- plugins: {
166
- astro: pluginAstro
167
- }
168
- },
169
- {
170
- files,
171
- languageOptions: {
172
- globals: pluginAstro.environments.astro.globals,
173
- parser: parserAstro,
174
- parserOptions: {
175
- extraFileExtensions: [".astro"],
176
- // eslint-disable-next-line unicorn/no-await-expression-member -- ignore for now
177
- ...typescript2 && { parser: (await interopDefault(import('typescript-eslint'))).parser }
178
- },
179
- sourceType: "module"
180
- },
181
- name: "zayne/astro/recommended",
182
- processor: typescript2 ? "astro/client-side-ts" : "astro/astro",
183
- rules: pluginAstro.configs.recommended.at(-1)?.rules
184
- },
185
- {
186
- files,
187
- name: "zayne/astro/rules",
188
- rules: {
189
- ...overrides
190
- }
191
- }
192
- ];
223
+ //#endregion
224
+ //#region src/configs/comments.ts
225
+ const comments = async (options = {}) => {
226
+ const { overrides, type = "app" } = options;
227
+ const eslintPluginComments = await interopDefault(import("@eslint-community/eslint-plugin-eslint-comments"));
228
+ return [{
229
+ name: "zayne/eslint-comments/rules",
230
+ plugins: { "eslint-comments": eslintPluginComments },
231
+ rules: {
232
+ "eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
233
+ "eslint-comments/no-aggregating-enable": "error",
234
+ "eslint-comments/no-duplicate-disable": "error",
235
+ "eslint-comments/no-unlimited-disable": "error",
236
+ "eslint-comments/no-unused-enable": "error",
237
+ ...type !== "app" && { "eslint-comments/require-description": "warn" },
238
+ ...overrides
239
+ }
240
+ }];
193
241
  };
194
242
 
195
- // src/configs/comments.ts
196
- var comments = async (options = {}) => {
197
- const { overrides, type = "app" } = options;
198
- const eslintPluginComments = await interopDefault(
199
- import('@eslint-community/eslint-plugin-eslint-comments')
200
- );
201
- return [
202
- {
203
- name: "zayne/eslint-comments/rules",
204
- plugins: {
205
- "eslint-comments": eslintPluginComments
206
- },
207
- rules: {
208
- "eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
209
- "eslint-comments/no-aggregating-enable": "error",
210
- "eslint-comments/no-duplicate-disable": "error",
211
- "eslint-comments/no-unlimited-disable": "error",
212
- "eslint-comments/no-unused-enable": "error",
213
- ...type !== "app" && {
214
- "eslint-comments/require-description": "warn"
215
- },
216
- ...overrides
217
- }
218
- }
219
- ];
243
+ //#endregion
244
+ //#region src/configs/depend.ts
245
+ const depend = async (options = {}) => {
246
+ const { files = [GLOB_SRC], overrides } = options;
247
+ await ensurePackages(["eslint-plugin-depend"]);
248
+ const [eslintPluginDepend, jsoncParser] = await Promise.all([interopDefault(import("eslint-plugin-depend")), interopDefault(import("jsonc-eslint-parser"))]);
249
+ return [{
250
+ files,
251
+ name: "zayne/depend/recommended",
252
+ plugins: { depend: eslintPluginDepend },
253
+ rules: {
254
+ ...eslintPluginDepend.configs["flat/recommended"]?.rules,
255
+ ...overrides
256
+ }
257
+ }, {
258
+ files: ["package.json", "**/package.json"],
259
+ languageOptions: { parser: jsoncParser },
260
+ name: "zayne/depend/recommended/package-json",
261
+ plugins: { depend: eslintPluginDepend },
262
+ rules: {
263
+ ...eslintPluginDepend.configs["flat/recommended"]?.rules,
264
+ ...overrides
265
+ }
266
+ }];
220
267
  };
221
- var ignores = (userIgnores = []) => {
222
- return [globalIgnores([...GLOB_EXCLUDE, ...userIgnores], "zayne/defaults/ignores")];
268
+
269
+ //#endregion
270
+ //#region src/configs/ignores.ts
271
+ const ignores = (userIgnores = []) => {
272
+ return [globalIgnores([...GLOB_EXCLUDE, ...userIgnores], "zayne/defaults/ignores")];
223
273
  };
224
- var gitIgnores = async (options) => {
225
- const antfuGitIgnore = await interopDefault(import('eslint-config-flat-gitignore'));
226
- const config = antfuGitIgnore({
227
- name: "zayne/gitignore",
228
- strict: false,
229
- ...options
230
- });
231
- return [config];
274
+ const gitIgnores = async (options) => {
275
+ const antfuGitIgnore = await interopDefault(import("eslint-config-flat-gitignore"));
276
+ const config = antfuGitIgnore({
277
+ name: "zayne/gitignore",
278
+ strict: false,
279
+ ...options
280
+ });
281
+ return [config];
232
282
  };
233
283
 
234
- // src/configs/imports.ts
235
- var imports = async (options = {}) => {
236
- const { overrides, stylistic: stylistic2 = true, typescript: typescript2 = true } = options;
237
- const eslintPluginImportX = await interopDefault(import('eslint-plugin-import-x'));
238
- return [
239
- {
240
- name: "zayne/import/setup",
241
- plugins: {
242
- import: eslintPluginImportX
243
- },
244
- ...typescript2 && {
245
- settings: eslintPluginImportX.flatConfigs.typescript.settings
246
- }
247
- },
248
- {
249
- name: "zayne/import/recommended",
250
- rules: {
251
- ...eslintPluginImportX.flatConfigs.recommended.rules,
252
- ...typescript2 && eslintPluginImportX.flatConfigs.typescript.rules
253
- }
254
- },
255
- {
256
- name: "zayne/import/rules",
257
- rules: {
258
- // == This rules keeps giving issues, so off for now
259
- "import/extensions": "off",
260
- // "import/extensions": [
261
- // "error",
262
- // "never",
263
- // { ignorePackages: true, pattern: { css: "always", png: "always", svg: "always" } },
264
- // ],
265
- "import/first": "error",
266
- "import/no-absolute-path": "error",
267
- // "import/no-cycle": ["error", { ignoreExternal: true, maxDepth: 3 }],
268
- "import/no-duplicates": "error",
269
- "import/no-extraneous-dependencies": ["error", { devDependencies: true }],
270
- "import/no-mutable-exports": "error",
271
- "import/no-named-default": "error",
272
- "import/no-relative-packages": "error",
273
- "import/no-self-import": "error",
274
- "import/no-unresolved": "off",
275
- "import/no-useless-path-segments": ["error", { commonjs: true }],
276
- "import/no-webpack-loader-syntax": "error",
277
- ...stylistic2 && { "import/newline-after-import": "error" },
278
- ...overrides
279
- }
280
- }
281
- ];
284
+ //#endregion
285
+ //#region src/configs/imports.ts
286
+ const imports = async (options = {}) => {
287
+ const { overrides, stylistic: stylistic$1 = true, typescript: typescript$1 = true } = options;
288
+ const eslintPluginImportX = await interopDefault(import("eslint-plugin-import-x"));
289
+ return [
290
+ {
291
+ name: "zayne/import/setup",
292
+ plugins: { import: eslintPluginImportX },
293
+ ...typescript$1 && { settings: eslintPluginImportX.flatConfigs.typescript.settings }
294
+ },
295
+ {
296
+ name: "zayne/import/recommended",
297
+ rules: {
298
+ ...eslintPluginImportX.flatConfigs.recommended.rules,
299
+ ...typescript$1 && eslintPluginImportX.flatConfigs.typescript.rules
300
+ }
301
+ },
302
+ {
303
+ name: "zayne/import/rules",
304
+ rules: {
305
+ "import/extensions": "off",
306
+ "import/first": "error",
307
+ "import/no-absolute-path": "error",
308
+ "import/no-duplicates": "error",
309
+ "import/no-extraneous-dependencies": ["error", { devDependencies: true }],
310
+ "import/no-mutable-exports": "error",
311
+ "import/no-named-default": "error",
312
+ "import/no-relative-packages": "error",
313
+ "import/no-self-import": "error",
314
+ "import/no-unresolved": "off",
315
+ "import/no-useless-path-segments": ["error", { commonjs: true }],
316
+ "import/no-webpack-loader-syntax": "error",
317
+ ...stylistic$1 && { "import/newline-after-import": "error" },
318
+ ...overrides
319
+ }
320
+ }
321
+ ];
282
322
  };
283
- var javascript = async (options = {}) => {
284
- const { overrides } = options;
285
- const eslintJs = await interopDefault(import('@eslint/js'));
286
- return [
287
- {
288
- languageOptions: {
289
- ecmaVersion: "latest",
290
- globals: {
291
- ...globals.browser,
292
- ...globals.node,
293
- document: "readonly",
294
- navigator: "readonly",
295
- window: "readonly"
296
- },
297
- parserOptions: {
298
- ecmaVersion: "latest",
299
- sourceType: "module"
300
- },
301
- sourceType: "module"
302
- },
303
- linterOptions: {
304
- reportUnusedDisableDirectives: true
305
- },
306
- name: "zayne/js-eslint/setup"
307
- },
308
- {
309
- ...eslintJs.configs.recommended,
310
- name: "zayne/js-eslint/recommended"
311
- },
312
- {
313
- name: "zayne/js-eslint/rules",
314
- rules: {
315
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
316
- "array-callback-return": ["error", { allowImplicit: true }],
317
- "block-scoped-var": "error",
318
- "class-methods-use-this": "error",
319
- complexity: ["warn", 50],
320
- "constructor-super": "error",
321
- curly: ["error", "multi-line"],
322
- "default-case": ["error", { commentPattern: "^no default$" }],
323
- "default-case-last": "error",
324
- "default-param-last": "error",
325
- "dot-notation": ["error", { allowKeywords: true }],
326
- eqeqeq: ["error", "always", { null: "ignore" }],
327
- "grouped-accessor-pairs": "error",
328
- "logical-assignment-operators": "warn",
329
- "max-depth": ["error", 2],
330
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
331
- "no-alert": "warn",
332
- "no-array-constructor": "error",
333
- "no-async-promise-executor": "error",
334
- "no-await-in-loop": "error",
335
- "no-caller": "error",
336
- "no-case-declarations": "error",
337
- "no-class-assign": "error",
338
- "no-compare-neg-zero": "error",
339
- "no-cond-assign": ["error", "always"],
340
- "no-console": ["error", { allow: ["warn", "error", "info", "trace"] }],
341
- "no-const-assign": "error",
342
- "no-constant-condition": "warn",
343
- "no-constructor-return": "error",
344
- "no-control-regex": "error",
345
- "no-debugger": "error",
346
- "no-delete-var": "error",
347
- "no-dupe-args": "error",
348
- "no-dupe-class-members": "error",
349
- "no-dupe-keys": "error",
350
- "no-duplicate-case": "error",
351
- "no-else-return": ["error", { allowElseIf: false }],
352
- "no-empty": ["error", { allowEmptyCatch: true }],
353
- "no-empty-character-class": "error",
354
- "no-empty-pattern": "error",
355
- "no-eval": ["error", { allowIndirect: true }],
356
- "no-ex-assign": "error",
357
- "no-extend-native": "error",
358
- "no-extra-bind": "error",
359
- "no-extra-boolean-cast": "error",
360
- "no-fallthrough": "error",
361
- "no-func-assign": "error",
362
- "no-global-assign": "error",
363
- "no-implicit-coercion": "warn",
364
- "no-implied-eval": "error",
365
- "no-import-assign": "error",
366
- "no-invalid-regexp": "error",
367
- "no-irregular-whitespace": "error",
368
- "no-iterator": "error",
369
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
370
- "no-lone-blocks": "error",
371
- "no-loop-func": "error",
372
- "no-loss-of-precision": "error",
373
- "no-misleading-character-class": "error",
374
- "no-multi-str": "error",
375
- "no-new": "error",
376
- "no-new-func": "error",
377
- "no-new-native-nonconstructor": "error",
378
- "no-new-wrappers": "error",
379
- "no-obj-calls": "error",
380
- "no-octal": "error",
381
- "no-octal-escape": "error",
382
- "no-param-reassign": [
383
- "error",
384
- {
385
- ignorePropertyModificationsFor: [
386
- "acc",
387
- // for reduce accumulators
388
- "accumulator",
389
- // for reduce accumulators
390
- "e",
391
- // for e.returnvalue
392
- "ctx",
393
- // for Koa routing
394
- "context",
395
- // for Koa routing
396
- "req",
397
- // for Express requests
398
- "request",
399
- // for Express requests
400
- "res",
401
- // for Express responses
402
- "response",
403
- // for Express responses
404
- "$scope",
405
- // for Angular 1 scopes
406
- "staticContext"
407
- // for ReactRouter context
408
- ],
409
- props: true
410
- }
411
- ],
412
- "no-proto": "error",
413
- "no-prototype-builtins": "error",
414
- "no-redeclare": ["error", { builtinGlobals: false }],
415
- "no-regex-spaces": "error",
416
- "no-restricted-exports": [
417
- "error",
418
- {
419
- restrictedNamedExports: [
420
- "default",
421
- // use `export default` to provide a default export
422
- "then"
423
- // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
424
- ]
425
- }
426
- ],
427
- "no-restricted-globals": [
428
- "error",
429
- {
430
- message: "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite",
431
- name: "isFinite"
432
- },
433
- {
434
- message: "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan",
435
- name: "isNaN"
436
- },
437
- { message: "Use `globalThis` instead.", name: "global" },
438
- { message: "Use `globalThis` instead.", name: "self" }
439
- ],
440
- "no-restricted-imports": ["off", { paths: [], patterns: [] }],
441
- "no-restricted-properties": [
442
- "error",
443
- {
444
- message: "arguments.callee is deprecated",
445
- object: "arguments",
446
- property: "callee"
447
- },
448
- {
449
- message: "Please use Number.isFinite instead",
450
- object: "global",
451
- property: "isFinite"
452
- },
453
- {
454
- message: "Please use Number.isFinite instead",
455
- object: "self",
456
- property: "isFinite"
457
- },
458
- {
459
- message: "Please use Number.isFinite instead",
460
- object: "window",
461
- property: "isFinite"
462
- },
463
- {
464
- message: "Please use Number.isNaN instead",
465
- object: "global",
466
- property: "isNaN"
467
- },
468
- {
469
- message: "Please use Number.isNaN instead",
470
- object: "self",
471
- property: "isNaN"
472
- },
473
- {
474
- message: "Please use Number.isNaN instead",
475
- object: "window",
476
- property: "isNaN"
477
- },
478
- {
479
- message: "Use the exponentiation operator (**) instead.",
480
- object: "Math",
481
- property: "pow"
482
- },
483
- {
484
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
485
- property: "__proto__"
486
- },
487
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
488
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
489
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
490
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
491
- ],
492
- "no-restricted-syntax": [
493
- "error",
494
- "ForInStatement",
495
- "LabeledStatement",
496
- "WithStatement",
497
- "TSEnumDeclaration[const=true]",
498
- "TSExportAssignment"
499
- ],
500
- "no-return-assign": ["error", "except-parens"],
501
- "no-script-url": "error",
502
- "no-self-assign": ["error", { props: true }],
503
- "no-self-compare": "error",
504
- "no-sequences": "error",
505
- "no-shadow-restricted-names": "error",
506
- "no-sparse-arrays": "error",
507
- "no-template-curly-in-string": "error",
508
- "no-this-before-super": "error",
509
- "no-throw-literal": "error",
510
- "no-undef": "error",
511
- "no-undef-init": "error",
512
- "no-unexpected-multiline": "error",
513
- "no-unmodified-loop-condition": "error",
514
- "no-unneeded-ternary": ["warn", { defaultAssignment: false }],
515
- "no-unreachable": "error",
516
- "no-unreachable-loop": "error",
517
- "no-unsafe-finally": "error",
518
- "no-unsafe-negation": "error",
519
- "no-unused-expressions": [
520
- "error",
521
- {
522
- allowShortCircuit: true,
523
- allowTaggedTemplates: true,
524
- allowTernary: true
525
- }
526
- ],
527
- "no-unused-vars": [
528
- "warn",
529
- {
530
- args: "all",
531
- argsIgnorePattern: "^_",
532
- caughtErrors: "all",
533
- destructuredArrayIgnorePattern: "^_",
534
- reportUsedIgnorePattern: true,
535
- vars: "all",
536
- varsIgnorePattern: "[iI]gnored"
537
- }
538
- ],
539
- "no-useless-backreference": "error",
540
- "no-useless-call": "error",
541
- "no-useless-catch": "error",
542
- "no-useless-computed-key": "error",
543
- "no-useless-concat": "error",
544
- "no-useless-constructor": "error",
545
- "no-useless-rename": [
546
- "error",
547
- { ignoreDestructuring: false, ignoreExport: false, ignoreImport: false }
548
- ],
549
- "no-useless-return": "error",
550
- "no-var": "error",
551
- "no-with": "error",
552
- "object-shorthand": ["error", "always", { avoidQuotes: true, ignoreConstructors: false }],
553
- "one-var": ["error", { initialized: "never" }],
554
- "operator-assignment": "warn",
555
- "prefer-arrow-callback": [
556
- "error",
557
- {
558
- allowNamedFunctions: false,
559
- allowUnboundThis: true
560
- }
561
- ],
562
- "prefer-const": [
563
- "error",
564
- {
565
- destructuring: "all",
566
- ignoreReadBeforeAssign: true
567
- }
568
- ],
569
- "prefer-exponentiation-operator": "error",
570
- "prefer-object-has-own": "error",
571
- "prefer-object-spread": "warn",
572
- "prefer-promise-reject-errors": "error",
573
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
574
- "prefer-rest-params": "error",
575
- "prefer-spread": "error",
576
- "prefer-template": "error",
577
- radix: "error",
578
- "symbol-description": "error",
579
- "unicode-bom": ["error", "never"],
580
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
581
- "valid-typeof": ["error", { requireStringLiterals: true }],
582
- "vars-on-top": "error",
583
- yoda: ["error", "never"],
584
- ...overrides
585
- }
586
- }
587
- ];
323
+
324
+ //#endregion
325
+ //#region src/configs/javascript.ts
326
+ const javascript = async (options = {}) => {
327
+ const { overrides } = options;
328
+ const eslintJs = await interopDefault(import("@eslint/js"));
329
+ return [
330
+ {
331
+ languageOptions: {
332
+ ecmaVersion: "latest",
333
+ globals: {
334
+ ...globals.browser,
335
+ ...globals.node,
336
+ document: "readonly",
337
+ navigator: "readonly",
338
+ window: "readonly"
339
+ },
340
+ parserOptions: {
341
+ ecmaVersion: "latest",
342
+ sourceType: "module"
343
+ },
344
+ sourceType: "module"
345
+ },
346
+ linterOptions: { reportUnusedDisableDirectives: true },
347
+ name: "zayne/js-eslint/setup"
348
+ },
349
+ {
350
+ ...eslintJs.configs.recommended,
351
+ name: "zayne/js-eslint/recommended"
352
+ },
353
+ {
354
+ name: "zayne/js-eslint/rules",
355
+ rules: {
356
+ "accessor-pairs": ["error", {
357
+ enforceForClassMembers: true,
358
+ setWithoutGet: true
359
+ }],
360
+ "array-callback-return": ["error", { allowImplicit: true }],
361
+ "block-scoped-var": "error",
362
+ "class-methods-use-this": "error",
363
+ complexity: ["warn", 50],
364
+ "constructor-super": "error",
365
+ curly: ["error", "multi-line"],
366
+ "default-case": ["error", { commentPattern: "^no default$" }],
367
+ "default-case-last": "error",
368
+ "default-param-last": "error",
369
+ "dot-notation": ["error", { allowKeywords: true }],
370
+ eqeqeq: [
371
+ "error",
372
+ "always",
373
+ { null: "ignore" }
374
+ ],
375
+ "grouped-accessor-pairs": "error",
376
+ "logical-assignment-operators": "warn",
377
+ "max-depth": ["error", 2],
378
+ "new-cap": ["error", {
379
+ capIsNew: false,
380
+ newIsCap: true,
381
+ properties: true
382
+ }],
383
+ "no-alert": "warn",
384
+ "no-array-constructor": "error",
385
+ "no-async-promise-executor": "error",
386
+ "no-await-in-loop": "error",
387
+ "no-caller": "error",
388
+ "no-case-declarations": "error",
389
+ "no-class-assign": "error",
390
+ "no-compare-neg-zero": "error",
391
+ "no-cond-assign": ["error", "always"],
392
+ "no-console": ["error", { allow: [
393
+ "warn",
394
+ "error",
395
+ "info",
396
+ "trace"
397
+ ] }],
398
+ "no-const-assign": "error",
399
+ "no-constant-condition": "warn",
400
+ "no-constructor-return": "error",
401
+ "no-control-regex": "error",
402
+ "no-debugger": "error",
403
+ "no-delete-var": "error",
404
+ "no-dupe-args": "error",
405
+ "no-dupe-class-members": "error",
406
+ "no-dupe-keys": "error",
407
+ "no-duplicate-case": "error",
408
+ "no-else-return": ["error", { allowElseIf: false }],
409
+ "no-empty": ["error", { allowEmptyCatch: true }],
410
+ "no-empty-character-class": "error",
411
+ "no-empty-pattern": "error",
412
+ "no-eval": ["error", { allowIndirect: true }],
413
+ "no-ex-assign": "error",
414
+ "no-extend-native": "error",
415
+ "no-extra-bind": "error",
416
+ "no-extra-boolean-cast": "error",
417
+ "no-fallthrough": "error",
418
+ "no-func-assign": "error",
419
+ "no-global-assign": "error",
420
+ "no-implicit-coercion": "warn",
421
+ "no-implied-eval": "error",
422
+ "no-import-assign": "error",
423
+ "no-invalid-regexp": "error",
424
+ "no-irregular-whitespace": "error",
425
+ "no-iterator": "error",
426
+ "no-labels": ["error", {
427
+ allowLoop: false,
428
+ allowSwitch: false
429
+ }],
430
+ "no-lone-blocks": "error",
431
+ "no-loop-func": "error",
432
+ "no-loss-of-precision": "error",
433
+ "no-misleading-character-class": "error",
434
+ "no-multi-str": "error",
435
+ "no-new": "error",
436
+ "no-new-func": "error",
437
+ "no-new-native-nonconstructor": "error",
438
+ "no-new-wrappers": "error",
439
+ "no-obj-calls": "error",
440
+ "no-octal": "error",
441
+ "no-octal-escape": "error",
442
+ "no-param-reassign": ["error", {
443
+ ignorePropertyModificationsFor: [
444
+ "acc",
445
+ "accumulator",
446
+ "e",
447
+ "ctx",
448
+ "context",
449
+ "req",
450
+ "request",
451
+ "res",
452
+ "response",
453
+ "$scope",
454
+ "staticContext"
455
+ ],
456
+ props: true
457
+ }],
458
+ "no-proto": "error",
459
+ "no-prototype-builtins": "error",
460
+ "no-redeclare": ["error", { builtinGlobals: false }],
461
+ "no-regex-spaces": "error",
462
+ "no-restricted-exports": ["error", { restrictedNamedExports: ["default", "then"] }],
463
+ "no-restricted-globals": [
464
+ "error",
465
+ {
466
+ message: "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite",
467
+ name: "isFinite"
468
+ },
469
+ {
470
+ message: "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan",
471
+ name: "isNaN"
472
+ },
473
+ {
474
+ message: "Use `globalThis` instead.",
475
+ name: "global"
476
+ },
477
+ {
478
+ message: "Use `globalThis` instead.",
479
+ name: "self"
480
+ }
481
+ ],
482
+ "no-restricted-imports": ["off", {
483
+ paths: [],
484
+ patterns: []
485
+ }],
486
+ "no-restricted-properties": [
487
+ "error",
488
+ {
489
+ message: "arguments.callee is deprecated",
490
+ object: "arguments",
491
+ property: "callee"
492
+ },
493
+ {
494
+ message: "Please use Number.isFinite instead",
495
+ object: "global",
496
+ property: "isFinite"
497
+ },
498
+ {
499
+ message: "Please use Number.isFinite instead",
500
+ object: "self",
501
+ property: "isFinite"
502
+ },
503
+ {
504
+ message: "Please use Number.isFinite instead",
505
+ object: "window",
506
+ property: "isFinite"
507
+ },
508
+ {
509
+ message: "Please use Number.isNaN instead",
510
+ object: "global",
511
+ property: "isNaN"
512
+ },
513
+ {
514
+ message: "Please use Number.isNaN instead",
515
+ object: "self",
516
+ property: "isNaN"
517
+ },
518
+ {
519
+ message: "Please use Number.isNaN instead",
520
+ object: "window",
521
+ property: "isNaN"
522
+ },
523
+ {
524
+ message: "Use the exponentiation operator (**) instead.",
525
+ object: "Math",
526
+ property: "pow"
527
+ },
528
+ {
529
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
530
+ property: "__proto__"
531
+ },
532
+ {
533
+ message: "Use `Object.defineProperty` instead.",
534
+ property: "__defineGetter__"
535
+ },
536
+ {
537
+ message: "Use `Object.defineProperty` instead.",
538
+ property: "__defineSetter__"
539
+ },
540
+ {
541
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
542
+ property: "__lookupGetter__"
543
+ },
544
+ {
545
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
546
+ property: "__lookupSetter__"
547
+ }
548
+ ],
549
+ "no-restricted-syntax": [
550
+ "error",
551
+ "ForInStatement",
552
+ "LabeledStatement",
553
+ "WithStatement",
554
+ "TSEnumDeclaration[const=true]",
555
+ "TSExportAssignment"
556
+ ],
557
+ "no-return-assign": ["error", "except-parens"],
558
+ "no-script-url": "error",
559
+ "no-self-assign": ["error", { props: true }],
560
+ "no-self-compare": "error",
561
+ "no-sequences": "error",
562
+ "no-shadow-restricted-names": "error",
563
+ "no-sparse-arrays": "error",
564
+ "no-template-curly-in-string": "error",
565
+ "no-this-before-super": "error",
566
+ "no-throw-literal": "error",
567
+ "no-undef": "error",
568
+ "no-undef-init": "error",
569
+ "no-unexpected-multiline": "error",
570
+ "no-unmodified-loop-condition": "error",
571
+ "no-unneeded-ternary": ["warn", { defaultAssignment: false }],
572
+ "no-unreachable": "error",
573
+ "no-unreachable-loop": "error",
574
+ "no-unsafe-finally": "error",
575
+ "no-unsafe-negation": "error",
576
+ "no-unused-expressions": ["error", {
577
+ allowShortCircuit: true,
578
+ allowTaggedTemplates: true,
579
+ allowTernary: true
580
+ }],
581
+ "no-unused-vars": ["warn", {
582
+ args: "all",
583
+ argsIgnorePattern: "^_",
584
+ caughtErrors: "all",
585
+ destructuredArrayIgnorePattern: "^_",
586
+ reportUsedIgnorePattern: true,
587
+ vars: "all",
588
+ varsIgnorePattern: "[iI]gnored"
589
+ }],
590
+ "no-useless-backreference": "error",
591
+ "no-useless-call": "error",
592
+ "no-useless-catch": "error",
593
+ "no-useless-computed-key": "error",
594
+ "no-useless-concat": "error",
595
+ "no-useless-constructor": "error",
596
+ "no-useless-rename": ["error", {
597
+ ignoreDestructuring: false,
598
+ ignoreExport: false,
599
+ ignoreImport: false
600
+ }],
601
+ "no-useless-return": "error",
602
+ "no-var": "error",
603
+ "no-with": "error",
604
+ "object-shorthand": [
605
+ "error",
606
+ "always",
607
+ {
608
+ avoidQuotes: true,
609
+ ignoreConstructors: false
610
+ }
611
+ ],
612
+ "one-var": ["error", { initialized: "never" }],
613
+ "operator-assignment": "warn",
614
+ "prefer-arrow-callback": ["error", {
615
+ allowNamedFunctions: false,
616
+ allowUnboundThis: true
617
+ }],
618
+ "prefer-const": ["error", {
619
+ destructuring: "all",
620
+ ignoreReadBeforeAssign: true
621
+ }],
622
+ "prefer-exponentiation-operator": "error",
623
+ "prefer-object-has-own": "error",
624
+ "prefer-object-spread": "warn",
625
+ "prefer-promise-reject-errors": "error",
626
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
627
+ "prefer-rest-params": "error",
628
+ "prefer-spread": "error",
629
+ "prefer-template": "error",
630
+ radix: "error",
631
+ "symbol-description": "error",
632
+ "unicode-bom": ["error", "never"],
633
+ "use-isnan": ["error", {
634
+ enforceForIndexOf: true,
635
+ enforceForSwitchCase: true
636
+ }],
637
+ "valid-typeof": ["error", { requireStringLiterals: true }],
638
+ "vars-on-top": "error",
639
+ yoda: ["error", "never"],
640
+ ...overrides
641
+ }
642
+ }
643
+ ];
588
644
  };
589
645
 
590
- // src/configs/jsdoc.ts
591
- var jsdoc = async (options = {}) => {
592
- const { overrides, stylistic: stylistic2 = true } = options;
593
- const eslintPluginJsdoc = await interopDefault(import('eslint-plugin-jsdoc'));
594
- return [
595
- {
596
- name: "zayne/jsdoc/rules",
597
- plugins: {
598
- jsdoc: eslintPluginJsdoc
599
- },
600
- rules: {
601
- "jsdoc/check-access": "warn",
602
- "jsdoc/check-param-names": "warn",
603
- "jsdoc/check-property-names": "warn",
604
- "jsdoc/check-types": "warn",
605
- "jsdoc/empty-tags": "warn",
606
- "jsdoc/implements-on-classes": "warn",
607
- "jsdoc/no-defaults": "warn",
608
- "jsdoc/no-multi-asterisks": "warn",
609
- "jsdoc/require-description": ["warn", { descriptionStyle: "any" }],
610
- "jsdoc/require-param-name": "warn",
611
- "jsdoc/require-property": "warn",
612
- "jsdoc/require-property-description": "warn",
613
- "jsdoc/require-property-name": "warn",
614
- "jsdoc/require-returns-check": "warn",
615
- "jsdoc/require-returns-description": "warn",
616
- "jsdoc/require-yields-check": "warn",
617
- ...stylistic2 && {
618
- "jsdoc/check-alignment": "warn",
619
- "jsdoc/multiline-blocks": "warn",
620
- "jsdoc/require-description": ["warn", { descriptionStyle: "tag" }]
621
- },
622
- ...overrides
623
- }
624
- }
625
- ];
646
+ //#endregion
647
+ //#region src/configs/jsdoc.ts
648
+ const jsdoc = async (options = {}) => {
649
+ const { overrides, stylistic: stylistic$1 = true } = options;
650
+ const eslintPluginJsdoc = await interopDefault(import("eslint-plugin-jsdoc"));
651
+ return [{
652
+ name: "zayne/jsdoc/rules",
653
+ plugins: { jsdoc: eslintPluginJsdoc },
654
+ rules: {
655
+ "jsdoc/check-access": "warn",
656
+ "jsdoc/check-param-names": "warn",
657
+ "jsdoc/check-property-names": "warn",
658
+ "jsdoc/check-types": "warn",
659
+ "jsdoc/empty-tags": "warn",
660
+ "jsdoc/implements-on-classes": "warn",
661
+ "jsdoc/no-defaults": "warn",
662
+ "jsdoc/no-multi-asterisks": "warn",
663
+ "jsdoc/require-description": ["warn", { descriptionStyle: "any" }],
664
+ "jsdoc/require-param-name": "warn",
665
+ "jsdoc/require-property": "warn",
666
+ "jsdoc/require-property-description": "warn",
667
+ "jsdoc/require-property-name": "warn",
668
+ "jsdoc/require-returns-check": "warn",
669
+ "jsdoc/require-returns-description": "warn",
670
+ "jsdoc/require-yields-check": "warn",
671
+ ...stylistic$1 && {
672
+ "jsdoc/check-alignment": "warn",
673
+ "jsdoc/multiline-blocks": "warn",
674
+ "jsdoc/require-description": ["warn", { descriptionStyle: "tag" }]
675
+ },
676
+ ...overrides
677
+ }
678
+ }];
626
679
  };
627
680
 
628
- // src/configs/jsonc.ts
629
- var jsonc = async (options = {}) => {
630
- const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides, stylistic: stylistic2 = true } = options;
631
- const [eslintPluginJsonc, jsoncParser] = await Promise.all([
632
- interopDefault(import('eslint-plugin-jsonc')),
633
- interopDefault(import('jsonc-eslint-parser'))
634
- ]);
635
- return [
636
- {
637
- name: "zayne/jsonc/setup",
638
- plugins: {
639
- jsonc: eslintPluginJsonc
640
- }
641
- },
642
- {
643
- files,
644
- languageOptions: {
645
- parser: jsoncParser
646
- },
647
- name: "zayne/jsonc/rules",
648
- rules: {
649
- "jsonc/no-bigint-literals": "error",
650
- "jsonc/no-binary-expression": "error",
651
- "jsonc/no-binary-numeric-literals": "error",
652
- "jsonc/no-dupe-keys": "error",
653
- "jsonc/no-escape-sequence-in-identifier": "error",
654
- "jsonc/no-floating-decimal": "error",
655
- "jsonc/no-hexadecimal-numeric-literals": "error",
656
- "jsonc/no-infinity": "error",
657
- "jsonc/no-multi-str": "error",
658
- "jsonc/no-nan": "error",
659
- "jsonc/no-number-props": "error",
660
- "jsonc/no-numeric-separators": "error",
661
- "jsonc/no-octal": "error",
662
- "jsonc/no-octal-escape": "error",
663
- "jsonc/no-octal-numeric-literals": "error",
664
- "jsonc/no-parenthesized": "error",
665
- "jsonc/no-plus-sign": "error",
666
- "jsonc/no-regexp-literals": "error",
667
- "jsonc/no-sparse-arrays": "error",
668
- "jsonc/no-template-literals": "error",
669
- "jsonc/no-undefined-value": "error",
670
- "jsonc/no-unicode-codepoint-escapes": "error",
671
- "jsonc/no-useless-escape": "error",
672
- "jsonc/space-unary-ops": "error",
673
- "jsonc/valid-json-number": "error",
674
- "jsonc/vue-custom-block/no-parsing-error": "error",
675
- ...stylistic2 && {
676
- "jsonc/array-bracket-spacing": ["error", "never"],
677
- "jsonc/comma-dangle": ["error", "never"],
678
- "jsonc/comma-style": ["error", "last"],
679
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
680
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
681
- "jsonc/object-curly-spacing": ["error", "always"],
682
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
683
- "jsonc/quote-props": "error",
684
- "jsonc/quotes": "error"
685
- },
686
- ...overrides
687
- }
688
- }
689
- ];
681
+ //#endregion
682
+ //#region src/configs/jsonc.ts
683
+ const jsonc = async (options = {}) => {
684
+ const { files = [
685
+ GLOB_JSON,
686
+ GLOB_JSON5,
687
+ GLOB_JSONC
688
+ ], overrides, stylistic: stylistic$1 = true } = options;
689
+ const [eslintPluginJsonc, jsoncParser] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
690
+ return [{
691
+ name: "zayne/jsonc/setup",
692
+ plugins: { jsonc: eslintPluginJsonc }
693
+ }, {
694
+ files,
695
+ languageOptions: { parser: jsoncParser },
696
+ name: "zayne/jsonc/rules",
697
+ rules: {
698
+ "jsonc/no-bigint-literals": "error",
699
+ "jsonc/no-binary-expression": "error",
700
+ "jsonc/no-binary-numeric-literals": "error",
701
+ "jsonc/no-dupe-keys": "error",
702
+ "jsonc/no-escape-sequence-in-identifier": "error",
703
+ "jsonc/no-floating-decimal": "error",
704
+ "jsonc/no-hexadecimal-numeric-literals": "error",
705
+ "jsonc/no-infinity": "error",
706
+ "jsonc/no-multi-str": "error",
707
+ "jsonc/no-nan": "error",
708
+ "jsonc/no-number-props": "error",
709
+ "jsonc/no-numeric-separators": "error",
710
+ "jsonc/no-octal": "error",
711
+ "jsonc/no-octal-escape": "error",
712
+ "jsonc/no-octal-numeric-literals": "error",
713
+ "jsonc/no-parenthesized": "error",
714
+ "jsonc/no-plus-sign": "error",
715
+ "jsonc/no-regexp-literals": "error",
716
+ "jsonc/no-sparse-arrays": "error",
717
+ "jsonc/no-template-literals": "error",
718
+ "jsonc/no-undefined-value": "error",
719
+ "jsonc/no-unicode-codepoint-escapes": "error",
720
+ "jsonc/no-useless-escape": "error",
721
+ "jsonc/space-unary-ops": "error",
722
+ "jsonc/valid-json-number": "error",
723
+ "jsonc/vue-custom-block/no-parsing-error": "error",
724
+ ...stylistic$1 && {
725
+ "jsonc/array-bracket-spacing": ["error", "never"],
726
+ "jsonc/comma-dangle": ["error", "never"],
727
+ "jsonc/comma-style": ["error", "last"],
728
+ "jsonc/key-spacing": ["error", {
729
+ afterColon: true,
730
+ beforeColon: false
731
+ }],
732
+ "jsonc/object-curly-newline": ["error", {
733
+ consistent: true,
734
+ multiline: true
735
+ }],
736
+ "jsonc/object-curly-spacing": ["error", "always"],
737
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
738
+ "jsonc/quote-props": "error",
739
+ "jsonc/quotes": "error"
740
+ },
741
+ ...overrides
742
+ }
743
+ }];
690
744
  };
691
745
 
692
- // src/configs/node.ts
693
- var node = async (options = {}) => {
694
- const { overrides, security = false, type = "app" } = options;
695
- const [eslintPluginNode, eslintPluginSecurity] = await Promise.all([
696
- interopDefault(import('eslint-plugin-n')),
697
- ...security ? [interopDefault(import('eslint-plugin-security'))] : []
698
- ]);
699
- const config = [
700
- {
701
- name: "zayne/node/recommended",
702
- plugins: {
703
- node: eslintPluginNode
704
- },
705
- rules: renameRules(eslintPluginNode.configs["flat/recommended-module"].rules, {
706
- n: "node"
707
- })
708
- },
709
- {
710
- name: "zayne/node/rules",
711
- rules: {
712
- "node/no-deprecated-api": "error",
713
- "node/no-exports-assign": "error",
714
- "node/no-extraneous-import": "off",
715
- // eslint-plugin-import-x handles this
716
- "node/no-missing-import": "off",
717
- "node/no-path-concat": "error",
718
- "node/no-unpublished-import": "off",
719
- "node/process-exit-as-throw": "error",
720
- ...type === "lib-strict" ? {
721
- "node/no-unsupported-features/es-syntax": "error",
722
- "node/no-unsupported-features/node-builtins": "error"
723
- } : {
724
- "node/no-unsupported-features/es-syntax": "off",
725
- "node/no-unsupported-features/node-builtins": "off"
726
- },
727
- ...overrides
728
- }
729
- }
730
- ];
731
- if (security && eslintPluginSecurity) {
732
- config.push({
733
- name: "zayne/node/security/recommended",
734
- plugins: {
735
- security: eslintPluginSecurity
736
- },
737
- rules: eslintPluginSecurity.configs.recommended.rules
738
- });
739
- }
740
- return config;
746
+ //#endregion
747
+ //#region src/configs/node.ts
748
+ const node = async (options = {}) => {
749
+ const { overrides, security = false, type = "app" } = options;
750
+ const [eslintPluginNode, eslintPluginSecurity] = await Promise.all([interopDefault(import("eslint-plugin-n")), ...security ? [interopDefault(import("eslint-plugin-security"))] : []]);
751
+ const config = [{
752
+ name: "zayne/node/recommended",
753
+ plugins: { node: eslintPluginNode },
754
+ rules: renameRules(eslintPluginNode.configs["flat/recommended-module"].rules, { n: "node" })
755
+ }, {
756
+ name: "zayne/node/rules",
757
+ rules: {
758
+ "node/no-deprecated-api": "error",
759
+ "node/no-exports-assign": "error",
760
+ "node/no-extraneous-import": "off",
761
+ "node/no-missing-import": "off",
762
+ "node/no-path-concat": "error",
763
+ "node/no-unpublished-import": "off",
764
+ "node/no-unsupported-features/es-syntax": "off",
765
+ "node/no-unsupported-features/node-builtins": "off",
766
+ "node/process-exit-as-throw": "error",
767
+ ...type === "app-strict" && { "node/no-process-env": "error" },
768
+ ...type === "lib-strict" && {
769
+ "node/no-unsupported-features/es-syntax": "error",
770
+ "node/no-unsupported-features/node-builtins": "error"
771
+ },
772
+ ...overrides
773
+ }
774
+ }];
775
+ if (security && eslintPluginSecurity) config.push({
776
+ name: "zayne/node/security/recommended",
777
+ plugins: { security: eslintPluginSecurity },
778
+ rules: eslintPluginSecurity.configs.recommended.rules
779
+ });
780
+ return config;
741
781
  };
742
782
 
743
- // src/configs/perfectionist.ts
744
- var perfectionist = async (options = {}) => {
745
- const { overrides } = options;
746
- const eslintPluginPerfectionist = await interopDefault(import('eslint-plugin-perfectionist'));
747
- return [
748
- {
749
- name: "zayne/perfectionist/rules",
750
- plugins: {
751
- perfectionist: eslintPluginPerfectionist
752
- },
753
- rules: {
754
- "perfectionist/sort-array-includes": [
755
- "warn",
756
- {
757
- order: "asc",
758
- type: "alphabetical"
759
- }
760
- ],
761
- "perfectionist/sort-classes": [
762
- "warn",
763
- {
764
- order: "asc",
765
- type: "alphabetical"
766
- }
767
- ],
768
- "perfectionist/sort-interfaces": [
769
- "warn",
770
- {
771
- order: "asc",
772
- type: "alphabetical"
773
- }
774
- ],
775
- "perfectionist/sort-intersection-types": [
776
- "warn",
777
- {
778
- groups: [
779
- "conditional",
780
- "literal",
781
- "import",
782
- "intersection",
783
- "keyword",
784
- "tuple",
785
- "named",
786
- "object",
787
- "function",
788
- "operator",
789
- "union",
790
- "nullish"
791
- ],
792
- order: "asc",
793
- type: "alphabetical"
794
- }
795
- ],
796
- "perfectionist/sort-maps": [
797
- "warn",
798
- {
799
- order: "asc",
800
- type: "alphabetical"
801
- }
802
- ],
803
- "perfectionist/sort-object-types": [
804
- "warn",
805
- {
806
- order: "asc",
807
- type: "alphabetical"
808
- }
809
- ],
810
- "perfectionist/sort-objects": [
811
- "warn",
812
- {
813
- order: "asc",
814
- type: "alphabetical"
815
- }
816
- ],
817
- "perfectionist/sort-switch-case": [
818
- "warn",
819
- {
820
- order: "asc",
821
- type: "alphabetical"
822
- }
823
- ],
824
- "perfectionist/sort-union-types": [
825
- "warn",
826
- {
827
- groups: [
828
- "conditional",
829
- "literal",
830
- "import",
831
- "intersection",
832
- "keyword",
833
- "tuple",
834
- "named",
835
- "object",
836
- "function",
837
- "operator",
838
- "union",
839
- "nullish"
840
- ],
841
- order: "asc",
842
- type: "alphabetical"
843
- }
844
- ],
845
- "perfectionist/sort-variable-declarations": [
846
- "warn",
847
- {
848
- order: "asc",
849
- type: "alphabetical"
850
- }
851
- ]
852
- // "perfectionist/sort-svelte-attributes": [
853
- // "warn",
854
- // {
855
- // order: "asc",
856
- // type: "alphabetical",
857
- // },
858
- // ],
859
- // "perfectionist/sort-astro-attributes": [
860
- // "warn",
861
- // {
862
- // order: "asc",
863
- // type: "alphabetical",
864
- // },
865
- // ],
866
- // "perfectionist/sort-vue-attributes": [
867
- // "warn",
868
- // {
869
- // order: "asc",
870
- // type: "alphabetical",
871
- // },
872
- // ],
873
- // "perfectionist/sort-jsx-props": [
874
- // "warn",
875
- // {
876
- // // ignorePattern: ["src"],
877
- // order: "asc",
878
- // type: "alphabetical",
879
- // },
880
- // ],
881
- },
882
- ...overrides
883
- }
884
- ];
783
+ //#endregion
784
+ //#region src/configs/perfectionist.ts
785
+ const perfectionist = async (options = {}) => {
786
+ const { overrides } = options;
787
+ const eslintPluginPerfectionist = await interopDefault(import("eslint-plugin-perfectionist"));
788
+ return [{
789
+ name: "zayne/perfectionist/rules",
790
+ plugins: { perfectionist: eslintPluginPerfectionist },
791
+ rules: {
792
+ "perfectionist/sort-array-includes": ["warn", {
793
+ order: "asc",
794
+ type: "alphabetical"
795
+ }],
796
+ "perfectionist/sort-classes": ["warn", {
797
+ order: "asc",
798
+ type: "alphabetical"
799
+ }],
800
+ "perfectionist/sort-interfaces": ["warn", {
801
+ order: "asc",
802
+ type: "alphabetical"
803
+ }],
804
+ "perfectionist/sort-intersection-types": ["warn", {
805
+ groups: [
806
+ "conditional",
807
+ "literal",
808
+ "import",
809
+ "intersection",
810
+ "keyword",
811
+ "tuple",
812
+ "named",
813
+ "object",
814
+ "function",
815
+ "operator",
816
+ "union",
817
+ "nullish"
818
+ ],
819
+ order: "asc",
820
+ type: "alphabetical"
821
+ }],
822
+ "perfectionist/sort-maps": ["warn", {
823
+ order: "asc",
824
+ type: "alphabetical"
825
+ }],
826
+ "perfectionist/sort-object-types": ["warn", {
827
+ order: "asc",
828
+ type: "alphabetical"
829
+ }],
830
+ "perfectionist/sort-objects": ["warn", {
831
+ order: "asc",
832
+ type: "alphabetical"
833
+ }],
834
+ "perfectionist/sort-switch-case": ["warn", {
835
+ order: "asc",
836
+ type: "alphabetical"
837
+ }],
838
+ "perfectionist/sort-union-types": ["warn", {
839
+ groups: [
840
+ "conditional",
841
+ "literal",
842
+ "import",
843
+ "intersection",
844
+ "keyword",
845
+ "tuple",
846
+ "named",
847
+ "object",
848
+ "function",
849
+ "operator",
850
+ "union",
851
+ "nullish"
852
+ ],
853
+ order: "asc",
854
+ type: "alphabetical"
855
+ }],
856
+ "perfectionist/sort-variable-declarations": ["warn", {
857
+ order: "asc",
858
+ type: "alphabetical"
859
+ }]
860
+ },
861
+ ...overrides
862
+ }];
885
863
  };
886
864
 
887
- // src/configs/pnpm.ts
865
+ //#endregion
866
+ //#region src/configs/pnpm.ts
888
867
  async function pnpm(options = {}) {
889
- const { overrides } = options;
890
- const [eslintPluginPnpm, yamlParser, jsoncParser] = await Promise.all([
891
- interopDefault(import('eslint-plugin-pnpm')),
892
- interopDefault(import('yaml-eslint-parser')),
893
- interopDefault(import('jsonc-eslint-parser'))
894
- ]);
895
- return [
896
- {
897
- files: ["package.json", "**/package.json"],
898
- languageOptions: {
899
- parser: jsoncParser
900
- },
901
- name: "zayne/pnpm/package-json",
902
- plugins: {
903
- pnpm: eslintPluginPnpm
904
- },
905
- rules: {
906
- "pnpm/json-enforce-catalog": "error",
907
- "pnpm/json-prefer-workspace-settings": "error",
908
- "pnpm/json-valid-catalog": "error",
909
- ...overrides?.json
910
- }
911
- },
912
- {
913
- files: ["pnpm-workspace.yaml"],
914
- languageOptions: {
915
- parser: yamlParser
916
- },
917
- name: "zayne/pnpm/pnpm-workspace-yaml",
918
- plugins: {
919
- pnpm: eslintPluginPnpm
920
- },
921
- rules: {
922
- "pnpm/yaml-no-duplicate-catalog-item": "error",
923
- "pnpm/yaml-no-unused-catalog-item": "error",
924
- ...overrides?.yaml
925
- }
926
- }
927
- ];
868
+ const { overrides } = options;
869
+ await ensurePackages(["eslint-plugin-pnpm"]);
870
+ const [eslintPluginPnpm, yamlParser, jsoncParser] = await Promise.all([
871
+ interopDefault(import("eslint-plugin-pnpm")),
872
+ interopDefault(import("yaml-eslint-parser")),
873
+ interopDefault(import("jsonc-eslint-parser"))
874
+ ]);
875
+ return [{
876
+ files: ["package.json", "**/package.json"],
877
+ languageOptions: { parser: jsoncParser },
878
+ name: "zayne/pnpm/rules/package-json",
879
+ plugins: { pnpm: eslintPluginPnpm },
880
+ rules: {
881
+ "pnpm/json-enforce-catalog": "error",
882
+ "pnpm/json-prefer-workspace-settings": "error",
883
+ "pnpm/json-valid-catalog": "error",
884
+ ...overrides?.json
885
+ }
886
+ }, {
887
+ files: ["pnpm-workspace.yaml"],
888
+ languageOptions: { parser: yamlParser },
889
+ name: "zayne/pnpm/rules/pnpm-workspace-yaml",
890
+ plugins: { pnpm: eslintPluginPnpm },
891
+ rules: {
892
+ "pnpm/yaml-no-duplicate-catalog-item": "error",
893
+ "pnpm/yaml-no-unused-catalog-item": "error",
894
+ ...overrides?.yaml
895
+ }
896
+ }];
928
897
  }
929
- var defaultPluginRenameMap = defineEnum({
930
- "@eslint-react/debug": "react-debug",
931
- "@eslint-react/dom": "react-dom",
932
- "@eslint-react/hooks-extra": "react-hooks-extra",
933
- "@eslint-react/naming-convention": "react-naming-convention",
934
- "@eslint-react/web-api": "react-web-api",
935
- /* eslint-disable perfectionist/sort-objects -- @eslint-react has to be below the rest to avoid plugin rename issues */
936
- "@eslint-react": "react",
937
- /* eslint-enable perfectionist/sort-objects -- @eslint-react has to be below the rest to avoid plugin rename issues */
938
- "@next/next": "nextjs-next",
939
- "@stylistic": "stylistic",
940
- "@tanstack/query": "tanstack-query",
941
- "@typescript-eslint": "ts-eslint",
942
- "import-x": "import",
943
- n: "node"
898
+
899
+ //#endregion
900
+ //#region src/constants.ts
901
+ const defaultPluginRenameMap = defineEnum({
902
+ "@eslint-react/debug": "react-debug",
903
+ "@eslint-react/dom": "react-dom",
904
+ "@eslint-react/hooks-extra": "react-hooks-extra",
905
+ "@eslint-react/naming-convention": "react-naming-convention",
906
+ "@eslint-react/web-api": "react-web-api",
907
+ "@eslint-react": "react",
908
+ "@next/next": "nextjs-next",
909
+ "@stylistic": "stylistic",
910
+ "@tanstack/query": "tanstack-query",
911
+ "@typescript-eslint": "ts-eslint",
912
+ "import-x": "import",
913
+ n: "node"
944
914
  });
945
- var ReactRefreshAllowConstantExportPackages = ["vite"];
946
- var RemixPackages = ["@remix-run/node", "@remix-run/react", "@remix-run/serve", "@remix-run/dev"];
947
- var NextJsPackages = ["next"];
948
- var isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
949
- var isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
950
- var isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
951
- var react = async (options = {}) => {
952
- const {
953
- compiler = false,
954
- files = [GLOB_SRC],
955
- nextjs = isUsingNext,
956
- overrides,
957
- refresh = true,
958
- typescript: typescript2 = true
959
- } = options;
960
- await ensurePackages([
961
- "@eslint-react/eslint-plugin",
962
- "eslint-plugin-react-hooks",
963
- ...refresh ? ["eslint-plugin-react-refresh"] : [],
964
- ...nextjs ? ["@next/eslint-plugin-next"] : []
965
- ]);
966
- const [eslintPluginReact, eslintReactHooks, eslintPluginReactRefresh] = await Promise.all([
967
- interopDefault(import('@eslint-react/eslint-plugin')),
968
- interopDefault(import('eslint-plugin-react-hooks')),
969
- ...refresh ? [interopDefault(import('eslint-plugin-react-refresh'))] : []
970
- ]);
971
- const eslintPluginNextjs = nextjs && await interopDefault(import('@next/eslint-plugin-next'));
972
- const recommendedReactConfig = eslintPluginReact.configs[typescript2 ? "recommended-type-checked" : "recommended"];
973
- const config = [
974
- {
975
- name: "zayne/react/setup",
976
- plugins: {
977
- ...renamePlugins(recommendedReactConfig.plugins, defaultPluginRenameMap),
978
- "react-hooks": eslintReactHooks
979
- },
980
- settings: recommendedReactConfig.settings
981
- },
982
- {
983
- files,
984
- languageOptions: {
985
- parserOptions: {
986
- ecmaFeatures: {
987
- jsx: true
988
- },
989
- sourceType: "module",
990
- // eslint-disable-next-line unicorn/no-await-expression-member -- ignore for now
991
- ...typescript2 && { parser: (await interopDefault(import('typescript-eslint'))).parser }
992
- }
993
- },
994
- name: "zayne/react/setup-processor"
995
- },
996
- {
997
- files,
998
- name: "zayne/react/recommended",
999
- rules: renameRules(recommendedReactConfig.rules, defaultPluginRenameMap)
1000
- },
1001
- {
1002
- files,
1003
- name: "zayne/react/rules",
1004
- rules: {
1005
- // Hook Extra rules
1006
- "react-hooks-extra/ensure-custom-hooks-using-other-hooks": "error",
1007
- "react-hooks-extra/no-unnecessary-use-callback": "warn",
1008
- "react-hooks-extra/no-unnecessary-use-memo": "warn",
1009
- "react-hooks-extra/prefer-use-state-lazy-initialization": "error",
1010
- // Hook rules
1011
- "react-hooks/exhaustive-deps": "warn",
1012
- "react-hooks/rules-of-hooks": "error",
1013
- // Naming convention rules
1014
- "react-naming-convention/component-name": "warn",
1015
- "react-naming-convention/use-state": "off",
1016
- // Regular React rules
1017
- "react/avoid-shorthand-boolean": "error",
1018
- "react/function-component-definition": "off",
1019
- "react/no-array-index-key": "error",
1020
- "react/no-children-count": "off",
1021
- "react/no-children-only": "off",
1022
- "react/no-children-prop": "error",
1023
- "react/no-clone-element": "off",
1024
- "react/no-complex-conditional-rendering": "warn",
1025
- "react/no-missing-component-display-name": "error",
1026
- "react/no-useless-fragment": "error",
1027
- "react/prefer-destructuring-assignment": "error",
1028
- "react/prefer-read-only-props": "off",
1029
- "react/prefer-shorthand-fragment": "error",
1030
- ...overrides
1031
- }
1032
- }
1033
- ];
1034
- if (refresh && eslintPluginReactRefresh) {
1035
- config.push({
1036
- files,
1037
- name: "zayne/react/refresh",
1038
- plugins: {
1039
- "react-refresh": eslintPluginReactRefresh
1040
- },
1041
- rules: {
1042
- "react-refresh/only-export-components": [
1043
- "warn",
1044
- {
1045
- allowConstantExport: isAllowConstantExport,
1046
- allowExportNames: [
1047
- ...isUsingNext ? [
1048
- "dynamic",
1049
- "dynamicParams",
1050
- "revalidate",
1051
- "fetchCache",
1052
- "runtime",
1053
- "preferredRegion",
1054
- "maxDuration",
1055
- "config",
1056
- "generateStaticParams",
1057
- "metadata",
1058
- "generateMetadata",
1059
- "viewport",
1060
- "generateViewport"
1061
- ] : [],
1062
- ...isUsingRemix ? ["meta", "links", "headers", "loader", "action"] : []
1063
- ]
1064
- }
1065
- ]
1066
- }
1067
- });
1068
- }
1069
- if (compiler) {
1070
- config.push({
1071
- files,
1072
- name: "zayne/react/compiler",
1073
- rules: {
1074
- "react-hooks/react-compiler": "error"
1075
- }
1076
- });
1077
- }
1078
- if (nextjs && eslintPluginNextjs) {
1079
- config.push({
1080
- files,
1081
- name: "zayne/react/nextjs",
1082
- plugins: {
1083
- "nextjs-next": fixupPluginRules(eslintPluginNextjs)
1084
- },
1085
- rules: renameRules(
1086
- // eslint-disable-next-line ts-eslint/no-unsafe-argument -- missing types
1087
- {
1088
- // @ts-expect-error -- missing types
1089
- // eslint-disable-next-line ts-eslint/no-unsafe-member-access -- missing types
1090
- ...eslintPluginNextjs.configs?.recommended?.rules,
1091
- // @ts-expect-error -- missing types
1092
- // eslint-disable-next-line ts-eslint/no-unsafe-member-access -- missing types
1093
- ...eslintPluginNextjs.configs?.["core-web-vitals"]?.rules
1094
- },
1095
- defaultPluginRenameMap
1096
- )
1097
- });
1098
- }
1099
- return config;
915
+
916
+ //#endregion
917
+ //#region src/configs/react.ts
918
+ const ReactRefreshAllowConstantExportPackages = ["vite"];
919
+ const RemixPackages = [
920
+ "@remix-run/node",
921
+ "@remix-run/react",
922
+ "@remix-run/serve",
923
+ "@remix-run/dev"
924
+ ];
925
+ const NextJsPackages = ["next"];
926
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
927
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
928
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
929
+ const react = async (options = {}) => {
930
+ const { compiler = false, files = [GLOB_SRC], nextjs = isUsingNext, overrides, refresh = true, typescript: typescript$1 = true } = options;
931
+ await ensurePackages([
932
+ "@eslint-react/eslint-plugin",
933
+ "eslint-plugin-react-hooks",
934
+ ...refresh ? ["eslint-plugin-react-refresh"] : [],
935
+ ...nextjs ? ["@next/eslint-plugin-next"] : []
936
+ ]);
937
+ const [eslintPluginReact, eslintReactHooks, eslintPluginReactRefresh] = await Promise.all([
938
+ interopDefault(import("@eslint-react/eslint-plugin")),
939
+ interopDefault(import("eslint-plugin-react-hooks")),
940
+ ...refresh ? [interopDefault(import("eslint-plugin-react-refresh"))] : []
941
+ ]);
942
+ const eslintPluginNextjs = nextjs && await interopDefault(import("@next/eslint-plugin-next"));
943
+ const recommendedReactConfig = eslintPluginReact.configs[typescript$1 ? "recommended-type-checked" : "recommended"];
944
+ const config = [
945
+ {
946
+ name: "zayne/react/setup",
947
+ plugins: {
948
+ ...renamePlugins(recommendedReactConfig.plugins, defaultPluginRenameMap),
949
+ "react-hooks": eslintReactHooks
950
+ },
951
+ settings: recommendedReactConfig.settings
952
+ },
953
+ {
954
+ files,
955
+ languageOptions: { parserOptions: {
956
+ ecmaFeatures: { jsx: true },
957
+ sourceType: "module",
958
+ ...typescript$1 && { parser: (await interopDefault(import("typescript-eslint"))).parser }
959
+ } },
960
+ name: "zayne/react/setup-processor"
961
+ },
962
+ {
963
+ files,
964
+ name: "zayne/react/recommended",
965
+ rules: renameRules(recommendedReactConfig.rules, defaultPluginRenameMap)
966
+ },
967
+ {
968
+ files,
969
+ name: "zayne/react/rules",
970
+ rules: {
971
+ "react-hooks-extra/ensure-custom-hooks-using-other-hooks": "error",
972
+ "react-hooks-extra/no-unnecessary-use-callback": "warn",
973
+ "react-hooks-extra/no-unnecessary-use-memo": "warn",
974
+ "react-hooks-extra/prefer-use-state-lazy-initialization": "error",
975
+ "react-hooks/exhaustive-deps": "warn",
976
+ "react-hooks/rules-of-hooks": "error",
977
+ "react-naming-convention/component-name": "warn",
978
+ "react-naming-convention/use-state": "off",
979
+ "react/avoid-shorthand-boolean": "error",
980
+ "react/function-component-definition": "off",
981
+ "react/no-array-index-key": "error",
982
+ "react/no-children-count": "off",
983
+ "react/no-children-only": "off",
984
+ "react/no-children-prop": "error",
985
+ "react/no-clone-element": "off",
986
+ "react/no-complex-conditional-rendering": "warn",
987
+ "react/no-missing-component-display-name": "error",
988
+ "react/no-useless-fragment": "error",
989
+ "react/prefer-destructuring-assignment": "error",
990
+ "react/prefer-read-only-props": "off",
991
+ "react/prefer-shorthand-fragment": "error",
992
+ ...overrides
993
+ }
994
+ }
995
+ ];
996
+ if (refresh && eslintPluginReactRefresh) config.push({
997
+ files,
998
+ name: "zayne/react/refresh",
999
+ plugins: { "react-refresh": eslintPluginReactRefresh },
1000
+ rules: { "react-refresh/only-export-components": ["warn", {
1001
+ allowConstantExport: isAllowConstantExport,
1002
+ allowExportNames: [...isUsingNext ? [
1003
+ "dynamic",
1004
+ "dynamicParams",
1005
+ "revalidate",
1006
+ "fetchCache",
1007
+ "runtime",
1008
+ "preferredRegion",
1009
+ "maxDuration",
1010
+ "config",
1011
+ "generateStaticParams",
1012
+ "metadata",
1013
+ "generateMetadata",
1014
+ "viewport",
1015
+ "generateViewport"
1016
+ ] : [], ...isUsingRemix ? [
1017
+ "meta",
1018
+ "links",
1019
+ "headers",
1020
+ "loader",
1021
+ "action"
1022
+ ] : []]
1023
+ }] }
1024
+ });
1025
+ if (compiler) config.push({
1026
+ files,
1027
+ name: "zayne/react/compiler",
1028
+ rules: { "react-hooks/react-compiler": "error" }
1029
+ });
1030
+ if (nextjs && eslintPluginNextjs) config.push({
1031
+ files,
1032
+ name: "zayne/react/nextjs",
1033
+ plugins: { "nextjs-next": fixupPluginRules(eslintPluginNextjs) },
1034
+ rules: renameRules(
1035
+ // eslint-disable-next-line ts-eslint/no-unsafe-argument -- missing types
1036
+ {
1037
+ ...eslintPluginNextjs.configs?.recommended?.rules,
1038
+ ...eslintPluginNextjs.configs?.["core-web-vitals"]?.rules
1039
+ },
1040
+ defaultPluginRenameMap
1041
+ )
1042
+ });
1043
+ return config;
1100
1044
  };
1101
1045
 
1102
- // src/configs/solid.ts
1103
- var solid = async (options = {}) => {
1104
- const { files = [GLOB_SRC], overrides, typescript: typescript2 = true } = options;
1105
- await ensurePackages(["eslint-plugin-solid"]);
1106
- const eslintPluginSolid = await interopDefault(import('eslint-plugin-solid'));
1107
- const recommendedSolidConfig = eslintPluginSolid.configs[typescript2 ? "flat/typescript" : "flat/recommended"];
1108
- return [
1109
- {
1110
- name: "zayne/solid/setup",
1111
- plugins: {
1112
- solid: eslintPluginSolid
1113
- }
1114
- },
1115
- {
1116
- files,
1117
- name: "zayne/solid/recommended",
1118
- rules: recommendedSolidConfig.rules
1119
- },
1120
- {
1121
- name: "zayne/solid/rules",
1122
- rules: {
1123
- "solid/no-innerhtml": ["error", { allowStatic: true }],
1124
- "solid/style-prop": ["error", { styleProps: ["style", "css"] }]
1125
- },
1126
- ...overrides
1127
- }
1128
- ];
1046
+ //#endregion
1047
+ //#region src/configs/solid.ts
1048
+ const solid = async (options = {}) => {
1049
+ const { files = [GLOB_SRC], overrides, typescript: typescript$1 = true } = options;
1050
+ await ensurePackages(["eslint-plugin-solid"]);
1051
+ const eslintPluginSolid = await interopDefault(import("eslint-plugin-solid"));
1052
+ const recommendedSolidConfig = eslintPluginSolid.configs[typescript$1 ? "flat/typescript" : "flat/recommended"];
1053
+ return [
1054
+ {
1055
+ name: "zayne/solid/setup",
1056
+ plugins: { solid: eslintPluginSolid }
1057
+ },
1058
+ {
1059
+ files,
1060
+ name: "zayne/solid/recommended",
1061
+ rules: recommendedSolidConfig.rules
1062
+ },
1063
+ {
1064
+ name: "zayne/solid/rules",
1065
+ rules: {
1066
+ "solid/no-innerhtml": ["error", { allowStatic: true }],
1067
+ "solid/style-prop": ["error", { styleProps: ["style", "css"] }]
1068
+ },
1069
+ ...overrides
1070
+ }
1071
+ ];
1129
1072
  };
1130
1073
 
1131
- // src/configs/sort.ts
1132
- var sortPackageJson = () => [
1133
- {
1134
- files: ["**/package.json"],
1135
- name: "zayne/sort/package.json",
1136
- rules: {
1137
- "jsonc/sort-array-values": [
1138
- "error",
1139
- {
1140
- order: { type: "asc" },
1141
- pathPattern: "^files$"
1142
- }
1143
- ],
1144
- "jsonc/sort-keys": [
1145
- "error",
1146
- {
1147
- order: [
1148
- "publisher",
1149
- "name",
1150
- "displayName",
1151
- "type",
1152
- "version",
1153
- "private",
1154
- "packageManager",
1155
- "description",
1156
- "author",
1157
- "contributors",
1158
- "license",
1159
- "funding",
1160
- "homepage",
1161
- "repository",
1162
- "bugs",
1163
- "keywords",
1164
- "categories",
1165
- "sideEffects",
1166
- "exports",
1167
- "main",
1168
- "module",
1169
- "unpkg",
1170
- "jsdelivr",
1171
- "types",
1172
- "typesVersions",
1173
- "bin",
1174
- "icon",
1175
- "files",
1176
- "engines",
1177
- "activationEvents",
1178
- "contributes",
1179
- "scripts",
1180
- "peerDependencies",
1181
- "peerDependenciesMeta",
1182
- "dependencies",
1183
- "optionalDependencies",
1184
- "devDependencies",
1185
- "pnpm",
1186
- "overrides",
1187
- "resolutions",
1188
- "husky",
1189
- "simple-git-hooks",
1190
- "lint-staged",
1191
- "eslintConfig"
1192
- ],
1193
- pathPattern: "^$"
1194
- },
1195
- {
1196
- order: { type: "asc" },
1197
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1198
- },
1199
- {
1200
- order: { type: "asc" },
1201
- pathPattern: "scripts"
1202
- },
1203
- {
1204
- order: { type: "asc" },
1205
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1206
- },
1207
- {
1208
- order: ["types", "import", "require", "default"],
1209
- pathPattern: "^exports.*$"
1210
- },
1211
- {
1212
- order: [
1213
- // client hooks only
1214
- "pre-commit",
1215
- "prepare-commit-msg",
1216
- "commit-msg",
1217
- "post-commit",
1218
- "pre-rebase",
1219
- "post-rewrite",
1220
- "post-checkout",
1221
- "post-merge",
1222
- "pre-push",
1223
- "pre-auto-gc"
1224
- ],
1225
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1226
- }
1227
- ]
1228
- }
1229
- }
1230
- ];
1231
- var sortTsconfig = () => [
1232
- {
1233
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1234
- name: "zayne/sort/tsconfig.json",
1235
- rules: {
1236
- "jsonc/sort-keys": [
1237
- "error",
1238
- {
1239
- order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
1240
- pathPattern: "^$"
1241
- },
1242
- {
1243
- order: [
1244
- /* Projects */
1245
- "incremental",
1246
- "composite",
1247
- "tsBuildInfoFile",
1248
- "disableSourceOfProjectReferenceRedirect",
1249
- "disableSolutionSearching",
1250
- "disableReferencedProjectLoad",
1251
- /* Language and Environment */
1252
- "target",
1253
- "jsx",
1254
- "jsxFactory",
1255
- "jsxFragmentFactory",
1256
- "jsxImportSource",
1257
- "lib",
1258
- "moduleDetection",
1259
- "noLib",
1260
- "reactNamespace",
1261
- "useDefineForClassFields",
1262
- "emitDecoratorMetadata",
1263
- "experimentalDecorators",
1264
- /* Modules */
1265
- "baseUrl",
1266
- "rootDir",
1267
- "rootDirs",
1268
- "customConditions",
1269
- "module",
1270
- "moduleResolution",
1271
- "moduleSuffixes",
1272
- "noResolve",
1273
- "paths",
1274
- "resolveJsonModule",
1275
- "resolvePackageJsonExports",
1276
- "resolvePackageJsonImports",
1277
- "typeRoots",
1278
- "types",
1279
- "allowArbitraryExtensions",
1280
- "allowImportingTsExtensions",
1281
- "allowUmdGlobalAccess",
1282
- /* JavaScript Support */
1283
- "allowJs",
1284
- "checkJs",
1285
- "maxNodeModuleJsDepth",
1286
- /* Type Checking */
1287
- "strict",
1288
- "strictBindCallApply",
1289
- "strictFunctionTypes",
1290
- "strictNullChecks",
1291
- "strictPropertyInitialization",
1292
- "allowUnreachableCode",
1293
- "allowUnusedLabels",
1294
- "alwaysStrict",
1295
- "exactOptionalPropertyTypes",
1296
- "noFallthroughCasesInSwitch",
1297
- "noImplicitAny",
1298
- "noImplicitOverride",
1299
- "noImplicitReturns",
1300
- "noImplicitThis",
1301
- "noPropertyAccessFromIndexSignature",
1302
- "noUncheckedIndexedAccess",
1303
- "noUnusedLocals",
1304
- "noUnusedParameters",
1305
- "useUnknownInCatchVariables",
1306
- /* Emit */
1307
- "declaration",
1308
- "declarationDir",
1309
- "declarationMap",
1310
- "downlevelIteration",
1311
- "emitBOM",
1312
- "emitDeclarationOnly",
1313
- "importHelpers",
1314
- "importsNotUsedAsValues",
1315
- "inlineSourceMap",
1316
- "inlineSources",
1317
- "mapRoot",
1318
- "newLine",
1319
- "noEmit",
1320
- "noEmitHelpers",
1321
- "noEmitOnError",
1322
- "outDir",
1323
- "outFile",
1324
- "preserveConstEnums",
1325
- "preserveValueImports",
1326
- "removeComments",
1327
- "sourceMap",
1328
- "sourceRoot",
1329
- "stripInternal",
1330
- /* Interop Constraints */
1331
- "allowSyntheticDefaultImports",
1332
- "esModuleInterop",
1333
- "forceConsistentCasingInFileNames",
1334
- "isolatedDeclarations",
1335
- "isolatedModules",
1336
- "preserveSymlinks",
1337
- "verbatimModuleSyntax",
1338
- /* Completeness */
1339
- "skipDefaultLibCheck",
1340
- "skipLibCheck"
1341
- ],
1342
- pathPattern: "^compilerOptions$"
1343
- }
1344
- ]
1345
- }
1346
- }
1347
- ];
1074
+ //#endregion
1075
+ //#region src/configs/sort.ts
1076
+ /**
1077
+ * @description - Sort package.json
1078
+ *
1079
+ * Requires `jsonc` config
1080
+ */
1081
+ const sortPackageJson = () => [{
1082
+ files: ["**/package.json"],
1083
+ name: "zayne/sort/package.json",
1084
+ rules: {
1085
+ "jsonc/sort-array-values": ["error", {
1086
+ order: { type: "asc" },
1087
+ pathPattern: "^files$"
1088
+ }],
1089
+ "jsonc/sort-keys": [
1090
+ "error",
1091
+ {
1092
+ order: [
1093
+ "publisher",
1094
+ "name",
1095
+ "displayName",
1096
+ "type",
1097
+ "version",
1098
+ "private",
1099
+ "packageManager",
1100
+ "description",
1101
+ "author",
1102
+ "contributors",
1103
+ "license",
1104
+ "funding",
1105
+ "homepage",
1106
+ "repository",
1107
+ "bugs",
1108
+ "keywords",
1109
+ "categories",
1110
+ "sideEffects",
1111
+ "exports",
1112
+ "main",
1113
+ "module",
1114
+ "unpkg",
1115
+ "jsdelivr",
1116
+ "types",
1117
+ "typesVersions",
1118
+ "bin",
1119
+ "icon",
1120
+ "files",
1121
+ "engines",
1122
+ "activationEvents",
1123
+ "contributes",
1124
+ "scripts",
1125
+ "peerDependencies",
1126
+ "peerDependenciesMeta",
1127
+ "dependencies",
1128
+ "optionalDependencies",
1129
+ "devDependencies",
1130
+ "pnpm",
1131
+ "overrides",
1132
+ "resolutions",
1133
+ "husky",
1134
+ "simple-git-hooks",
1135
+ "lint-staged",
1136
+ "eslintConfig"
1137
+ ],
1138
+ pathPattern: "^$"
1139
+ },
1140
+ {
1141
+ order: { type: "asc" },
1142
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1143
+ },
1144
+ {
1145
+ order: { type: "asc" },
1146
+ pathPattern: "scripts"
1147
+ },
1148
+ {
1149
+ order: { type: "asc" },
1150
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1151
+ },
1152
+ {
1153
+ order: [
1154
+ "types",
1155
+ "import",
1156
+ "require",
1157
+ "default"
1158
+ ],
1159
+ pathPattern: "^exports.*$"
1160
+ },
1161
+ {
1162
+ order: [
1163
+ "pre-commit",
1164
+ "prepare-commit-msg",
1165
+ "commit-msg",
1166
+ "post-commit",
1167
+ "pre-rebase",
1168
+ "post-rewrite",
1169
+ "post-checkout",
1170
+ "post-merge",
1171
+ "pre-push",
1172
+ "pre-auto-gc"
1173
+ ],
1174
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1175
+ }
1176
+ ]
1177
+ }
1178
+ }];
1179
+ /**
1180
+ * Sort tsconfig.json
1181
+ *
1182
+ * Requires `jsonc` config
1183
+ */
1184
+ const sortTsconfig = () => [{
1185
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1186
+ name: "zayne/sort/tsconfig.json",
1187
+ rules: { "jsonc/sort-keys": [
1188
+ "error",
1189
+ {
1190
+ order: [
1191
+ "extends",
1192
+ "compilerOptions",
1193
+ "references",
1194
+ "files",
1195
+ "include",
1196
+ "exclude"
1197
+ ],
1198
+ pathPattern: "^$"
1199
+ },
1200
+ {
1201
+ order: [
1202
+ "incremental",
1203
+ "composite",
1204
+ "tsBuildInfoFile",
1205
+ "disableSourceOfProjectReferenceRedirect",
1206
+ "disableSolutionSearching",
1207
+ "disableReferencedProjectLoad",
1208
+ "target",
1209
+ "jsx",
1210
+ "jsxFactory",
1211
+ "jsxFragmentFactory",
1212
+ "jsxImportSource",
1213
+ "lib",
1214
+ "moduleDetection",
1215
+ "noLib",
1216
+ "reactNamespace",
1217
+ "useDefineForClassFields",
1218
+ "emitDecoratorMetadata",
1219
+ "experimentalDecorators",
1220
+ "baseUrl",
1221
+ "rootDir",
1222
+ "rootDirs",
1223
+ "customConditions",
1224
+ "module",
1225
+ "moduleResolution",
1226
+ "moduleSuffixes",
1227
+ "noResolve",
1228
+ "paths",
1229
+ "resolveJsonModule",
1230
+ "resolvePackageJsonExports",
1231
+ "resolvePackageJsonImports",
1232
+ "typeRoots",
1233
+ "types",
1234
+ "allowArbitraryExtensions",
1235
+ "allowImportingTsExtensions",
1236
+ "allowUmdGlobalAccess",
1237
+ "allowJs",
1238
+ "checkJs",
1239
+ "maxNodeModuleJsDepth",
1240
+ "strict",
1241
+ "strictBindCallApply",
1242
+ "strictFunctionTypes",
1243
+ "strictNullChecks",
1244
+ "strictPropertyInitialization",
1245
+ "allowUnreachableCode",
1246
+ "allowUnusedLabels",
1247
+ "alwaysStrict",
1248
+ "exactOptionalPropertyTypes",
1249
+ "noFallthroughCasesInSwitch",
1250
+ "noImplicitAny",
1251
+ "noImplicitOverride",
1252
+ "noImplicitReturns",
1253
+ "noImplicitThis",
1254
+ "noPropertyAccessFromIndexSignature",
1255
+ "noUncheckedIndexedAccess",
1256
+ "noUnusedLocals",
1257
+ "noUnusedParameters",
1258
+ "useUnknownInCatchVariables",
1259
+ "declaration",
1260
+ "declarationDir",
1261
+ "declarationMap",
1262
+ "downlevelIteration",
1263
+ "emitBOM",
1264
+ "emitDeclarationOnly",
1265
+ "importHelpers",
1266
+ "importsNotUsedAsValues",
1267
+ "inlineSourceMap",
1268
+ "inlineSources",
1269
+ "mapRoot",
1270
+ "newLine",
1271
+ "noEmit",
1272
+ "noEmitHelpers",
1273
+ "noEmitOnError",
1274
+ "outDir",
1275
+ "outFile",
1276
+ "preserveConstEnums",
1277
+ "preserveValueImports",
1278
+ "removeComments",
1279
+ "sourceMap",
1280
+ "sourceRoot",
1281
+ "stripInternal",
1282
+ "allowSyntheticDefaultImports",
1283
+ "esModuleInterop",
1284
+ "forceConsistentCasingInFileNames",
1285
+ "isolatedDeclarations",
1286
+ "isolatedModules",
1287
+ "preserveSymlinks",
1288
+ "verbatimModuleSyntax",
1289
+ "skipDefaultLibCheck",
1290
+ "skipLibCheck"
1291
+ ],
1292
+ pathPattern: "^compilerOptions$"
1293
+ }
1294
+ ] }
1295
+ }];
1348
1296
 
1349
- // src/configs/stylistic.ts
1350
- var stylistic = async (options = {}) => {
1351
- const { jsx: jsx2 = true, overrides } = options;
1352
- const eslintPluginStylistic = await interopDefault(import('@stylistic/eslint-plugin'));
1353
- return [
1354
- // == Stylistic Rules (Optional)
1355
- {
1356
- name: "zayne/stylistic/rules",
1357
- plugins: {
1358
- stylistic: eslintPluginStylistic
1359
- },
1360
- rules: {
1361
- "stylistic/no-floating-decimal": "error",
1362
- "stylistic/spaced-comment": [
1363
- "warn",
1364
- "always",
1365
- {
1366
- block: {
1367
- balanced: true,
1368
- exceptions: ["*"],
1369
- markers: ["!"]
1370
- },
1371
- line: {
1372
- exceptions: ["/", "#"],
1373
- markers: ["/"]
1374
- }
1375
- }
1376
- ],
1377
- ...jsx2 && {
1378
- "stylistic/jsx-self-closing-comp": "warn"
1379
- },
1380
- ...overrides
1381
- }
1382
- }
1383
- ];
1297
+ //#endregion
1298
+ //#region src/configs/stylistic.ts
1299
+ const stylistic = async (options = {}) => {
1300
+ const { jsx: jsx$1 = true, overrides } = options;
1301
+ const eslintPluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
1302
+ return [{
1303
+ name: "zayne/stylistic/rules",
1304
+ plugins: { stylistic: eslintPluginStylistic },
1305
+ rules: {
1306
+ "stylistic/no-floating-decimal": "error",
1307
+ "stylistic/spaced-comment": [
1308
+ "warn",
1309
+ "always",
1310
+ {
1311
+ block: {
1312
+ balanced: true,
1313
+ exceptions: ["*"],
1314
+ markers: ["!"]
1315
+ },
1316
+ line: {
1317
+ exceptions: ["/", "#"],
1318
+ markers: ["/"]
1319
+ }
1320
+ }
1321
+ ],
1322
+ ...jsx$1 && { "stylistic/jsx-self-closing-comp": "warn" },
1323
+ ...overrides
1324
+ }
1325
+ }];
1384
1326
  };
1385
1327
 
1386
- // src/configs/tailwindcss.ts
1387
- var tailwindcss = async (options = {}) => {
1388
- const { overrides, settings: tailwindCssSettings } = options;
1389
- await ensurePackages(["eslint-plugin-tailwindcss"]);
1390
- const eslintPluginTailwindCss = await interopDefault(import('eslint-plugin-tailwindcss'));
1391
- return [
1392
- {
1393
- name: "zayne/tailwindcss/setup",
1394
- plugins: {
1395
- tailwindcss: eslintPluginTailwindCss
1396
- },
1397
- settings: {
1398
- tailwindcss: {
1399
- callees: ["tv", "cnMerge", "cn", "cnJoin", "twMerge", "twJoin"],
1400
- classRegex: "^class(Name|Names)?$",
1401
- cssFiles: [],
1402
- removeDuplicates: false,
1403
- // Turned off cuz prettier already handles this via plugin
1404
- ...tailwindCssSettings
1405
- }
1406
- }
1407
- },
1408
- {
1409
- name: "zayne/tailwindcss/recommended",
1410
- rules: eslintPluginTailwindCss.configs["flat/recommended"][1]?.rules
1411
- },
1412
- {
1413
- name: "zayne/tailwindcss/rules",
1414
- rules: {
1415
- "tailwindcss/no-contradicting-classname": "off",
1416
- // Turned off cuz tw intellisense already handles this
1417
- "tailwindcss/no-custom-classname": [
1418
- "warn",
1419
- { ignoredKeys: ["compoundVariants", "defaultVariants", "responsiveVariants"] }
1420
- ],
1421
- ...overrides
1422
- }
1423
- }
1424
- ];
1328
+ //#endregion
1329
+ //#region src/configs/tailwindcss.ts
1330
+ const tailwindcss = async (options = {}) => {
1331
+ const { overrides, settings: tailwindCssSettings } = options;
1332
+ await ensurePackages(["eslint-plugin-tailwindcss"]);
1333
+ const eslintPluginTailwindCss = await interopDefault(import("eslint-plugin-tailwindcss"));
1334
+ return [
1335
+ {
1336
+ name: "zayne/tailwindcss/setup",
1337
+ plugins: { tailwindcss: eslintPluginTailwindCss },
1338
+ settings: { tailwindcss: {
1339
+ callees: [
1340
+ "tv",
1341
+ "cnMerge",
1342
+ "cn",
1343
+ "cnJoin",
1344
+ "twMerge",
1345
+ "twJoin"
1346
+ ],
1347
+ classRegex: "^class(Name|Names)?$",
1348
+ cssFiles: [],
1349
+ removeDuplicates: false,
1350
+ ...tailwindCssSettings
1351
+ } }
1352
+ },
1353
+ {
1354
+ name: "zayne/tailwindcss/recommended",
1355
+ rules: eslintPluginTailwindCss.configs["flat/recommended"][1]?.rules
1356
+ },
1357
+ {
1358
+ name: "zayne/tailwindcss/rules",
1359
+ rules: {
1360
+ "tailwindcss/no-contradicting-classname": "off",
1361
+ "tailwindcss/no-custom-classname": ["warn", { ignoredKeys: [
1362
+ "compoundVariants",
1363
+ "defaultVariants",
1364
+ "responsiveVariants"
1365
+ ] }],
1366
+ ...overrides
1367
+ }
1368
+ }
1369
+ ];
1425
1370
  };
1426
1371
 
1427
- // src/configs/tanstack.ts
1428
- var tanstack = async (options = {}) => {
1429
- const { overrides, query = true } = options;
1430
- const config = [];
1431
- await ensurePackages([...query ? ["@tanstack/eslint-plugin-query"] : []]);
1432
- const [eslintPluginTanstackQuery] = await Promise.all(
1433
- query ? [interopDefault(import('@tanstack/eslint-plugin-query'))] : []
1434
- );
1435
- if (query && eslintPluginTanstackQuery) {
1436
- config.push(
1437
- {
1438
- name: "zayne/tanstack-query/recommended",
1439
- plugins: {
1440
- "tanstack-query": eslintPluginTanstackQuery
1441
- },
1442
- rules: renameRules(
1443
- eslintPluginTanstackQuery.configs["flat/recommended"][0]?.rules,
1444
- defaultPluginRenameMap
1445
- )
1446
- },
1447
- {
1448
- name: "zayne/tanstack-query/rules",
1449
- rules: {
1450
- ...overrides
1451
- }
1452
- }
1453
- );
1454
- }
1455
- return config;
1372
+ //#endregion
1373
+ //#region src/configs/tanstack.ts
1374
+ const tanstack = async (options = {}) => {
1375
+ const { overrides, query = true } = options;
1376
+ const config = [];
1377
+ await ensurePackages([...query ? ["@tanstack/eslint-plugin-query"] : []]);
1378
+ const [eslintPluginTanstackQuery] = await Promise.all(query ? [interopDefault(import("@tanstack/eslint-plugin-query"))] : []);
1379
+ if (query && eslintPluginTanstackQuery) config.push({
1380
+ name: "zayne/tanstack-query/recommended",
1381
+ plugins: { "tanstack-query": eslintPluginTanstackQuery },
1382
+ rules: renameRules(eslintPluginTanstackQuery.configs["flat/recommended"][0]?.rules, defaultPluginRenameMap)
1383
+ }, {
1384
+ name: "zayne/tanstack-query/rules",
1385
+ rules: { ...overrides }
1386
+ });
1387
+ return config;
1456
1388
  };
1457
1389
 
1458
- // src/configs/toml.ts
1459
- var toml = async (options = {}) => {
1460
- const { files = [GLOB_TOML], overrides, stylistic: stylistic2 = true } = options;
1461
- const [pluginToml, parserToml] = await Promise.all([
1462
- interopDefault(import('eslint-plugin-toml')),
1463
- interopDefault(import('toml-eslint-parser'))
1464
- ]);
1465
- return [
1466
- {
1467
- name: "zayne/toml/setup",
1468
- plugins: {
1469
- toml: pluginToml
1470
- }
1471
- },
1472
- {
1473
- files,
1474
- languageOptions: {
1475
- parser: parserToml
1476
- },
1477
- name: "zayne/toml/rules",
1478
- rules: {
1479
- "style/spaced-comment": "off",
1480
- "toml/comma-style": "error",
1481
- "toml/keys-order": "error",
1482
- "toml/no-space-dots": "error",
1483
- "toml/no-unreadable-number-separator": "error",
1484
- "toml/precision-of-fractional-seconds": "error",
1485
- "toml/precision-of-integer": "error",
1486
- "toml/tables-order": "error",
1487
- "toml/vue-custom-block/no-parsing-error": "error",
1488
- ...stylistic2 && {
1489
- "toml/array-bracket-newline": "error",
1490
- "toml/array-bracket-spacing": "error",
1491
- "toml/array-element-newline": "error",
1492
- // "toml/indent": ["error", indent],
1493
- "toml/inline-table-curly-spacing": "error",
1494
- "toml/key-spacing": "error",
1495
- "toml/padding-line-between-pairs": "error",
1496
- "toml/padding-line-between-tables": "error",
1497
- "toml/quoted-keys": "error",
1498
- "toml/spaced-comment": "error",
1499
- "toml/table-bracket-spacing": "error"
1500
- },
1501
- ...overrides
1502
- }
1503
- }
1504
- ];
1390
+ //#endregion
1391
+ //#region src/configs/toml.ts
1392
+ const toml = async (options = {}) => {
1393
+ const { files = [GLOB_TOML], overrides, stylistic: stylistic$1 = true } = options;
1394
+ const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
1395
+ return [{
1396
+ name: "zayne/toml/setup",
1397
+ plugins: { toml: pluginToml }
1398
+ }, {
1399
+ files,
1400
+ languageOptions: { parser: parserToml },
1401
+ name: "zayne/toml/rules",
1402
+ rules: {
1403
+ "style/spaced-comment": "off",
1404
+ "toml/comma-style": "error",
1405
+ "toml/keys-order": "error",
1406
+ "toml/no-space-dots": "error",
1407
+ "toml/no-unreadable-number-separator": "error",
1408
+ "toml/precision-of-fractional-seconds": "error",
1409
+ "toml/precision-of-integer": "error",
1410
+ "toml/tables-order": "error",
1411
+ "toml/vue-custom-block/no-parsing-error": "error",
1412
+ ...stylistic$1 && {
1413
+ "toml/array-bracket-newline": "error",
1414
+ "toml/array-bracket-spacing": "error",
1415
+ "toml/array-element-newline": "error",
1416
+ "toml/inline-table-curly-spacing": "error",
1417
+ "toml/key-spacing": "error",
1418
+ "toml/padding-line-between-pairs": "error",
1419
+ "toml/padding-line-between-tables": "error",
1420
+ "toml/quoted-keys": "error",
1421
+ "toml/spaced-comment": "error",
1422
+ "toml/table-bracket-spacing": "error"
1423
+ },
1424
+ ...overrides
1425
+ }
1426
+ }];
1505
1427
  };
1506
1428
 
1507
- // src/configs/typescript.ts
1508
- var typescript = async (options = {}) => {
1509
- const {
1510
- allowDefaultProjects,
1511
- componentExts = [],
1512
- files = [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
1513
- filesTypeAware = [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
1514
- ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS],
1515
- overrides,
1516
- overridesTypeAware,
1517
- parserOptions,
1518
- stylistic: stylistic2 = true,
1519
- tsconfigPath
1520
- } = options;
1521
- const isTypeAware = Boolean(tsconfigPath);
1522
- const tsEslint = await interopDefault(import('typescript-eslint'));
1523
- const projectServiceObject = isTypeAware && (allowDefaultProjects ? {
1524
- projectService: {
1525
- allowDefaultProject: allowDefaultProjects,
1526
- defaultProject: tsconfigPath
1527
- },
1528
- tsconfigRootDir: process.cwd()
1529
- } : {
1530
- project: tsconfigPath,
1531
- tsconfigRootDir: process.cwd()
1532
- });
1533
- const makeParser = (parsedFiles, ignores2) => ({
1534
- files: parsedFiles,
1535
- ...ignores2 && { ignores: ignores2 },
1536
- languageOptions: {
1537
- parser: tsEslint.parser,
1538
- parserOptions: {
1539
- ecmaFeatures: { globalReturn: true },
1540
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1541
- sourceType: "module",
1542
- ...projectServiceObject,
1543
- ...parserOptions
1544
- }
1545
- }
1546
- });
1547
- const selectedBaseRuleSet = isTypeAware ? "strictTypeChecked" : "strict";
1548
- const selectedStylisticRuleSet = isTypeAware ? "strictTypeChecked" : "strict";
1549
- const typeAwareRules = {
1550
- "ts-eslint/no-unnecessary-type-parameters": "off",
1551
- "ts-eslint/non-nullable-type-assertion-style": "off",
1552
- "ts-eslint/prefer-nullish-coalescing": ["error", { ignoreConditionalTests: true }],
1553
- "ts-eslint/restrict-template-expressions": [
1554
- "error",
1555
- { allowBoolean: true, allowNullish: true, allowNumber: true }
1556
- ],
1557
- "ts-eslint/return-await": ["error", "in-try-catch"]
1558
- };
1559
- return [
1560
- {
1561
- name: `zayne/ts-eslint/${isTypeAware ? "type-aware-setup" : "setup"}`,
1562
- ...makeParser(files),
1563
- ...isTypeAware && makeParser(filesTypeAware, ignoresTypeAware)
1564
- },
1565
- ...renamePluginInConfigs({
1566
- configs: tsEslint.configs[selectedBaseRuleSet],
1567
- overrides: {
1568
- files,
1569
- name: `zayne/ts-eslint/${selectedBaseRuleSet}`
1570
- },
1571
- renameMap: { "@typescript-eslint": "ts-eslint" }
1572
- }),
1573
- ...stylistic2 ? renamePluginInConfigs({
1574
- configs: tsEslint.configs[selectedStylisticRuleSet],
1575
- overrides: {
1576
- files,
1577
- name: `zayne/ts-eslint/${selectedStylisticRuleSet}`
1578
- },
1579
- renameMap: { "@typescript-eslint": "ts-eslint" }
1580
- }) : [],
1581
- {
1582
- files,
1583
- name: "zayne/ts-eslint/rules",
1584
- rules: {
1585
- "ts-eslint/array-type": ["error", { default: "array-simple" }],
1586
- "ts-eslint/consistent-type-definitions": ["error", "type"],
1587
- "ts-eslint/default-param-last": "error",
1588
- "ts-eslint/member-ordering": "error",
1589
- "ts-eslint/method-signature-style": ["error", "property"],
1590
- "ts-eslint/no-confusing-void-expression": "off",
1591
- "ts-eslint/no-empty-function": [
1592
- "error",
1593
- { allow: ["arrowFunctions", "functions", "methods"] }
1594
- ],
1595
- "ts-eslint/no-import-type-side-effects": "error",
1596
- "ts-eslint/no-shadow": "error",
1597
- "ts-eslint/no-unused-expressions": [
1598
- "error",
1599
- {
1600
- allowShortCircuit: true,
1601
- allowTernary: true
1602
- }
1603
- ],
1604
- "ts-eslint/no-unused-vars": [
1605
- "warn",
1606
- {
1607
- args: "all",
1608
- argsIgnorePattern: "^_",
1609
- caughtErrors: "all",
1610
- destructuredArrayIgnorePattern: "^_",
1611
- reportUsedIgnorePattern: true,
1612
- vars: "all",
1613
- varsIgnorePattern: "[iI]gnored"
1614
- }
1615
- ],
1616
- "ts-eslint/no-use-before-define": "off",
1617
- "ts-eslint/no-useless-constructor": "error",
1618
- ...overrides
1619
- }
1620
- },
1621
- isTypeAware ? {
1622
- files: filesTypeAware,
1623
- ignores: ignoresTypeAware,
1624
- name: "zayne/ts-eslint/rules-type-aware",
1625
- rules: {
1626
- ...typeAwareRules,
1627
- ...overridesTypeAware
1628
- }
1629
- } : {}
1630
- ];
1429
+ //#endregion
1430
+ //#region src/configs/typescript.ts
1431
+ const typescript = async (options = {}) => {
1432
+ const { allowDefaultProject, componentExts = [], files = [
1433
+ GLOB_TS,
1434
+ GLOB_TSX,
1435
+ ...componentExts.map((ext) => `**/*.${ext}`)
1436
+ ], filesTypeAware = [
1437
+ GLOB_TS,
1438
+ GLOB_TSX,
1439
+ ...componentExts.map((ext) => `**/*.${ext}`)
1440
+ ], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], overrides, overridesTypeAware, parserOptions, stylistic: stylistic$1 = true, tsconfigPath } = options;
1441
+ const isTypeAware = Boolean(tsconfigPath);
1442
+ const tsEslint = await interopDefault(import("typescript-eslint"));
1443
+ const projectServiceObject = isTypeAware && (allowDefaultProject ? {
1444
+ projectService: {
1445
+ allowDefaultProject,
1446
+ defaultProject: tsconfigPath
1447
+ },
1448
+ tsconfigRootDir: process.cwd()
1449
+ } : {
1450
+ project: tsconfigPath ?? true,
1451
+ tsconfigRootDir: process.cwd()
1452
+ });
1453
+ const makeParser = (parsedFiles, ignores$1) => ({
1454
+ files: parsedFiles,
1455
+ ...ignores$1 && { ignores: ignores$1 },
1456
+ languageOptions: {
1457
+ parser: tsEslint.parser,
1458
+ parserOptions: {
1459
+ ecmaFeatures: { globalReturn: true },
1460
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1461
+ sourceType: "module",
1462
+ ...parserOptions,
1463
+ ...projectServiceObject
1464
+ }
1465
+ }
1466
+ });
1467
+ const selectedBaseRuleSet = isTypeAware ? "strictTypeChecked" : "strict";
1468
+ const selectedStylisticRuleSet = isTypeAware ? "strictTypeChecked" : "strict";
1469
+ const typeAwareRules = {
1470
+ "ts-eslint/no-unnecessary-type-parameters": "off",
1471
+ "ts-eslint/non-nullable-type-assertion-style": "off",
1472
+ "ts-eslint/prefer-nullish-coalescing": ["error", { ignoreConditionalTests: true }],
1473
+ "ts-eslint/restrict-template-expressions": ["error", {
1474
+ allowBoolean: true,
1475
+ allowNullish: true,
1476
+ allowNumber: true
1477
+ }],
1478
+ "ts-eslint/return-await": ["error", "in-try-catch"]
1479
+ };
1480
+ return [
1481
+ {
1482
+ name: `zayne/ts-eslint/${isTypeAware ? "type-aware-setup" : "setup"}`,
1483
+ ...makeParser(files),
1484
+ ...isTypeAware && makeParser(filesTypeAware, ignoresTypeAware)
1485
+ },
1486
+ ...renamePluginInConfigs({
1487
+ configs: tsEslint.configs[selectedBaseRuleSet],
1488
+ overrides: {
1489
+ files,
1490
+ name: `zayne/ts-eslint/${selectedBaseRuleSet}`
1491
+ },
1492
+ renameMap: { "@typescript-eslint": "ts-eslint" }
1493
+ }),
1494
+ ...stylistic$1 ? renamePluginInConfigs({
1495
+ configs: tsEslint.configs[selectedStylisticRuleSet],
1496
+ overrides: {
1497
+ files,
1498
+ name: `zayne/ts-eslint/${selectedStylisticRuleSet}`
1499
+ },
1500
+ renameMap: { "@typescript-eslint": "ts-eslint" }
1501
+ }) : [],
1502
+ {
1503
+ files,
1504
+ name: "zayne/ts-eslint/rules",
1505
+ rules: {
1506
+ "ts-eslint/array-type": ["error", { default: "array-simple" }],
1507
+ "ts-eslint/consistent-type-definitions": ["error", "type"],
1508
+ "ts-eslint/default-param-last": "error",
1509
+ "ts-eslint/member-ordering": "error",
1510
+ "ts-eslint/method-signature-style": ["error", "property"],
1511
+ "ts-eslint/no-confusing-void-expression": "off",
1512
+ "ts-eslint/no-empty-function": ["error", { allow: [
1513
+ "arrowFunctions",
1514
+ "functions",
1515
+ "methods"
1516
+ ] }],
1517
+ "ts-eslint/no-import-type-side-effects": "error",
1518
+ "ts-eslint/no-shadow": "error",
1519
+ "ts-eslint/no-unused-expressions": ["error", {
1520
+ allowShortCircuit: true,
1521
+ allowTernary: true
1522
+ }],
1523
+ "ts-eslint/no-unused-vars": ["warn", {
1524
+ args: "all",
1525
+ argsIgnorePattern: "^_",
1526
+ caughtErrors: "all",
1527
+ destructuredArrayIgnorePattern: "^_",
1528
+ reportUsedIgnorePattern: true,
1529
+ vars: "all",
1530
+ varsIgnorePattern: "[iI]gnored"
1531
+ }],
1532
+ "ts-eslint/no-use-before-define": "off",
1533
+ "ts-eslint/no-useless-constructor": "error",
1534
+ ...overrides
1535
+ }
1536
+ },
1537
+ isTypeAware ? {
1538
+ files: filesTypeAware,
1539
+ ignores: ignoresTypeAware,
1540
+ name: "zayne/ts-eslint/rules-type-aware",
1541
+ rules: {
1542
+ ...typeAwareRules,
1543
+ ...overridesTypeAware
1544
+ }
1545
+ } : {}
1546
+ ];
1631
1547
  };
1632
1548
 
1633
- // src/configs/unicorn.ts
1634
- var unicorn = async (options = {}) => {
1635
- const { overrides, type = "app" } = options;
1636
- const eslintPluginUnicorn = await interopDefault(import('eslint-plugin-unicorn'));
1637
- return [
1638
- {
1639
- ...eslintPluginUnicorn.configs["flat/recommended"],
1640
- name: "zayne/unicorn/recommended"
1641
- },
1642
- {
1643
- name: "zayne/unicorn/rules",
1644
- rules: {
1645
- "unicorn/filename-case": [
1646
- "warn",
1647
- {
1648
- cases: {
1649
- camelCase: true,
1650
- kebabCase: true,
1651
- pascalCase: true
1652
- }
1653
- }
1654
- ],
1655
- ...type === "app" ? {
1656
- "unicorn/prefer-global-this": "off"
1657
- } : {
1658
- "unicorn/prefer-global-this": "warn"
1659
- },
1660
- "unicorn/new-for-builtins": "off",
1661
- "unicorn/no-array-for-each": "off",
1662
- "unicorn/no-array-reduce": "off",
1663
- "unicorn/no-negated-condition": "off",
1664
- "unicorn/no-null": "off",
1665
- "unicorn/no-useless-undefined": ["error", { checkArguments: true }],
1666
- "unicorn/numeric-separators-style": "off",
1667
- "unicorn/prevent-abbreviations": "off",
1668
- ...overrides
1669
- }
1670
- }
1671
- ];
1549
+ //#endregion
1550
+ //#region src/configs/unicorn.ts
1551
+ const unicorn = async (options = {}) => {
1552
+ const { overrides, type = "app" } = options;
1553
+ const eslintPluginUnicorn = await interopDefault(import("eslint-plugin-unicorn"));
1554
+ return [{
1555
+ ...eslintPluginUnicorn.configs.recommended,
1556
+ name: "zayne/unicorn/recommended"
1557
+ }, {
1558
+ name: "zayne/unicorn/rules",
1559
+ rules: {
1560
+ "unicorn/filename-case": ["warn", { cases: {
1561
+ camelCase: true,
1562
+ kebabCase: true,
1563
+ pascalCase: true
1564
+ } }],
1565
+ ...type === "app" ? { "unicorn/prefer-global-this": "off" } : { "unicorn/prefer-global-this": "warn" },
1566
+ "unicorn/new-for-builtins": "off",
1567
+ "unicorn/no-array-for-each": "off",
1568
+ "unicorn/no-array-reduce": "off",
1569
+ "unicorn/no-negated-condition": "off",
1570
+ "unicorn/no-null": "off",
1571
+ "unicorn/no-useless-undefined": ["error", { checkArguments: true }],
1572
+ "unicorn/numeric-separators-style": "off",
1573
+ "unicorn/prevent-abbreviations": "off",
1574
+ ...overrides
1575
+ }
1576
+ }];
1672
1577
  };
1673
- var vue = async (options = {}) => {
1674
- const {
1675
- files = [GLOB_VUE],
1676
- overrides,
1677
- sfcBlocks = true,
1678
- stylistic: stylistic2 = true,
1679
- typescript: typescript2 = true,
1680
- vueVersion = 3
1681
- } = options;
1682
- await ensurePackages([
1683
- "eslint-plugin-vue",
1684
- "vue-eslint-parser",
1685
- ...sfcBlocks ? ["eslint-processor-vue-blocks"] : []
1686
- ]);
1687
- const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1688
- interopDefault(import('eslint-plugin-vue')),
1689
- interopDefault(import('vue-eslint-parser')),
1690
- ...sfcBlocks ? [interopDefault(import('eslint-processor-vue-blocks'))] : []
1691
- ]);
1692
- return [
1693
- {
1694
- /**
1695
- * This allows Vue plugin to work with auto imports
1696
- * @ see https://github.com/vuejs/eslint-plugin-vue/pull/2422
1697
- */
1698
- languageOptions: {
1699
- globals: {
1700
- computed: "readonly",
1701
- defineEmits: "readonly",
1702
- defineExpose: "readonly",
1703
- defineProps: "readonly",
1704
- onMounted: "readonly",
1705
- onUnmounted: "readonly",
1706
- reactive: "readonly",
1707
- ref: "readonly",
1708
- shallowReactive: "readonly",
1709
- shallowRef: "readonly",
1710
- toRef: "readonly",
1711
- toRefs: "readonly",
1712
- watch: "readonly",
1713
- watchEffect: "readonly"
1714
- }
1715
- },
1716
- name: "zayne/vue/setup",
1717
- plugins: {
1718
- vue: pluginVue
1719
- }
1720
- },
1721
- {
1722
- files,
1723
- languageOptions: {
1724
- parser: parserVue,
1725
- parserOptions: {
1726
- ecmaFeatures: {
1727
- jsx: true
1728
- },
1729
- extraFileExtensions: [".vue"],
1730
- sourceType: "module",
1731
- // eslint-disable-next-line unicorn/no-await-expression-member -- ignore for now
1732
- ...typescript2 && { parser: (await interopDefault(import('typescript-eslint'))).parser }
1733
- }
1734
- },
1735
- name: "zayne/vue/setup/file-processor",
1736
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([
1737
- pluginVue.processors[".vue"],
1738
- processorVueBlocks?.({
1739
- ...resolveOptions(sfcBlocks),
1740
- blocks: {
1741
- styles: true,
1742
- ...resolveOptions(sfcBlocks).blocks
1743
- }
1744
- }) ?? pluginVue.processors[".vue"]
1745
- ])
1746
- },
1747
- {
1748
- files,
1749
- name: "zayne/vue/recommended",
1750
- rules: {
1751
- ...pluginVue.configs.base.rules,
1752
- ...pluginVue.configs[`flat/${vueVersion === 2 ? "vue2-" : ""}essential`].at(-1)?.rules,
1753
- ...pluginVue.configs[`flat/${vueVersion === 2 ? "vue2-" : ""}strongly-recommended`].at(-1)?.rules,
1754
- ...pluginVue.configs[`flat/${vueVersion === 2 ? "vue2-" : ""}recommended`].at(-1)?.rules
1755
- }
1756
- },
1757
- {
1758
- files,
1759
- name: "zayne/vue/rules",
1760
- rules: {
1761
- "node/prefer-global/process": "off",
1762
- "vue/block-order": [
1763
- "error",
1764
- {
1765
- order: ["script", "template", "style"]
1766
- }
1767
- ],
1768
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
1769
- "vue/component-options-name-casing": ["error", "PascalCase"],
1770
- // == this is deprecated
1771
- "vue/component-tags-order": "off",
1772
- "vue/custom-event-name-casing": ["error", "camelCase"],
1773
- "vue/define-macros-order": [
1774
- "error",
1775
- {
1776
- order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1777
- }
1778
- ],
1779
- "vue/dot-location": ["error", "property"],
1780
- "vue/dot-notation": ["error", { allowKeywords: true }],
1781
- "vue/eqeqeq": ["error", "smart"],
1782
- "vue/html-indent": "off",
1783
- "vue/html-quotes": ["error", "double"],
1784
- "vue/max-attributes-per-line": "off",
1785
- "vue/multi-word-component-names": "off",
1786
- "vue/no-dupe-keys": "off",
1787
- "vue/no-empty-pattern": "error",
1788
- "vue/no-irregular-whitespace": "error",
1789
- "vue/no-loss-of-precision": "error",
1790
- "vue/no-restricted-syntax": [
1791
- "error",
1792
- "DebuggerStatement",
1793
- "LabeledStatement",
1794
- "WithStatement"
1795
- ],
1796
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
1797
- "vue/no-setup-props-reactivity-loss": "off",
1798
- "vue/no-sparse-arrays": "error",
1799
- "vue/no-unused-refs": "error",
1800
- "vue/no-useless-v-bind": "error",
1801
- "vue/no-v-html": "off",
1802
- "vue/object-shorthand": [
1803
- "error",
1804
- "always",
1805
- {
1806
- avoidQuotes: true,
1807
- ignoreConstructors: false
1808
- }
1809
- ],
1810
- "vue/prefer-separate-static-class": "error",
1811
- "vue/prefer-template": "error",
1812
- "vue/prop-name-casing": ["error", "camelCase"],
1813
- "vue/require-default-prop": "off",
1814
- "vue/require-prop-types": "off",
1815
- "vue/singleline-html-element-content-newline": "off",
1816
- "vue/space-infix-ops": "error",
1817
- "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1818
- ...stylistic2 && {
1819
- "vue/array-bracket-spacing": ["error", "never"],
1820
- "vue/arrow-spacing": ["error", { after: true, before: true }],
1821
- "vue/block-spacing": ["error", "always"],
1822
- "vue/block-tag-newline": [
1823
- "error",
1824
- {
1825
- multiline: "always",
1826
- singleline: "always"
1827
- }
1828
- ],
1829
- "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1830
- "vue/comma-dangle": ["error", "always-multiline"],
1831
- "vue/comma-spacing": ["error", { after: true, before: false }],
1832
- "vue/comma-style": ["error", "last"],
1833
- "vue/html-comment-content-spacing": [
1834
- "error",
1835
- "always",
1836
- {
1837
- exceptions: ["-"]
1838
- }
1839
- ],
1840
- "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1841
- "vue/keyword-spacing": ["error", { after: true, before: true }],
1842
- "vue/object-curly-newline": "off",
1843
- "vue/object-curly-spacing": ["error", "always"],
1844
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1845
- "vue/operator-linebreak": ["error", "before"],
1846
- "vue/padding-line-between-blocks": ["error", "always"],
1847
- "vue/quote-props": ["error", "consistent-as-needed"],
1848
- "vue/space-in-parens": ["error", "never"],
1849
- "vue/template-curly-spacing": "error"
1850
- },
1851
- "ts-eslint/no-unused-vars": "off",
1852
- ...overrides
1853
- }
1854
- }
1855
- ];
1578
+
1579
+ //#endregion
1580
+ //#region src/configs/vue.ts
1581
+ const vue = async (options = {}) => {
1582
+ const { files = [GLOB_VUE], overrides, sfcBlocks = true, stylistic: stylistic$1 = true, typescript: typescript$1 = true, vueVersion = 3 } = options;
1583
+ await ensurePackages([
1584
+ "eslint-plugin-vue",
1585
+ "vue-eslint-parser",
1586
+ ...sfcBlocks ? ["eslint-processor-vue-blocks"] : []
1587
+ ]);
1588
+ const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1589
+ interopDefault(import("eslint-plugin-vue")),
1590
+ interopDefault(import("vue-eslint-parser")),
1591
+ ...sfcBlocks ? [interopDefault(import("eslint-processor-vue-blocks"))] : []
1592
+ ]);
1593
+ return [
1594
+ {
1595
+ languageOptions: { globals: {
1596
+ computed: "readonly",
1597
+ defineEmits: "readonly",
1598
+ defineExpose: "readonly",
1599
+ defineProps: "readonly",
1600
+ onMounted: "readonly",
1601
+ onUnmounted: "readonly",
1602
+ reactive: "readonly",
1603
+ ref: "readonly",
1604
+ shallowReactive: "readonly",
1605
+ shallowRef: "readonly",
1606
+ toRef: "readonly",
1607
+ toRefs: "readonly",
1608
+ watch: "readonly",
1609
+ watchEffect: "readonly"
1610
+ } },
1611
+ name: "zayne/vue/setup",
1612
+ plugins: { vue: pluginVue }
1613
+ },
1614
+ {
1615
+ files,
1616
+ languageOptions: {
1617
+ parser: parserVue,
1618
+ parserOptions: {
1619
+ ecmaFeatures: { jsx: true },
1620
+ extraFileExtensions: [".vue"],
1621
+ sourceType: "module",
1622
+ ...typescript$1 && { parser: (await interopDefault(import("typescript-eslint"))).parser }
1623
+ }
1624
+ },
1625
+ name: "zayne/vue/setup/file-processor",
1626
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([pluginVue.processors[".vue"], processorVueBlocks?.({
1627
+ ...resolveOptions(sfcBlocks),
1628
+ blocks: {
1629
+ styles: true,
1630
+ ...resolveOptions(sfcBlocks).blocks
1631
+ }
1632
+ }) ?? pluginVue.processors[".vue"]])
1633
+ },
1634
+ {
1635
+ files,
1636
+ name: "zayne/vue/recommended",
1637
+ rules: {
1638
+ ...pluginVue.configs.base.rules,
1639
+ ...pluginVue.configs[`flat/${vueVersion === 2 ? "vue2-" : ""}essential`].at(-1)?.rules,
1640
+ ...pluginVue.configs[`flat/${vueVersion === 2 ? "vue2-" : ""}strongly-recommended`].at(-1)?.rules,
1641
+ ...pluginVue.configs[`flat/${vueVersion === 2 ? "vue2-" : ""}recommended`].at(-1)?.rules
1642
+ }
1643
+ },
1644
+ {
1645
+ files,
1646
+ name: "zayne/vue/rules",
1647
+ rules: {
1648
+ "node/prefer-global/process": "off",
1649
+ "vue/block-order": ["error", { order: [
1650
+ "script",
1651
+ "template",
1652
+ "style"
1653
+ ] }],
1654
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1655
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1656
+ "vue/component-tags-order": "off",
1657
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1658
+ "vue/define-macros-order": ["error", { order: [
1659
+ "defineOptions",
1660
+ "defineProps",
1661
+ "defineEmits",
1662
+ "defineSlots"
1663
+ ] }],
1664
+ "vue/dot-location": ["error", "property"],
1665
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1666
+ "vue/eqeqeq": ["error", "smart"],
1667
+ "vue/html-indent": "off",
1668
+ "vue/html-quotes": ["error", "double"],
1669
+ "vue/max-attributes-per-line": "off",
1670
+ "vue/multi-word-component-names": "off",
1671
+ "vue/no-dupe-keys": "off",
1672
+ "vue/no-empty-pattern": "error",
1673
+ "vue/no-irregular-whitespace": "error",
1674
+ "vue/no-loss-of-precision": "error",
1675
+ "vue/no-restricted-syntax": [
1676
+ "error",
1677
+ "DebuggerStatement",
1678
+ "LabeledStatement",
1679
+ "WithStatement"
1680
+ ],
1681
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1682
+ "vue/no-setup-props-reactivity-loss": "off",
1683
+ "vue/no-sparse-arrays": "error",
1684
+ "vue/no-unused-refs": "error",
1685
+ "vue/no-useless-v-bind": "error",
1686
+ "vue/no-v-html": "off",
1687
+ "vue/object-shorthand": [
1688
+ "error",
1689
+ "always",
1690
+ {
1691
+ avoidQuotes: true,
1692
+ ignoreConstructors: false
1693
+ }
1694
+ ],
1695
+ "vue/prefer-separate-static-class": "error",
1696
+ "vue/prefer-template": "error",
1697
+ "vue/prop-name-casing": ["error", "camelCase"],
1698
+ "vue/require-default-prop": "off",
1699
+ "vue/require-prop-types": "off",
1700
+ "vue/singleline-html-element-content-newline": "off",
1701
+ "vue/space-infix-ops": "error",
1702
+ "vue/space-unary-ops": ["error", {
1703
+ nonwords: false,
1704
+ words: true
1705
+ }],
1706
+ ...stylistic$1 && {
1707
+ "vue/array-bracket-spacing": ["error", "never"],
1708
+ "vue/arrow-spacing": ["error", {
1709
+ after: true,
1710
+ before: true
1711
+ }],
1712
+ "vue/block-spacing": ["error", "always"],
1713
+ "vue/block-tag-newline": ["error", {
1714
+ multiline: "always",
1715
+ singleline: "always"
1716
+ }],
1717
+ "vue/brace-style": [
1718
+ "error",
1719
+ "stroustrup",
1720
+ { allowSingleLine: true }
1721
+ ],
1722
+ "vue/comma-dangle": ["error", "always-multiline"],
1723
+ "vue/comma-spacing": ["error", {
1724
+ after: true,
1725
+ before: false
1726
+ }],
1727
+ "vue/comma-style": ["error", "last"],
1728
+ "vue/html-comment-content-spacing": [
1729
+ "error",
1730
+ "always",
1731
+ { exceptions: ["-"] }
1732
+ ],
1733
+ "vue/key-spacing": ["error", {
1734
+ afterColon: true,
1735
+ beforeColon: false
1736
+ }],
1737
+ "vue/keyword-spacing": ["error", {
1738
+ after: true,
1739
+ before: true
1740
+ }],
1741
+ "vue/object-curly-newline": "off",
1742
+ "vue/object-curly-spacing": ["error", "always"],
1743
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1744
+ "vue/operator-linebreak": ["error", "before"],
1745
+ "vue/padding-line-between-blocks": ["error", "always"],
1746
+ "vue/quote-props": ["error", "consistent-as-needed"],
1747
+ "vue/space-in-parens": ["error", "never"],
1748
+ "vue/template-curly-spacing": "error"
1749
+ },
1750
+ "ts-eslint/no-unused-vars": "off",
1751
+ ...overrides
1752
+ }
1753
+ }
1754
+ ];
1856
1755
  };
1857
1756
 
1858
- // src/configs/yaml.ts
1859
- var yaml = async (options = {}) => {
1860
- const { files = [GLOB_YAML], overrides, stylistic: stylistic2 = true } = options;
1861
- const [pluginYaml, parserYaml] = await Promise.all([
1862
- interopDefault(import('eslint-plugin-yml')),
1863
- interopDefault(import('yaml-eslint-parser'))
1864
- ]);
1865
- return [
1866
- {
1867
- name: "zayne/yaml/setup",
1868
- plugins: {
1869
- yaml: pluginYaml
1870
- }
1871
- },
1872
- {
1873
- files,
1874
- languageOptions: {
1875
- parser: parserYaml
1876
- },
1877
- name: "zayne/yaml/rules",
1878
- rules: {
1879
- "yaml/block-mapping": "error",
1880
- "yaml/block-sequence": "error",
1881
- "yaml/no-empty-key": "error",
1882
- "yaml/no-empty-sequence-entry": "error",
1883
- "yaml/no-irregular-whitespace": "error",
1884
- "yaml/plain-scalar": "error",
1885
- "yaml/vue-custom-block/no-parsing-error": "error",
1886
- ...stylistic2 && {
1887
- "yaml/block-mapping-question-indicator-newline": "error",
1888
- "yaml/block-sequence-hyphen-indicator-newline": "error",
1889
- "yaml/flow-mapping-curly-newline": "error",
1890
- "yaml/flow-mapping-curly-spacing": "error",
1891
- "yaml/flow-sequence-bracket-newline": "error",
1892
- "yaml/flow-sequence-bracket-spacing": "error",
1893
- // "yaml/indent": ["error", indent],
1894
- "yaml/key-spacing": "error",
1895
- "yaml/no-tab-indent": "error",
1896
- // "yaml/quotes": [
1897
- // "error",
1898
- // { avoidEscape: true, prefer: quotes === "backtick" ? "double" : quotes },
1899
- // ],
1900
- "yaml/spaced-comment": "error"
1901
- },
1902
- "stylistic/spaced-comment": "off",
1903
- ...overrides
1904
- }
1905
- }
1906
- ];
1757
+ //#endregion
1758
+ //#region src/configs/yaml.ts
1759
+ const yaml = async (options = {}) => {
1760
+ const { files = [GLOB_YAML], overrides, stylistic: stylistic$1 = true } = options;
1761
+ const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
1762
+ return [{
1763
+ name: "zayne/yaml/setup",
1764
+ plugins: { yaml: pluginYaml }
1765
+ }, {
1766
+ files,
1767
+ languageOptions: { parser: parserYaml },
1768
+ name: "zayne/yaml/rules",
1769
+ rules: {
1770
+ "yaml/block-mapping": "error",
1771
+ "yaml/block-sequence": "error",
1772
+ "yaml/no-empty-key": "error",
1773
+ "yaml/no-empty-sequence-entry": "error",
1774
+ "yaml/no-irregular-whitespace": "error",
1775
+ "yaml/plain-scalar": "error",
1776
+ "yaml/vue-custom-block/no-parsing-error": "error",
1777
+ ...stylistic$1 && {
1778
+ "yaml/block-mapping-question-indicator-newline": "error",
1779
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1780
+ "yaml/flow-mapping-curly-newline": "error",
1781
+ "yaml/flow-mapping-curly-spacing": "error",
1782
+ "yaml/flow-sequence-bracket-newline": "error",
1783
+ "yaml/flow-sequence-bracket-spacing": "error",
1784
+ "yaml/key-spacing": "error",
1785
+ "yaml/no-tab-indent": "error",
1786
+ "yaml/spaced-comment": "error"
1787
+ },
1788
+ "stylistic/spaced-comment": "off",
1789
+ ...overrides
1790
+ }
1791
+ }];
1907
1792
  };
1908
1793
 
1909
- // src/configs/jsx.ts
1910
- var jsx = () => {
1911
- return [
1912
- {
1913
- files: [GLOB_JSX, GLOB_TSX],
1914
- languageOptions: {
1915
- parserOptions: {
1916
- ecmaFeatures: {
1917
- jsx: true
1918
- }
1919
- }
1920
- },
1921
- name: "zayne/jsx/setup"
1922
- }
1923
- ];
1794
+ //#endregion
1795
+ //#region src/configs/jsx.ts
1796
+ const jsx = () => {
1797
+ return [{
1798
+ files: [GLOB_JSX, GLOB_TSX],
1799
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
1800
+ name: "zayne/jsx/setup"
1801
+ }];
1924
1802
  };
1925
1803
 
1926
- // src/factory.ts
1927
- var ReactPackages = ["react", "react-dom"];
1928
- var zayne = (options = {}, ...userConfigs) => {
1929
- const {
1930
- autoRenamePlugins = true,
1931
- componentExts = [],
1932
- type = "app",
1933
- withDefaults = true,
1934
- ...restOfOptions
1935
- } = options;
1936
- const enableGitignore = restOfOptions.gitignore ?? true;
1937
- const enableJsx = restOfOptions.jsx ?? true;
1938
- const enableComments = restOfOptions.comments ?? withDefaults;
1939
- const enableImports = restOfOptions.imports ?? withDefaults;
1940
- const enableJsdoc = restOfOptions.jsdoc ?? withDefaults;
1941
- const enablePnpmCatalogs = restOfOptions.pnpm;
1942
- const enableJsonc = restOfOptions.jsonc ?? withDefaults;
1943
- const enableNode = restOfOptions.node ?? withDefaults;
1944
- const enablePerfectionist = restOfOptions.perfectionist ?? withDefaults;
1945
- const enableReact = restOfOptions.react ?? (withDefaults && ReactPackages.some((pkg) => isPackageExists(pkg)));
1946
- const enableStylistic = restOfOptions.stylistic ?? withDefaults;
1947
- const enableToml = restOfOptions.toml ?? withDefaults;
1948
- const enableTypeScript = restOfOptions.typescript ?? (withDefaults && isPackageExists("typescript"));
1949
- const enableUnicorn = restOfOptions.unicorn ?? withDefaults;
1950
- const enableYaml = restOfOptions.yaml ?? withDefaults;
1951
- const isStylistic = Boolean(enableStylistic);
1952
- const tsconfigPath = isObject(enableTypeScript) && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : null;
1953
- const isTypeAware = Boolean(tsconfigPath);
1954
- const configs = [];
1955
- configs.push(ignores(restOfOptions.ignores), javascript(restOfOptions.javascript));
1956
- if (enableJsx) {
1957
- configs.push(jsx());
1958
- }
1959
- if (restOfOptions.vue) {
1960
- componentExts.push("vue");
1961
- }
1962
- if (restOfOptions.astro) {
1963
- componentExts.push("astro");
1964
- }
1965
- if (enableTypeScript) {
1966
- configs.push(
1967
- typescript({
1968
- componentExts,
1969
- stylistic: isStylistic,
1970
- ...resolveOptions(enableTypeScript)
1971
- })
1972
- );
1973
- }
1974
- if (enableStylistic) {
1975
- configs.push(stylistic({ jsx: enableJsx, ...resolveOptions(enableStylistic) }));
1976
- }
1977
- if (enableComments) {
1978
- configs.push(comments({ type, ...resolveOptions(enableComments) }));
1979
- }
1980
- if (enableGitignore) {
1981
- configs.push(gitIgnores(resolveOptions(enableGitignore)));
1982
- }
1983
- if (enableImports) {
1984
- configs.push(
1985
- imports({ stylistic: isStylistic, typescript: isTypeAware, ...resolveOptions(enableImports) })
1986
- );
1987
- }
1988
- if (enablePnpmCatalogs) {
1989
- configs.push(pnpm(resolveOptions(enablePnpmCatalogs)));
1990
- }
1991
- if (enableNode) {
1992
- configs.push(node({ type, ...resolveOptions(enableNode) }));
1993
- }
1994
- if (enablePerfectionist) {
1995
- configs.push(perfectionist(resolveOptions(enablePerfectionist)));
1996
- }
1997
- if (enableUnicorn) {
1998
- configs.push(unicorn({ type, ...resolveOptions(enableUnicorn) }));
1999
- }
2000
- if (enableJsonc) {
2001
- configs.push(
2002
- jsonc({ stylistic: isStylistic, ...resolveOptions(enableJsonc) }),
2003
- sortPackageJson(),
2004
- sortTsconfig()
2005
- );
2006
- }
2007
- if (enableJsdoc) {
2008
- configs.push(jsdoc({ stylistic: isStylistic, ...resolveOptions(enableJsdoc) }));
2009
- }
2010
- if (restOfOptions.tailwindcss) {
2011
- configs.push(tailwindcss(resolveOptions(restOfOptions.tailwindcss)));
2012
- }
2013
- if (restOfOptions.tanstack) {
2014
- configs.push(tanstack(resolveOptions(restOfOptions.tanstack)));
2015
- }
2016
- if (enableToml) {
2017
- configs.push(
2018
- toml({
2019
- stylistic: isStylistic,
2020
- ...resolveOptions(enableToml)
2021
- })
2022
- );
2023
- }
2024
- if (enableYaml) {
2025
- configs.push(
2026
- yaml({
2027
- stylistic: isStylistic,
2028
- ...resolveOptions(enableYaml)
2029
- })
2030
- );
2031
- }
2032
- if (enableReact) {
2033
- configs.push(react({ typescript: isTypeAware, ...resolveOptions(enableReact) }));
2034
- }
2035
- if (restOfOptions.vue) {
2036
- configs.push(
2037
- vue({ stylistic: isStylistic, typescript: isTypeAware, ...resolveOptions(restOfOptions.vue) })
2038
- );
2039
- }
2040
- if (restOfOptions.solid) {
2041
- configs.push(solid({ typescript: isTypeAware, ...resolveOptions(restOfOptions.solid) }));
2042
- }
2043
- if (restOfOptions.astro) {
2044
- configs.push(astro({ typescript: isTypeAware, ...resolveOptions(restOfOptions.astro) }));
2045
- }
2046
- assert(
2047
- !("files" in restOfOptions),
2048
- `[@zayne-labs/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second config array instead.`
2049
- );
2050
- let composer = new FlatConfigComposer();
2051
- composer = composer.append(...configs, ...userConfigs);
2052
- if (autoRenamePlugins) {
2053
- composer = composer.renamePlugins(defaultPluginRenameMap);
2054
- }
2055
- return composer;
1804
+ //#endregion
1805
+ //#region src/factory.ts
1806
+ const ReactPackages = ["react", "react-dom"];
1807
+ /**
1808
+ * @description Construct an array of ESLint flat config items.
1809
+ * @param options
1810
+ * The options for generating the ESLint configurations.
1811
+ * @param userConfigs
1812
+ * The extra user configurations to be merged with the generated configurations.
1813
+ * @returns
1814
+ * The merged ESLint configurations.
1815
+ */
1816
+ const zayne = (options = {}, ...userConfigs) => {
1817
+ const { autoRenamePlugins = true, componentExts = [], type = "app", withDefaults = true,...restOfOptions } = options;
1818
+ const enableGitignore = restOfOptions.gitignore ?? true;
1819
+ const enableJsx = restOfOptions.jsx ?? true;
1820
+ const enableComments = restOfOptions.comments ?? withDefaults;
1821
+ const enableImports = restOfOptions.imports ?? withDefaults;
1822
+ const enableJsdoc = restOfOptions.jsdoc ?? withDefaults;
1823
+ const enablePnpmCatalogs = restOfOptions.pnpm;
1824
+ const enableJsonc = restOfOptions.jsonc ?? withDefaults;
1825
+ const enableNode = restOfOptions.node ?? withDefaults;
1826
+ const enablePerfectionist = restOfOptions.perfectionist ?? withDefaults;
1827
+ const enableReact = restOfOptions.react ?? (withDefaults && ReactPackages.some((pkg) => isPackageExists(pkg)));
1828
+ const enableStylistic = restOfOptions.stylistic ?? withDefaults;
1829
+ const enableToml = restOfOptions.toml ?? withDefaults;
1830
+ const enableTypeScript = restOfOptions.typescript ?? (withDefaults && isPackageExists("typescript"));
1831
+ const enableUnicorn = restOfOptions.unicorn ?? withDefaults;
1832
+ const enableYaml = restOfOptions.yaml ?? withDefaults;
1833
+ const isStylistic = Boolean(enableStylistic);
1834
+ const tsconfigPath = isObject(enableTypeScript) && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : null;
1835
+ const isTypeAware = Boolean(tsconfigPath);
1836
+ const configs = [];
1837
+ configs.push(ignores(restOfOptions.ignores), javascript(restOfOptions.javascript));
1838
+ if (enableJsx) configs.push(jsx());
1839
+ if (restOfOptions.vue) componentExts.push("vue");
1840
+ if (restOfOptions.astro) componentExts.push("astro");
1841
+ if (enableTypeScript) configs.push(typescript({
1842
+ componentExts,
1843
+ stylistic: isStylistic,
1844
+ ...resolveOptions(enableTypeScript)
1845
+ }));
1846
+ if (enableStylistic) configs.push(stylistic({
1847
+ jsx: enableJsx,
1848
+ ...resolveOptions(enableStylistic)
1849
+ }));
1850
+ if (enableComments) configs.push(comments({
1851
+ type,
1852
+ ...resolveOptions(enableComments)
1853
+ }));
1854
+ if (enableGitignore) configs.push(gitIgnores(resolveOptions(enableGitignore)));
1855
+ if (enableImports) configs.push(imports({
1856
+ stylistic: isStylistic,
1857
+ typescript: isTypeAware,
1858
+ ...resolveOptions(enableImports)
1859
+ }));
1860
+ if (enablePnpmCatalogs) configs.push(pnpm(resolveOptions(enablePnpmCatalogs)));
1861
+ if (enableNode) configs.push(node({
1862
+ type,
1863
+ ...resolveOptions(enableNode)
1864
+ }));
1865
+ if (enablePerfectionist) configs.push(perfectionist(resolveOptions(enablePerfectionist)));
1866
+ if (enableUnicorn) configs.push(unicorn({
1867
+ type,
1868
+ ...resolveOptions(enableUnicorn)
1869
+ }));
1870
+ if (enableJsonc) configs.push(jsonc({
1871
+ stylistic: isStylistic,
1872
+ ...resolveOptions(enableJsonc)
1873
+ }), sortPackageJson(), sortTsconfig());
1874
+ if (enableJsdoc) configs.push(jsdoc({
1875
+ stylistic: isStylistic,
1876
+ ...resolveOptions(enableJsdoc)
1877
+ }));
1878
+ if (enableToml) configs.push(toml({
1879
+ stylistic: isStylistic,
1880
+ ...resolveOptions(enableToml)
1881
+ }));
1882
+ if (enableYaml) configs.push(yaml({
1883
+ stylistic: isStylistic,
1884
+ ...resolveOptions(enableYaml)
1885
+ }));
1886
+ if (enableReact) configs.push(react({
1887
+ typescript: isTypeAware,
1888
+ ...resolveOptions(enableReact)
1889
+ }));
1890
+ if (restOfOptions.vue) configs.push(vue({
1891
+ stylistic: isStylistic,
1892
+ typescript: isTypeAware,
1893
+ ...resolveOptions(restOfOptions.vue)
1894
+ }));
1895
+ if (restOfOptions.solid) configs.push(solid({
1896
+ typescript: isTypeAware,
1897
+ ...resolveOptions(restOfOptions.solid)
1898
+ }));
1899
+ if (restOfOptions.astro) configs.push(astro({
1900
+ typescript: isTypeAware,
1901
+ ...resolveOptions(restOfOptions.astro)
1902
+ }));
1903
+ if (restOfOptions.tailwindcss) configs.push(tailwindcss(resolveOptions(restOfOptions.tailwindcss)));
1904
+ if (restOfOptions.tanstack) configs.push(tanstack(resolveOptions(restOfOptions.tanstack)));
1905
+ if (restOfOptions.depend) configs.push(depend(resolveOptions(restOfOptions.depend)));
1906
+ assert(!("files" in restOfOptions), `[@zayne-labs/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second config array instead.`);
1907
+ let composer = new FlatConfigComposer();
1908
+ composer = composer.append(...configs, ...userConfigs);
1909
+ if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenameMap);
1910
+ return composer;
2056
1911
  };
2057
1912
 
2058
- export { GLOB_ALL_SRC, 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_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, astro, combine, comments, ensurePackages, gitIgnores, ignores, imports, interopDefault, isObject, isPackageInScope, javascript, jsdoc, jsonc, node, perfectionist, pnpm, react, renamePluginInConfigs, renamePlugins, renameRules, resolveOptions, solid, sortPackageJson, sortTsconfig, stylistic, tailwindcss, tanstack, toml, typescript, unicorn, vue, yaml, zayne };
2059
- //# sourceMappingURL=index.js.map
1913
+ //#endregion
1914
+ export { GLOB_ALL_SRC, 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_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, astro, combine, comments, depend, ensurePackages, gitIgnores, ignores, imports, interopDefault, isObject, isPackageInScope, javascript, jsdoc, jsonc, node, perfectionist, pnpm, react, renamePluginInConfigs, renamePlugins, renameRules, resolveOptions, solid, sortPackageJson, sortTsconfig, stylistic, tailwindcss, tanstack, toml, typescript, unicorn, vue, yaml, zayne };
2060
1915
  //# sourceMappingURL=index.js.map