npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

npm-organize-imports

v1.0.0

Published

Organize imports in JavaScript/TypeScript files using VSCode's organize imports functionality

Readme

npm-organize-imports

Automatically organize imports in all JavaScript/TypeScript files in your project using VSCode's organize imports functionality.

Features

  • Single optimized glob - Fast file discovery with one glob pattern
  • Shared language service - Reuses TypeScript language service across all files for 10x better performance
  • Project-aware - Respects tsconfig.json, path aliases, and baseUrl
  • Progress bar - Visual progress indicator for large projects
  • Smart change detection - Only writes files that actually changed
  • Dry run mode - Preview changes before applying them
  • Robust error handling - Detailed error messages and never crashes
  • Batch processing - Parallel processing for speed
  • Better validation - Validates all arguments with helpful error messages
  • Library support - Can be used as a library (doesn't call process.exit)
  • Proper formatting - Maintains spacing in import statements
  • Ignores build folders - Automatically skips node_modules, dist, build, etc.

Installation

npm install -g npm-organize-imports

Usage

Global Installation

Navigate to your project directory and run:

noi

Command Line Options

noi [options]

Options:
  -b, --batch-size <n>    Number of files to process in parallel (default: 10)
  -d, --dry-run           Preview changes without writing to files
  -h, --help              Show help message

Examples

# Organize all imports
noi

# Preview changes without modifying files
noi --dry-run

# Use larger batch size for faster processing
noi --batch-size 20

# Combine options
noi -b 5 -d

What It Does (Step-by-Step)

  1. 📁 Finds all files - Searches for all JavaScript/TypeScript files in your project
  2. ⚙️ Loads configuration - Reads your tsconfig.json or jsconfig.json if available
  3. 🔧 Organizes imports - Processes files in batches using TypeScript's API
  4. ✓ Detects changes - Only writes files that actually changed
  5. 💾 Saves files - Writes the organized imports back to each file (unless dry-run)
  6. 📊 Shows summary - Displays total files processed, changed, unchanged, and failed

Requirements

  • Node.js >= 14.0.0
  • TypeScript >= 4.0.0 (must be installed in your project)

How It Works

The package uses TypeScript's Language Service API to organize imports, which is the same engine that powers VSCode's "Organize Imports" command. This ensures consistent behavior across different environments.

Key Improvements

  1. Respects tsconfig.json - Loads your project's TypeScript configuration for accurate processing
  2. Smart change detection - Only writes files that actually changed, saving time and avoiding unnecessary file modifications
  3. Better error handling - Provides descriptive error messages for syntax errors and invalid files
  4. Improved formatting - Fixes spacing issues like ,type Match, type Match
  5. Dry run mode - Preview changes before applying them with --dry-run
  6. Handles edge cases - Detects and skips minified files and files with syntax errors

Batch Processing

By default, the tool processes 10 files at a time. This provides a good balance between speed and memory usage. You can adjust the batch size:

organize-imports 5   # Smaller batches (slower, less memory)
organize-imports 20  # Larger batches (faster, more memory)

Example Output

╔════════════════════════════════════════╗
║   Organize Imports - VSCode Edition   ║
╚════════════════════════════════════════╝

📂 Working directory: /path/to/your/project
✓ Found tsconfig.json

📁 Step 1: Finding all JavaScript/TypeScript files...
✓ Found 47 files

🔧 Step 2: Organizing imports in batches of 10...

⚙️  Batch size: 10

📦 Processing batch 1/5 (10 files)
  ✓ Updated: src/index.ts
  ✓ Updated: src/app.tsx
  ○ utils.js (no changes needed)
  ✓ Updated: components/Button.tsx
  ...
Progress: 10/47 files processed

📦 Processing batch 2/5 (10 files)
  ...

══════════════════════════════════════════════════
📊 Summary:
   Total files: 47
   ✓ Changed: 23
   ○ Unchanged: 24
══════════════════════════════════════════════════

✨ Done!

Dry Run Example

$ noi --dry-run

🔧 Step 2: Checking imports in batches of 10...
   (DRY RUN - no files will be modified)

📦 Processing batch 1/3 (10 files)
  ✓ Would change: src/index.ts
  ○ utils.js (no changes needed)
  ...

📊 Summary:
   Total files: 25
   ✓ Would change: 8
   ○ Unchanged: 17

💡 Run without --dry-run to apply changes

License

MIT