Registry / devops / js-cleanup

js-cleanup

JSON →
library1.2.0jsnpmunverified

js-cleanup is a smart comment and whitespace cleaner for JavaScript-like files (JS, TS, Flow, React, ES9+). Current stable version is 1.2.0, released September 2020. It provides configurable comment filtering (preserve 'all'/'some'/'none'), blank line compaction, trailing whitespace removal, line ending normalization, TypeScript definitions, and sourcemap support. Unlike minifiers like Uglify, it preserves code style while giving fine-grained control over comments. Requires Node >=10.14.2 (<11.x). Release cadence is low; repository appears in maintenance mode.

npm install js-cleanup
INSTALL
IMPORT
SIG · JS-CLEANUP
J
js-cleanup
devopsjavascriptv1.2.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.

jsCleanup
import { jsCleanup } from 'js-cleanup'
const jsCleanup = require('js-cleanup')
The package exports a named function jsCleanup; default import does not exist. CJS require() works but is less idiomatic for ESM.
Result
import { Result } from 'js-cleanup'
Type-only import for TypeScript users; valid as a type import.
Options
import { Options } from 'js-cleanup'
import { Options } from 'js-cleanup' (casing mismatch, Options vs options)
Options type is exported as a named interface. Ensure correct capitalization.

Demonstrates basic usage of jsCleanup: removes comments, compacts blank lines, and normalizes line endings.

import { jsCleanup } from 'js-cleanup'; const sourceCode = `function hello() { // this is a comment console.log('Hello, world!'); }`; const result = jsCleanup(sourceCode, 'hello.js', { comments: 'some', compactComments: true, maxEmptyLines: 0, lineEndings: 'unix', sourcemap: false }); console.log(result.code); // function hello() { // console.log('Hello, world!'); // }
js-cleanup --version
Debug
Known issues
breakingNode.js v11 is buggy and unsupported. Avoid using it with js-cleanup.
fix
Upgrade to Node.js v10.14.2, v12.0.0, or later (excluding v11).
affects: >=1.0.0
gotchaThe default export is not available; use named import { jsCleanup }.
fix
Use import { jsCleanup } from 'js-cleanup' instead of default import.
affects: >=1.0.0
deprecatedType definitions require manual installation of @types/js-cleanup if not using TypeScript >=2.2?
fix
Ensure TypeScript version is >=2.2 to consume bundled types.
affects: >=1.0.0
breakingMinimum Node.js version increased to 10.14.2 or 12.0.0 in v1.2.0.
fix
Upgrade Node.js to >=10.14.2 (v11 excluded) or >=12.0.0.
affects: >=1.2.0
gotchaThe 'comments' option accepts string or RegExp. Using 'none' removes all comments, but triple-slash directives may also be removed unless 'ts3s' filter is used.
fix
Use comments: 'ts3s' to preserve TypeScript triple-slash directives while removing other comments.
affects: >=1.0.0
Errors
Common errors & fixes
Uncaught ReferenceError: jsCleanup is not defined
Using default import instead of named import.
fix
Use import { jsCleanup } from 'js-cleanup'.
Cannot find module 'js-cleanup'
Package not installed or incorrect import path.
fix
Run 'npm install js-cleanup --save-dev' and ensure the import path is correct.
TypeError: jsCleanup is not a function
Attempting to call default export or require result incorrectly.
fix
Ensure you use import { jsCleanup } from 'js-cleanup' and then call jsCleanup() with correct arguments.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
js-cleanup — npm install js-cleanup · libregistry