简体   繁体   English

eslint - 如何为特定文件设置sourceType

[英]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.

相关问题 Eslint - 脚本和模块的 SourceType 混合 - Eslint - SourceType mixture of script and module 如何告诉 eslint:禁用下一行“'import'和'export'可能只与'sourceType:module'一起出现” - How to tell eslint to: disable next line "'import' and 'export' may appear only with 'sourceType: module'" 如何在全球范围内设置 eslint 规则? - how to set eslint rules globally? 您如何仅针对特定规则或一组规则运行 eslint - 仅命令行 - How do you run eslint for only a specific rule or set of rules - command line only 如何使用 ESlint 禁止特定的命名函数 - How to forbid a specific named function with ESlint 如何忽略特定计算机的 eslint 规则 - How to ignore eslint rule for a specific computer 如何在 ESLint 中设置全局警告级别? - How to set global warning level in ESLint? ESLint:如何在文件内设置“ new-cap”规则的“ capIsNewExceptions”选项? - ESLint: How to set “new-cap” rule's “capIsNewExceptions” option within a file? create-react-app eslint 错误“解析错误:‘import’和‘export’可能只出现在‘sourceType:module’中” - create-react-app eslint error "Parsing error: 'import' and 'export' may appear only with 'sourceType: module'" ESLint-如何覆盖扩展文件的严重性 - ESLint - How to override extended file severity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM