Skip to content

Commit bc5c739

Browse files
committed
Refactor ESLint config to better support external configs
This should make using `codeclimate prepare` to use external configs simpler: I've moved all things that might vary by project into an example base file, and only keep rules in the two other files (base for all projects, and the ES6 variant to additionally pull in for ES6 projects).
1 parent b8c0f0f commit bc5c739

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

javascript/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
## ESLint
44

5-
This repo contains an `eslintrc.js` file that should be included (as
6-
`.eslintrc.js`) in each project. Periodically, a repo's `.eslintrc.js` file
7-
should be synced with the one here.
5+
This repo contains an `eslintrc.base.js` file specifying rules useful for all
6+
projects, as well as an `eslintrc.es6.js` with rules specific to ES6 projects.
7+
8+
We suggest creating an `.eslintrc.js` in your own project based on the
9+
`eslintrc.example.js` file here, using `codeclimate prepare` to pull in the base
10+
rules (and the ES6 rules if appropriate).
811

912
### Variable and Function Names
1013

@@ -46,8 +49,8 @@ api.getModel("id").then(function(data) {
4649
### ECMAScript 6
4750

4851
There is an additional set of ESLint rules we use for ES6 code: these are in
49-
`eslintrc-es6.js`, and can be included into the main `.eslintrc.js` file in ES6
50-
projects with an `"extends"` directive.
52+
`eslintrc.es6.js`, and can be included into your `.eslintrc.js` with an
53+
`"extends"` directive.
5154

5255
The rules there are mostly self explanatory, with one perhaps requiring an
5356
explanatory note: `=>` functions are preferred over the `var self = this;`
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
module.exports = {
2-
"env": {
3-
"node": true, // When in a backend context
4-
"browser": true, // When in a web context
5-
"jquery": true, // When in a web context
6-
"es6": true, // When using ES6 features
7-
},
82
"rules": {
93
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
104
"camelcase": [2, { "properties": "always" }],
@@ -23,9 +17,4 @@ module.exports = {
2317
"space-infix-ops": 2,
2418
"strict": 0,
2519
},
26-
/**
27-
* globals should be defined per file when possible. Use the directive here
28-
* when there are project-level globals (such as jquery)
29-
*/
30-
"globals": {},
3120
};
File renamed without changes.

javascript/eslintrc.example.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
"env": {
3+
"node": true, // When in a backend context
4+
"browser": true, // When in a web context
5+
"jquery": true, // When in a web context
6+
"es6": true, // When using ES6 features
7+
},
8+
// It's recommended these files be pulled in via `codeclimate prepare`
9+
extends: [
10+
".eslintrc.base.js",
11+
".eslintrc.es6.js" // only for ES6 projects
12+
],
13+
/**
14+
* globals should be defined per file when possible. Use the directive here
15+
* when there are project-level globals (such as jquery)
16+
*/
17+
"globals": {},
18+
};

0 commit comments

Comments
 (0)