question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errorneous linting of jsx fragments

See original GitHub issue

Is this a bug report?

yes

Steps to Reproduce

  1. create app npx create-react-app app
  2. replace content of src/App.js with
import React from 'react';

const App = (
  <>App</>
);

export default App;
  1. run npx eslint ./src inside app

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

https://github.com/vadzim/errorneous-fragment-linting.git

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
stale[bot]commented, Jan 1, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found