In August 2018, I published an article with the title "How to create your own shared esLint, prettier and stylelint configuration" on Medium. One of the results of the article, is this shareable eslint-config (and the one for stylelint).
It lints your javascript projects with ease, based on the popular javascript code style from Airbnb.
- based on the the popular javascript code style from Airbnb
- easy switchable to their smaller set of rules eslint-config-airbnb-base
- with prettier support, thanks to eslint-plugin-prettier
- with react, react-hooks and jest support
The default export contains all default Airbnb ESLint rules, including ECMAScript 6+, and the ones listed below. It requires some peerDependencies as well.
Install the package with
npm install eslint-config-ns --save-dev
# or
yarn add eslint-config-ns -D
Then install the correct versions of each peerDependency package, which are listed by the command:
npm info "eslint-config-ns@latest" peerDependencies
If using npm 5+, use this shortcut:
npx install-peerdeps --dev eslint-config-ns
# or
yarn add eslint-config-ns -D --peer
Now add the config to either your package.json
:
{
"eslintConfig": {
"extends": "eslint-config-ns"
}
}
to your .eslintrc
:
{
"extends": "eslint-config-ns"
}
or .eslintrc.js
:
module.exports = {
extends: 'eslint-config-ns',
}
This is how you use or extend the eslint-config-ns
prettier config in your
app:
// prettier.config.js
module.exports = require('eslint-config-ns/prettier.config')
This ESLint configuration comes with some fundamental assumptions:
- react and/or node environment
- jest as the selected test-suite
- browser and/or node environment
- parser: babel (used babel-eslint parser)
Even though I made some assumptions, you can easily overwrite, extend and unset rules and any other setting in your custom eslint config.
Stefan Natter |