Style Cleanup
raw JSON → 1.3.0 verified Fri May 01 auth: no javascript
A CLI tool to lint and automatically fix unused style declarations in React Native and Aphrodite codebases. Version 1.3.0 is the latest stable release, with low release cadence. It works by static analysis of JS files, detecting styles that are never referenced. Key differentiators: supports both React Native and Aphrodite, offers safe (fix) and aggressive (fix-force) removal modes, and handles glob patterns for batch processing. Unlike general linting tools, it specifically targets style objects and can remove dead code programmatically.
Common errors
error Error: Cannot find module 'babel-core' ↓
cause The tool depends on Babel 6 internally, which may not be installed or is incompatible with Babel 7+.
fix
Install babel-core explicitly: npm install babel-core@6
error SyntaxError: Unexpected token import ↓
cause The tool does not support ES modules (import/export) by default; may require older Babel configuration.
fix
Transpile your source files to CommonJS before running stylecleanup, or use an older codebase.
error stylecleanup: command not found ↓
cause Global installation missing or not in PATH.
fix
Use npx stylecleanup instead: npx stylecleanup check ./src/**/*.js
Warnings
gotcha fix command skips styles that might be used via computed property access (e.g., styles[something]), so not all unused styles are removed. ↓
fix Use fix-force to remove those as well, but be aware it may delete actually used styles.
gotcha The tool only analyzes static references; dynamic style access patterns like Object.assign or spread operators may cause false negatives. ↓
fix Manually review the results when using fix commands; consider adding tests to verify style usage.
deprecated The project appears to be unmaintained (last update around 2017); may not work with modern Babel or newer React Native versions. ↓
fix Consider alternatives like ESLint plugins (eslint-plugin-react-native or eslint-plugin-styled-components) for modern projects.
breaking No breaking changes documented; license is MIT but no changelog available. ↓
fix Test in a non-critical branch before running fix-force in production code.
Install
npm install stylecleanup yarn add stylecleanup pnpm add stylecleanup Imports
- stylecleanup (CLI) wrong
npm run stylecleanupcorrectnpx stylecleanup check ./src/**/*.js - default export
Not applicable (CLI-only; no programmatic API is documented)
Quickstart
// Ensure you have stylecleanup installed globally
// Then run on your source files:
npx stylecleanup check ./src/**/*.js
// To automatically remove unused styles (safe mode):
npx stylecleanup fix ./src/**/*.js
// To force-remove all potentially unused styles:
npx stylecleanup fix-force ./src/**/*.js