eslint-config-ns
v4.0.0
Published
eslint config ready to be used in multiple projects
Downloads
2,334
Maintainers
Readme
eslint-config-ns
eslint-config-ns
lints your JavaScript projects with ease, and is mainly based
on the popular
JavaScript code style from Airbnb
with further customizations derived on my own experience.
Contents
Related Configs
- JavaScript: eslint-config-ns-base
- JavaScript React: eslint-config-ns
- TypeScript: eslint-config-ns-ts-base
- TypeScript React: eslint-config-ns-ts
Background Story
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 one for stylelint).
Features
The config is built upon Airbnb's ESLint rules with additional rules and optimizations (see assumptions).
- based on the the popular JavaScript code style from Airbnb
- with React, react-hooks, Jest, and Prettier support
Installation
Install the package with
npm install eslint-config-ns --save-dev
# or
yarn add eslint-config-ns -D
eslint-config-ns
requires you to take care of it's peerDependencies
. Install
the correct version of each peerDependencies
package, which are listed with
the following 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
Usage
Now add eslint-config-ns
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',
}
Prettier Config
This is how you can use or extend the eslint-config-ns
prettier config in your
app:
// prettier.config.js
module.exports = require('eslint-config-ns/prettier.config')
Assumptions
eslint-config-ns
comes with some fundamental assumptions:
- React and/or Node.js environment
- Browser and/or Node.js environment
- Jest as the selected test-suite
- it uses the
@babel/eslint-parser
parser
Even though I made some assumptions, you can easily overwrite, extend and unset rules and any other setting in your custom eslint config.