@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/bin/index.js +2 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +304 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +8721 -9347
- package/dist/index.js +1858 -2003
- package/dist/index.js.map +1 -1
- package/package.json +38 -32
package/dist/index.js
CHANGED
|
@@ -1,2060 +1,1915 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fileURLToPath } from
|
|
3
|
-
import { isPackageExists } from
|
|
4
|
-
import { globalIgnores } from
|
|
5
|
-
import globals from
|
|
6
|
-
import { fixupPluginRules } from
|
|
7
|
-
import { mergeProcessors } from
|
|
8
|
-
import { FlatConfigComposer } from
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
const interopDefault = async (module) => {
|
|
104
|
+
const resolved = await module;
|
|
105
|
+
return resolved.default ?? resolved;
|
|
96
106
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
222
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
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
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
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
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
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
|
-
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region src/configs/pnpm.ts
|
|
888
867
|
async function pnpm(options = {}) {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
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
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
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
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
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
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
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
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
]
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
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
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
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
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
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
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
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
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
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
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
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
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
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
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
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
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
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
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
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
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
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
|
-
|
|
2059
|
-
|
|
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
|