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

eslint-plugin-comment-cleaner

v1.1.0

Published

ESLint plugin to detect and flag commented-out code in your codebase

Downloads

192

Readme

eslint-plugin-comment-cleaner

ESLint plugin to detect, flag, and auto-fix commented-out code in your JavaScript and TypeScript projects.

npm version License: MIT

Built on the same smart detection engine as the comment-cleaner CLI.


✨ Features

  • 🔧 Auto-fix — run eslint --fix to automatically remove all flagged comments
  • 🧠 Smart detection — knows the difference between explanatory comments and actual dead code
  • 📦 no-commented-imports — dedicated rule that specifically targets commented-out import and require statements
  • 🔒 @keep annotation — mark any comment to permanently suppress the warning
  • ⚙️ Configurable — set custom ignore patterns per project
  • 🔌 ESLint v7, v8, v9 — supports both legacy and flat config
  • Zero dependencies

📦 Installation

npm install --save-dev eslint-plugin-comment-cleaner

🚀 Setup

ESLint v9 (Flat config — eslint.config.js or eslint.config.mjs)

import commentCleaner from "eslint-plugin-comment-cleaner";

export default [
  {
    plugins: {
      "comment-cleaner": commentCleaner,
    },
    rules: {
      "comment-cleaner/no-commented-code":    "warn",
      "comment-cleaner/no-commented-imports": "warn",
    },
  },
];

Or use the built-in recommended flat config:

import commentCleaner from "eslint-plugin-comment-cleaner";

export default [
  commentCleaner.configs["flat/recommended"],
];

ESLint v7 / v8 (Legacy config — .eslintrc.js)

module.exports = {
  plugins: ["comment-cleaner"],
  rules: {
    "comment-cleaner/no-commented-code":    "warn",
    "comment-cleaner/no-commented-imports": "warn",
  },
};

Or use the recommended config:

module.exports = {
  extends: ["plugin:comment-cleaner/recommended"],
};

🔧 Auto-fix

Both rules support ESLint's --fix flag. Running this will automatically delete all flagged commented-out code:

npx eslint ./src --fix

No manual deletion needed — ESLint removes the entire comment line including whitespace.


📏 Rules

comment-cleaner/no-commented-code

Detects and flags commented-out code of any kind — variables, functions, classes, JSX, assignments, and more.

// ❌ Flagged — will be auto-removed with --fix
// const BASE_URL = 'https://api.legacy.com/v1';
// function oldGetUser(id) { return db.query(id); }
// this.state = { loading: false };

// ✅ Ignored — explanatory comments
// Load posts from Firebase
// TODO: add retry logic
// @keep const LEGACY_URL = 'https://legacy.api.com';

Options:

| Option | Type | Default | Description | |--------|------|---------|-------------| | ignorePatterns | string[] | [] | Regex patterns — matching comments are ignored |

rules: {
  "comment-cleaner/no-commented-code": ["warn", {
    ignorePatterns: ["eslint-disable", "prettier-ignore"]
  }]
}

comment-cleaner/no-commented-imports

A focused rule specifically for commented-out import and require statements — the most common type of dead code in JS/TS projects.

// ❌ Flagged — will be auto-removed with --fix
// import axios from 'axios';
// import { useState, useEffect } from 'react';
// import type { User } from './types';
// const db = require('./db');

// ✅ Ignored
// @keep import legacy from './old-api'; // needed for migration
// TODO: re-add axios when backend is ready

No options needed — it just works.


🔒 @keep Annotation

Add @keep anywhere in a comment to permanently suppress the warning for that block:

// @keep const LEGACY_URL = 'https://legacy.api.com';
// @keep import { oldHelper } from './legacy';

/* @keep
  .old-card { display: none; }
*/

🧠 How Detection Works

Only flags actual dead code — not comments that explain what your code does.

✅ These are IGNORED

// Load posts from Firebase
// TODO: add retry logic
// Helper function to split the title
/** @param {string} id - The user ID */
// @keep const LEGACY_URL = 'https://legacy.api.com';
// https://docs.firebase.google.com

❌ These are FLAGGED (and auto-fixed)

// import TwitterTimeline from "../components/TwitterTimeline";
// const BASE_URL = 'https://api.legacy.com/v1';
// function oldGetUser(id) { return db.query(id); }
// this.state = { loading: false };
// fetchUser(id).then(res => res.json());

💡 Tips

  • Run npx eslint ./src --fix to auto-remove everything in one shot
  • Use no-commented-imports alongside no-commented-code for full coverage
  • Add @keep to any comment you want to intentionally preserve
  • Use ignorePatterns to skip comments matching specific strings or patterns
  • Both rules work with TypeScript files out of the box

🔗 Related


👨‍💻 Author

Nwamini Emmanuel O


📝 License

MIT © 2026 Nwamini Emmanuel O