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

esplint

v0.10.2

Published

A ESLint warning tracker to help introduce rules into a legacy code base

Downloads

22,787

Readme

esplint

npm Build Status codecov npm

An ESLint warning tracker to help introduce rules into a legacy code base

About

Linting is a powerful way to catch bad code and enforce best practices. That said, turning a rule on for an existing project can be difficult. It can surface hidden violations that you must fix before you can use the rule at all.

Instead, esplint allows you to turn new rules on as “warnings,” and prevent further violations. esplint tracks the number of eslint “warnings” in each file and prevents the number of “warnings” from increasing. When the number of “warnings” decreases, esplint records the new lower number. This way you can fix existing, legacy violations over time while avoiding further violations.

For more information about the motivation behind esplint, read this post.

Getting Started

Install esplint as a dev dependency of your project.

$ npm install esplint --save-dev

Create .esplintrc.js and add your configurations.

module.exports = {
  surfaceArea: [ ... ],
  rules: [ ...the rules you wish to track... ]
};

Run

$ ./node_modules/.bin/esplint

This will create a .esplint.rec.json record file that stores the number of eslint warnings per file. Add this file to your git repository.

NOTE: This record file will only include files with warnings. If a file is included in the esplint "surfaceArea" but not present in the record file then it has none of the tracked warnings.

Now add this esplint check to your validation on commit hooks (using lint-staged) or CI.

Here's an example using lint-staged:

// package.json

{
  ...
  "scripts": {
    "precommit": "lint-staged"
  },
  "lint-staged": {
    "*.js": [
      "esplint --stage-record-file"
    ]
  },
  ...
}

See a full example here.

Command line

$ ./node_modules/.bin/esplint --help

esplint [files..]

Run check and update record

Commands:
  esplint [files..]                  Run check and update record      [default]
  esplint stats                      Print stats about eslint violations
  esplint suppress <rule> [files..]  Disable eslint on specific lines to
                                      suppress a rule

Positionals:
  files  Paths to files or directories to run esplint on           [default: []]

Options:
  --version    Show version number                                     [boolean]
  --help       Show help                                               [boolean]
  --overwrite  Ignore existing record file            [boolean] [default: false]
  --no-write   Don't update record file               [boolean] [default: false]
  --stage-record-file  Git add record file. Helpful when running esplint on a
                       pre-commit hook.               [boolean] [default: false]

esplint

Run check and update record.

The options are:

  • --overwrite — Ignore existing record file. Useful to bypass the esplint check and force an increase in the number of warnings.
  • --no-write — Only perform warning count check and don't update the record file if the warning count goes down.
  • --stage-record-file — After esplint succeeds, this will git add the record file. This is helpful when running esplint on a pre-commit hook.

esplint stats

Print stats about eslint violations.

esplint suppress

Will suppress all existing violations of a eslint rule. It does this by inserting disable-eslint-next-line comments into your code.

NOTE: esplint suppress doesn't work very well with JSX because comments in JSX are very finicky. If you have an idea, let me know and open an issue.

Configuration

// .esplintrc.js

module.exports = {
  surfaceArea: [ ... ],
  eslint: { ... },
  rules: [ ... ],
  write: true,
};

The options are:

  • surfaceArea — An array of files and/or directories to track. Use [ "." ] to track all Javascript files in the current directory. These files and directories are used if no files or directories are specified from the CLI
  • eslint — ESLint class options.
  • rules — An array of eslint rule names to track.
  • write — Corresponds to the negation of the --no-write CLI option. See Command line options.

Git Conflicts

Git conflicts can sometimes occur in the record file. If that happens, running esplint should fix most cases.