Skip to content

Commit ef4baa3

Browse files
committed
[compiler] Script to produce markdown of lint rule docs (facebook#34260)
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. DiffTrain build for [425ba0a](facebook@425ba0a)
1 parent 620f58b commit ef4baa3

36 files changed

+144
-107
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18001,14 +18001,20 @@ var ErrorCategory;
1800118001
ErrorCategory["Fire"] = "Fire";
1800218002
ErrorCategory["FBT"] = "FBT";
1800318003
})(ErrorCategory || (ErrorCategory = {}));
18004+
const RULE_NAME_PATTERN = /^[a-z]+(-[a-z]+)*$/;
1800418005
function getRuleForCategory(category) {
18006+
const rule = getRuleForCategoryImpl(category);
18007+
invariant(RULE_NAME_PATTERN.test(rule.name), `Invalid rule name, got '${rule.name}' but rules must match ${RULE_NAME_PATTERN.toString()}`);
18008+
return rule;
18009+
}
18010+
function getRuleForCategoryImpl(category) {
1800518011
switch (category) {
1800618012
case ErrorCategory.AutomaticEffectDependencies: {
1800718013
return {
1800818014
category,
1800918015
name: 'automatic-effect-dependencies',
1801018016
description: 'Verifies that automatic effect dependencies are compiled if opted-in',
18011-
recommended: true,
18017+
recommended: false,
1801218018
};
1801318019
}
1801418020
case ErrorCategory.CapitalizedCalls: {
@@ -18023,7 +18029,7 @@ function getRuleForCategory(category) {
1802318029
return {
1802418030
category,
1802518031
name: 'config',
18026-
description: 'Validates the configuration',
18032+
description: 'Validates the compiler configuration options',
1802718033
recommended: true,
1802818034
};
1802918035
}
@@ -18047,15 +18053,15 @@ function getRuleForCategory(category) {
1804718053
return {
1804818054
category,
1804918055
name: 'set-state-in-effect',
18050-
description: 'Validates against calling setState synchronously in an effect',
18056+
description: 'Validates against calling setState synchronously in an effect, which can lead to re-renders that degrade performance',
1805118057
recommended: true,
1805218058
};
1805318059
}
1805418060
case ErrorCategory.ErrorBoundaries: {
1805518061
return {
1805618062
category,
1805718063
name: 'error-boundaries',
18058-
description: 'Validates usage of error boundaries instead of try/catch for errors in JSX',
18064+
description: 'Validates usage of error boundaries instead of try/catch for errors in child components',
1805918065
recommended: true,
1806018066
};
1806118067
}
@@ -18079,15 +18085,16 @@ function getRuleForCategory(category) {
1807918085
return {
1808018086
category,
1808118087
name: 'gating',
18082-
description: 'Validates configuration of gating mode',
18088+
description: 'Validates configuration of [gating mode](https://react.dev/reference/react-compiler/gating)',
1808318089
recommended: true,
1808418090
};
1808518091
}
1808618092
case ErrorCategory.Globals: {
1808718093
return {
1808818094
category,
1808918095
name: 'globals',
18090-
description: 'Validates against assignment/mutation of globals during render',
18096+
description: 'Validates against assignment/mutation of globals during render, part of ensuring that ' +
18097+
'[side effects must render outside of render](https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)',
1809118098
recommended: true,
1809218099
};
1809318100
}
@@ -18103,7 +18110,7 @@ function getRuleForCategory(category) {
1810318110
return {
1810418111
category,
1810518112
name: 'immutability',
18106-
description: 'Validates that immutable values (props, state, etc) are not mutated',
18113+
description: 'Validates against mutating props, state, and other values that [are immutable](https://react.dev/reference/rules/components-and-hooks-must-be-pure#props-and-state-are-immutable)',
1810718114
recommended: true,
1810818115
};
1810918116
}
@@ -18119,39 +18126,41 @@ function getRuleForCategory(category) {
1811918126
return {
1812018127
category,
1812118128
name: 'preserve-manual-memoization',
18122-
description: 'Validates that existing manual memoized is preserved by the compiler',
18129+
description: 'Validates that existing manual memoized is preserved by the compiler. ' +
18130+
'React Compiler will only compile components and hooks if its inference ' +
18131+
'[matches or exceeds the existing manual memoization](https://react.dev/learn/react-compiler/introduction#what-should-i-do-about-usememo-usecallback-and-reactmemo)',
1812318132
recommended: true,
1812418133
};
1812518134
}
1812618135
case ErrorCategory.Purity: {
1812718136
return {
1812818137
category,
1812918138
name: 'purity',
18130-
description: 'Validates that the component/hook is pure, and does not call known-impure functions',
18139+
description: 'Validates that [components/hooks are pure](https://react.dev/reference/rules/components-and-hooks-must-be-pure) by checking that they do not call known-impure functions',
1813118140
recommended: true,
1813218141
};
1813318142
}
1813418143
case ErrorCategory.Refs: {
1813518144
return {
1813618145
category,
1813718146
name: 'refs',
18138-
description: 'Validates correct usage of refs, not reading/writing during render',
18147+
description: 'Validates correct usage of refs, not reading/writing during render. See the "pitfalls" section in [`useRef()` usage](https://react.dev/reference/react/useRef#usage)',
1813918148
recommended: true,
1814018149
};
1814118150
}
1814218151
case ErrorCategory.RenderSetState: {
1814318152
return {
1814418153
category,
1814518154
name: 'set-state-in-render',
18146-
description: 'Validates against setting state during render',
18155+
description: 'Validates against setting state during render, which can trigger additional renders and potential infinite render loops',
1814718156
recommended: true,
1814818157
};
1814918158
}
1815018159
case ErrorCategory.StaticComponents: {
1815118160
return {
1815218161
category,
1815318162
name: 'static-components',
18154-
description: 'Validates that components are static, not recreated every render',
18163+
description: 'Validates that components are static, not recreated every render. Components that are recreated dynamically can reset state and trigger excessive re-rendering',
1815518164
recommended: true,
1815618165
};
1815718166
}
@@ -18183,15 +18192,15 @@ function getRuleForCategory(category) {
1818318192
return {
1818418193
category,
1818518194
name: 'unsupported-syntax',
18186-
description: 'Validates against syntax that we do not plan to support',
18195+
description: 'Validates against syntax that we do not plan to support in React Compiler',
1818718196
recommended: true,
1818818197
};
1818918198
}
1819018199
case ErrorCategory.UseMemo: {
1819118200
return {
1819218201
category,
1819318202
name: 'use-memo',
18194-
description: 'Validates usage of the useMemo() hook',
18203+
description: 'Validates usage of the useMemo() hook against common mistakes. See [`useMemo()` docs](https://react.dev/reference/react/useMemo) for more information.',
1819518204
recommended: true,
1819618205
};
1819718206
}

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11d7bcf88cf13fa8fe6e091d2199c3905f5bb274
1+
425ba0ad6d3ebd1779f6a658dcbf5c666d054948
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11d7bcf88cf13fa8fe6e091d2199c3905f5bb274
1+
425ba0ad6d3ebd1779f6a658dcbf5c666d054948

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ __DEV__ &&
14091409
exports.useTransition = function () {
14101410
return resolveDispatcher().useTransition();
14111411
};
1412-
exports.version = "19.2.0-www-classic-11d7bcf8-20250822";
1412+
exports.version = "19.2.0-www-classic-425ba0ad-20250822";
14131413
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14141414
"function" ===
14151415
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ __DEV__ &&
14091409
exports.useTransition = function () {
14101410
return resolveDispatcher().useTransition();
14111411
};
1412-
exports.version = "19.2.0-www-modern-11d7bcf8-20250822";
1412+
exports.version = "19.2.0-www-modern-425ba0ad-20250822";
14131413
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14141414
"function" ===
14151415
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactSharedInternals.H.useTransition();
602602
};
603-
exports.version = "19.2.0-www-classic-11d7bcf8-20250822";
603+
exports.version = "19.2.0-www-classic-425ba0ad-20250822";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactSharedInternals.H.useTransition();
602602
};
603-
exports.version = "19.2.0-www-modern-11d7bcf8-20250822";
603+
exports.version = "19.2.0-www-modern-425ba0ad-20250822";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-classic-11d7bcf8-20250822";
607+
exports.version = "19.2.0-www-classic-425ba0ad-20250822";
608608
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
609609
"function" ===
610610
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-modern-11d7bcf8-20250822";
607+
exports.version = "19.2.0-www-modern-425ba0ad-20250822";
608608
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
609609
"function" ===
610610
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19588,10 +19588,10 @@ __DEV__ &&
1958819588
(function () {
1958919589
var internals = {
1959019590
bundleType: 1,
19591-
version: "19.2.0-www-classic-11d7bcf8-20250822",
19591+
version: "19.2.0-www-classic-425ba0ad-20250822",
1959219592
rendererPackageName: "react-art",
1959319593
currentDispatcherRef: ReactSharedInternals,
19594-
reconcilerVersion: "19.2.0-www-classic-11d7bcf8-20250822"
19594+
reconcilerVersion: "19.2.0-www-classic-425ba0ad-20250822"
1959519595
};
1959619596
internals.overrideHookState = overrideHookState;
1959719597
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19625,7 +19625,7 @@ __DEV__ &&
1962519625
exports.Shape = Shape;
1962619626
exports.Surface = Surface;
1962719627
exports.Text = Text;
19628-
exports.version = "19.2.0-www-classic-11d7bcf8-20250822";
19628+
exports.version = "19.2.0-www-classic-425ba0ad-20250822";
1962919629
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1963019630
"function" ===
1963119631
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)