React JSX error : Unclosed regular expression
Asked Answered
H

5

27

Recently I was facing an issue coding React app on Visual Studio code. Because of this issue, whenever I wrote JSX inside the render function of the React Component and saved it, it would go messed up (I mean indentation would get messy). See the pic: enter image description here

This error was also showing error like: 1. Unclosed regular expression

How to solve this?

Humbuggery answered 1/7, 2017 at 13:38 Comment(0)
H
49

If you are using jshint plugin, remove it and install ESLint plugin.

It is a good replacement for jshint in reactJS work.

Harbinger answered 5/8, 2019 at 3:9 Comment(3)
After that you should restart the computer for cleaning RAM.Hideaway
Restarting VS Code should be enough.Harbinger
this solves my problem, i have the jslint install globally, and esLint extension installed in vscodeHarquebusier
H
10

I tried several options like creating a .eslintrc file or .jshintrc file.

But it turned out that in my Visual Studio Code IDE, there was third party extensions(eslint/jslint/tslint/beautify/jsformatter etc) that were causing a big mess in my JSX code.

I had to go to the extensions and disable all the extension which could hinder in the natural process of linting and code cleaning of React framework.

enter image description here

(These extensions are really great. But disabling them helped me in solving this issue of mine, no offense to anyone.)

If you are facing the same issue and the issue persists event after adding a .jshintrc with content:

{
    "esversion": 6
}

then consider disabling the third party extensions.

Hope my answer helped.

Humbuggery answered 1/7, 2017 at 13:38 Comment(4)
I am pretty sure it was only the formatter. Automatic formatters have many problems. And using multiple formatters at once is just not possible. Using multiple linters at once is probably unnecessary.Ricci
True it is unnecessary. I just had those linters lying out there for no reason, which was causing the issue.Humbuggery
ya this help me outAnabantid
This answer led me to disabling JSHint which solved my issue.Neckerchief
S
10

the extension that did it for me was...

jshint

dbaeumer.jshint
Dirk Baeumer

as @abhay-shiro says, disabling a few extensions will usually resolve the issue.

Schluter answered 29/11, 2018 at 13:3 Comment(0)
U
2

I had the same problem, but it was "beautify" extension which was causing the error, I uninstalled it and installed prettier. It fixed the problem.

Unpretentious answered 9/1, 2019 at 6:46 Comment(0)
S
-8

I solved this issue by disabling show syntax errors checkbox in visual studio 2015.

Tools -> options - > text editor -> javascript -> intelliSense -> general -> show syntax errors(disable)

Stepdaughter answered 22/3, 2018 at 6:56 Comment(1)
This is exactly how the Chernobyl disaster happened. You don't overlook warnings, you get rid of or fix the things that caused them.Griffin

© 2022 - 2024 — McMap. All rights reserved.