JavaScript code style in WebStorm shows unterminated statement warning
I’m using WebStorm 2016.1 on a NodeJS project and cannot seem to figure out some of the code styling issues that keep triggering warnings.
For instance, I get these gray blocks where I haven’t terminated a line with a semi-colon, which I don’t want to do because that goes against the eslint settings for the project. I add the ;
and I get an eslint warning instead.
What setting do I need to change to stop this?
To fix this, change the following setting in Editor > Inspections
of WebStorm:
]
Try the following Steps:
Ctrl-Shift-A –> Unterminated Statement –> Off
Also for other unwanted inspection problems press Alt+Enter on highlighted code. Context menu will be shown with suggested solutions, including disabling the inspection.
In my case there was a lot of this “unterminated statement” so I just copy the whole code to editor like notepad, delete everything and copy back from a notepad, and all ‘unterminated statement’ gone.
To give a bit more background, the code snippets on some sites include additional characters (such as <200b>
in the snippet below) that are not visible unless it is copy & pasted into a program such as vi
. The <200b>
represents a Zero-width space as described here: https://en.wikipedia.org/wiki/Zero-width_space
The example below was taken from https://redux.js.org/recipes/writing-tests.
import React from 'react'
import Enzyme, { mount } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16';
import Header from '../../components/Header'
<200b>
Enzyme.configure({ adapter: new Adapter() });
<200b>
function setup() {
const props = {
addTodo: jest.fn()
}
<200b>
const enzymeWrapper = mount(<Header {...props} />)
<200b>
return {
props,
enzymeWrapper
}
}
I suspect the problem is that the Zero-width space has some impact on how the Jetbrains IDE’s apply it to Javascript files, because if I remove the <200b>
manually from the code and then paste it back into the IDE, then it works.
Probably worthwhile to open a bug report.
Should help, try it. It seems like the issue of some additional not editable symbols.