Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Ignore Array.forEach in mocha-no-side-effect-code #545

Closed
reduckted opened this issue Oct 13, 2018 · 0 comments
Closed

Ignore Array.forEach in mocha-no-side-effect-code #545

reduckted opened this issue Oct 13, 2018 · 0 comments
Labels
Difficulty: Medium People with non-trivial experience in TSLint should be able to send a pull request for this issue. Status: Accepting PRs Type: Rule Feature Adding a feature to an existing rule.
Milestone

Comments

@reduckted
Copy link
Contributor

When I write parameterized tests, I use this style of code:

[1, 2, 3].forEach((value) => {
    it(`should work for a value of ${value}.`, () => {
        // Do the test.
    });
});

This ends up creating and running three tests:

  • "should work for a value of 1."
  • "should work for a value of 2."
  • "should work for a value of 3."

But, if the mocha-no-side-effect-code rule is enabled, this is flagged as an error because the rule treats Array.forEach as having side effects.

This could be ignored using the ignore option with something like "\.forEach\(", but I think this is something the rule should just handle in the first place.

@JoshuaKGoldberg JoshuaKGoldberg added Status: Accepting PRs Difficulty: Medium People with non-trivial experience in TSLint should be able to send a pull request for this issue. Type: Rule Feature Adding a feature to an existing rule. Hacktoberfest labels Oct 14, 2018
@JoshuaKGoldberg JoshuaKGoldberg added this to the 6.0.0-beta0 milestone Nov 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Difficulty: Medium People with non-trivial experience in TSLint should be able to send a pull request for this issue. Status: Accepting PRs Type: Rule Feature Adding a feature to an existing rule.
Projects
None yet
Development

No branches or pull requests

2 participants