Skip to content

Commit e7f495e

Browse files
committed
docs: add auto-fix availability notes for various rules
1 parent 262dc32 commit e7f495e

9 files changed

+48
-1
lines changed

website/pages/docs/rules/avoid-shorthand-boolean.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ react-x/avoid-shorthand-boolean
2020

2121
Enforces the use of explicit boolean values for boolean attributes.
2222

23+
A **safe** auto-fix is available for this rule.
24+
2325
## Examples
2426

2527
### Failing

website/pages/docs/rules/dom-no-unknown-property.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ react-dom/no-unknown-property
2626
In JSX most DOM properties and attributes should be camelCased to be consistent with standard JavaScript style. This can be a possible source of error if you are used to writing plain HTML.
2727
Only `data-*` and `aria-*` attributes are usings hyphens and lowercase letters in JSX.
2828

29+
A **unsafe** auto-fix is available for this rule.
30+
2931
## Examples
3032

3133
### Failing

website/pages/docs/rules/no-component-will-mount.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Prevents usage of `componentWillMount` in class components.
2929

3030
This API has been renamed from `componentWillMount` to `UNSAFE_componentWillMount`. The old name has been deprecated. In a future major version of React, only the new name will work.
3131

32+
A **safe** codemod is available for this rule.
33+
3234
## Examples
3335

3436
### Failing

website/pages/docs/rules/no-component-will-receive-props.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Prevents usage of `componentWillReceiveProps` in class components.
2929

3030
This API has been renamed from `componentWillReceiveProps` to `UNSAFE_componentWillReceiveProps`. The old name has been deprecated. In a future major version of React, only the new name will work.
3131

32+
A **safe** codemod is available for this rule.
33+
3234
## Examples
3335

3436
### Failing

website/pages/docs/rules/no-component-will-update.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Prevents usage of `componentWillUpdate` in class components.
2929

3030
This API has been renamed from `componentWillUpdate` to `UNSAFE_componentWillUpdate`. The old name has been deprecated. In a future major version of React, only the new name will work.
3131

32+
A **safe** codemod is available for this rule.
33+
3234
## Examples
3335

3436
### Failing

website/pages/docs/rules/no-context-provider.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Disallows using `<Context.Provider>`.
2929

3030
In React 19, you can render `<Context>` as a provider instead of `<Context.Provider>`.
3131

32+
A **safe** codemod is available for this rule.
33+
3234
## Examples
3335

3436
### Failing

website/pages/docs/rules/no-forward-ref.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ In React 19, `forwardRef` is no longer necessary. Pass `ref` as a prop instead.
3131

3232
`forwardRef` will deprecated in a future release. Learn more [here](https://react.dev/blog/2024/12/05/react-19#ref-as-a-prop).
3333

34+
A **unsafe** codemod is available for this rule.
35+
3436
## Examples
3537

3638
### Failing
@@ -39,14 +41,43 @@ In React 19, `forwardRef` is no longer necessary. Pass `ref` as a prop instead.
3941
import { forwardRef } from "react";
4042

4143
const MyInput = forwardRef(function MyInput(props, ref) {
42-
// ...
44+
return <input ref={ref} {...props} />;
45+
});
46+
```
47+
48+
```tsx
49+
import React from "react";
50+
51+
interface MyInputProps {
52+
value: string;
53+
onChange: (value: string) => void;
54+
}
55+
56+
const MyInput = React.forwardRef<MyInputProps, HTMLInputElement>(function MyInput(
57+
{ value, onChange },
58+
ref,
59+
) {
60+
return <input ref={ref} value={value} onChange={(e) => onChange(e.target.value)} />;
4361
});
4462
```
4563

4664
### Passing
4765

4866
```tsx
4967
function MyInput({ ref, ...props }) {
68+
return <input ref={ref} {...props} />;
69+
}
70+
```
71+
72+
```tsx
73+
import React from "react";
74+
75+
interface MyInputProps {
76+
value: string;
77+
onChange: (value: string) => void;
78+
}
79+
80+
function MyInput({ ref, value, onChange }: MyInputProps & { ref: React.RefObject<HTMLInputElement> }) {
5081
// ...
5182
}
5283
```

website/pages/docs/rules/prefer-react-namespace-import.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ react-x/prefer-react-namespace-import
2020

2121
Enforces React is imported via a namespace import.
2222

23+
A **safe** auto-fix is available for this rule.
24+
2325
## Examples
2426

2527
### Failing

website/pages/docs/rules/prefer-shorthand-boolean.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ react-x/prefer-shorthand-boolean
2020

2121
Enforces the use of shorthand syntax for boolean attributes.
2222

23+
A **safe** auto-fix is available for this rule.
24+
2325
## Examples
2426

2527
This rule enforces the use of shorthand syntax for boolean attributes.

0 commit comments

Comments
 (0)