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

@voxpelli/eslint-formatter-summary

v3.0.0

Published

ESLint summary formatter aggregating results by rule

Downloads

476

Readme

npm version npm downloads

@voxpelli/eslint-formatter-summary

ESLint formatter aggregating results by rule

Fork of mhipszki/eslint-formatter-summary pending the upstreaming of some/all changes.

Features

  • aggregated errors / warnings per rule
  • sort by rule name, number of errors or warnings
  • NEW: output markdown

TL;DR

This formatter simply aggregates the ESLint results by rule and shows the following output:

It can also be configured to sort results by rule, errors or warnings using env vars e.g.

EFS_SORT_BY=rule EFS_SORT_DESC=true eslint -f @voxpelli/eslint-formatter-summary ./src

(see details below).

How to install

npm i -D @voxpelli/eslint-formatter-summary

How to use

When you run ESLint just specify @voxpelli/eslint-formatter-summary as the formatter:

eslint -f @voxpelli/eslint-formatter-summary [file|dir|glob]*

See http://eslint.org/docs/user-guide/command-line-interface#-f---format

Intention

It is a matter of minutes to add ESLint to a new project, however it can be quite challenging to introduce it (or just add a stricter rule set) to existing projects, already large codebases.

Possibly hundreds if not thousands of errors will pop up which can seem overwhelming to be fixed when we see the default formatted output, forcing us to back up from making our code base better / more consistent.

This package provides a custom ESLint formatter to help in these situations to make the right decisions by showing the linting results aggregated by rule. It gives an overview of all rules failing showing the total number of errors and warnings summed up by rule.

Having this summary overview can give us the opportunity e.g. to consider suppressing certain rules for now and bringing them back in later when we are ready to fix them.

Output format

With the default ESLint formatter you might get several thousands of lines of failing rules in various files in the output e.g.:

The Summary Formatter simply aggregates the ESLint results by rule and shows the following output instead:

In the above example we can notice that the comma-dangle rule is responsible for about 2/3 of the failures, so we can consider turning it off or just suppressing it to a warning for now as we can do so with the other failing rules.

Sorting output

Default sorting is by errors in a descending order

Configuration options can be passed to the formatter to alter the output.

Using theEFS_SORT_BY env var the aggregated results can be sorted by either rule, errors or warnings e.g.

EFS_SORT_BY=rule eslint -f @voxpelli/eslint-formatter-summary ./src

sorted string results are shown in ASCENDING order by default and numbers in DESCENDING order, but the order can be reversed using EFS_SORT_REVERSE=true:

EFS_SORT_BY=rule EFS_SORT_REVERSE=true eslint -f @voxpelli/eslint-formatter-summary ./src

Changing output format

To output the summary as a markdown table, set EFS_OUTPUT=markdown

EFS_OUTPUT=markdown eslint -f @voxpelli/eslint-formatter-summary ./src

Example:

| Errors | Warnings | Rule | | ------ | -------- | --------------- | | 1 | 0 | no-const-assigntest.js | | 1 | 0 | no-undeftest.js | | 1 | 0 | no-unused-varstest.js |

Supported Node versions

This project targets the current LTS releases of Node.js. See engines.node in package.json.

Supported ESLint versions

ESLint versions are supported from v8 onwards.

Contribute

Please feel free to submit an issue describing your proposal you would like to discuss. PRs are also welcome!

Run unit tests

npm test

Test build project

Once the project is built the distribution version can be tested via passing a .js file to npm run try.

For example:

npm run try test.js

CI build

The project is built on GitHub Actions targeting each supported Node.js versions (see the list above).

During the CI build all source files are linted and all unit tests need to pass resulting in a coverage report.

License

MIT