npm.io
0.0.7 • Published 9 years ago

@prodigy/eslint-config-prodigy

Licence
—
Version
0.0.7
Deps
0
Vulns
0
Weekly
0

Prodigy Shared ESLint

This repo contains ESLint configuration for use against all of Prodigy's JavaScript projects. Our rules are based on the AirBnB ESLint Configuration for both ES5 and ES6+. Changes to these rules can be proposed via a issues or a pull request.

If you haven't read the AirBnB Styleguide it's worth a read, because some of their guidelines cannot yet be enforced by linters (filenames, for instance).

Usage

Install the linter:

npm install --save-dev eslint eslint-plugin-import eslint-config-airbnb-base@9.0.0
npm install --save-dev @prodigy/eslint-config-prodigy

Then add the configuration to your package.json.

For an ES6+ project:

"eslintConfig": {
    "extends": "@prodigy/eslint-config-prodigy"
}

For an ES5 project:

"eslintConfig": {
    "extends": "@prodigy/eslint-config-prodigy/es5"
}
For Tests:

With tests, you can include an eslintrc.json file in your tests folder and it will change the rules for use in tests:

{
    "extends": "@prodigy/eslint-config-prodigy/tests"
}

This will override settings from the ESLint config at the lower levels.

NPM Script

If you want, you can also add an npm command for linting to your package.json:

"scripts": {
  "lint": "eslint --ignore-path .gitignore ."
}

Or, for just files that have changed since the dev branch:

"scripts": {
  "lint": "git diff --name-only dev | grep "\.js\$" | xargs eslint"
}

Automatic Fixing

Many of the errors detected by ESLint can be automatically fixed. Whether or not you should do this on a project-wide basis should be discussed ahead of time with your team. Doing this carelessly can lead to a messy git history.

That said, you can have ESLint fix errors on a per-file basis or configure your editor with a command that can automatically lint. It is always a good idea to fix linting problems with code in a separate commit or PR before you make changes.

To fix changes in a file:

./node_modules/.bin/eslint --fix file.js

To fix changes in a folder (recursive):

./node_modules/.bin/eslint --fix .

Editor Configuration

Most of the value of the linter will come from editor integration. The following plugins may be of value:

Note, that to get ESLint working with your editor, you may need to install it globally (with -g).