Skip to content

Commit afc398b

Browse files
fix: corrected setup for blockESLintPlugin (#2196)
## PR Checklist - [x] Addresses an existing open issue: fixes #2195 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Switches the default `README.md` usage to a `defaultUsage` Addon, then pipes `blockTypeScript`'s example files through `blockExample`. That way `--exclude-example-files` gets them out of the way so that `--add-eslint-plugin` can swap in the eslint-doc-generator table. 🎁
1 parent 6062f49 commit afc398b

14 files changed

+357
-123
lines changed

Diff for: src/base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export const base = createBase({
289289
);
290290

291291
const getReadmeUsage = lazyValue(
292-
async () => await readReadmeUsage(getEmoji, getReadme, getRepository),
292+
async () => await readReadmeUsage(getReadme),
293293
);
294294

295295
const getRepository = lazyValue(

Diff for: src/blocks/blockESLintPlugin.test.ts

+184-4
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,41 @@ describe("blockESLintPlugin", () => {
8888
},
8989
"block": [Function],
9090
},
91+
{
92+
"addons": {
93+
"defaultUsage": [
94+
"Add this plugin to the list of plugins in your [ESLint configuration file](https://eslint.org/docs/latest/use/configure/configuration-files):
95+
96+
\`\`\`shell
97+
npm i test-repository -D
98+
\`\`\`
99+
100+
\`\`\`ts
101+
import testRepository from "test-repository";
102+
103+
export default [
104+
// (other plugins)
105+
testRepository.configs.recommended, // 👈
106+
];
107+
\`\`\`
108+
109+
### Rules
110+
111+
These are all set to \`"error"\` in the recommended config:
112+
113+
<!-- begin auto-generated rules list --><!-- end auto-generated rules list -->",
114+
],
115+
},
116+
"block": [Function],
117+
},
91118
{
92119
"addons": {
93120
"properties": {
121+
"dependencies": {
122+
"@typescript-eslint/utils": "^8.29.0",
123+
},
94124
"devDependencies": {
125+
"@typescript-eslint/rule-tester": "8.29.1",
95126
"eslint-doc-generator": "2.1.0",
96127
"eslint-plugin-eslint-plugin": "6.4.0",
97128
},
@@ -131,6 +162,20 @@ describe("blockESLintPlugin", () => {
131162
export default config;
132163
",
133164
},
165+
"scripts": [
166+
{
167+
"commands": [
168+
"pnpm build",
169+
],
170+
"phase": 2,
171+
},
172+
{
173+
"commands": [
174+
"pnpm eslint-doc-generator --init-rule-docs",
175+
],
176+
"phase": 3,
177+
},
178+
],
134179
}
135180
`);
136181
});
@@ -221,10 +266,41 @@ describe("blockESLintPlugin", () => {
221266
},
222267
"block": [Function],
223268
},
269+
{
270+
"addons": {
271+
"defaultUsage": [
272+
"Add this plugin to the list of plugins in your [ESLint configuration file](https://eslint.org/docs/latest/use/configure/configuration-files):
273+
274+
\`\`\`shell
275+
npm i test-repository -D
276+
\`\`\`
277+
278+
\`\`\`ts
279+
import testRepository from "test-repository";
280+
281+
export default [
282+
// (other plugins)
283+
testRepository.configs.recommended, // 👈
284+
];
285+
\`\`\`
286+
287+
### Rules
288+
289+
These are all set to \`"error"\` in the recommended config:
290+
291+
<!-- begin auto-generated rules list --><!-- end auto-generated rules list -->",
292+
],
293+
},
294+
"block": [Function],
295+
},
224296
{
225297
"addons": {
226298
"properties": {
299+
"dependencies": {
300+
"@typescript-eslint/utils": "^8.29.0",
301+
},
227302
"devDependencies": {
303+
"@typescript-eslint/rule-tester": "8.29.1",
228304
"eslint-doc-generator": "2.1.0",
229305
"eslint-plugin-eslint-plugin": "6.4.0",
230306
},
@@ -264,6 +340,20 @@ describe("blockESLintPlugin", () => {
264340
export default config;
265341
",
266342
},
343+
"scripts": [
344+
{
345+
"commands": [
346+
"pnpm build",
347+
],
348+
"phase": 2,
349+
},
350+
{
351+
"commands": [
352+
"pnpm eslint-doc-generator --init-rule-docs",
353+
],
354+
"phase": 3,
355+
},
356+
],
267357
}
268358
`);
269359
});
@@ -352,10 +442,41 @@ describe("blockESLintPlugin", () => {
352442
},
353443
"block": [Function],
354444
},
445+
{
446+
"addons": {
447+
"defaultUsage": [
448+
"Add this plugin to the list of plugins in your [ESLint configuration file](https://eslint.org/docs/latest/use/configure/configuration-files):
449+
450+
\`\`\`shell
451+
npm i test-repository -D
452+
\`\`\`
453+
454+
\`\`\`ts
455+
import testRepository from "test-repository";
456+
457+
export default [
458+
// (other plugins)
459+
testRepository.configs.recommended, // 👈
460+
];
461+
\`\`\`
462+
463+
### Rules
464+
465+
These are all set to \`"error"\` in the recommended config:
466+
467+
<!-- begin auto-generated rules list --><!-- end auto-generated rules list -->",
468+
],
469+
},
470+
"block": [Function],
471+
},
355472
{
356473
"addons": {
357474
"properties": {
475+
"dependencies": {
476+
"@typescript-eslint/utils": "^8.29.0",
477+
},
358478
"devDependencies": {
479+
"@typescript-eslint/rule-tester": "8.29.1",
359480
"eslint-doc-generator": "2.1.0",
360481
"eslint-plugin-eslint-plugin": "6.4.0",
361482
},
@@ -429,7 +550,7 @@ describe("blockESLintPlugin", () => {
429550
export default plugin;
430551
",
431552
"rules": {
432-
"example.test.ts": "import { rule } from "./enums.js";
553+
"enums.test.ts": "import { rule } from "./enums.js";
433554
import { ruleTester } from "./ruleTester.js";
434555
435556
ruleTester.run("enums", rule, {
@@ -450,7 +571,7 @@ describe("blockESLintPlugin", () => {
450571
valid: [\`const Values = {};\`, \`const Values = {} as const;\`],
451572
});
452573
",
453-
"example.ts": "import { createRule } from "../utils.js";
574+
"enums.ts": "import { createRule } from "../utils.js";
454575
455576
export const rule = createRule({
456577
create(context) {
@@ -477,10 +598,10 @@ describe("blockESLintPlugin", () => {
477598
name: "enums",
478599
});
479600
",
480-
"index.ts": "import { rule as example } from "./example.js";
601+
"index.ts": "import { rule as enums } from "./enums.js";
481602
482603
export const rules = {
483-
example,
604+
enums,
484605
};
485606
",
486607
"ruleTester.ts": "import { RuleTester } from "@typescript-eslint/rule-tester";
@@ -503,6 +624,20 @@ describe("blockESLintPlugin", () => {
503624
",
504625
},
505626
},
627+
"scripts": [
628+
{
629+
"commands": [
630+
"pnpm build",
631+
],
632+
"phase": 2,
633+
},
634+
{
635+
"commands": [
636+
"pnpm eslint-doc-generator --init-rule-docs",
637+
],
638+
"phase": 3,
639+
},
640+
],
506641
}
507642
`);
508643
});
@@ -596,10 +731,41 @@ describe("blockESLintPlugin", () => {
596731
},
597732
"block": [Function],
598733
},
734+
{
735+
"addons": {
736+
"defaultUsage": [
737+
"Add this plugin to the list of plugins in your [ESLint configuration file](https://eslint.org/docs/latest/use/configure/configuration-files):
738+
739+
\`\`\`shell
740+
npm i test-repository -D
741+
\`\`\`
742+
743+
\`\`\`ts
744+
import testRepository from "test-repository";
745+
746+
export default [
747+
// (other plugins)
748+
testRepository.configs.recommended, // 👈
749+
];
750+
\`\`\`
751+
752+
### Rules
753+
754+
These are all set to \`"error"\` in the recommended config:
755+
756+
<!-- begin auto-generated rules list --><!-- end auto-generated rules list -->",
757+
],
758+
},
759+
"block": [Function],
760+
},
599761
{
600762
"addons": {
601763
"properties": {
764+
"dependencies": {
765+
"@typescript-eslint/utils": "^8.29.0",
766+
},
602767
"devDependencies": {
768+
"@typescript-eslint/rule-tester": "8.29.1",
603769
"eslint-doc-generator": "2.1.0",
604770
"eslint-plugin-eslint-plugin": "6.4.0",
605771
},
@@ -640,6 +806,20 @@ describe("blockESLintPlugin", () => {
640806
export default config;
641807
",
642808
},
809+
"scripts": [
810+
{
811+
"commands": [
812+
"pnpm build",
813+
],
814+
"phase": 2,
815+
},
816+
{
817+
"commands": [
818+
"pnpm eslint-doc-generator --init-rule-docs",
819+
],
820+
"phase": 3,
821+
},
822+
],
643823
}
644824
`);
645825
});

0 commit comments

Comments
 (0)