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

unnecessary-file-police

v1.0.0

Published

A pre-publish hook that screams at you if you are about to publish unnecessary files

Readme

Unnecessary File Police 🚔

A pre-publish hook that screams at you if you are about to publish unnecessary files to npm.

The Problem

People accidentally publish massive files to npm (Photoshop files, local databases, test videos), creating "bloatware" packages that waste bandwidth and storage space.

How It Works

You run npx diet-police (or add it to prepublishOnly). It scans the folder and ignores standard code files. It alerts you:

⚠️  Warning: You are about to publish 'design-mockup.psd' (55MB). Add to .npmignore?

Why It's Unique

Existing tools just tell you the size of the package. This one identifies suspicious file types that don't belong in a registry.

Installation

npm install unnecessary-file-police --save-dev

Usage

As a CLI Tool

# Scan current directory
npx diet-police

# Scan specific directory
npx diet-police --directory ./my-package

# Set custom threshold (default: 10MB)
npx diet-police --threshold 5242880

# Verbose output
npx diet-police --verbose

# Auto-fix: automatically add suggestions to .npmignore
npx diet-police --auto-fix

As a Pre-publish Hook

Add to your package.json:

{
  "scripts": {
    "prepublishOnly": "diet-police"
  }
}

Now it will automatically run before you publish to npm!

What It Detects

Suspicious File Extensions

  • Design files: .psd, .ai, .sketch, .fig, .xd
  • Videos: .mp4, .mov, .avi, .mkv
  • Databases: .db, .sqlite, .sqlite3
  • Archives: .zip, .tar, .gz, .rar, .7z
  • Executables: .exe, .dmg, .pkg, .deb, .rpm, .iso
  • Documents: .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx
  • Audio files: .wav, .flac, .aac, .ogg, .wma

Large Files

Any file larger than 10MB (configurable) that doesn't have a standard code extension will be flagged.

Allowed Extensions (Ignored)

Standard code and configuration files are ignored:

  • JavaScript/TypeScript: .js, .ts, .jsx, .tsx
  • Styles: .css, .scss, .sass, .less
  • Config: .json, .yml, .yaml, .md, .txt
  • Build files: .html, .vue, .svelte
  • Other languages: .py, .java, .c, .cpp, .go, .rs, etc.

Examples

Example Output

🔍 Scanning for unnecessary files...

⚠️  Found 3 suspicious file(s):

1. design-mockup.psd (55.2MB)
   Reason: suspicious extension

2. test-video.mp4 (12.8MB)
   Reason: large file

3. local.db (2.1MB)
   Reason: suspicious extension

Total size of suspicious files: 70.1MB

💡 Suggested .npmignore entries:
  **/*.psd
  **/*.mp4
  **/*.db

💡 Run with --auto-fix to automatically add these to .npmignore

🚨 Please review these files before publishing!

Auto-fix Mode

npx diet-police --auto-fix

This will automatically add the suggested patterns to your .npmignore file.

API Usage

const UnnecessaryFilePolice = require('unnecessary-file-police');

const police = new UnnecessaryFilePolice({
  threshold: 10 * 1024 * 1024, // 10MB
  suspiciousExtensions: ['.psd', '.mp4'],
  allowedExtensions: ['.js', '.json']
});

const suspiciousFiles = await police.scanDirectory('./my-package');
const suggestions = police.generateNpmignoreSuggestions(suspiciousFiles);

console.log('Suspicious files:', suspiciousFiles);
console.log('Npmignore suggestions:', suggestions);

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | threshold | number | 10485760 (10MB) | File size threshold in bytes | | suspiciousExtensions | array | See above | File extensions to flag | | allowedExtensions | array | See above | File extensions to ignore |

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT © [Your Name]

Related Tools

  • npm-pack-list - Shows what files will be included in your npm package
  • size-limit - Limit the size of your npm package

Stop bloatware before it happens! 🚔📦