Skip to content

fix(no-side-effects): ignore functions stored as object property values - #2918

Merged
NullVoxPopuli merged 1 commit into
ember-cli:masterfrom
abedinm:fix/no-side-effects-object-callbacks
Dec 2, 2026
Merged

NullVoxPopuli merged 1 commit into
ember-cli:masterfrom
abedinm:fix/no-side-effects-object-callbacks

Conversation

@abedinm

@abedinm abedinm commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #1156

no-side-effects reported assignments inside a function that is only stored as an object property value, for example:

get foo() {
  return { bar: (x) => { this.x = x; } };
}

That function is not called while the getter or computed property runs, so it is not a side effect of it. The rule now skips arrow functions, function expressions and method shorthands that are the value of an object property.

Functions that may run during the getter (for example a callback passed to forEach) are still checked; an invalid test covers that.

Tests: added 4 valid cases and 1 invalid case to tests/lib/rules/no-side-effects.js. The 4 valid cases fail without the change. pnpm test (270 files, 10067 tests) and pnpm lint:js, lint:prettier, lint:docs, lint:eslint-docs, lint:package-json pass locally. I did not run lint:remote.

@NullVoxPopuli
NullVoxPopuli merged commit 6ce84bc into ember-cli:master Dec 2, 2026
12 checks passed
@NullVoxPopuli

Copy link
Copy Markdown
Contributor

tyty

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.

[ember/no-side-effects] False-positive with an assignment in a lambda

2 participants