Skip to main content

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?

  1. Prevents confusing references to variables that have not been declared yet in the read order.
  2. Allows functions and classes to reference each other freely for alphabetical organization.
  3. 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.

OptionTypeDefaultDescription
classesbooleantrueCheck class declarations.
functionsbooleantrueCheck function declarations.
ignoreFilesstring[][]File patterns to skip.
typesbooleantrueCheck type alias and interface declarations.
variablesbooleantrueCheck 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 functions to false if you want to allow function forward references for alphabetical organization.
  • All categories are checked by default — Set classes, functions, or types to false individually to allow forward references for specific categories.