From d53d9064b9dd0dd6a8ea39e07b16310c8364db69 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Thu, 29 Jul 2021 11:09:42 -0700 Subject: [PATCH] Docs: Prepare data for website to indicate rules with suggestions (#14830) Co-authored-by: Milos Djermanovic --- Makefile.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile.js b/Makefile.js index 62b1d76669f..6d1ee39198e 100644 --- a/Makefile.js +++ b/Makefile.js @@ -197,7 +197,8 @@ function generateRuleIndexPage() { name: basename, description: rule.meta.docs.description, recommended: rule.meta.docs.recommended || false, - fixable: !!rule.meta.fixable + fixable: !!rule.meta.fixable, + hasSuggestions: !!rule.meta.docs.suggestion }, category = categoriesData.categories.find(c => c.name === rule.meta.docs.category); @@ -640,6 +641,7 @@ target.gensite = function(prereleaseVersion) { const RECOMMENDED_TEXT = "\n\n(recommended) The `\"extends\": \"eslint:recommended\"` property in a configuration file enables this rule."; const FIXABLE_TEXT = "\n\n(fixable) The `--fix` option on the [command line](../user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule."; + const HAS_SUGGESTIONS_TEXT = "\n\n(hasSuggestions) Some problems reported by this rule are manually fixable by editor [suggestions](../developer-guide/working-with-rules#providing-suggestions)."; // 4. Loop through all files in temporary directory process.stdout.write("> Updating files (Steps 4-9): 0/... - ...\r"); @@ -669,13 +671,14 @@ target.gensite = function(prereleaseVersion) { const rule = rules.get(ruleName); const isRecommended = rule && rule.meta.docs.recommended; const isFixable = rule && rule.meta.fixable; + const hasSuggestions = rule && rule.meta.docs.suggestion; // Incorporate the special portion into the documentation content const textSplit = text.split("\n"); const ruleHeading = textSplit[0]; const ruleDocsContent = textSplit.slice(1).join("\n"); - text = `${ruleHeading}${isRecommended ? RECOMMENDED_TEXT : ""}${isFixable ? FIXABLE_TEXT : ""}\n${ruleDocsContent}`; + text = `${ruleHeading}${isRecommended ? RECOMMENDED_TEXT : ""}${isFixable ? FIXABLE_TEXT : ""}${hasSuggestions ? HAS_SUGGESTIONS_TEXT : ""}\n${ruleDocsContent}`; title = `${ruleName} - Rules`; if (rule && rule.meta) {