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 🙏

© 2025 – Pkg Stats / Ryan Hefner

eslint-plugin-publicimage

v1.0.1

Published

Prevent large image imports from public folder

Downloads

7

Readme

eslint-plugin-public-dir-image-size

npm version license

An ESLint rule to prevent importing large images from your project's public directory, helping you maintain optimal bundle sizes and application performance.

Features

  • 🚫 Blocks imports of oversized images from public directories
  • ⚙️ Configurable maximum file size threshold
  • 📁 Supports custom public directory paths
  • 🖼️ Filters by common image extensions (jpg, png, etc.)
  • 🛠️ Catches both import statements and require() calls
  • 📝 Clear error messages with file details

Installation

npm install eslint-plugin-public-dir-image-size --save-dev

Usage

  1. Add plugin to your ESLint configuration (.eslintrc.js):
module.exports = {
  plugins: ["public-dir-image-size"],
  rules: {
    "public-dir-image-size/no-large-images": [
      "error",
      {
        publicDir: "public", // Custom public directory
        maxSizeMB: 1, // Maximum allowed image size (MB)
        allowedExtensions: [
          // Allowed image formats
          "jpg",
          "jpeg",
          "png",
          "gif",
          "webp",
        ],
      },
    ],
  },
};
  1. The rule will automatically check:
    • import statements
    • require() calls
    • Both relative and absolute paths to public directory

Configuration Options

| Option | Type | Default | Description | | ------------------- | -------- | --------------------------------------- | --------------------------------------- | | publicDir | string | "public" | Your public directory name | | maxSizeMB | number | 1 | Maximum allowed image size in megabytes | | allowedExtensions | string[] | ["jpg", "jpeg", "png", "gif", "webp"] | Image formats to check |

Example Error Messages

// When image exceeds size limit
Error: Image '/hero.jpg' exceeds maximum size of 1MB.

// When image not found
Error: Image '/missing.png' not found.

// When permission denied
Error: Permission denied when accessing image '/protected.jpg'.

Why Use This?

  • 🚨 Prevent Accidental Large Uploads: Catch oversized images during development so your Next.js bills won't shock you
  • ⏱️ Performance Guardrails: Enforce performance best practices
  • 🔍 Early Detection: Find issues before they reach production

License

MIT ©. See LICENSE for details.


Note: This rule only checks images imported via absolute paths starting with /. Make sure your project structure matches the configured publicDir.