Skip to content

Commit 4f3b211

Browse files
fix: correct blockESLintPlugin peerDependencies and config file name (#2138)
## PR Checklist - [x] Addresses an existing open issue: fixes #2134, #2137 - [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 🎁
1 parent 1a97d1f commit 4f3b211

File tree

3 files changed

+143
-23
lines changed

3 files changed

+143
-23
lines changed

cspell.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"attw",
1616
"boop",
1717
"dbaeumer",
18-
"eslint-doc-generatorrc.js",
18+
"eslint-doc-generatorrc",
1919
"infile",
2020
"joshuakgoldberg",
2121
"markdownlintignore",

src/blocks/blockESLintPlugin.test.ts

+136-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { blockESLintPlugin } from "./blockESLintPlugin.js";
55
import { optionsBase } from "./options.fakes.js";
66

77
describe("blockESLintPlugin", () => {
8-
test("without mode", () => {
8+
test("without options or mode", () => {
99
const creation = testBlock(blockESLintPlugin, {
1010
options: optionsBase,
1111
});
@@ -16,7 +16,7 @@ describe("blockESLintPlugin", () => {
1616
{
1717
"addons": {
1818
"words": [
19-
"eslint-doc-generatorrc.js",
19+
"eslint-doc-generatorrc",
2020
],
2121
},
2222
"block": [Function],
@@ -95,11 +95,6 @@ describe("blockESLintPlugin", () => {
9595
"eslint-doc-generator": "2.1.0",
9696
"eslint-plugin-eslint-plugin": "6.4.0",
9797
},
98-
"peerDependencies": {
99-
"@typescript-eslint/parser": ">=8",
100-
"eslint": ">=9",
101-
"typescript": ">=5",
102-
},
10398
"scripts": {
10499
"build:docs": "eslint-doc-generator",
105100
"lint:docs": "eslint-doc-generator --check",
@@ -140,6 +135,139 @@ describe("blockESLintPlugin", () => {
140135
`);
141136
});
142137

138+
test("with options.type set to commonjs", () => {
139+
const creation = testBlock(blockESLintPlugin, {
140+
options: {
141+
...optionsBase,
142+
type: "commonjs",
143+
},
144+
});
145+
146+
expect(creation).toMatchInlineSnapshot(`
147+
{
148+
"addons": [
149+
{
150+
"addons": {
151+
"words": [
152+
"eslint-doc-generatorrc",
153+
],
154+
},
155+
"block": [Function],
156+
},
157+
{
158+
"addons": {
159+
"sections": {
160+
"Building": {
161+
"innerSections": [
162+
{
163+
"contents": "
164+
Run [\`eslint-doc-generator\`](https://github.com/bmish/eslint-doc-generator) to generate Markdown files documenting rules.
165+
166+
\`\`\`shell
167+
pnpm build:docs
168+
\`\`\`
169+
",
170+
"heading": "Building Docs",
171+
},
172+
],
173+
},
174+
"Linting": {
175+
"contents": {
176+
"items": [
177+
"- \`pnpm lint:docs\` ([eslint-doc-generator](https://github.com/bmish/eslint-doc-generator)): Generates and validates documentation for ESLint rules",
178+
],
179+
},
180+
},
181+
},
182+
},
183+
"block": [Function],
184+
},
185+
{
186+
"addons": {
187+
"extensions": [
188+
"eslintPlugin.configs["flat/recommended"]",
189+
],
190+
"ignores": [
191+
".eslint-doc-generatorrc.mjs",
192+
"docs/rules/*/*.ts",
193+
],
194+
"imports": [
195+
{
196+
"source": {
197+
"packageName": "eslint-plugin-eslint-plugin",
198+
"version": "6.4.0",
199+
},
200+
"specifier": "eslintPlugin",
201+
},
202+
],
203+
},
204+
"block": [Function],
205+
},
206+
{
207+
"addons": {
208+
"jobs": [
209+
{
210+
"name": "Lint Docs",
211+
"steps": [
212+
{
213+
"run": "pnpm build || exit 0",
214+
},
215+
{
216+
"run": "pnpm lint:docs",
217+
},
218+
],
219+
},
220+
],
221+
},
222+
"block": [Function],
223+
},
224+
{
225+
"addons": {
226+
"properties": {
227+
"devDependencies": {
228+
"eslint-doc-generator": "2.1.0",
229+
"eslint-plugin-eslint-plugin": "6.4.0",
230+
},
231+
"scripts": {
232+
"build:docs": "eslint-doc-generator",
233+
"lint:docs": "eslint-doc-generator --check",
234+
},
235+
},
236+
},
237+
"block": [Function],
238+
},
239+
{
240+
"addons": {
241+
"coverage": {
242+
"exclude": [
243+
"src/index.ts",
244+
"src/rules/index.ts",
245+
],
246+
},
247+
},
248+
"block": [Function],
249+
},
250+
],
251+
"files": {
252+
".eslint-doc-generatorrc.mjs": "import prettier from "prettier";
253+
254+
/** @type {import('eslint-doc-generator').GenerateOptions} */
255+
const config = {
256+
postprocess: async (content, path) =>
257+
prettier.format(content, {
258+
...(await prettier.resolveConfig(path)),
259+
parser: "markdown",
260+
}),
261+
ruleDocTitleFormat: "prefix-name",
262+
};
263+
264+
export default config;
265+
",
266+
},
267+
}
268+
`);
269+
});
270+
143271
test("setup mode", () => {
144272
const creation = testBlock(blockESLintPlugin, {
145273
mode: "setup",
@@ -152,7 +280,7 @@ describe("blockESLintPlugin", () => {
152280
{
153281
"addons": {
154282
"words": [
155-
"eslint-doc-generatorrc.js",
283+
"eslint-doc-generatorrc",
156284
],
157285
},
158286
"block": [Function],
@@ -231,11 +359,6 @@ describe("blockESLintPlugin", () => {
231359
"eslint-doc-generator": "2.1.0",
232360
"eslint-plugin-eslint-plugin": "6.4.0",
233361
},
234-
"peerDependencies": {
235-
"@typescript-eslint/parser": ">=8",
236-
"eslint": ">=9",
237-
"typescript": ">=5",
238-
},
239362
"scripts": {
240363
"build:docs": "eslint-doc-generator",
241364
"lint:docs": "eslint-doc-generator --check",

src/blocks/blockESLintPlugin.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ export const blockESLintPlugin = base.createBlock({
1010
about: {
1111
name: "ESLint Plugin",
1212
},
13-
produce() {
13+
produce({ options }) {
14+
const configFileName = `.eslint-doc-generatorrc.${options.type === "commonjs" ? "mjs" : "js"}`;
15+
1416
return {
1517
addons: [
1618
blockCSpell({
17-
words: ["eslint-doc-generatorrc.js"],
19+
words: ["eslint-doc-generatorrc"],
1820
}),
1921
blockDevelopmentDocs({
2022
sections: {
@@ -43,7 +45,7 @@ pnpm build:docs
4345
}),
4446
blockESLint({
4547
extensions: ['eslintPlugin.configs["flat/recommended"]'],
46-
ignores: [".eslint-doc-generatorrc.js", "docs/rules/*/*.ts"],
48+
ignores: [configFileName, "docs/rules/*/*.ts"],
4749
imports: [
4850
{
4951
source: {
@@ -71,11 +73,6 @@ pnpm build:docs
7173
"eslint-doc-generator": "2.1.0",
7274
"eslint-plugin-eslint-plugin": "6.4.0",
7375
},
74-
peerDependencies: {
75-
"@typescript-eslint/parser": ">=8",
76-
eslint: ">=9",
77-
typescript: ">=5",
78-
},
7976
scripts: {
8077
"build:docs": "eslint-doc-generator",
8178
"lint:docs": "eslint-doc-generator --check",
@@ -89,7 +86,7 @@ pnpm build:docs
8986
}),
9087
],
9188
files: {
92-
".eslint-doc-generatorrc.js": `import prettier from "prettier";
89+
[configFileName]: `import prettier from "prettier";
9390
9491
/** @type {import('eslint-doc-generator').GenerateOptions} */
9592
const config = {

0 commit comments

Comments
 (0)