3

I am trying to work on a react with flux project using VS Code. The VS Code will give errors and warnings for the JSX in the .js files. I keep the .js extension instead of .jsx as I want the intellisense from VS Code.

How can I have JSX validation and highlighting in .js file in VSCode? Or, is there a way to have proper JSX validation and keep the intellisense in VSCode at the same time?

Dmitry Shvedov
  • 3,169
  • 4
  • 39
  • 51
Y.S
  • 31
  • 3

2 Answers2

4

VSCode (v1.0.0) added new way to associates files. Select language mode and choose Configure.. . To add jsx syntax capabilities and goodies in your file you can edit the file.associations.

"files.associations": {
    "*.js":"javascriptreact"
}
wogsland
  • 9,106
  • 19
  • 57
  • 93
dstoiloff
  • 41
  • 2
0

If I understand you correctly, if you have a .jsx file extension or manually select the JavaScript React language mode, you get validation and highlighting, but no IntelliSense. If you change the language mode or file extension to JavaScript, you get IntelliSense but don't get the validation and highlighting.

To manually select a language mode, open the command palette (ctrl+shift+p or cmd+shift+p) and start typing 'language'. Select 'Change Language Mode' and then select 'Javascript'.

Unfortunately for now there is no way to have both at the same time. You'll have to wait for the language services to be updated or try to create your own extension to fill the void.

Llewey
  • 8,684
  • 2
  • 26
  • 19