create-typescript-app 2.24.4 → 2.25.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/base.d.ts +11 -6
- package/lib/base.js +5 -0
- package/lib/blocks/blockAllContributors.d.ts +1 -0
- package/lib/blocks/blockAreTheTypesWrong.d.ts +1 -0
- package/lib/blocks/blockCSpell.d.ts +1 -0
- package/lib/blocks/blockCTATransitions.d.ts +1 -0
- package/lib/blocks/blockCodecov.d.ts +1 -0
- package/lib/blocks/blockContributingDocs.d.ts +1 -0
- package/lib/blocks/blockContributorCovenant.d.ts +1 -0
- package/lib/blocks/blockDevelopmentDocs.d.ts +1 -0
- package/lib/blocks/blockESLint.d.ts +5 -1
- package/lib/blocks/blockESLint.js +25 -12
- package/lib/blocks/blockESLintComments.d.ts +1 -0
- package/lib/blocks/blockESLintJSDoc.d.ts +1 -0
- package/lib/blocks/blockESLintJSONC.d.ts +1 -0
- package/lib/blocks/blockESLintMarkdown.d.ts +1 -0
- package/lib/blocks/blockESLintMoreStyling.d.ts +1 -0
- package/lib/blocks/blockESLintNode.d.ts +1 -0
- package/lib/blocks/blockESLintPackageJson.d.ts +1 -0
- package/lib/blocks/blockESLintPerfectionist.d.ts +1 -0
- package/lib/blocks/blockESLintPlugin.d.ts +72 -0
- package/lib/blocks/blockESLintPlugin.js +226 -0
- package/lib/blocks/blockESLintRegexp.d.ts +1 -0
- package/lib/blocks/blockESLintYML.d.ts +1 -0
- package/lib/blocks/blockExampleFiles.d.ts +1 -0
- package/lib/blocks/blockFunding.d.ts +1 -0
- package/lib/blocks/blockGitHubActionsCI.d.ts +1 -0
- package/lib/blocks/blockGitHubApps.d.ts +1 -0
- package/lib/blocks/blockGitHubIssueTemplates.d.ts +1 -0
- package/lib/blocks/blockGitHubPRTemplate.d.ts +1 -0
- package/lib/blocks/blockGitignore.d.ts +1 -0
- package/lib/blocks/blockKnip.d.ts +1 -0
- package/lib/blocks/blockMITLicense.d.ts +1 -0
- package/lib/blocks/blockMain.d.ts +1 -0
- package/lib/blocks/blockMarkdownlint.d.ts +1 -0
- package/lib/blocks/blockNcc.d.ts +1 -0
- package/lib/blocks/blockNvmrc.d.ts +1 -0
- package/lib/blocks/blockPRCompliance.d.ts +1 -0
- package/lib/blocks/blockPackageJson.d.ts +1 -0
- package/lib/blocks/blockPnpmDedupe.d.ts +1 -0
- package/lib/blocks/blockPrettier.d.ts +1 -0
- package/lib/blocks/blockPrettierPluginCurly.d.ts +1 -0
- package/lib/blocks/blockPrettierPluginPackageJson.d.ts +1 -0
- package/lib/blocks/blockPrettierPluginSh.d.ts +1 -0
- package/lib/blocks/blockREADME.d.ts +1 -0
- package/lib/blocks/blockREADME.js +6 -2
- package/lib/blocks/blockReleaseIt.d.ts +1 -0
- package/lib/blocks/blockRemoveDependencies.d.ts +1 -0
- package/lib/blocks/blockRemoveFiles.d.ts +1 -0
- package/lib/blocks/blockRemoveWorkflows.d.ts +1 -0
- package/lib/blocks/blockRenovate.d.ts +1 -0
- package/lib/blocks/blockRepositoryBranchRuleset.d.ts +1 -0
- package/lib/blocks/blockRepositoryLabels.d.ts +1 -0
- package/lib/blocks/blockRepositorySecrets.d.ts +1 -0
- package/lib/blocks/blockRepositorySettings.d.ts +1 -0
- package/lib/blocks/blockSecurityDocs.d.ts +1 -0
- package/lib/blocks/blockTSup.d.ts +1 -0
- package/lib/blocks/blockTemplatedWith.d.ts +1 -0
- package/lib/blocks/blockTypeScript.d.ts +1 -0
- package/lib/blocks/blockVSCode.d.ts +1 -0
- package/lib/blocks/blockVitest.d.ts +1 -0
- package/lib/blocks/index.d.ts +118 -1
- package/lib/blocks/index.js +4 -0
- package/lib/data/packageData.d.ts +1 -1
- package/lib/index.d.ts +7 -0
- package/lib/options/readDocumentation.d.ts +1 -1
- package/lib/options/readDocumentation.js +4 -2
- package/lib/options/readReadmeAdditional.js +2 -2
- package/lib/options/readReadmeFootnotes.d.ts +4 -0
- package/lib/options/readReadmeFootnotes.js +17 -0
- package/lib/presets/common.d.ts +5 -0
- package/lib/presets/everything.d.ts +5 -0
- package/lib/presets/index.d.ts +15 -0
- package/lib/presets/minimal.d.ts +5 -0
- package/lib/schemas.d.ts +10 -2
- package/lib/schemas.js +1 -0
- package/lib/template.d.ts +5 -0
- package/lib/template.js +2 -0
- package/package.json +1 -1
package/lib/base.d.ts
CHANGED
|
@@ -13,16 +13,16 @@ declare const base: bingo_stratum.Base<{
|
|
|
13
13
|
name: z.ZodString;
|
|
14
14
|
profile: z.ZodString;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
name: string;
|
|
16
17
|
avatar_url: string;
|
|
17
18
|
contributions: string[];
|
|
18
19
|
login: string;
|
|
19
|
-
name: string;
|
|
20
20
|
profile: string;
|
|
21
21
|
}, {
|
|
22
|
+
name: string;
|
|
22
23
|
avatar_url: string;
|
|
23
24
|
contributions: string[];
|
|
24
25
|
login: string;
|
|
25
|
-
name: string;
|
|
26
26
|
profile: string;
|
|
27
27
|
}>, "many">>;
|
|
28
28
|
description: z.ZodDefault<z.ZodString>;
|
|
@@ -32,21 +32,25 @@ declare const base: bingo_stratum.Base<{
|
|
|
32
32
|
readme: z.ZodObject<{
|
|
33
33
|
additional: z.ZodOptional<z.ZodString>;
|
|
34
34
|
explainer: z.ZodOptional<z.ZodString>;
|
|
35
|
+
footnotes: z.ZodOptional<z.ZodString>;
|
|
35
36
|
usage: z.ZodString;
|
|
36
37
|
}, "strip", z.ZodTypeAny, {
|
|
37
38
|
usage: string;
|
|
38
39
|
additional?: string | undefined;
|
|
39
40
|
explainer?: string | undefined;
|
|
41
|
+
footnotes?: string | undefined;
|
|
40
42
|
}, {
|
|
41
43
|
usage: string;
|
|
42
44
|
additional?: string | undefined;
|
|
43
45
|
explainer?: string | undefined;
|
|
46
|
+
footnotes?: string | undefined;
|
|
44
47
|
}>;
|
|
45
48
|
}, "strip", z.ZodTypeAny, {
|
|
46
49
|
readme: {
|
|
47
50
|
usage: string;
|
|
48
51
|
additional?: string | undefined;
|
|
49
52
|
explainer?: string | undefined;
|
|
53
|
+
footnotes?: string | undefined;
|
|
50
54
|
};
|
|
51
55
|
development?: string | undefined;
|
|
52
56
|
}, {
|
|
@@ -54,6 +58,7 @@ declare const base: bingo_stratum.Base<{
|
|
|
54
58
|
usage: string;
|
|
55
59
|
additional?: string | undefined;
|
|
56
60
|
explainer?: string | undefined;
|
|
61
|
+
footnotes?: string | undefined;
|
|
57
62
|
};
|
|
58
63
|
development?: string | undefined;
|
|
59
64
|
}>;
|
|
@@ -92,11 +97,11 @@ declare const base: bingo_stratum.Base<{
|
|
|
92
97
|
href: z.ZodString;
|
|
93
98
|
title: z.ZodString;
|
|
94
99
|
}, "strip", z.ZodTypeAny, {
|
|
95
|
-
href: string;
|
|
96
100
|
title: string;
|
|
97
|
-
}, {
|
|
98
101
|
href: string;
|
|
102
|
+
}, {
|
|
99
103
|
title: string;
|
|
104
|
+
href: string;
|
|
100
105
|
}>>;
|
|
101
106
|
keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
102
107
|
logo: z.ZodOptional<z.ZodObject<{
|
|
@@ -135,15 +140,15 @@ declare const base: bingo_stratum.Base<{
|
|
|
135
140
|
}, "strip", z.ZodTypeAny, {
|
|
136
141
|
dependencies?: Record<string, string> | undefined;
|
|
137
142
|
devDependencies?: Record<string, string> | undefined;
|
|
143
|
+
scripts?: Record<string, string> | undefined;
|
|
138
144
|
peerDependencies?: Record<string, string> | undefined;
|
|
139
145
|
peerDependenciesMeta?: Record<string, unknown> | undefined;
|
|
140
|
-
scripts?: Record<string, string> | undefined;
|
|
141
146
|
}, {
|
|
142
147
|
dependencies?: Record<string, string> | undefined;
|
|
143
148
|
devDependencies?: Record<string, string> | undefined;
|
|
149
|
+
scripts?: Record<string, string> | undefined;
|
|
144
150
|
peerDependencies?: Record<string, string> | undefined;
|
|
145
151
|
peerDependenciesMeta?: Record<string, unknown> | undefined;
|
|
146
|
-
scripts?: Record<string, string> | undefined;
|
|
147
152
|
}>>;
|
|
148
153
|
pnpm: z.ZodOptional<z.ZodString>;
|
|
149
154
|
repository: z.ZodString;
|
package/lib/base.js
CHANGED
|
@@ -30,6 +30,7 @@ import { readPackageData } from "./options/readPackageData.js";
|
|
|
30
30
|
import { readPnpm } from "./options/readPnpm.js";
|
|
31
31
|
import { readReadmeAdditional } from "./options/readReadmeAdditional.js";
|
|
32
32
|
import { readReadmeExplainer } from "./options/readReadmeExplainer.js";
|
|
33
|
+
import { readReadmeFootnotes } from "./options/readReadmeFootnotes.js";
|
|
33
34
|
import { readReadmeUsage } from "./options/readReadmeUsage.js";
|
|
34
35
|
import { readRepository } from "./options/readRepository.js";
|
|
35
36
|
import { readRulesetId } from "./options/readRulesetId.js";
|
|
@@ -125,6 +126,7 @@ const base = createBase({
|
|
|
125
126
|
getDevelopmentDocumentation,
|
|
126
127
|
getReadmeAdditional,
|
|
127
128
|
getReadmeExplainer,
|
|
129
|
+
getReadmeFootnotes,
|
|
128
130
|
getReadmeUsage
|
|
129
131
|
)
|
|
130
132
|
);
|
|
@@ -184,6 +186,9 @@ const base = createBase({
|
|
|
184
186
|
const getReadmeExplainer = lazyValue(
|
|
185
187
|
async () => await readReadmeExplainer(getReadme)
|
|
186
188
|
);
|
|
189
|
+
const getReadmeFootnotes = lazyValue(
|
|
190
|
+
async () => await readReadmeFootnotes(getReadme)
|
|
191
|
+
);
|
|
187
192
|
const getReadmeUsage = lazyValue(
|
|
188
193
|
async () => await readReadmeUsage(getEmoji, getReadme, getRepository)
|
|
189
194
|
);
|
|
@@ -2,7 +2,10 @@ import * as bingo_stratum from 'bingo-stratum';
|
|
|
2
2
|
|
|
3
3
|
declare const blockESLint: bingo_stratum.BlockWithAddons<{
|
|
4
4
|
imports: {
|
|
5
|
-
source: string
|
|
5
|
+
source: string | {
|
|
6
|
+
version: string;
|
|
7
|
+
packageName: string;
|
|
8
|
+
};
|
|
6
9
|
specifier: string;
|
|
7
10
|
types?: boolean | undefined;
|
|
8
11
|
}[];
|
|
@@ -35,6 +38,7 @@ declare const blockESLint: bingo_stratum.BlockWithAddons<{
|
|
|
35
38
|
usage: string;
|
|
36
39
|
additional?: string | undefined;
|
|
37
40
|
explainer?: string | undefined;
|
|
41
|
+
footnotes?: string | undefined;
|
|
38
42
|
};
|
|
39
43
|
development?: string | undefined;
|
|
40
44
|
};
|
|
@@ -43,7 +43,10 @@ const zExtension = z.object({
|
|
|
43
43
|
settings: z.record(z.string(), z.unknown()).optional()
|
|
44
44
|
});
|
|
45
45
|
const zPackageImport = z.object({
|
|
46
|
-
source: z.
|
|
46
|
+
source: z.union([
|
|
47
|
+
z.string(),
|
|
48
|
+
z.object({ packageName: z.string(), version: z.string() })
|
|
49
|
+
]),
|
|
47
50
|
specifier: z.string(),
|
|
48
51
|
types: z.boolean().optional()
|
|
49
52
|
});
|
|
@@ -72,7 +75,7 @@ ${explanation2}
|
|
|
72
75
|
'import eslint from "@eslint/js";',
|
|
73
76
|
'import tseslint from "typescript-eslint";',
|
|
74
77
|
...imports.map(
|
|
75
|
-
(packageImport) => `import ${packageImport.specifier} from "${packageImport.source}"`
|
|
78
|
+
(packageImport) => `import ${packageImport.specifier} from "${typeof packageImport.source === "string" ? packageImport.source : packageImport.source.packageName}"`
|
|
76
79
|
)
|
|
77
80
|
].sort(
|
|
78
81
|
(a, b) => a.replace(/.+from/, "").localeCompare(b.replace(/.+from/, ""))
|
|
@@ -154,16 +157,26 @@ Each should be shown in VS Code, and can be run manually on the command-line:
|
|
|
154
157
|
}),
|
|
155
158
|
blockPackageJson({
|
|
156
159
|
properties: {
|
|
157
|
-
devDependencies:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
devDependencies: {
|
|
161
|
+
...getPackageDependencies(
|
|
162
|
+
"@eslint/js",
|
|
163
|
+
"@types/node",
|
|
164
|
+
"eslint",
|
|
165
|
+
"typescript-eslint",
|
|
166
|
+
...imports.filter((imported) => typeof imported.source === "string").flatMap(({ source, types }) => {
|
|
167
|
+
const { name } = parsePackageName(source);
|
|
168
|
+
return types ? [name, `@types/${name}`] : [name];
|
|
169
|
+
})
|
|
170
|
+
),
|
|
171
|
+
...Object.fromEntries(
|
|
172
|
+
imports.filter(
|
|
173
|
+
(imported) => typeof imported.source === "object"
|
|
174
|
+
).map((imported) => [
|
|
175
|
+
imported.source.packageName,
|
|
176
|
+
imported.source.version
|
|
177
|
+
])
|
|
178
|
+
)
|
|
179
|
+
},
|
|
167
180
|
scripts: {
|
|
168
181
|
lint: "eslint . --max-warnings 0"
|
|
169
182
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as bingo_stratum from 'bingo-stratum';
|
|
2
|
+
|
|
3
|
+
declare const blockESLintPlugin: bingo_stratum.BlockWithoutAddons<{
|
|
4
|
+
access: "public" | "restricted";
|
|
5
|
+
description: string;
|
|
6
|
+
directory: string;
|
|
7
|
+
documentation: {
|
|
8
|
+
readme: {
|
|
9
|
+
usage: string;
|
|
10
|
+
additional?: string | undefined;
|
|
11
|
+
explainer?: string | undefined;
|
|
12
|
+
footnotes?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
development?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
email: {
|
|
17
|
+
github: string;
|
|
18
|
+
npm: string;
|
|
19
|
+
};
|
|
20
|
+
title: string;
|
|
21
|
+
node: {
|
|
22
|
+
minimum: string;
|
|
23
|
+
pinned?: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
owner: string;
|
|
26
|
+
repository: string;
|
|
27
|
+
type?: "commonjs" | "module" | undefined;
|
|
28
|
+
author?: string | undefined;
|
|
29
|
+
bin?: string | Record<string, string> | undefined;
|
|
30
|
+
contributors?: {
|
|
31
|
+
avatar_url: string;
|
|
32
|
+
contributions: string[];
|
|
33
|
+
login: string;
|
|
34
|
+
name: string;
|
|
35
|
+
profile: string;
|
|
36
|
+
}[] | undefined;
|
|
37
|
+
emoji?: string | undefined;
|
|
38
|
+
existingLabels?: {
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
color: string;
|
|
42
|
+
}[] | undefined;
|
|
43
|
+
funding?: string | undefined;
|
|
44
|
+
guide?: {
|
|
45
|
+
href: string;
|
|
46
|
+
title: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
keywords?: string[] | undefined;
|
|
49
|
+
logo?: {
|
|
50
|
+
alt: string;
|
|
51
|
+
src: string;
|
|
52
|
+
height?: number | undefined;
|
|
53
|
+
width?: number | undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
packageData?: {
|
|
56
|
+
dependencies?: Record<string, string> | undefined;
|
|
57
|
+
devDependencies?: Record<string, string> | undefined;
|
|
58
|
+
peerDependencies?: Record<string, string> | undefined;
|
|
59
|
+
peerDependenciesMeta?: Record<string, unknown> | undefined;
|
|
60
|
+
scripts?: Record<string, string> | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
pnpm?: string | undefined;
|
|
63
|
+
rulesetId?: string | undefined;
|
|
64
|
+
version?: string | undefined;
|
|
65
|
+
words?: string[] | undefined;
|
|
66
|
+
workflowsVersions?: Record<string, Record<string, {
|
|
67
|
+
pinned?: boolean | undefined;
|
|
68
|
+
hash?: string | undefined;
|
|
69
|
+
}>> | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
|
|
72
|
+
export { blockESLintPlugin };
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { base } from "../base.js";
|
|
2
|
+
import { blockCSpell } from "./blockCSpell.js";
|
|
3
|
+
import { blockDevelopmentDocs } from "./blockDevelopmentDocs.js";
|
|
4
|
+
import { blockESLint } from "./blockESLint.js";
|
|
5
|
+
import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
|
|
6
|
+
import { blockPackageJson } from "./blockPackageJson.js";
|
|
7
|
+
import { blockVitest } from "./blockVitest.js";
|
|
8
|
+
const blockESLintPlugin = base.createBlock({
|
|
9
|
+
about: {
|
|
10
|
+
name: "ESLint Plugin"
|
|
11
|
+
},
|
|
12
|
+
produce() {
|
|
13
|
+
return {
|
|
14
|
+
addons: [
|
|
15
|
+
blockCSpell({
|
|
16
|
+
words: ["eslint-doc-generatorrc.js"]
|
|
17
|
+
}),
|
|
18
|
+
blockDevelopmentDocs({
|
|
19
|
+
sections: {
|
|
20
|
+
Building: {
|
|
21
|
+
innerSections: [
|
|
22
|
+
{
|
|
23
|
+
contents: `
|
|
24
|
+
Run [\`eslint-doc-generator\`](https://github.com/bmish/eslint-doc-generator) to generate Markdown files documenting rules.
|
|
25
|
+
|
|
26
|
+
\`\`\`shell
|
|
27
|
+
pnpm build:docs
|
|
28
|
+
\`\`\`
|
|
29
|
+
`,
|
|
30
|
+
heading: "Building Docs"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
Linting: {
|
|
35
|
+
contents: {
|
|
36
|
+
items: [
|
|
37
|
+
`- \`pnpm lint:docs\` ([eslint-doc-generator](https://github.com/bmish/eslint-doc-generator)): Generates and validates documentation for ESLint rules`
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
blockESLint({
|
|
44
|
+
extensions: ['eslintPlugin.configs["flat/recommended"]'],
|
|
45
|
+
ignores: [".eslint-doc-generatorrc.js", "docs/rules/*/*.ts"],
|
|
46
|
+
imports: [
|
|
47
|
+
{
|
|
48
|
+
source: {
|
|
49
|
+
packageName: "eslint-plugin-eslint-plugin",
|
|
50
|
+
version: "6.4.0"
|
|
51
|
+
},
|
|
52
|
+
specifier: "eslintPlugin"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}),
|
|
56
|
+
blockGitHubActionsCI({
|
|
57
|
+
jobs: [
|
|
58
|
+
{
|
|
59
|
+
name: "Lint Docs",
|
|
60
|
+
steps: [
|
|
61
|
+
{ run: "pnpm build || exit 0" },
|
|
62
|
+
{ run: "pnpm lint:docs" }
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}),
|
|
67
|
+
blockPackageJson({
|
|
68
|
+
properties: {
|
|
69
|
+
devDependencies: {
|
|
70
|
+
"eslint-doc-generator": "2.1.0",
|
|
71
|
+
"eslint-plugin-eslint-plugin": "6.4.0"
|
|
72
|
+
},
|
|
73
|
+
peerDependencies: {
|
|
74
|
+
"@typescript-eslint/parser": ">=8",
|
|
75
|
+
eslint: ">=9",
|
|
76
|
+
typescript: ">=5"
|
|
77
|
+
},
|
|
78
|
+
scripts: {
|
|
79
|
+
"build:docs": "eslint-doc-generator",
|
|
80
|
+
"lint:docs": "eslint-doc-generator --check"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
blockVitest({
|
|
85
|
+
coverage: {
|
|
86
|
+
exclude: ["src/index.ts", "src/rules/index.ts"]
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
],
|
|
90
|
+
files: {
|
|
91
|
+
".eslint-doc-generatorrc.js": `import prettier from "prettier";
|
|
92
|
+
|
|
93
|
+
/** @type {import('eslint-doc-generator').GenerateOptions} */
|
|
94
|
+
const config = {
|
|
95
|
+
postprocess: async (content, path) =>
|
|
96
|
+
prettier.format(content, {
|
|
97
|
+
...(await prettier.resolveConfig(path)),
|
|
98
|
+
parser: "markdown",
|
|
99
|
+
}),
|
|
100
|
+
ruleDocTitleFormat: "prefix-name",
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default config;
|
|
104
|
+
`
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
setup({ options }) {
|
|
109
|
+
const pluginName = options.repository.replace("eslint-plugin-", "");
|
|
110
|
+
return {
|
|
111
|
+
files: {
|
|
112
|
+
src: {
|
|
113
|
+
"index.ts": `import Module from "node:module";
|
|
114
|
+
|
|
115
|
+
import { rules } from "./rules/index.js";
|
|
116
|
+
|
|
117
|
+
const require = Module.createRequire(import.meta.url);
|
|
118
|
+
|
|
119
|
+
const { name, version } =
|
|
120
|
+
// \`import\`ing here would bypass the TSConfig's \`"rootDir": "src"\`
|
|
121
|
+
require("../package.json") as typeof import("../package.json");
|
|
122
|
+
|
|
123
|
+
export const plugin = {
|
|
124
|
+
configs: {
|
|
125
|
+
get recommended() {
|
|
126
|
+
return recommended;
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
meta: { name, version },
|
|
130
|
+
rules,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const recommended = {
|
|
134
|
+
plugins: {
|
|
135
|
+
"${pluginName}": plugin,
|
|
136
|
+
},
|
|
137
|
+
rules: Object.fromEntries(
|
|
138
|
+
Object.keys(rules).map((rule) => [\`${pluginName}/\${rule}\`, "error"]),
|
|
139
|
+
),
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export { rules };
|
|
143
|
+
|
|
144
|
+
export default plugin;
|
|
145
|
+
`,
|
|
146
|
+
rules: {
|
|
147
|
+
"example.test.ts": `import { rule } from "./enums.js";
|
|
148
|
+
import { ruleTester } from "./ruleTester.js";
|
|
149
|
+
|
|
150
|
+
ruleTester.run("enums", rule, {
|
|
151
|
+
invalid: [
|
|
152
|
+
{
|
|
153
|
+
code: \`enum Values {}\`,
|
|
154
|
+
errors: [
|
|
155
|
+
{
|
|
156
|
+
column: 1,
|
|
157
|
+
endColumn: 15,
|
|
158
|
+
endLine: 1,
|
|
159
|
+
line: 1,
|
|
160
|
+
messageId: "enum",
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
valid: [\`const Values = {};\`, \`const Values = {} as const;\`],
|
|
166
|
+
});
|
|
167
|
+
`,
|
|
168
|
+
"example.ts": `import { createRule } from "../utils.js";
|
|
169
|
+
|
|
170
|
+
export const rule = createRule({
|
|
171
|
+
create(context) {
|
|
172
|
+
return {
|
|
173
|
+
TSEnumDeclaration(node) {
|
|
174
|
+
context.report({
|
|
175
|
+
messageId: "enum",
|
|
176
|
+
node,
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
defaultOptions: [],
|
|
182
|
+
meta: {
|
|
183
|
+
docs: {
|
|
184
|
+
description: "Avoid using TypeScript's enums.",
|
|
185
|
+
},
|
|
186
|
+
messages: {
|
|
187
|
+
enum: "This enum will not be allowed under TypeScript's --erasableSyntaxOnly.",
|
|
188
|
+
},
|
|
189
|
+
schema: [],
|
|
190
|
+
type: "problem",
|
|
191
|
+
},
|
|
192
|
+
name: "enums",
|
|
193
|
+
});
|
|
194
|
+
`,
|
|
195
|
+
"index.ts": `import { rule as example } from "./example.js";
|
|
196
|
+
|
|
197
|
+
export const rules = {
|
|
198
|
+
example,
|
|
199
|
+
};
|
|
200
|
+
`,
|
|
201
|
+
"ruleTester.ts": `import { RuleTester } from "@typescript-eslint/rule-tester";
|
|
202
|
+
import * as vitest from "vitest";
|
|
203
|
+
|
|
204
|
+
RuleTester.afterAll = vitest.afterAll;
|
|
205
|
+
RuleTester.it = vitest.it;
|
|
206
|
+
RuleTester.itOnly = vitest.it.only;
|
|
207
|
+
RuleTester.describe = vitest.describe;
|
|
208
|
+
|
|
209
|
+
export const ruleTester = new RuleTester();
|
|
210
|
+
`
|
|
211
|
+
},
|
|
212
|
+
"utils.ts": `import { ESLintUtils } from "@typescript-eslint/utils";
|
|
213
|
+
|
|
214
|
+
export const createRule = ESLintUtils.RuleCreator(
|
|
215
|
+
(name) =>
|
|
216
|
+
\`https://github.com/${options.owner}/${options.repository}/blob/main/docs/rules/\${name}.md\`,
|
|
217
|
+
);
|
|
218
|
+
`
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
export {
|
|
225
|
+
blockESLintPlugin
|
|
226
|
+
};
|