angularjs promises 用finally这个词。 grunt jshint 抱怨

angularjs promises use the word finally. grunt jshint complains

AngularJS 允许在承诺的 return 之后使用 finally。但是,当我有 grunt-jshint 运行 时,我会不断收到

Expected an identifier and instead saw 'finally' (a reserved word).

有人知道如何在 jshint 中关闭它吗?

es5 选项

This option enables syntax first defined in the ECMAScript 5.1 specification. This includes allowing reserved keywords as object properties.

如果您使用的是 2.0.0 之前的 jshint 版本,则可以选择设置 es5 标志。从 2.0.0 开始,es5 是默认值。我假设您使用的是旧版本。

或者

你也可以说 promise['finally'](function(){}); 而不是 promise.finally(function(){});

参见