create-typescript-app 2.39.0 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/blocks/blockESLintPlugin.d.ts +3 -1
- package/lib/blocks/blockESLintPlugin.js +16 -2
- package/lib/blocks/eslint/blockESLintPluginIntake.d.ts +5 -0
- package/lib/blocks/eslint/blockESLintPluginIntake.js +48 -0
- package/lib/blocks/eslint/schemas.d.ts +2 -1
- package/lib/blocks/eslint/schemas.js +2 -0
- package/lib/blocks/index.d.ts +3 -1
- package/lib/data/packageData.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as bingo_stratum from 'bingo-stratum';
|
|
2
2
|
|
|
3
|
-
declare const blockESLintPlugin: bingo_stratum.
|
|
3
|
+
declare const blockESLintPlugin: bingo_stratum.BlockWithAddons<{
|
|
4
|
+
configEmoji?: [string, string][] | undefined;
|
|
5
|
+
}, {
|
|
4
6
|
access: "public" | "restricted";
|
|
5
7
|
description: string;
|
|
6
8
|
directory: string;
|
|
@@ -5,11 +5,24 @@ import { blockESLint } from "./blockESLint.js";
|
|
|
5
5
|
import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
|
|
6
6
|
import { blockPackageJson } from "./blockPackageJson.js";
|
|
7
7
|
import { blockVitest } from "./blockVitest.js";
|
|
8
|
+
import { blockESLintPluginIntake } from "./eslint/blockESLintPluginIntake.js";
|
|
9
|
+
import { zConfigEmoji } from "./eslint/schemas.js";
|
|
10
|
+
import { intakeFile } from "./intake/intakeFile.js";
|
|
8
11
|
const blockESLintPlugin = base.createBlock({
|
|
9
12
|
about: {
|
|
10
13
|
name: "ESLint Plugin"
|
|
11
14
|
},
|
|
12
|
-
|
|
15
|
+
addons: {
|
|
16
|
+
configEmoji: zConfigEmoji
|
|
17
|
+
},
|
|
18
|
+
intake({ files }) {
|
|
19
|
+
const docGeneratorConfigRaw = intakeFile(files, [
|
|
20
|
+
[".eslint-doc-generatorrc.js", ".eslint-doc-generatorrc.mjs"]
|
|
21
|
+
]);
|
|
22
|
+
return docGeneratorConfigRaw ? blockESLintPluginIntake(docGeneratorConfigRaw[0]) : void 0;
|
|
23
|
+
},
|
|
24
|
+
produce({ addons, options }) {
|
|
25
|
+
const { configEmoji } = addons;
|
|
13
26
|
const configFileName = `.eslint-doc-generatorrc.${options.type === "commonjs" ? "mjs" : "js"}`;
|
|
14
27
|
return {
|
|
15
28
|
addons: [
|
|
@@ -88,7 +101,8 @@ pnpm build:docs
|
|
|
88
101
|
|
|
89
102
|
/** @type {import('eslint-doc-generator').GenerateOptions} */
|
|
90
103
|
const config = {
|
|
91
|
-
|
|
104
|
+
${configEmoji ? `configEmoji: ${JSON.stringify(configEmoji)},
|
|
105
|
+
` : ""}postprocess: async (content, path) =>
|
|
92
106
|
prettier.format(content, {
|
|
93
107
|
...(await prettier.resolveConfig(path)),
|
|
94
108
|
parser: "markdown",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AST_NODE_TYPES,
|
|
3
|
+
parse as parseAST
|
|
4
|
+
} from "@typescript-eslint/typescript-estree";
|
|
5
|
+
import JSON5 from "json5";
|
|
6
|
+
import { tryCatch } from "../../utils/tryCatch.js";
|
|
7
|
+
import { zConfigEmoji } from "./schemas.js";
|
|
8
|
+
function blockESLintPluginIntake(sourceText) {
|
|
9
|
+
const ast = tryCatch(
|
|
10
|
+
() => parseAST(sourceText, {
|
|
11
|
+
comment: true,
|
|
12
|
+
loc: true,
|
|
13
|
+
range: true
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
if (!ast) {
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
const config = findConfig(ast.body);
|
|
20
|
+
if (!config) {
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
const configEmoji = findConfigEmoji(config.properties);
|
|
24
|
+
if (!configEmoji) {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
const { data } = zConfigEmoji.safeParse(
|
|
28
|
+
JSON5.parse(sourceText.slice(...configEmoji.range))
|
|
29
|
+
);
|
|
30
|
+
return data && { configEmoji: data };
|
|
31
|
+
function findConfig(body) {
|
|
32
|
+
for (const node of body) {
|
|
33
|
+
if (node.type === AST_NODE_TYPES.VariableDeclaration && node.declarations[0].id.type === AST_NODE_TYPES.Identifier && node.declarations[0].id.name === "config" && node.declarations[0].init?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
34
|
+
return node.declarations[0].init;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function findConfigEmoji(properties) {
|
|
39
|
+
for (const node of properties) {
|
|
40
|
+
if (node.type === AST_NODE_TYPES.Property && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "configEmoji" && node.value.type === AST_NODE_TYPES.ArrayExpression) {
|
|
41
|
+
return node.value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
blockESLintPluginIntake
|
|
48
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
declare const zConfigEmoji: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>, "many">>;
|
|
3
4
|
declare const zRuleOptions: z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"off">, z.ZodLiteral<"warn">, z.ZodTuple<[z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">]>, z.ZodUnknown], null>, z.ZodTuple<[z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">]>, z.ZodUnknown, z.ZodUnknown], null>]>;
|
|
4
5
|
type RuleOptions = z.infer<typeof zRuleOptions>;
|
|
5
6
|
declare const zExtensionRuleGroup: z.ZodObject<{
|
|
@@ -94,4 +95,4 @@ declare const zPackageImport: z.ZodObject<{
|
|
|
94
95
|
types?: boolean | undefined;
|
|
95
96
|
}>;
|
|
96
97
|
|
|
97
|
-
export { type Extension, type ExtensionRuleGroup, type ExtensionRules, type RuleOptions, zExtension, zExtensionRuleGroup, zExtensionRules, zPackageImport, zRuleOptions };
|
|
98
|
+
export { type Extension, type ExtensionRuleGroup, type ExtensionRules, type RuleOptions, zConfigEmoji, zExtension, zExtensionRuleGroup, zExtensionRules, zPackageImport, zRuleOptions };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
const zConfigEmoji = z.array(z.tuple([z.string(), z.string()])).optional();
|
|
2
3
|
const zRuleOptions = z.union([
|
|
3
4
|
z.literal("error"),
|
|
4
5
|
z.literal("off"),
|
|
@@ -36,6 +37,7 @@ const zPackageImport = z.object({
|
|
|
36
37
|
types: z.boolean().optional()
|
|
37
38
|
});
|
|
38
39
|
export {
|
|
40
|
+
zConfigEmoji,
|
|
39
41
|
zExtension,
|
|
40
42
|
zExtensionRuleGroup,
|
|
41
43
|
zExtensionRules,
|
package/lib/blocks/index.d.ts
CHANGED
|
@@ -1186,7 +1186,9 @@ declare const blocks: {
|
|
|
1186
1186
|
hash?: string | undefined;
|
|
1187
1187
|
}>> | undefined;
|
|
1188
1188
|
}>;
|
|
1189
|
-
blockESLintPlugin: bingo_stratum.
|
|
1189
|
+
blockESLintPlugin: bingo_stratum.BlockWithAddons<{
|
|
1190
|
+
configEmoji?: [string, string][] | undefined;
|
|
1191
|
+
}, {
|
|
1190
1192
|
access: "public" | "restricted";
|
|
1191
1193
|
description: string;
|
|
1192
1194
|
directory: string;
|