Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs] use
markdown-magic
to automatically sort all rules alphabeti…
…cally To make it easier to find rules. This adds a script to auto-generate the list of rules and embeds special tags to README. Usage: $ npm run generate-list-of-rules Check whether the auto-generated changes are committed: $ npm run generate-list-of-rules:check Use `markdown-magic` package to transform README https://www.npmjs.com/package/markdown-magic
- Loading branch information
1 parent
45b9d32
commit 182b045
Showing
5 changed files
with
94 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const {rules} = require('./index'); | ||
|
||
const ruleListItems = Object.keys(rules) | ||
.sort() | ||
.map((id) => { | ||
const {meta} = rules[id]; | ||
const {fixable, docs} = meta; | ||
return `* [react/${id}](docs/rules/${id}.md): ${docs.description}${fixable ? ' (fixable)' : ''}`; | ||
}); | ||
|
||
const BASIC_RULES = () => ruleListItems.filter(rule => !rule.includes('react/jsx-')).join('\n'); | ||
const JSX_RULES = () => ruleListItems.filter(rule => rule.includes('react/jsx-')).join('\n'); | ||
|
||
module.exports = { | ||
transforms: { | ||
BASIC_RULES, | ||
JSX_RULES | ||
}, | ||
callback: () => { | ||
// eslint-disable-next-line no-console | ||
console.log('The auto-generating of rules finished!'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters