From 37101efd6b3e5434a4389dc131e693afc52981aa Mon Sep 17 00:00:00 2001 From: Stalin <161853795+0x5t4l1n@users.noreply.github.com> Date: Mon, 3 Aug 2026 01:00:40 +0530 Subject: [PATCH] fix: warn when Ember object property is initialised with a call expression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves #300. The avoid-leaking-state-in-ember-objects rule called isAllowed() which unconditionally permitted any CallExpression value (e.g. myProp: A()). Call expressions that return objects or arrays produce a shared instance across all instances of the Ember object, leaking state just like an inline array/object literal would. Remove types.isCallExpression from the isAllowed allow-list so that myProp: A(), myProp: EmberObject.create(), etc. are flagged. Pure function calls that return primitives will also be flagged, but that is the safe default — users can add them to the ignoredProperties list for their specific case. --- lib/rules/avoid-leaking-state-in-ember-objects.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rules/avoid-leaking-state-in-ember-objects.js b/lib/rules/avoid-leaking-state-in-ember-objects.js index 3069286991..471f45000a 100644 --- a/lib/rules/avoid-leaking-state-in-ember-objects.js +++ b/lib/rules/avoid-leaking-state-in-ember-objects.js @@ -37,7 +37,9 @@ function isAllowed(value) { ember.isFunctionExpression(value) || types.isLiteral(value) || types.isIdentifier(value) || - types.isCallExpression(value) || + // NOTE: CallExpression intentionally removed — myProp: A() or + // myProp: EmberObject.create() creates a shared instance across all + // object instances, leaking state. See issue #300. types.isBinaryExpression(value) || types.isTemplateLiteral(value) || types.isTaggedTemplateExpression(value) ||