Registry / testing / babel-plugin-remove-stylename

babel-plugin-remove-stylename

JSON →
library0.1.0jsnpmunverified

A Babel plugin that removes styleName props from React JSX elements at build time. Developed to silence React warnings about unknown DOM props when using react-css-modules in test environments. Version 0.1.0 is the current and only stable release. This plugin is a niche utility for testing setups, with no updates since its initial release. It differs from alternatives that mock CSS modules by operating on the AST level, ensuring styleName props are completely removed from the output.

npm install babel-plugin-remove-stylename
INSTALL
IMPORT
SIG · BABEL-PLUGIN-REMOV
B
babel-plugin-remove-stylename
testingjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
// In .babelrc or babel.config.js plugins: ["remove-stylename"]
plugins: ["babel-plugin-remove-stylename"]
The plugin name is 'remove-stylename', not the full npm package name.
with options
plugins: [["remove-stylename", { /* options */ }]]
plugins: ["remove-stylename", {}]
Options must be in a nested array.

Babel configuration to remove styleName props only in test environment.

// Install first: npm install babel-plugin-remove-stylename --save-dev // Then configure Babel (e.g., in package.json): "babel": { "env": { "test": { "plugins": ["remove-stylename"] } } } // Example input: <div styleName="container">Hello</div> // Output: <div>Hello</div>
Debug
Known issues
gotchaJest caches Babel transformations aggressively; you may need to run with --no-cache after installing or modifying this plugin.
fix
Run jest with --no-cache flag or clear cache manually.
affects: >=0.0.0
gotchaPlugin name in Babel config must be 'remove-stylename', not the full package name 'babel-plugin-remove-stylename'.
fix
Use 'remove-stylename' as the plugin name.
affects: >=0.0.0
gotchaPlugin only affects JSX elements with styleName attribute; it does not handle CSS module imports or class name resolution.
fix
Combine with other CSS module mocking in tests if needed.
affects: >=0.0.0
Errors
Common errors & fixes
ReferenceError: [BABEL] unknown: Unknown plugin "remove-stylename" specified in ...
Plugin not installed or Babel cannot find it.
fix
Run 'npm install babel-plugin-remove-stylename --save-dev' and ensure node_modules is present.
Jest encountered an unexpected token when processing JSX after adding the plugin.
Babel configuration with plugin but missing @babel/preset-react.
fix
Add '@babel/preset-react' to your Babel presets in test environment.
The styleName attribute is not being removed in output.
Plugin not applied in the correct environment (e.g., test only).
fix
Verify the plugin is in the 'test' env section of Babel config and that Jest uses babel-jest.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
babel-corerequiredBabel plugin API dependency
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
babel-plugin-remove-stylename — npm install babel-plugin-remove-stylename · libregistry