Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Intellij how to set javascript to es6 on a per-file basis?

I know how to set Javascript Language Version to ES6 for the whole project (Language & Frameworks -> Javascript...etc).

But how to set it only for one file ? I have a big ES5 project and would like to start using ES6 one file at a time without having Intellij complaining on all files.

Is there some kind of annotation like "/** ES6 **/" i could use ? Or is it in a panel inside preferences ?

like image 253
Manel Avatar asked Dec 03 '25 14:12

Manel


1 Answers

I faced the same question and fortunately this feature was released recently (since IntelliJ 2017.3).

From official website:

The easiest option is to enable the highest language version for the whole project in Preferences | Languages and Frameworks | JavaScript. For example, if you use ES5.1 and JSX, enable JSX (since it’s a superset of ES5.1 and ES6).

Now you can also configure different JavaScript language versions for different folders. Click the button next to the drop-down with the version, then select a folder and the language version used for its files. The version specified on the main settings page will be applied by default for all other JavaScript files in the project.


(source: cloudfront.net)

like image 108
Dmitry Kach Avatar answered Dec 06 '25 07:12

Dmitry Kach



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!