Skip to content

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

License

Notifications You must be signed in to change notification settings

RyanZim/eslint-config-problems

Repository files navigation

eslint-config-problems

eslint-config-problemsis anESLintconfig that doesn't regulate your code style. It only catches actual problems with your code.

It's designed for use withPrettier,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 likeeval
  • Disallow archaic language features likewith
  • Disallow obvious bad practices likenew Number(13)
  • Force usage of ES2015+ features supported by Node.js v10+
  • Point out places the code could be made shorter. For example:
    if(someCondition)returnsomeValue;
    else{
    // Do something else
    }
    Theelseblock is unneeded, since theifblock contains areturnstatement.eslint-config-problemswill point this out to you (or auto-fix with the--fixoption).

eslint-config-problemsalso setsecmaVersion: 2020in theparserOptions,so that ESLint can parse modern code (includingBigInt) 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-problemsdoesn't set any environments by default, other than thees6environment. So you'll have to manually set your environment in your ESLint config. Here's alist of environments.

If you're using ES Modules, you will need to setsourceType: modulein theparserOptions,like this:

parserOptions:
sourceType:module

Just ESLint

npm install -D eslint eslint-config-problems

In youreslintrc.yaml:

extends:'problems'
env:
#Set your environments here; for example:
node:true
npm install -D eslint prettier eslint-config-problems eslint-plugin-prettier

In youreslintrc.yaml:

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

License

ISC

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published