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

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

@reduckted

Description

@reduckted

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: MediumPeople with non-trivial experience in TSLint should be able to send a pull request for this issue.Status: Accepting PRsType: Rule FeatureAdding a feature to an existing rule.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions