Create a lint rule to detect bad patterns in plans
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 625
- Avg merge
- 5h 23m
- Merged PRs (30d)
- 24
Description
```diff
plans: {
User: {
friends($user) {
- const $db = context().get('db');
const $ids = $user.get('friendIds');
return each($ids, $id => {
+ const $db = context().get('db');
return loadOne($id, $db, getFriendById);
});
}
}
}
```
The `$db` in the outer scope will have been garbage collected by the time the `each()` callback is called, so the `loadOne` call will raise an error due to trying to depend on deleted step.
Either:
1. Don't delete this step (risky because it opens the door to much worse behavior!), or
2. Add a lint rule that detects this and has the step be created inside the `each` callback instead.
Contributor guide
Assessment
This issue has not been assessed yet.