Registry /
devops / babel-plugin-danger-remove-unused-import
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ module.exports = require('babel-plugin-danger-remove-unused-import')
✗ import plugin from 'babel-plugin-danger-remove-unused-import'
CJS module; no default export. Use require() or .default in ESM.
plugin
✓ const plugin = require('babel-plugin-danger-remove-unused-import')
✗ import { plugin } from 'babel-plugin-danger-remove-unused-import'
No named export; use default require.
Babel config
✓ plugins: [['danger-remove-unused-import', { ignore: ['react'] }]]
✗ plugins: ['babel-plugin-danger-remove-unused-import']
Plugin name without prefix works if package is installed.
Show basic usage: configure plugin with ignore option to preserve React imports while removing unused lodash import.
// babel.config.js
module.exports = {
plugins: [
['danger-remove-unused-import', { ignore: ['react'] }]
]
};
// Input: import unused from 'unused-module';
// Output: (import removed)
const plugin = require('babel-plugin-danger-remove-unused-import');
const babel = require('@babel/core');
const code = `import _ from 'lodash'; import React from 'react'; console.log('hi');`;
babel.transformSync(code, { plugins: [[plugin, { ignore: ['react'] }]] });
// Result: import React from 'react'; console.log('hi');
Errors
Common errors & fixes
Plugin threw: Cannot find module 'babel-plugin-danger-remove-unused-import'
Package not installed or placed in wrong plugins array path.
fixRun `npm install babel-plugin-danger-remove-unused-import --save-dev` and ensure correct babel.config.js plugins entry.
TypeError: Cannot read property 'references' of undefined
Plugin not compatible with Babel 7.x parser or used without proper preset/env.
fixUse @babel/preset-env and ensure Babel version 6 or 7 compatibility in plugin's peerDependencies.
The plugin does not remove imports that are used as type annotations
Plugin only checks runtime references, not TypeScript type usage.
fixUse TypeScript compiler or type-aware plugin for type-only imports.
Audit
Dependencies
No dependency data recorded yet.