Skip to content

Commit ce5606e

Browse files
committed
Exclude member expressions from permissive tracking.
1 parent a1a7dd7 commit ce5606e

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

docs/reactivity.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ const Component = (props) => {
218218
return <div>{value()}</div>;
219219
};
220220

221+
const Component = (props) => {
222+
const [value] = createSignal(props.value);
223+
};
224+
221225
const Component = (props) => {
222226
const derived = () => props.value;
223227
const oops = derived();

src/rules/reactivity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ export default createRule<Options, MessageIds>({
836836
if (
837837
isFunctionNode(traced) ||
838838
(traced.type === "Identifier" &&
839+
traced.parent.type !== "MemberExpression" &&
839840
!(traced.parent.type === "CallExpression" && traced.parent.callee === traced))
840841
) {
841842
pushTrackedScope(childNode, "called-function");

test/rules/reactivity.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,13 @@ export const cases = run("reactivity", rule, {
402402
},
403403
],
404404
},
405+
{
406+
code: `
407+
const Component = props => {
408+
const [value] = createSignal(props.value);
409+
}`,
410+
errors: [{ messageId: "untrackedReactive", type: T.MemberExpression }],
411+
},
405412
// mark `props` as props by name before we've determined if Component is a component in :exit
406413
{
407414
code: `

0 commit comments

Comments
 (0)