Errorneous linting of jsx fragments
See original GitHub issueIs this a bug report?
yes
Steps to Reproduce
- create app
npx create-react-app app
- replace content of
src/App.js
with
import React from 'react';
const App = (
<>App</>
);
export default App;
- run
npx eslint ./src
insideapp
Expected Behavior
no errors, no warnings
Actual Behavior
There is a warning:
.../src/App.js
1:8 warning 'React' is defined but never used no-unused-vars
✖ 1 problem (0 errors, 1 warning)
If I remove react import from src/App.js
, then it shows an error:
.../src/App.js
2:3 error 'React' must be in scope when using JSX react/react-in-jsx-scope
✖ 1 problem (1 error, 0 warnings)
Reproducible Demo
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
eslint-plugin-react/jsx-fragments.md at master - GitHub
React -specific linting rules for ESLint. Contribute to jsx-eslint/eslint-plugin-react development by creating an account on GitHub.
Read more >Unexpected token when linting shorthand react fragments ...
When using <React.Fragment> I get an error saying it prefers shorthand (Which is what I want) and can quickfix into shorthand fragments <>...
Read more >eslint-plugin-react | Yarn - Package Manager
React specific linting rules for ESLint. eslint, eslint-plugin, eslintplugin, react ... npm install eslint eslint-plugin-react --save-dev.
Read more >Configure Visual Studio Code to Lint React and JSX Syntax
For this to work, you need to make sure your ESLint library and plugins are installed with npm install as above; once you...
Read more >React: Guide to Fragments - Bits and Pieces - Bit.dev
The above is the wrong output of the table element. The div element shouldn't be present. React components are meant to return elements...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It seems this is fixed in https://github.com/yannickcr/eslint-plugin-react/commit/18898e1c41ff0d9f2f8e1c93267b6cda91328765#diff-d41ba36daf851354b9587064dc4ee0ac but still not published
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.