Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk2 min

How to Configure @typescript-eslint/no-unused-vars for Underscore Names

Configure the TypeScript-aware unused-vars rule correctly: disable ESLint’s core rule and set underscore ignore patterns for each relevant name category.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use @typescript-eslint/no-unused-vars, disable ESLint’s core no-unused-vars rule, then configure an underscore ignore pattern separately for each name category your project wants to exempt. The official example uses ^_. A variable pattern alone does not exempt unused arguments, caught errors, or destructured array elements.

Enable the TypeScript-aware rule

@typescript-eslint/no-unused-vars extends ESLint’s core unused-variable rule with support for TypeScript features, including types. The typescript-eslint rule documentation warns that the core rule can report incorrect errors for TypeScript, so turn it off when enabling the extension.

As an Amazon Associate I earn from qualifying purchases.

export default defineConfig({
  rules: {
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": "error",
  },
});

This is the flat-config form. The documentation also provides a legacy configuration form. Extending plugin:@typescript-eslint/recommended enables the rule as well.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to ignore underscore-prefixed names

Set ^_ as the ignore pattern for each category where a leading underscore means “intentionally unused.” These are independent settings: varsIgnorePattern does not set a policy for arguments, caught errors, or destructured array elements.

{
  "@typescript-eslint/no-unused-vars": [
    "error",
    {
      "args": "all",
      "argsIgnorePattern": "^_",
      "caughtErrors": "all",
      "caughtErrorsIgnorePattern": "^_",
      "destructuredArrayIgnorePattern": "^_",
      "varsIgnorePattern": "^_",
      "ignoreRestSiblings": true
    }
  ]
}

This follows the official FAQ’s example for emulating TypeScript’s underscore exemption. The args: "all" and caughtErrors: "all" settings make the corresponding ignore patterns relevant to all arguments and caught errors. ignoreRestSiblings: true handles the documented rest-sibling case. Keep only the exemptions that match your project’s convention.

Which underscore settings control which names?

Setting Applies to
varsIgnorePattern Variables
argsIgnorePattern Function arguments
caughtErrorsIgnorePattern Caught errors
destructuredArrayIgnorePattern Destructured array elements

For example, if your policy exempts only underscore-prefixed variables, configure varsIgnorePattern without assuming it changes argument handling. Add the other patterns only if those categories should follow the same convention.

Rank #2
TypeScript Programming Language - Software Engineer & Coder T-Shirt
  • TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
  • TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem

How this differs from TypeScript compiler checks

TypeScript’s noUnusedLocals and noUnusedParameters compiler options can report unused locals and parameters. The lint rule offers configurable exemptions such as varsIgnorePattern, and ESLint can be configured for lines, files, and folders; compiler options are tied to a TSConfig. Compiler errors may also block builds more directly than lint findings. The typescript-eslint documentation recommends its rule for flagging unused locals and parameters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Disabling those compiler options does not guarantee that an editor will stop visually dimming unused variables: for example, VS Code may still grey them out.

Should the rule automatically remove unused imports?

By default, the TypeScript-specific enableAutofixRemoval.imports option is false. Unused imports receive suggestion fixes rather than automatic fixes. Setting it to true allows automatic removal; if every specifier in an import declaration is unused, the declaration is removed.

Use automatic removal only if your codebase does not rely on import side effects. An import can execute module code even when its imported binding is not referenced, so automatic deletion may change runtime behavior in projects that depend on that behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why can apparently used code still be reported?

A variable is used only in a type position

The rule does not count a variable used only for a type as used. The documentation illustrates this with typeof and a Zod schema. If a runtime value exists only to derive a type, consider whether a direct type declaration better expresses the intent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A name appears in a JSDoc link

JSDoc @link references are not recognized as uses by this rule. The documentation points to a separate JSDoc rule as a possible way to address undefined references.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.