Skip to content

Commit 693a689

Browse files
pkuczynskiljharb
authored andcommitted
[Docs] jsx-uses-react, react-in-jsx-scope: document react/jsx-runtime config
1 parent 2459c00 commit 693a689

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1717
### Changed
1818
* [Docs] [`jsx-no-bind`]: updates discussion of refs ([#2998][] @dimitropoulos)
1919
* [Refactor] `utils/Components`: correct spelling and delete unused code ([#3026][] @ohhoney1)
20+
* [Docs] [`jsx-uses-react`], [`react-in-jsx-scope`]: document [`react/jsx-runtime`] config ([#3018][] @pkuczynski @ljharb)
2021

2122
[#3026]: https://github.com/yannickcr/eslint-plugin-react/pull/3026
2223
[#3025]: https://github.com/yannickcr/eslint-plugin-react/pull/3025
24+
[#3018]: https://github.com/yannickcr/eslint-plugin-react/pull/3018
2325
[#3016]: https://github.com/yannickcr/eslint-plugin-react/issues/3016
2426
[#3006]: https://github.com/yannickcr/eslint-plugin-react/pull/3006
2527
[#3001]: https://github.com/yannickcr/eslint-plugin-react/pull/3001
@@ -3298,6 +3300,8 @@ If you're still not using React 15 you can keep the old behavior by setting the
32983300
### Added
32993301
* First revision
33003302

3303+
[`react/jsx-runtime`]: https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/index.js#L163-L176
3304+
33013305
[`display-name`]: docs/rules/display-name.md
33023306
[`forbid-component-props`]: docs/rules/forbid-component-props.md
33033307
[`forbid-elements`]: docs/rules/forbid-elements.md

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ $ npm install eslint-plugin-react --save-dev
2121

2222
# Configuration
2323

24+
2425
Use [our preset](#recommended) to get reasonable defaults:
2526

2627
```json
@@ -30,6 +31,8 @@ Use [our preset](#recommended) to get reasonable defaults:
3031
]
3132
```
3233

34+
If you are using the [new JSX transform from React 17](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#removing-unused-react-imports), extend [`react/jsx-runtime`](https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/index.js#L163-L176) in your eslint config to disable the relevant rules.
35+
3336
You should also specify settings that will be shared across all the plugin rules. ([More about eslint shared settings](https://eslint.org/docs/user-guide/configuring/configuration-files#adding-shared-settings))
3437

3538
```json5

docs/rules/jsx-uses-react.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ var Hello = <div>Hello {this.props.name}</div>;
4343

4444
## When Not To Use It
4545

46-
If you are not using JSX, if React is declared as global variable or if you do not use the `no-unused-vars` rule then you can disable this rule.
46+
If you are not using JSX, if React is declared as global variable, or if you do not use the `no-unused-vars` rule.
47+
48+
If you are using the [new JSX transform from React 17](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#removing-unused-react-imports), you should disable this rule by extending [`react/jsx-runtime`](https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/index.js#L163-L176) in your eslint config.

docs/rules/react-in-jsx-scope.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Prevent missing React when using JSX (react/react-in-jsx-scope)
22

3-
When using JSX, `<a />` expands to `React.createElement("a")`. Therefore the
4-
`React` variable must be in scope.
3+
When using JSX, `<a />` expands to `React.createElement("a")`. Therefore the `React` variable must be in scope.
54

65
If you are using the @jsx pragma this rule will check the designated variable and not the `React` one.
76

@@ -43,4 +42,6 @@ var Hello = <div>Hello {this.props.name}</div>;
4342

4443
## When Not To Use It
4544

46-
If you are setting `React` as a global variable you can disable this rule.
45+
If you are not using JSX, or if you are setting `React` as a global variable.
46+
47+
If you are using the [new JSX transform from React 17](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#removing-unused-react-imports), you should disable this rule by extending [`react/jsx-runtime`](https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/index.js#L163-L176) in your eslint config.

0 commit comments

Comments
 (0)