Webstorm not recognising JavaScript file

流过昼夜 提交于 2019-11-28 05:37:29

So I see three possible reasons of 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

3) There is a custom plugin that overrides default behaviour for files with this name (unlikely)

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

If the file was marked as "Plain Text", then this can be fixed as follows:

  1. Right click on the file.

  2. One of the menu options is "Mark as Javascript" . Just below "Delete".

  3. Click that. Your file is now recognized as javascript by WebStorm.

Since WebStorm was not allowing screenshots after right click so couldn't add it here.

File -> Settings -> Editor -> FileTypes -> Text files -> check for "ContentRepository.js" pattern there and remove it.

For me this did the trick
1) Preferences
2) Editor
3) FileTypes
4) Search for javascript
5) Add *.js to registered patterns

You can also try "Template data languages" (in file > settings) which will force a specific language synatax high-lighting on a specific file or folder. See screenshot below

For a block of code you can also use "language injection". Simply high-light the block of code, wait for the little lamp to appear then select the bottom choice and then the language you need (screenshot also attached)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!