No Use Before Define
Catch identifiers used before their declaration so read order matches definition order. Set individual options to false to allow forward references for specific categories.
Summary
The no-use-before-define rule reports any identifier that is referenced before its declaration — including variables, functions, classes, and types.
All categories are checked by default. Set individual options to false to allow forward references for specific categories.
Why Use This Rule?
- Prevents confusing references to variables that have not been declared yet in the read order.
- Allows functions and classes to reference each other freely for alphabetical organization.
- Catches temporal dead zone errors at lint time instead of at runtime.
Examples
Configuration
Options
warning
ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.
| Option | Type | Default | Description |
|---|---|---|---|
classes | boolean | true | Check class declarations. |
functions | boolean | true | Check function declarations. |
ignoreFiles | string[] | [] | File patterns to skip. |
types | boolean | true | Check type alias and interface declarations. |
variables | boolean | true | Check const and let declarations. |
Autofix
Autofix is not available for this rule. Flagged code must be updated manually.
Troubleshooting
- Function forward references are flagged — Set
functionstofalseif you want to allow function forward references for alphabetical organization. - All categories are checked by default — Set
classes,functions, ortypestofalseindividually to allow forward references for specific categories.