Skip to content
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

Docs: Prepare data for website to indicate rules with suggestions #14830

Merged
merged 3 commits into from Jul 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile.js
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: This is changing in v8.0.0. It will be meta.hasSuggestions. See #13398

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to link to #14573? I'll update that PR after this is merged to ensure this code refers to meta.hasSuggestions once that change takes place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works too. I was intending to point out that meta.docs.suggestions would be going away.

hasSuggestions: !!rule.meta.docs.suggestion
},
category = categoriesData.categories.find(c => c.name === rule.meta.docs.category);

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
bmish marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down