Skip to content
This repository was archived by the owner on Mar 7, 2019. It is now read-only.

Commit 3d572b7

Browse files
(breaking) Add support for Node.js v6
1 parent cd09ded commit 3d572b7

File tree

8 files changed

+61
-39
lines changed

8 files changed

+61
-39
lines changed

default.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module.exports = {
44
extends: [
5-
'./environments/nodejs/latest.js',
5+
'./environments/nodejs/v6.js',
66
'./environments/nodejs/best-practices.js',
77
'./environments/nodejs/optional.js'
88
]

environments/nodejs/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ These configuration files are suitable to lint code which will run on Node.js.
44

55
## Configurations
66

7-
### javascript/environments/nodejs/latest
7+
### @strv/javascript/environments/nodejs/v6
88

9-
Suitable for the very latest version of Node.js. It configures ESLint to allow known ES 2015 features and disallow those still missing as well as includes Node-specific ruleset for known errors.
9+
Suitable for projects running on Node.js v6. Also includes Node-specific ruleset for known errors.
1010

11-
### javascript/environments/nodejs/legacy
11+
### @strv/javascript/environments/nodejs/v5
1212

13-
Suitable for legacy versions of Node.js (0.12 and older). Also includes Node-specific rulesets for known errors.
13+
Suitable for projects running on Node.js v5. It configures ESLint to allow known ES 2015 features and disallow those still missing. Also includes Node-specific rulesets for known errors.
1414

15-
### javascript/environments/nodejs/best-practices
15+
### @strv/javascript/environments/nodejs/best-practices
1616

1717
Use this ruleset in conjunction with one of the version-specific configuration files. Provides additional safety checks to flag potentially unsafe code.
1818

19-
### javascript/environments/nodejs/optional
19+
### @strv/javascript/environments/nodejs/optional
2020

2121
Use this ruleset in conjunction with any of the above. Provides additional insights into potential inconsistencies in the project.
2222

environments/nodejs/best-practices.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ module.exports = {
4141
'no-sync': 1,
4242

4343
// Suggest using Reflect methods where applicable
44-
// @TODO: Requires Node.js support
44+
// This rule should be enabled per environment because not all environments might have support
45+
// for the Reflect API.
4546
'prefer-reflect': 0,
4647

4748
// Disallow process.env

environments/nodejs/known-errors.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ module.exports = {
3232
// trace.
3333
'no-process-exit': 2,
3434

35-
// Suggest using the rest parameters instead of `arguments`
36-
// @TODO: Requires Node.js support
37-
'prefer-rest-params': 0
35+
// Enforce usage of the rest parameters instead of the weird `arguments`
36+
'prefer-rest-params': 2
3837
}
3938
}

environments/nodejs/legacy.js

-23
This file was deleted.

environments/nodejs/latest.js renamed to environments/nodejs/v5.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
'use strict'
1010

11+
/**
12+
* This file configures ESLint to work with the Node.js 5.0 release
13+
*/
1114
module.exports = {
12-
// This file configures ESLint to work with the newest ES 2015 syntax and features
1315
extends: './known-errors.js',
1416

1517
env: {
@@ -22,8 +24,13 @@ module.exports = {
2224
},
2325

2426
rules: {
25-
// ESLint no longer supports disabling some still unsuported ES 2015 features, so we need to use
26-
// this rule to disable that syntax
27+
// Node.js v5 does not support Reflect API
28+
'prefer-reflect': 0,
29+
30+
// Node.js v5 does not support rest params
31+
'prefer-rest-params': 0,
32+
33+
// The following ES 2015 syntax is not supported by Node.js v5
2734
'no-restricted-syntax': [
2835
2,
2936
// Rest parameters (not to be confused with rest arguments)
@@ -32,7 +39,7 @@ module.exports = {
3239
'AssignmentPattern',
3340
// Destructuring assignment
3441
'ObjectPattern',
35-
// Experimental object/rest spread
42+
// Experimental object/rest spread (not in ES 2015)
3643
'ExperimentalRestProperty'
3744
]
3845
}

environments/nodejs/v6.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* js-coding-standards
3+
*
4+
* @author Robert Rossmann <[email protected]>
5+
* @copyright 2016 STRV
6+
* @license http://choosealicense.com/licenses/bsd-3-clause BSD-3-Clause License
7+
*/
8+
9+
'use strict'
10+
11+
/**
12+
* This file configures ESLint to work with the Node.js 6.0 release
13+
*/
14+
module.exports = {
15+
extends: './known-errors.js',
16+
17+
env: {
18+
node: true,
19+
es6: true
20+
},
21+
22+
parserOptions: {
23+
ecmaVersion: 6
24+
},
25+
26+
rules: {
27+
// ESLint no longer supports disabling some still unsuported ES 2015 features, so we need to use
28+
// this rule to disable that syntax
29+
'no-restricted-syntax': [
30+
2,
31+
// Experimental object/rest spread (not in ES 2015)
32+
'ExperimentalRestProperty'
33+
],
34+
35+
// Suggest using Reflect API where applicable
36+
'prefer-reflect': 1
37+
}
38+
}

examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
// overwriting some configuration options. Here, we are including the
1717
// base configuration for Node.js development and we opt-in to the
1818
// best-practices ruleset.
19-
'@strv/javascript/environments/nodejs/latest',
19+
'@strv/javascript/environments/nodejs/v6',
2020
'@strv/javascript/environments/nodejs/best-practices',
2121
// If you are brave enough, you can also extend the "optional" ruleset
2222
'@strv/javascript/environments/nodejs/optional'

0 commit comments

Comments
 (0)