Error buddy should report "variable use before declaration" instead of a spelling mistake suggestion
- Dominant language
- JavaScript
- Stars
- 776
- Forks
- 180
- PR merge metrics
- No merged PRs in 30d
Description
Example:
```
console.log(ctr);
var ctr = 5;
```
Currently error buddy reports: "Did you mean to type 'str' instead of 'ctr'". It should probably report "You used 'ctr' before defining it". We should be able to handle this by passing the AST to BabyHint and doing some additional analysis to determine which variables are in scope.
We already compute which variables are in scope in `ASTTransforms.rewriteContextVariables`. This code should probably be extracted out in to ast-walker.js such that `walkAST` passes "scopes" as arg to the visitor methods `enter` and `leave`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with BabyHint and the existing scope computation in ASTTransforms.rewriteContextVariables. Read ast-walker.js and the walkAST visitor enter and leave paths to understand how scopes could be passed during traversal. Done means the example reports that ctr was used before declaration instead of suggesting str, without losing the existing scope behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100