Skip to content

no-array-prototype-extensions false positive: sinon.replace #2830

Description

@hoylemd

Using the sinon library's recommended usage of it's fakes feature.

Seems to be triggering on replace (though oddly, this doesn't appear to be a documented thing in the rule docs?

import sinon from 'sinon';

const fakeConfirm = sinon.fake.returns(true);
sinon.replace(window, 'confirm', fakeConfirm);

console.log(
  window.confirm('Are you a banana?') ? 'It's peanut butter jelly time!' : 'Perhaps you are a baseball bat'
);

sinon.restore();

If I may piggy-back on the report, it might be helpful to have some method to define custom exclusion patterns for this rule in the config to tide us over until the false positives can be fixed. Obviously, the rule can be disabled in-line (or for entire files), but that could also cover cases where the false-positive comes from project code instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions