An ESLint Shareable Config to find errors, typos and potentially dangerous code.
You'll first need to install ESLint
:
$ npm install eslint --save-dev
Note: You may install ESLint globally using the -g
flag.
Next, install eslint-config-pedant
:
$ npm install eslint-config-pedant --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-config-pedant
globally.
A globally-installed instance of ESLint can only use globally-installed ESLint plugins. A locally-installed ESLint can make use of both locally- and globally- installed ESLint plugins.
Shareable configs are designed to work with the extends
feature of .eslintrc
files. You can learn more about Shareable Config on the official ESLint website.
Add this to your .eslintrc
file:
{
"extends": "pedant"
}
Note: We omitted the eslint-config-
prefix since it is automatically assumed by ESLint.
You can override settings from the shareable config by adding them directly into your .eslintrc
file.
By default rules are suitable for ECMAScript 6
or higher.
If you are not using ECMAScript 6
, you can choose the config for ECMAScript 5
:
{
"extends": "pedant/es5"
}
Or config for ECMAScript 3
:
{
"extends": "pedant/es3"
}
Most likely this config will suite you, because it contains only those rules which are necessary to find errors, typos and potentially dangerous code.
To make sure that this config is right for you:
- Look at the examples of incorrect code.
- Look at the rules from this config. The detailed information about each rule you can find on the eslint website.
- Try this config in your project. If you agree with those errors then this config is for you.
This config intentionally does not limit your choice of code style.
If you want to check code style of your my code you can add stylistic rules to your config in your project.
Also, you can create your own Shareable Config or use one of the existing.
MIT © Andrew Abramov