eslint-config-springernature
![NPM version](http://img.shields.io/npm/v/%40springernature%2Feslint-config.svg)
ESLint shareable config used at Springer Nature.
Installation
Our default export contains all of our ESLint rules, and includes the following plugins:
Using Yarn
Manual
- run
npm info "@springernature/eslint-config@latest" peerDependencies
to list the peer dependencies and versions - run
yarn add --dev <dependency>@<version>
for each listed peer dependency
Automated
If you have npx
available then you can run npx install-peerdeps --dev @springernature/eslint-config
to install the dependencies automatically. This will detect and use Yarn if available.
Using NPM
Install the correct versions of each package, which are listed by the command:
npm info "@springernature/eslint-config@latest" peerDependencies
If using npm 5+, you have NPX
available, and can use this shortcut
npx install-peerdeps --dev @springernature/eslint-config
If using npm < 5, Linux/OSX users can run
(
export PKG=@springernature/eslint-config;
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)
Which produces and runs a command like:
npm install --save-dev @springernature/eslint-config eslint@^
If using npm < 5, Windows users can either install all the peer dependencies manually, or use the install-peerdeps cli tool.
npm install -g install-peerdeps
install-peerdeps --dev @springernature/eslint-config
The cli will produce and run a command like:
npm install --save-dev @springernature/eslint-config eslint@^
Usage
Add one of the following to your .eslintrc
file:
core
- The core Springer Nature code style (with ES6 support)legacy
- For legacy JS environments (without ES6 support)
These optional extensions can be added in addition to one of the above configurations:
Examples
{
"extends": "@springernature/eslint-config",
"rules": {
}
}
{
"extends": "@springernature/eslint-config/legacy",
"rules": {
}
}
{
"extends": [
"@springernature/eslint-config",
"@springernature/eslint-config/node",
"@springernature/eslint-config/jest"
],
"rules": {
}
}
Ignore files/folders
You can optionally create an .eslintignore
file to ignore file paths. The .eslintignore
file is a plain text file where each line is a glob pattern indicating which paths should be omitted from linting. For example, the following will ignore all files in the tests
and coverage
folders:
**/tests/*
**/coverage/*
If you want to ignore the same files and folders contained in the .gitignore
file, you can do so by omitting the creation of the .eslintignore
file and using the following command for linting instead:
eslint --ignore-path .gitignore **/*.js
Caveats
If you use gulp-eslint
, you’ll need version 4.0.0 or above. This will ensure that eslint 4.9.0 or greater is used, which is required for some of the rules that we use.
Contributing
For information on how to contribute to this config, please see the Contributing guidelines.
We should be maintaining this config by updating plugins to the latest versions, and upgrading ESLint when a new version is available in order to keep up to date with new rules and syntax changes.