mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
The docs site is in a separate repo, but this gives us a semi-automated way to update the docs about our lint rules. The script generates markdown files from the rule definitions which we can then manually copy/paste into the docs site somewhere. In the future we can automate this fully.
33 lines
915 B
JavaScript
33 lines
915 B
JavaScript
const ReactCompiler = require('../packages/babel-plugin-react-compiler/dist');
|
|
|
|
const combinedRules = [
|
|
{
|
|
name: 'rules-of-hooks',
|
|
recommended: true,
|
|
description:
|
|
'Validates that components and hooks follow the [Rules of Hooks](https://react.dev/reference/rules/rules-of-hooks)',
|
|
},
|
|
{
|
|
name: 'exhaustive-deps',
|
|
recommended: true,
|
|
description:
|
|
'Validates that hooks which accept dependency arrays (`useMemo()`, `useCallback()`, `useEffect()`, etc) ' +
|
|
'list all referenced variables in their dependency array. Referencing a value without including it in the ' +
|
|
'dependency array can lead to stale UI or callbacks.',
|
|
},
|
|
...ReactCompiler.LintRules,
|
|
];
|
|
|
|
const printed = combinedRules
|
|
.filter(rule => rule.recommended)
|
|
.map(rule => {
|
|
return `
|
|
## \`react-hooks/${rule.name}\`
|
|
|
|
${rule.description}
|
|
`.trim();
|
|
})
|
|
.join('\n\n');
|
|
|
|
console.log(printed);
|