Different syntax highlight in .js and .js.php


Hi there. I am playing around with the thought of having php code in Javascript files, by calling them .js.php, but the syntax highlighting is different from when it's just in a .js file, and a .js.php file. The code works just fine, and the syntax highlighting is perfect in the plain .js files, but it doesn't seem to like arrow functions and `.then().then()...` / chained fetch functions when in js.php. I am thinking the issue might be that the JavaScript version that it tries to highlight from is different from the two cases, but I can't seem to find any setting where I could change / fix this. Any help? 

Syntax in the .js file; all good

.js.php file; syntax highlighting invalid

another example of the syntax issues phpstorm thinks there is;

1 comment
Comment actions Permalink

Figured it out by myself; the fix is the setting; Settings > Languages & Frameworks > Template Data Languages > have one (or multiple) folders where you place your .js.php files, add them and set the language to ECMAScript 6, and add the root folder of the project as HTML, and select that it should not overwrite the other folder(s) set.

In my case at least, if I didn't add the root folder as HTML files, it thought all files in the project was Javascript ECMAScript 6.


Please sign in to leave a comment.