Skip to content

[Linting Rule] Unused Import

github-actions[bot] edited this page Nov 8, 2026 · 1 revision

Generated from 'wiki-linter.ts' on 2026-11-06, 13:56:07 UTC (v2.17.3), do not edit directly.

Unused Import [overview]

smell quickfix readability

This rule is a best-effort rule.

Finds packages that are attached but never used, so the code runs just the same without them. Requires a signature database, and packages that only do their work on load should be whitelisted in the configuration.
This linting rule is implemented in src/linter/rules/unused-import.ts.

Configuration

Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The unused-import rule accepts the following configuration options:

  • whitelist
    packages that do their work on load and hence should never be reported, however unused they look

Examples

library(stats)
print("no stats function is used")

The linting query can be used to run this rule on the above example:

[ { "type": "linter",   "rules": [ { "name": "unused-import",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (7 ms)
   ╰ Unused Import (unused-import):
       ╰ uncertain:
           ╰ Import of stats at 1.1-14 (1 quick fix(es) available)

More examples are the test cases in test/functionality/linter/lint-unused-import.test.ts.

Clone this wiki locally

⌂ 换网址