Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webstorm not recognising JavaScript file

Look

Webstorm doesn't recognize one of my .js files as a JavaScript file so I'm losing syntax highlighting and being able to add break points. I've looked in the workspace.xml file and the file in question seems to have similar settings to other .js files that work correctly.

If I change the name of the file it works ok. So somehow Webstorm is stuck on misinterpreting the type of a file that has this name. Where else can I edit the project?

Context menu

like image 619
Ian Warburton Avatar asked Nov 11 '14 18:11

Ian Warburton


People also ask

How do I change the file type on WebStorm?

Press Ctrl+Alt+S to open the IDE settings and select Editor | File Types. From the Recognized File Types list, select the file type that you want to associate with other filename patterns.

How do I add a file to WebStorm?

tip. You can also add files to your local repository from the Project tool window. Select the files you want to add, and press Ctrl+Alt+A or choose VCS | <your_VCS> | Add from the context menu.

Is WebStorm better than IntelliJ?

"Fantastically intelligent", "Best-in-class ide" and "Many languages support" are the key factors why developers consider IntelliJ IDEA; whereas "Intelligent ide ", "Smart development environment" and "Easy js debugging" are the primary reasons why WebStorm is favored.


1 Answers

So I see three possible reasons for the problem:

  1. The file was marked as 'Plain text'

  2. There is a pattern for 'Text files' file type that matches this file (or back: file type 'JavaScript' exclude this file name). See image below

enter image description here

  1. There is a custom plugin that overrides default behavior for files with this name (unlikely)

Updated: after several years I've found one more reason for the behavior and most likely it the main source of the issues. When you create a file without any extensions the "Register New File Type Association" is appeared. And you can accidentally specify a new file type, for some file name. It is can be fixed with (2) but it is the reason why the pattern was added there.

Register New File Type Association

Note: the solution works for all IDEA-based IDEs: IntelliJ IDEA, WebStorm, RubyMine, PyCharm, PhpStorm.

like image 52
anstarovoyt Avatar answered Sep 23 '22 02:09

anstarovoyt