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 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-disable-inserter

v0.4.0

Published

Easily insert `eslint-disable-next-line` comments into your code.

Downloads

14,119

Readme

eslint-disable-inserter

Easily insert eslint-disable-next-line comments into your code.

npm version CI-CD

When moving to a new ESLint config, or when adopting ESLint for the first time, it's common to have tons of violations that you want to silence for now.

This library exposes a helpful utility, eslint-disable-inserter, that will do all the heavy lifting, and insert // eslint-disable-next-line ... or {/* eslint-disable-next-line ... */} comments into your code.

It handles JSX detection, and will insert the correct comment in the correct places.

This utility is idempotent, so it can be used each time you add a new ESlint rule.

Example (Before/After)

With the following file, which has some violations and a existing comment:

export const MyComponent = () => {
  let count = 0
  count += 1
  const messages: any = undefined
  return (
    <div>
      <h1>MyComponent</h1>
      <p>Count: {count + messages.myMessage}</p>
      {/* eslint-disable-next-line eqeqeq -- my comment */}
      <p>Is Zero: {count == 0 ? messages.yes : messages.no}</p>
    </div>
  )
}

Running the following command:

eslint --format json . | eslint-disable-inserter

Will transform the file to:

export const MyComponent = () => {
  let count = 0
  count += 1
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- FIXME
  const messages: any = undefined
  return (
    <div>
      <h1>MyComponent</h1>
      {/* eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- FIXME */}
      <p>Count: {count + messages.myMessage}</p>
      {/* eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, eqeqeq -- FIXME my comment */}
      <p>Is Zero: {count == 0 ? messages.yes : messages.no}</p>
    </div>
  )
}

Installation

yarn add --dev eslint-disable-inserter

or

pnpm install -D eslint-disable-inserter

Usage

In your package.json, add the following script:

{
  "scripts": {
    "eslint:insert-disables": "eslint --format json . | eslint-disable-inserter"
  }
}

Alternatively, you can install it globally and do the piping in your shell.

Previewing your changes

The --dry-run / -d flag will prevent any filesystem writes, and will instead print the modified files to stdout for you to inspect.

Prevent FIXME addition

The --no-fix-me flag will to prevent addition of -- FIXME along with the eslint-disable-next-line comment

Special rules handled

max-lines

The max lines error is not tied to a specific line of code but at a position in the file. When encountered, the comment will be inserted at the right position in the file. Not just before the line that triggered the error as it's done with the other rules.

Keep track of your errors

The aim of this is to help you improve the quality of your code. It's important to have a plan to fix those errors.

I also published a small package to easily keep track of the eslint errors of your codebase: eslint-disabled-stats

License

MIT