Skip to content

Commit c8211fc

Browse files
authored
Add RC badge to RC-only lint rules (#8005)
1 parent 366b5fb commit c8211fc

22 files changed

+221
-29
lines changed

src/components/Layout/Sidebar/SidebarLink.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface SidebarLinkProps {
2424
selected?: boolean;
2525
title: string;
2626
level: number;
27-
version?: 'canary' | 'major' | 'experimental';
27+
version?: 'canary' | 'major' | 'experimental' | 'rc';
2828
icon?: React.ReactNode;
2929
isExpanded?: boolean;
3030
hideArrow?: boolean;
@@ -102,6 +102,12 @@ export function SidebarLink({
102102
className="ms-1 text-gray-30 dark:text-gray-60 inline-block w-3.5 h-3.5 align-[-3px]"
103103
/>
104104
)}
105+
{version === 'rc' && (
106+
<IconCanary
107+
title=" - This feature is available in the latest RC version"
108+
className="ms-1 text-gray-30 dark:text-gray-60 inline-block w-3.5 h-3.5 align-[-3px]"
109+
/>
110+
)}
105111
</div>
106112

107113
{isExpanded != null && !hideArrow && (

src/components/MDX/ExpandableCallout.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type CalloutVariants =
2424
| 'wip'
2525
| 'canary'
2626
| 'experimental'
27+
| 'rc'
2728
| 'major'
2829
| 'rsc';
2930

@@ -50,6 +51,15 @@ const variantMap = {
5051
overlayGradient:
5152
'linear-gradient(rgba(245, 249, 248, 0), rgba(245, 249, 248, 1)',
5253
},
54+
rc: {
55+
title: 'RC',
56+
Icon: IconCanary,
57+
containerClasses:
58+
'bg-gray-5 dark:bg-gray-60 dark:bg-opacity-20 text-primary dark:text-primary-dark text-lg',
59+
textColor: 'text-gray-60 dark:text-gray-30',
60+
overlayGradient:
61+
'linear-gradient(rgba(245, 249, 248, 0), rgba(245, 249, 248, 1)',
62+
},
5363
canary: {
5464
title: 'Canary',
5565
Icon: IconCanary,

src/components/MDX/MDXComponents.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ const Canary = ({children}: {children: React.ReactNode}) => (
106106
<ExpandableCallout type="canary">{children}</ExpandableCallout>
107107
);
108108

109+
const RC = ({children}: {children: React.ReactNode}) => (
110+
<ExpandableCallout type="rc">{children}</ExpandableCallout>
111+
);
112+
109113
const Experimental = ({children}: {children: React.ReactNode}) => (
110114
<ExpandableCallout type="experimental">{children}</ExpandableCallout>
111115
);
@@ -533,6 +537,7 @@ export const MDXComponents = {
533537
Math,
534538
MathI,
535539
Note,
540+
RC,
536541
Canary,
537542
Experimental,
538543
ExperimentalBadge,

src/components/PageHeading.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {IconExperimental} from './Icon/IconExperimental';
1919

2020
interface PageHeadingProps {
2121
title: string;
22-
version?: 'experimental' | 'canary';
22+
version?: 'experimental' | 'canary' | 'rc';
2323
experimental?: boolean;
2424
status?: string;
2525
description?: string;
@@ -46,6 +46,12 @@ function PageHeading({
4646
className="ms-4 mt-1 text-gray-50 dark:text-gray-40 inline-block w-6 h-6 align-[-1px]"
4747
/>
4848
)}
49+
{version === 'rc' && (
50+
<IconCanary
51+
title=" - This feature is available in the latest RC version"
52+
className="ms-4 mt-1 text-gray-50 dark:text-gray-40 inline-block w-6 h-6 align-[-1px]"
53+
/>
54+
)}
4955
{version === 'experimental' && (
5056
<IconExperimental
5157
title=" - This feature is available in the latest Experimental version of React"

src/content/reference/eslint-plugin-react-hooks/index.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: eslint-plugin-react-hooks
3+
version: rc
34
---
45

56
<Intro>
@@ -8,6 +9,14 @@ title: eslint-plugin-react-hooks
89

910
</Intro>
1011

12+
<RC>
13+
14+
These docs include rules available in the RC version of `eslint-plugin-react-hooks`.
15+
16+
You can try them by upgrading the lint plugin [to the most recent RC version](/learn/react-compiler/installation#eslint-integration).
17+
18+
</RC>
19+
1120
This plugin helps you catch violations of React's rules at build time, ensuring your components and hooks follow React's rules for correctness and performance. The lints cover both fundamental React patterns (exhaustive-deps and rules-of-hooks) and issues flagged by React Compiler. React Compiler diagnostics are automatically surfaced by this ESLint plugin, and can be used even if your app hasn't adopted the compiler yet.
1221

1322
<Note>
@@ -18,18 +27,23 @@ What this means for linting, is that you don’t need to fix all violations imme
1827

1928
## Available Lints {/*available-lints*/}
2029

21-
* [`component-hook-factories`](/reference/eslint-plugin-react-hooks/lints/component-hook-factories) - Validates against higher order functions defining nested components or hooks
30+
These rules are available in the stable version of `eslint-plugin-react-hooks`:
31+
32+
* [`exhaustive-deps`](/reference/eslint-plugin-react-hooks/lints/exhaustive-deps) - Validates that dependency arrays for React hooks contain all necessary dependencies
33+
* [`rules-of-hooks`](/reference/eslint-plugin-react-hooks/lints/rules-of-hooks) - Validates that components and hooks follow the Rules of Hooks
34+
35+
These rules are available in the RC version of `eslint-plugin-react-hooks`:
36+
37+
* [`component-hook-factories`](/reference/eslint-plugin-react-hooks/lints/component-hook-factories) - Validates higher order functions defining nested components or hooks
2238
* [`config`](/reference/eslint-plugin-react-hooks/lints/config) - Validates the compiler configuration options
2339
* [`error-boundaries`](/reference/eslint-plugin-react-hooks/lints/error-boundaries) - Validates usage of Error Boundaries instead of try/catch for child errors
24-
* [`exhaustive-deps`](/reference/eslint-plugin-react-hooks/lints/exhaustive-deps) - Validates that dependency arrays for React hooks contain all necessary dependencies
2540
* [`gating`](/reference/eslint-plugin-react-hooks/lints/gating) - Validates configuration of gating mode
2641
* [`globals`](/reference/eslint-plugin-react-hooks/lints/globals) - Validates against assignment/mutation of globals during render
2742
* [`immutability`](/reference/eslint-plugin-react-hooks/lints/immutability) - Validates against mutating props, state, and other immutable values
2843
* [`incompatible-library`](/reference/eslint-plugin-react-hooks/lints/incompatible-library) - Validates against usage of libraries which are incompatible with memoization
2944
* [`preserve-manual-memoization`](/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization) - Validates that existing manual memoization is preserved by the compiler
3045
* [`purity`](/reference/eslint-plugin-react-hooks/lints/purity) - Validates that components/hooks are pure by checking known-impure functions
3146
* [`refs`](/reference/eslint-plugin-react-hooks/lints/refs) - Validates correct usage of refs, not reading/writing during render
32-
* [`rules-of-hooks`](/reference/eslint-plugin-react-hooks/lints/rules-of-hooks) - Validates that components and hooks follow the Rules of Hooks
3347
* [`set-state-in-effect`](/reference/eslint-plugin-react-hooks/lints/set-state-in-effect) - Validates against calling setState synchronously in an effect
3448
* [`set-state-in-render`](/reference/eslint-plugin-react-hooks/lints/set-state-in-render) - Validates against setting state during render
3549
* [`static-components`](/reference/eslint-plugin-react-hooks/lints/static-components) - Validates that components are static, not recreated every render

src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: component-hook-factories
3+
version: rc
34
---
45

56
<Intro>
@@ -8,6 +9,14 @@ Validates against higher order functions defining nested components or hooks. Co
89

910
</Intro>
1011

12+
<RC>
13+
14+
This rule is available in the RC version of `eslint-plugin-react-hooks`.
15+
16+
You can try it by upgrading the lint plugin [to the most recent RC version](/learn/react-compiler/installation#eslint-integration).
17+
18+
</RC>
19+
1120
## Rule Details {/*rule-details*/}
1221

1322
Defining components or hooks inside other functions creates new instances on every call. React treats each as a completely different component, destroying and recreating the entire component tree, losing all state, and causing performance problems.

src/content/reference/eslint-plugin-react-hooks/lints/config.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: config
3+
version: rc
34
---
45

56
<Intro>
@@ -8,6 +9,14 @@ Validates the compiler [configuration options](/reference/react-compiler/configu
89

910
</Intro>
1011

12+
<RC>
13+
14+
This rule is available in the RC version of `eslint-plugin-react-hooks`.
15+
16+
You can try it by upgrading the lint plugin [to the most recent RC version](/learn/react-compiler/installation#eslint-integration).
17+
18+
</RC>
19+
1120
## Rule Details {/*rule-details*/}
1221

1322
React Compiler accepts various [configuration options](/reference/react-compiler/configuration) to control its behavior. This rule validates that your configuration uses correct option names and value types, preventing silent failures from typos or incorrect settings.

src/content/reference/eslint-plugin-react-hooks/lints/error-boundaries.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: error-boundaries
3+
version: rc
34
---
45

56
<Intro>
@@ -8,6 +9,14 @@ Validates usage of Error Boundaries instead of try/catch for errors in child com
89

910
</Intro>
1011

12+
<RC>
13+
14+
This rule is available in the RC version of `eslint-plugin-react-hooks`.
15+
16+
You can try it by upgrading the lint plugin [to the most recent RC version](/learn/react-compiler/installation#eslint-integration).
17+
18+
</RC>
19+
1120
## Rule Details {/*rule-details*/}
1221

1322
Try/catch blocks can't catch errors that happen during React's rendering process. Errors thrown in rendering methods or hooks bubble up through the component tree. Only [Error Boundaries](/reference/react/Component#catching-rendering-errors-with-an-error-boundary) can catch these errors.

src/content/reference/eslint-plugin-react-hooks/lints/gating.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: gating
3+
version: rc
34
---
45

56
<Intro>
@@ -8,6 +9,14 @@ Validates configuration of [gating mode](/reference/react-compiler/gating).
89

910
</Intro>
1011

12+
<RC>
13+
14+
This rule is available in the RC version of `eslint-plugin-react-hooks`.
15+
16+
You can try it by upgrading the lint plugin [to the most recent RC version](/learn/react-compiler/installation#eslint-integration).
17+
18+
</RC>
19+
1120
## Rule Details {/*rule-details*/}
1221

1322
Gating mode lets you gradually adopt React Compiler by marking specific components for optimization. This rule ensures your gating configuration is valid so the compiler knows which components to process.

src/content/reference/eslint-plugin-react-hooks/lints/globals.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: globals
3+
version: rc
34
---
45

56
<Intro>
@@ -8,6 +9,14 @@ Validates against assignment/mutation of globals during render, part of ensuring
89

910
</Intro>
1011

12+
<RC>
13+
14+
This rule is available in the RC version of `eslint-plugin-react-hooks`.
15+
16+
You can try it by upgrading the lint plugin [to the most recent RC version](/learn/react-compiler/installation#eslint-integration).
17+
18+
</RC>
19+
1120
## Rule Details {/*rule-details*/}
1221

1322
Global variables exist outside React's control. When you modify them during render, you break React's assumption that rendering is pure. This can cause components to behave differently in development vs production, break Fast Refresh, and make your app impossible to optimize with features like React Compiler.

0 commit comments

Comments
 (0)