Registry / devops / prettier-plugin-unused-imports-configurable

prettier-plugin-unused-imports-configurable

JSON →
library1.15.0jsnpmunverified

A Prettier plugin that automatically removes unused imports from JavaScript, TypeScript, and React files during formatting. Version 1.15.0 is the latest stable release, actively maintained with monthly updates. Key differentiators: configurable to ignore specific directories (ideal for monorepos), supports exclusion comments per file, handles namespace imports, aliases, and qualified usages, merges duplicate imports, and has extensive test coverage (>80%). Compared to similar plugins like `prettier-plugin-unused-imports`, this one offers more granular control over which folders to exclude.

npm install prettier-plugin-unused-imports-configurable
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-UN
P
prettier-plugin-unused-imports-configurable
devopsjavascriptv1.15.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Plugin
✓ Not directly imported; placed in .prettierrc: { "plugins": ["prettier-plugin-unused-imports-configurable"] }
✗ import prettierPluginUnusedImports from 'prettier-plugin-unused-imports-configurable'
This is a Prettier plugin, not a programmatic API. Configure via .prettierrc or Prettier options.
ignoreDirectories
✓ Add to .prettierrc: { "ignoreDirectories": ["src/generated"] }
✗ Set via environment variable or as a separate option
The option is camelCase 'ignoreDirectories', not 'ignoredDirectories'. Case-sensitive.
Exclusion comment
✓ // prettier-ignore-unused-imports-configurable (above the first import declaration)
✗ // prettier-ignore-unused-imports
The comment must be exactly 'prettier-ignore-unused-imports-configurable' and placed before the first import. Other comments are ignored.

Installs the plugin, configures .prettierrc to enable it and ignore a directory, then formats a TypeScript file to remove an unused import.

npm install --save-dev prettier prettier-plugin-unused-imports-configurable echo '{"plugins": ["prettier-plugin-unused-imports-configurable"], "ignoreDirectories": ["src/generated"]}' > .prettierrc echo 'import { unusedVar } from "./module"' > src/test.ts prettier --write src/test.ts # src/test.ts now has: (empty file, unused import removed)
Debug
Known issues
breakingVersion 1.15.0 replaced babel-ts parser with TypeScript parser for .ts/.tsx files. May cause differences in import detection for complex TypeScript features.
fix
Review your TypeScript imports after upgrading. The new parser may detect usage differently.
affects: >=1.15.0
gotchaThe option name is 'ignoreDirectories' (camelCase), not 'ignoredDirectories' or 'ignore-directories'. Incorrect casing will be silently ignored.
fix
Use 'ignoreDirectories' exactly as documented in .prettierrc.
affects: *
gotchaExclusion comment must be exactly '// prettier-ignore-unused-imports-configurable' and placed before the first import declaration. Comments after the first import are ignored.
fix
Place the comment on its own line above the first import statement in the file.
affects: *
deprecatedVersion 1.15.0 deprecated the babel-ts parser; the new TypeScript parser may require Prettier >=3.4.2.
fix
Ensure you have Prettier ^3.4.2 installed. If you encounter parsing errors, downgrade to <1.15.0.
affects: >=1.15.0
Errors
Common errors & fixes
Ignore directories option not working; imports in ignored folder are still removed
The option name 'ignoredDirectories' is misspelled; correct is 'ignoreDirectories'.
fix
Use 'ignoreDirectories' (without 'd' in 'ignore') in .prettierrc.
Import removal broken after upgrading to v1.15.0; TypeScript errors for some imports
Parser changed from babel-ts to TypeScript, which may parse JSX or type-only imports differently.
fix
Upgrade prettier to ^3.4.2. If issues persist, downgrade to 1.14.0 or file an issue on GitHub.
Exclusion comment not working; import still removed
Comment must be exactly 'prettier-ignore-unused-imports-configurable' and placed before the first import declaration.
fix
Check the comment spelling and ensure it appears on its own line above the first import.
Upgrade
Version history
1.15.0latest on npm
Audit
Dependencies
prettierrequiredpeer dependency - plugin requires Prettier >=3.4.2 to function
Agent activity
10 hits · last 30 days
node
10
Resources
prettier-plugin-unused-imports-configurable — npm install prettier-plugin-unused-imports-configurable · libregistry