Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-loose-assertions and many other rules don't work in arrow functions #213

Closed
edg2s opened this issue Nov 2, 2021 · 1 comment · Fixed by #214
Closed

no-loose-assertions and many other rules don't work in arrow functions #213

edg2s opened this issue Nov 2, 2021 · 1 comment · Fixed by #214

Comments

@edg2s
Copy link
Contributor

edg2s commented Nov 2, 2021

Config

{
  "qunit/no-loose-assertions": "error",
  "qunit/no-arrow-tests": "off"
}

Code

QUnit.test( 'foo', ( assert ) => {
  assert.notOk( bar );
} );

The above should trigger a no-loose-assertions error, but it doesn't unless the arrow function is converted to a real function.

@edg2s edg2s changed the title no-loose-assertions doesn't work in arrow functions no-loose-assertions & no-assert-ok don't work in arrow functions Nov 2, 2021
edg2s added a commit to edg2s/eslint-plugin-qunit that referenced this issue Nov 2, 2021
Both of these rules use utils.createAssertionCheck, which only
checks for non-arrow functions.

Fixes qunitjs#213
edg2s added a commit to edg2s/eslint-plugin-qunit that referenced this issue Nov 2, 2021
@edg2s edg2s changed the title no-loose-assertions & no-assert-ok don't work in arrow functions no-loose-assertions and many other rules don't work in arrow functions Nov 2, 2021
@edg2s
Copy link
Contributor Author

edg2s commented Nov 2, 2021

The full list of affected rules:

  • assert-args
  • literal-compare-order
  • no-assert-equal
  • no-assert-equal-boolean
  • no-assert-logical-expression
  • no-assert-ok
  • no-async-in-loops
  • no-compare-relation-boolean
  • no-conditional-assertions
  • no-early-return
  • no-loose-assertions
  • no-negated-ok
  • no-ok-equality
  • no-throws-string
  • require-expect
  • require-object-in-propequal
  • resolve-async

platinumazure pushed a commit that referenced this issue Nov 3, 2021
…214)

* Fix: Check for arrow functions in utils.getAssertContextNameForTest

Fixes #213

* Add tests to other affected rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant