Skip to content

fix: correct blockESLintPlugin peerDependencies and config file name #2138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"attw",
"boop",
"dbaeumer",
"eslint-doc-generatorrc.js",
"eslint-doc-generatorrc",
"infile",
"joshuakgoldberg",
"markdownlintignore",
Expand Down
149 changes: 136 additions & 13 deletions src/blocks/blockESLintPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { blockESLintPlugin } from "./blockESLintPlugin.js";
import { optionsBase } from "./options.fakes.js";

describe("blockESLintPlugin", () => {
test("without mode", () => {
test("without options or mode", () => {
const creation = testBlock(blockESLintPlugin, {
options: optionsBase,
});
Expand All @@ -16,7 +16,7 @@ describe("blockESLintPlugin", () => {
{
"addons": {
"words": [
"eslint-doc-generatorrc.js",
"eslint-doc-generatorrc",
],
},
"block": [Function],
Expand Down Expand Up @@ -95,11 +95,6 @@ describe("blockESLintPlugin", () => {
"eslint-doc-generator": "2.1.0",
"eslint-plugin-eslint-plugin": "6.4.0",
},
"peerDependencies": {
"@typescript-eslint/parser": ">=8",
"eslint": ">=9",
"typescript": ">=5",
},
"scripts": {
"build:docs": "eslint-doc-generator",
"lint:docs": "eslint-doc-generator --check",
Expand Down Expand Up @@ -140,6 +135,139 @@ describe("blockESLintPlugin", () => {
`);
});

test("with options.type set to commonjs", () => {
const creation = testBlock(blockESLintPlugin, {
options: {
...optionsBase,
type: "commonjs",
},
});

expect(creation).toMatchInlineSnapshot(`
{
"addons": [
{
"addons": {
"words": [
"eslint-doc-generatorrc",
],
},
"block": [Function],
},
{
"addons": {
"sections": {
"Building": {
"innerSections": [
{
"contents": "
Run [\`eslint-doc-generator\`](https://github.com/bmish/eslint-doc-generator) to generate Markdown files documenting rules.

\`\`\`shell
pnpm build:docs
\`\`\`
",
"heading": "Building Docs",
},
],
},
"Linting": {
"contents": {
"items": [
"- \`pnpm lint:docs\` ([eslint-doc-generator](https://github.com/bmish/eslint-doc-generator)): Generates and validates documentation for ESLint rules",
],
},
},
},
},
"block": [Function],
},
{
"addons": {
"extensions": [
"eslintPlugin.configs["flat/recommended"]",
],
"ignores": [
".eslint-doc-generatorrc.mjs",
"docs/rules/*/*.ts",
],
"imports": [
{
"source": {
"packageName": "eslint-plugin-eslint-plugin",
"version": "6.4.0",
},
"specifier": "eslintPlugin",
},
],
},
"block": [Function],
},
{
"addons": {
"jobs": [
{
"name": "Lint Docs",
"steps": [
{
"run": "pnpm build || exit 0",
},
{
"run": "pnpm lint:docs",
},
],
},
],
},
"block": [Function],
},
{
"addons": {
"properties": {
"devDependencies": {
"eslint-doc-generator": "2.1.0",
"eslint-plugin-eslint-plugin": "6.4.0",
},
"scripts": {
"build:docs": "eslint-doc-generator",
"lint:docs": "eslint-doc-generator --check",
},
},
},
"block": [Function],
},
{
"addons": {
"coverage": {
"exclude": [
"src/index.ts",
"src/rules/index.ts",
],
},
},
"block": [Function],
},
],
"files": {
".eslint-doc-generatorrc.mjs": "import prettier from "prettier";

/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
postprocess: async (content, path) =>
prettier.format(content, {
...(await prettier.resolveConfig(path)),
parser: "markdown",
}),
ruleDocTitleFormat: "prefix-name",
};

export default config;
",
},
}
`);
});

test("setup mode", () => {
const creation = testBlock(blockESLintPlugin, {
mode: "setup",
Expand All @@ -152,7 +280,7 @@ describe("blockESLintPlugin", () => {
{
"addons": {
"words": [
"eslint-doc-generatorrc.js",
"eslint-doc-generatorrc",
],
},
"block": [Function],
Expand Down Expand Up @@ -231,11 +359,6 @@ describe("blockESLintPlugin", () => {
"eslint-doc-generator": "2.1.0",
"eslint-plugin-eslint-plugin": "6.4.0",
},
"peerDependencies": {
"@typescript-eslint/parser": ">=8",
"eslint": ">=9",
"typescript": ">=5",
},
"scripts": {
"build:docs": "eslint-doc-generator",
"lint:docs": "eslint-doc-generator --check",
Expand Down
15 changes: 6 additions & 9 deletions src/blocks/blockESLintPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ export const blockESLintPlugin = base.createBlock({
about: {
name: "ESLint Plugin",
},
produce() {
produce({ options }) {
const configFileName = `.eslint-doc-generatorrc.${options.type === "commonjs" ? "mjs" : "js"}`;

return {
addons: [
blockCSpell({
words: ["eslint-doc-generatorrc.js"],
words: ["eslint-doc-generatorrc"],
}),
blockDevelopmentDocs({
sections: {
Expand Down Expand Up @@ -43,7 +45,7 @@ pnpm build:docs
}),
blockESLint({
extensions: ['eslintPlugin.configs["flat/recommended"]'],
ignores: [".eslint-doc-generatorrc.js", "docs/rules/*/*.ts"],
ignores: [configFileName, "docs/rules/*/*.ts"],
imports: [
{
source: {
Expand Down Expand Up @@ -71,11 +73,6 @@ pnpm build:docs
"eslint-doc-generator": "2.1.0",
"eslint-plugin-eslint-plugin": "6.4.0",
},
peerDependencies: {
"@typescript-eslint/parser": ">=8",
eslint: ">=9",
typescript: ">=5",
},
scripts: {
"build:docs": "eslint-doc-generator",
"lint:docs": "eslint-doc-generator --check",
Expand All @@ -89,7 +86,7 @@ pnpm build:docs
}),
],
files: {
".eslint-doc-generatorrc.js": `import prettier from "prettier";
[configFileName]: `import prettier from "prettier";

/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
Expand Down