[英]How to tell eslint to: disable next line "'import' and 'export' may appear only with 'sourceType: module'"
How to tell eslint to: disable next line for如何告诉 eslint:禁用下一行
"'import' and 'export' may appear only with 'sourceType: module'" "'import' 和 'export' 只能与 'sourceType: module' 一起出现"
Without configuration , it has to be inline .没有配置,它必须是内联的。
The following doesn't seem to be working以下似乎不起作用
/* eslint-disable */
// eslint-disable-next-line
Why:为什么:
Let's say you are writing a test inside a NON module project, and you want to prove you can or cannot dynamically import an ESM module.假设您正在非模块项目中编写测试,并且您想证明您可以或不能动态导入 ESM 模块。
describe('my test', it("doesn't work", ()=> require('./my.esm.js'))
Where 'my.esm.js' could be 'my.esm.js' 可能在哪里
export function noop {}
...or whatever ...管他呢
But the main project, nor the tests are module based.但是主要项目和测试都是基于模块的。
You can try to add "sourceType": "module"
to your eslint config file.您可以尝试将"sourceType": "module"
到您的 eslint 配置文件中。 Here's example:下面是例子:
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"semi": "error"
}
}
source: eslint docs来源: eslint 文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.