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 🙏

© 2021 – Pkg Stats / Ryan Hefner

eslint-config-problems

v5.0.0

Published

An eslint config that catches problems in your code, without checking style. For use with prettier.

Downloads

78,493

Readme

eslint-config-problems

eslint-config-problems is an ESLint config that doesn't regulate your code style. It only catches actual problems with your code.

It's designed for use with Prettier, the opinionated code formatter; but you could also use this as a solid base config to add stylistic rules on top of.

Contents

Rules

Rules were chosen based on the following criteria:

  • No stylistic rules; nothing that Prettier can fix
  • Prevent guaranteed runtime errors (i.e. no undefined variables)
  • Disallow "evil" things like eval
  • Disallow archaic language features like with
  • Disallow obvious bad practices like new Number(13)
  • Point out places the code could be made shorter. For example:
    if (someCondition) return someValue;
    else {
      // Do something else
    }
    The else block is unneeded, since the if block contains a return statement. eslint-config-problems will point this out to you (or auto-fix with the --fix option).

ES2015+

By default eslint-config-problems forces the use of ES2015+ features supported by Node.js versions 10 and higher. Here are the rules enforced:

  • no-var - Use let/const instead.
  • object-shorthand - Use object shorthand where possible.
  • prefer-arrow-callback - Use arrow functions as callbacks where possible.
  • prefer-numeric-literals - Don't use parseInt() to write binary, octal, and hexadecimal numbers, use the literal form instead.
  • prefer-template - Use template strings instead of string concatenation.
  • prefer-spread - Use the spread operator instead of .apply where possible.
  • prefer-rest-params - Use rest parameters instead of arguments.
  • Use the exponentiation operator (**) instead of Math.pow() (enforced via no-restricted-properties).
  • prefer-object-spread - Use object spread where possible, instead of Object.assign()
  • Use optional catch bindings when not using the error variable in the catch block (enforced by no-unused-vars with caughtErrors: 'all')
  • prefer-const - I realize this is very opinionated; if you don't like it, add prefer-const: off to your config.

It also sets ecmaVersion: 2020 in the parserOptions, so that ESLint can parse modern code (including BigInt in Node 10.8+) with no additional setup.

I disagree with rule X; you missed rule Y

If you disagree; feel free to open an issue. I'm open to changing rules if you have a good reason.

If I missed a rule that prevents an actual problem or is otherwise in keeping with the general guidelines above, please open an issue as well; I just might add it.

Installation & Usage

eslint-config-problems doesn't set any environments by default, other than the es6 environment. So you'll have to manually set your environment in your ESLint config. Here's a list of environments.

If you're using ES Modules, you will need to set sourceType: module in the parserOptions, like this:

parserOptions:
  sourceType: module

Just ESLint

npm install -D eslint eslint-config-problems

In your eslintrc.yaml:

extends: 'problems'
env:
  # Set your environments here; for example:
  node: true

With eslint-plugin-prettier

npm install -D eslint prettier eslint-config-problems eslint-plugin-prettier

In your eslintrc.yaml:

extends: 'problems'
env:
  # Set your environments here; for example:
  node: true
plugins:
  - prettier
rules:
  - prettier/prettier: error

License

ISC