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?

Bryan S.
  • 1,434
  • 11
  • 8
Abhay Shiro
  • 3,431
  • 2
  • 16
  • 26

5 Answers5

48

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

It is a good replacement for jshint in reactJS work.

Yuvraj Patil
  • 7,944
  • 5
  • 56
  • 56
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.

Matt Bierner
  • 58,117
  • 21
  • 175
  • 206
Abhay Shiro
  • 3,431
  • 2
  • 16
  • 26
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.

Community
  • 1
  • 1
Showcase Imagery
  • 372
  • 2
  • 19
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.

VikasKM
  • 212
  • 3
  • 7
-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)

Dayan
  • 369
  • 1
  • 5
  • 12
  • 39
    This is exactly how the Chernobyl disaster happened. You don't overlook warnings, you get rid of or fix the things that caused them. – Laszlo T Jul 03 '18 at 19:00