当 tslint 中的“no-floating-promises”为 true 时,如何忽略 Jasmine 承诺

Tre*_*phy 6 typescript protractor jasmine2.0 tslint

有没有办法打开“无浮动承诺”,但让它忽略“toEqual”、“toBe”等 Jasmine 承诺?我想使用它,但它到处抱怨我的期望语句。

expect(1).toEqual(1)  // Would complain about this
Run Code Online (Sandbox Code Playgroud)

例如:在此输入图像描述

Rob*_*Rob 3

我使用void茉莉花期望的关键字。尽管有一些关于这是否合适的讨论:https://github.com/palantir/tslint/issues/4653

void expect(1).toEqual(1)  // Would not complain about this
Run Code Online (Sandbox Code Playgroud)

  • 有效,但不喜欢这个解决方案,因为现在每个期望都必须以 void 开头 (3认同)