Skip to content

fix: Ignore findBy calls from ember-cli-mirage in no-array-prototype-extensions#2331

Merged
bmish merged 4 commits intoember-cli:masterfrom
VasylMarchuk:ignore-mirage-findby-calls
Sep 14, 2025
Merged

fix: Ignore findBy calls from ember-cli-mirage in no-array-prototype-extensions#2331
bmish merged 4 commits intoember-cli:masterfrom
VasylMarchuk:ignore-mirage-findby-calls

Conversation

@VasylMarchuk
Copy link
Contributor

@VasylMarchuk VasylMarchuk commented Sep 14, 2025

We're trying to fix array prototype extensions usages in our project, and are running into a lot of false positives in our tests when using findBy from ember-cli-mirage:

this.server.schema.courses.findBy({ slug: 'dummy' });
this.server.schema.users.findBy({ username: 'test' });

This adds an exception to lib/rules/no-array-prototype-extensions.js and adjusts the tests.

*/
const KNOWN_NON_ARRAY_FUNCTION_CALLS_REGEXP = new Set([
// ember-cli-mirage
/(window|undefined)\.server\.schema\.(.*)\.findBy\(\)/,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is (window|undefined) part of it? That doesn't seem related to this example.

Copy link
Contributor Author

@VasylMarchuk VasylMarchuk Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is how it comes up in eslint-plugin-ember's code that checks for exceptions (here in this file), as window.server... or undefined.server... even though in our tests we use this.server.... I am unsure why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change the regexp to just /\.server\.schema\.(.*)\.findBy\(\)/ if it seems more appropriate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like window / undefined is some artifact of our getName helper that we could probably fix separately. Either way, it's not relevant to us, so let's avoid including it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, changed to simply /\.server\.schema\.(.*)\.findBy\(\)/

@bmish bmish added the bug label Sep 14, 2025
Copy link
Member

@bmish bmish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bmish bmish merged commit eef345a into ember-cli:master Sep 14, 2025
11 checks passed
@bmish bmish changed the title Ignore findBy calls from ember-cli-mirage in no-array-prototype-extensions fix: Ignore findBy calls from ember-cli-mirage in no-array-prototype-extensions Sep 14, 2025
@VasylMarchuk VasylMarchuk deleted the ignore-mirage-findby-calls branch September 14, 2025 15:30
@github-actions github-actions bot mentioned this pull request Sep 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants