-
Notifications
You must be signed in to change notification settings - Fork 8
Linting JavaScript
Prerequisites
We lint our code using ESLint and use a common set of ESLint rules, eslint-config-leankit, authored specifically for LeanKit and hosted on npm. In order to use these rules you will need a .eslintrc.js file at the root of your project. At the bare minimum it'll look something like the following...
module.exports = {
extends: [ "leankit" ]
};
The eslint-config-leankit rules are broken into different configurations depending on the type of code you are writing. You can mix and match the configurations in the same .eslintrc.js file or extend rules in a nested .eslintrc.js file (located in a subfolder).
For a simple project you may just need one .eslintrc.js file. If that is the case you may want to combine configurations to match the coding style for your project. The following combines both the basic set of rules and rules specific to ES6.
.
└── .eslintrc.js // extends: [ "leankit", "leankit/es6" ]
For more complex projects you may want to enforce a basic set of rules for the whole project, but then extend more specific rules depending on the subfolder. The following shows how you can extend the rules set at the root along with something more specific (such as react, test, or es6).
.
├── client
│ ├── js
│ │ └── .eslintrc.js // extends: "react"
│ └── spec
│ │ └── .eslintrc.js // extends: "test"
│ └── .eslintrc.js // extends: "es6"
├── server
│ └── spec
│ └── .eslintrc.js // extends: "test"
└── .eslintrc.js // extends: "leankit"
For VisualStudio we are still using JSHint to lint our JavaScript so in that case refer to the .jshintrc file located under the linting/JavaScript folder in this repo. For all other projects please use ESLint and eslint-config-leankit.