Repository navigation
v0.6.0
What changed
oxlint.json now runs no-use-before-define with { "functions": true } (was false):
- Fails now: a function declaration referenced above its declaration, including a call from inside another function's body. Every kind of name —
const,let,var,class,enumand nowfunction— is declared before it is used, so a file reads in one direction: helpers first, the entry last. - Stays allowed: type-only references (default
ignoreTypeReferences).
The README's Decisions entry and the self-test are updated; no other rule changed.
What newly fails
export function main(): number {
return helper();
// error eslint(no-use-before-define): 'helper' was used before it was defined.
}
function helper(): number {
return 1;
}How to fix
- Move the function declaration (with its comments) above its first use. Moving a
functiondeclaration never changes behavior: declarations are hoisted. - oxlint has no autofix for this rule.
- Two functions that call each other cannot both come first: keep the order and put
// oxlint-disable-next-line no-use-before-defineon the use, with the reason, or restructure.
How to exempt
// oxlint-disable-next-line no-use-before-definereportUnusedDisableDirectives: "error" fails the comment once it is no longer needed. A repository can also set "functions": false in its own config.
Impact on consumers
Measured with oxlint 1.87.0 and a config that enables only this rule:
| Repository | Hits |
|---|---|
| agent-kit | 417 (reordered before adopting the tag) |
| project-template-rush | 0 |
The other consumers are measured when they adopt the tag.