Comment by girvo

Comment by girvo 3 days ago

1 reply

> There's no way to exhaustively detect with a linter that you used findOne and checked the result for null and threw a NotFoundError

Yes there is? Though this is usually better served with a type checker, it’s still totally feasible with a linter too if that’s your bag

> because avoiding it is just one line in CLAUDE.md.

Except no, it isn’t, because these tools still ignore that line sometimes so I still have to check for it myself.

bastawhiz 2 days ago

> Yes there is? Though this is usually better served with a type checker, it’s still totally feasible with a linter too if that’s your bag

It's not, because you would have to implement a full static analyzer that traces where the result of a `findOne` call is checked for `null` and then check that the condition always leads to a `NotFoundError`. At best you've got a linter that only works some of the time, at worst you've just made your linter terribly slow and buggy.

> these tools still ignore that line sometimes so I still have to check for it myself.

this is _literally_ the point of the article