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.

Parsing error: Subsequent lines with self-closing JSX tags

See original GitHub issue

Subject of the issue

Two lines with self-closing JSX tags seem to have issues:

error  Parsing error: unknown jsx node: "<Hero />\n<Featured />"

Your environment

  • OS: macOS 10.15.2
  • Packages:
    "@typescript-eslint/eslint-plugin": "^2.17.0",
    "@typescript-eslint/parser": "^2.17.0",
    "eslint": "^6.8.0",
    "eslint-config-prettier": "^6.9.0",
    "eslint-config-react-app": "^5.1.0",
    "eslint-plugin-flowtype": "^4.6.0",
    "eslint-plugin-graphql": "^3.1.1",
    "eslint-plugin-import": "^2.20.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-mdx": "^1.6.5",
    "eslint-plugin-prettier": "^3.1.2",
    "eslint-plugin-react": "^7.18.0",
    "eslint-plugin-react-hooks": "^2.3.0",
  • Env: yarn 1.21.1

Steps to reproduce

import Hero from '../components/hero';
import Featured from '../components/favorites';

<Hero />
<Featured />

Expected behaviour

The parser should be able to handle two separate self-closing JSX tags on subsequent lines.

Actual behaviour

The parser throws an error.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JounQincommented, Jan 26, 2020

@cpboyd Would you like to check whether v1.6.6 works?

1reaction
JounQincommented, Jan 26, 2020

This error is thrown from https://github.com/mdx-js/eslint-mdx/blob/master/packages/eslint-mdx/src/traverse.ts#L57 and adjacent self-closing jsx nodes are not parsed separately, it can be handlered by wrapping with <$></$>, I’ll try to fix it ASAP.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expected corresponding JSX closing tag for input Reactjs
In my case, the hr and input elements weren't closed properly. Parent Error was: JSX element 'div' has no corresponding closing tag, due...
Read more >
Troubleshooting MDX
The reason for this error is that only opening tags can be marked as self-closing. Remove the slash after the tag name and...
Read more >
React JSX - W3Schools
JSX will throw an error if the HTML is not properly closed. Attribute class = className. The class attribute is a much used...
Read more >
Adjacent JSX elements must be wrapped in an enclosing tag
Output: I get an error specifying that Adjacent JSX elements must be wrapped in an enclosing tag . To fix this error <h1>...
Read more >
vue/html-closing-bracket-newline
People have their own preference about the location of closing brackets. This rule enforces a line break (or no line break) before tag's...
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