【发布时间】:2019-09-30 02:39:18
【问题描述】:
我正在使用Promise.all 调用一组 Promise。我们的开发版本只支持 ES5。因此,当我使用以下语句时,ESLINT 会引发错误:
Promise.all([
service.document.getDocumentByPath( grantorPath ),
service.document.getDocumentByPath( synonymPath ),
service.document.getDocumentByPath( templatePath )
]).then(function([grantorDoc, synonymDoc, templateDoc]) {
ESLint error : Unexpected destructuring. eslint(es5/no-destructing)
我愿意
- 在不触及 eslint 规则的情况下移除 ESLINT 错误。
- 使用 Promise 解决后收到的结果(grantorDoc、synonymDoc、templateDoc)。
【问题讨论】:
-
禁用下一行的控件怎么样? stackoverflow.com/questions/27732209/…
-
那么您是否尝试编写代码以不使用解构?您可以通过不编写 ES5 中无效的代码来消除错误。
-
正如我在问题中提到的,我不想触及 ESLINT 规则。
-
为什么不能使用不使用解构的代码?
-
对象解构是 es6 自带的,所以如果你不想更改 eslint 规则,请遵循它们。
标签: javascript ecmascript-6 es6-promise eslint ecmascript-5