From 2ee963325a718be2d4abbfcf209e3b62b5f20cb9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 2 Jan 2023 11:28:46 -0500 Subject: [PATCH 1/2] chore(website): fix base rule source links forextended rules --- packages/website/plugins/generated-rule-docs.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts index 37bd4e02cc40..454b58caf2e0 100644 --- a/packages/website/plugins/generated-rule-docs.ts +++ b/packages/website/plugins/generated-rule-docs.ts @@ -313,7 +313,11 @@ export const generatedRuleDocs: Plugin = () => { { type: 'link', title: null, - url: `https://github.com/eslint/eslint/blob/main/docs/rules/${meta.docs.extendsBaseRule}.md`, + url: `https://github.com/eslint/eslint/blob/main/docs/rules/${ + meta.docs.extendsBaseRule === true + ? file.stem + : meta.docs.extendsBaseRule + }.md`, children: [ { type: 'text', From 369a01a54de742e42cf5481312651fadbb237c80 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 2 Jan 2023 11:53:35 -0500 Subject: [PATCH 2/2] Corrected and moved generated link --- .../website/plugins/generated-rule-docs.ts | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/packages/website/plugins/generated-rule-docs.ts b/packages/website/plugins/generated-rule-docs.ts index 454b58caf2e0..90f0b3fa6f70 100644 --- a/packages/website/plugins/generated-rule-docs.ts +++ b/packages/website/plugins/generated-rule-docs.ts @@ -298,43 +298,7 @@ export const generatedRuleDocs: Plugin = () => { } } - // 6. Add a notice about coming from ESLint core for extension rules - if (meta.docs.extendsBaseRule) { - root.children.push({ - children: [ - { - type: 'jsx', - value: '', - }, - { - type: 'text', - value: 'Taken with ❤️ ', - }, - { - type: 'link', - title: null, - url: `https://github.com/eslint/eslint/blob/main/docs/rules/${ - meta.docs.extendsBaseRule === true - ? file.stem - : meta.docs.extendsBaseRule - }.md`, - children: [ - { - type: 'text', - value: 'from ESLint core', - }, - ], - }, - { - type: 'jsx', - value: '', - }, - ], - type: 'paragraph', - } as mdast.Paragraph); - } - - // 7. Also add a link to view the rule's source and test code + // 6. Add a link to view the rule's source and test code root.children.push( { children: [ @@ -392,6 +356,42 @@ export const generatedRuleDocs: Plugin = () => { type: 'list', } as mdast.List, ); + + // 7. Also add a notice about coming from ESLint core for extension rules + if (meta.docs.extendsBaseRule) { + root.children.push({ + children: [ + { + type: 'jsx', + value: '', + }, + { + type: 'text', + value: 'Taken with ❤️ ', + }, + { + type: 'link', + title: null, + url: `https://github.com/eslint/eslint/blob/main/docs/src/rules/${ + meta.docs.extendsBaseRule === true + ? file.stem + : meta.docs.extendsBaseRule + }.md`, + children: [ + { + type: 'text', + value: 'from ESLint core', + }, + ], + }, + { + type: 'jsx', + value: '', + }, + ], + type: 'paragraph', + } as mdast.Paragraph); + } }; };