[英]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? 是否有一种方法在eslint中设置文件中的sourceType类似于规则和环境设置?
Something like 就像是
/*eslint sourceType: "module"*/
does not seen work 看不到工作
eslint的团队成员之一确认目前不支持此功能,目前设置sourceType的唯一方法是使用配置文件。
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" }
我必须为每个特殊的Javascript文件创建一个目录,并在目录中放入一个带有以下内容的
.eslintrc
文件: { "sourceType": "module" }
Maybe it's better to move all modules under a single directory, separated from legacy JS files. 也许最好将所有模块移动到一个目录下,与旧的JS文件分开。 But for temporary fix of the
Parsing error: 'import' and 'export may appear only with 'sourceType: module'
, I just put the .eslintrc
. 但是对于
Parsing error: 'import' and 'export may appear only with 'sourceType: module'
临时修复Parsing error: 'import' and 'export may appear only with 'sourceType: module'
,我只是放了.eslintrc
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.