admin管理员组

文章数量:1406312

WebStorm is not highlighting properly JS code whether its in HTML file or in JS file. It says unresolved variable or type document when I want to get ID of element using document.getElementByiD.

I have also captured settings

WebStorm is not highlighting properly JS code whether its in HTML file or in JS file. It says unresolved variable or type document when I want to get ID of element using document.getElementByiD.

I have also captured settings

Share Improve this question edited Dec 31, 2017 at 12:09 LazyOne 166k48 gold badges414 silver badges415 bronze badges asked Dec 31, 2017 at 9:20 jack_snipejack_snipe 1292 silver badges11 bronze badges 2
  • 4 General thought: please try File | Invalidate Caches... and restart IDE. Anything interesting in idea.log file? – LazyOne Commented Dec 31, 2017 at 12:20
  • 1 Check File -> Settings > Editor -> File Types, select JavaScript into list of file types and check if you have *.js into list of extensions below. Alternatively try to create new draft (Shift+Ctrl+Alt+Ins) for JavaScript language and take a look if it get highlighted. – Flying Commented Dec 31, 2017 at 12:26
Add a ment  | 

4 Answers 4

Reset to default 5

3 Things to try:

  1. Try File | Invalidate Caches and restart IDE. (credits @LazyOne)
  2. File -> Settings > Editor -> File Types, select JavaScript into list of file types and check if you have *.js into list of extensions below. Alternatively try to create new draft (Shift+Ctrl+Alt+Ins) for JavaScript language and take a look if it get highlighted. (credits @Flying)
  3. Go to File | Settings | Languages & Frameworks | JavaScript and Choose ECMAScript 5.1 and press ok. Files shoud now be highlighted correctly. Then, open the menu again and re-select ECMAScript 6+.

I had the same or similar problem. Unresolved variables did not "highlight". But the problem occurred only on a single .mjs -file as far as I could tell. In others it did highlight those errors.

This was a big problem because I had a large set of JavaScript code which took much time to test-run to see how it worked, and having mistyped variable names caused it to fail but only after running it again and again after making any change.

I tried many things which did not help but finally this action got the unresolved variables error-highlighting to work again:

  1. Open the file with missing error-highlights in WebStorm editor.

  2. From the top menu-bar navigate Code -> Analyze Code -> Configure Current File Analysis

  3. Choose "All Problems" (instead of "Syntax")

My problem was that I added an .eslintrc file but our project is using TS Lint. I just disabled eslint and things started working again.

Mine had power save mode on, I turned it off in notifications

本文标签: javascriptWebStorm is not highlighting JS codeStack Overflow