Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint - how to set the sourceType for a specific file

Is there a way in eslint to set the sourceType within the file similar to the rules and environment settings?

Something like

/*eslint sourceType: "module"*/

does not seen work

like image 964
doberkofler Avatar asked Apr 05 '16 18:04

doberkofler


2 Answers

I have to create one directory for each special Javascript file and put a .eslintrc file with the following content in the directory: { "sourceType": "module" }

Maybe it's better to move all modules under a single directory, separated from legacy JS files. But for temporary fix of the Parsing error: 'import' and 'export may appear only with 'sourceType: module', I just put the .eslintrc.

like image 95
Qi Fan Avatar answered Nov 12 '22 13:11

Qi Fan


One of the team members of eslint confirmed that this is currently not supported and the only way to set the sourceType currently is by using the configuration files.

like image 20
doberkofler Avatar answered Nov 12 '22 13:11

doberkofler