luau/Analysis
PhoenixWhitefire fba48ae3e4
Add CollapseClauseToAssert lint
Adds the `CollapseClauseToAssert` lint, which triggers in the following code:

```
-- `if`-clause can be collapsed to an `assert`
if X then
    error("SomeErrorMessage")
end
```

* Any number of conditions for the `if`
* No `else` block
* `error` cannot be given a `level` argument
* Error string must be constant (no string interpolation/concatenation) to avoid slowdowns
* Body must _only_ be an `error` call

Inspired due to the following code on luau-lang.org:
https://luau-lang.org/2023/03/31/luau-recap-march-2023.html#:~:text=if%20not%20x%20then%20error(%27first%20argument%20is%20nil%27)%20end
2024-08-11 16:00:44 +05:30
..
include/Luau Sync to upstream/release/638 (#1360) 2024-08-09 10:18:20 -07:00
src Add CollapseClauseToAssert lint 2024-08-11 16:00:44 +05:30