ember-cli / ember-cli/eslint-plugin-ember

no-array-prototype-extensions false positive: `sinon.replace`

Open
#2,830 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
263
Forks
214
Avg merge
30m
Merged PRs (30d)
5

Description

Using the [sinon](https://sinonjs.org/) library's [recommended usage](https://sinonjs.org/concepts/fakes/#using-fakes-instead-of-spies) 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](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-array-prototype-extensions.md)?

```
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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the report with the provided sinon.replace example, then read docs/rules/no-array-prototype-extensions.md and trace the rule entry point that flags replace. Confirm whether the call is incorrectly treated as an Array prototype extension; done means the example no longer reports a false positive, with regression coverage for the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.