no-unused-vars
Configuration
rslint.config.ts
Rule Details
Disallow unused variables.
Variables, functions, and function parameters that are declared but never used anywhere in the code are most likely an error due to incomplete refactoring. This rule extends the base ESLint no-unused-vars rule with TypeScript-specific awareness:
- Detects variables that are only used in type contexts (e.g., type annotations) and not in runtime code, reporting them as "defined but only used as a type"
- Recognizes type-level declarations (interfaces, type aliases, enums) and imports as validly used when referenced in type positions
- Handles declaration merging (e.g., interface + const with the same name)
- Respects ambient declarations (
declare module,.d.tsfiles) - Marks JSX factory and fragment factory imports as used when JSX elements are present (for
jsx: "preserve"/"react-native"modes)
Options
Examples of incorrect code for this rule:
Examples of correct code for this rule: