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

feat(website): add warning on top of formatting rule docs pages #5598

Merged
Changes from 2 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
25 changes: 20 additions & 5 deletions packages/website/plugins/generated-rule-docs.ts
Expand Up @@ -65,7 +65,22 @@ export const generatedRuleDocs: Plugin = () => {
type: 'blockquote',
} as mdast.Blockquote);

// 3. Add a rule attributes list...
// 3. Add a notice about formatting rules being 🤢
if (meta.type === 'layout') {
const warningNode = {
value: `
<admonition type="warning">
We strongly recommend you do not use this rule or any other formatting linter rules.
Use a separate dedicated formatter instead.
See <a href="/docs/linting/troubleshooting/formatting">What About Formatting?</a> for more information.
</admonition>
`,
type: 'jsx',
};
parent.children.unshift(warningNode);
}

// 4. Add a rule attributes list...
const attributesH2Index =
// ...before the first h2, if it exists...
parent.children.findIndex(
Expand All @@ -81,7 +96,7 @@ export const generatedRuleDocs: Plugin = () => {
};
parent.children.splice(attributesH2Index, 0, attributesNode);

// 4. Make sure the appropriate headers exist to place content under
// 5. Make sure the appropriate headers exist to place content under
const [howToUseH2Index, optionsH2Index] = ((): [number, number] => {
let howToUseH2Index = parent.children.findIndex(
createH2TextFilter('How to Use'),
Expand Down Expand Up @@ -149,7 +164,7 @@ export const generatedRuleDocs: Plugin = () => {
return [howToUseH2Index, optionsH2Index];
})();

// 5. Add a description of how to use / options for the rule
// 6. Add a description of how to use / options for the rule
const optionLevel = meta.docs.recommended === 'error' ? 'error' : 'warn';

if (meta.docs.extendsBaseRule) {
Expand Down Expand Up @@ -279,7 +294,7 @@ export const generatedRuleDocs: Plugin = () => {
}
}

// 6. Add a notice about coming from ESLint core for extension rules
// 7. Add a notice about coming from ESLint core for extension rules
if (meta.docs.extendsBaseRule) {
parent.children.push({
children: [
Expand Down Expand Up @@ -311,7 +326,7 @@ export const generatedRuleDocs: Plugin = () => {
} as mdast.Paragraph);
}

// 7. Also add a link to view the rule's source and test code
// 8. Also add a link to view the rule's source and test code
parent.children.push(
{
children: [
Expand Down