Skip to content

Commit b546647

Browse files
committed
Require Node.js 6
1 parent a6ce053 commit b546647

15 files changed

+43
-43
lines changed

.gitattributes

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
* text=auto
2-
*.js text eol=lf
1+
* text=auto eol=lf

.travis.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
language: node_js
22
node_js:
3+
- '10'
34
- '8'
45
- '6'
5-
- '4'
66
matrix:
77
include:
8-
- node_js: 8
8+
- node_js: 10
99
env: INTEGRATION=true
10-
before_install:
11-
- npm install --global npm
1210
script:
1311
- "[ \"$INTEGRATION\" = true ] && npm run integration || npm test"
1412
after_success: npm run coveralls

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "sindresorhus.com"
1111
},
1212
"engines": {
13-
"node": ">=4"
13+
"node": ">=6"
1414
},
1515
"scripts": {
1616
"test": "nyc ava",
@@ -48,9 +48,9 @@
4848
"del": "^3.0.0",
4949
"eslint": "^5.0.0",
5050
"eslint-ava-rule-tester": "^2.0.0",
51-
"execa": "^0.9.0",
52-
"listr": "^0.13.0",
53-
"nyc": "^11.0.3",
51+
"execa": "^0.10.0",
52+
"listr": "^0.14.1",
53+
"nyc": "^12.0.2",
5454
"pify": "^3.0.0",
5555
"tempy": "^0.2.1",
5656
"xo": "*"

rules/catch-error-name.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const getDocsUrl = require('./utils/get-docs-url');
44

55
// Matches `someObj.then([FunctionExpression | ArrowFunctionExpression])`
66
function isLintablePromiseCatch(node) {
7-
const callee = node.callee;
7+
const {callee} = node;
88

99
if (callee.type !== 'MemberExpression') {
1010
return false;
1111
}
1212

13-
const property = callee.property;
13+
const {property} = callee;
1414

1515
if (property.type !== 'Identifier' || property.name !== 'catch') {
1616
return false;
@@ -20,7 +20,7 @@ function isLintablePromiseCatch(node) {
2020
return false;
2121
}
2222

23-
const arg0 = node.arguments[0];
23+
const [arg0] = node.arguments;
2424

2525
return arg0.type === 'FunctionExpression' || arg0.type === 'ArrowFunctionExpression';
2626
}
@@ -42,7 +42,7 @@ const create = context => {
4242
caughtErrorsIgnorePattern: '^_$'
4343
}, context.options[0]);
4444

45-
const name = options.name;
45+
const {name} = options;
4646
const caughtErrorsIgnorePattern = new RegExp(options.caughtErrorsIgnorePattern);
4747
const stack = [];
4848

@@ -68,7 +68,7 @@ const create = context => {
6868
return {
6969
CallExpression: node => {
7070
if (isLintablePromiseCatch(node)) {
71-
const params = node.arguments[0].params;
71+
const {params} = node.arguments[0];
7272

7373
if (params.length > 0 && params[0].name === '_') {
7474
push(!astUtils.containsIdentifier('_', node.arguments[0].body));

rules/custom-error-definition.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const hasValidSuperClass = node => {
1818
return false;
1919
}
2020

21-
let name = node.superClass.name;
21+
let {name} = node.superClass;
2222

2323
if (node.superClass.type === 'MemberExpression') {
24-
name = node.superClass.property.name;
24+
({name} = node.superClass.property);
2525
}
2626

2727
return nameRegexp.test(name);
@@ -48,7 +48,7 @@ const customErrorDefinition = (context, node) => {
4848
return;
4949
}
5050

51-
const name = node.id.name;
51+
const {name} = node.id;
5252
const className = getClassName(name);
5353

5454
if (name !== className) {
@@ -58,8 +58,7 @@ const customErrorDefinition = (context, node) => {
5858
});
5959
}
6060

61-
const body = node.body.body;
62-
61+
const {body} = node.body;
6362
const constructor = body.find(x => x.kind === 'constructor');
6463

6564
if (!constructor) {

rules/explicit-length-check.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ function checkZeroType(context, node) {
3636
}
3737

3838
function checkNonZeroType(context, node, type) {
39-
const value = node.right.value;
40-
const operator = node.operator;
39+
const {value} = node.right;
40+
const {operator} = node;
4141

4242
switch (type) {
4343
case 'greater-than':
44-
if ((operatorTypes.gte.indexOf(operator) !== -1 && value === 1) ||
45-
(operatorTypes.ne.indexOf(operator) !== -1 && value === 0)
44+
if (
45+
(operatorTypes.gte.includes(operator) && value === 1) ||
46+
(operatorTypes.ne.includes(operator) && value === 0)
4647
) {
4748
reportError(
4849
context,
@@ -57,8 +58,9 @@ function checkNonZeroType(context, node, type) {
5758
}
5859
break;
5960
case 'greater-than-or-equal':
60-
if ((operatorTypes.gt.indexOf(operator) !== -1 && value === 0) ||
61-
(operatorTypes.ne.indexOf(operator) !== -1 && value === 0)
61+
if (
62+
(operatorTypes.gt.includes(operator) && value === 0) ||
63+
(operatorTypes.ne.includes(operator) && value === 0)
6264
) {
6365
reportError(
6466
context,
@@ -73,8 +75,9 @@ function checkNonZeroType(context, node, type) {
7375
}
7476
break;
7577
case 'not-equal':
76-
if ((operatorTypes.gt.indexOf(operator) !== -1 && value === 0) ||
77-
(operatorTypes.gte.indexOf(operator) !== -1 && value === 1)
78+
if (
79+
(operatorTypes.gt.includes(operator) && value === 0) ||
80+
(operatorTypes.gte.includes(operator) && value === 1)
7881
) {
7982
reportError(
8083
context,

rules/new-for-builtins.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const disallowNew = new Set([
3636
const create = context => {
3737
return {
3838
CallExpression: node => {
39-
const name = node.callee.name;
39+
const {name} = node.callee;
4040

4141
if (enforceNew.has(name)) {
4242
context.report({
@@ -47,7 +47,7 @@ const create = context => {
4747
}
4848
},
4949
NewExpression: node => {
50-
const name = node.callee.name;
50+
const {name} = node.callee;
5151

5252
if (disallowNew.has(name)) {
5353
context.report({

rules/no-abusive-eslint-disable.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ const disableRegex = /^eslint-disable(-next-line|-line)?($|(\s+(@[\w-]+\/[\w-]+\
55

66
const create = context => ({
77
Program: node => {
8-
node.comments.forEach(comment => {
8+
for (const comment of node.comments) {
99
const value = comment.value.trim();
1010
const res = disableRegex.exec(value);
1111

12-
if (res && // It's a eslint-disable comment
12+
if (
13+
res && // It's a eslint-disable comment
1314
!res[2] // But it did not specify any rules
1415
) {
1516
context.report({
@@ -24,7 +25,7 @@ const create = context => ({
2425
data: comment.loc.start
2526
});
2627
}
27-
});
28+
}
2829
}
2930
});
3031

rules/no-fn-reference-in-iterator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const fix = (context, node) => {
3434
const create = context => ({
3535
'CallExpression[callee.object.name!="Promise"]': node => {
3636
if (isIteratorMethod(node) && hasFunctionArgument(node)) {
37-
const arg = node.arguments[0];
37+
const [arg] = node.arguments;
3838

3939
context.report({
4040
node: arg,

rules/no-process-exit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const create = context => {
1212

1313
return {
1414
CallExpression: node => {
15-
const callee = node.callee;
15+
const {callee} = node;
1616

1717
if (callee.type === 'MemberExpression' && callee.object.name === 'process') {
1818
if (callee.property.name === 'on' || callee.property.name === 'once') {

rules/no-unsafe-regex.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const create = context => {
3232
let flags = null;
3333

3434
if (hasRegExp) {
35-
pattern = args[0].regex.pattern;
35+
({pattern} = args[0].regex);
3636
flags = args[1] && args[1].type === 'Literal' ? args[1].value : args[0].regex.flags;
3737
} else {
3838
pattern = args[0].value;

rules/prefer-spread.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const getDocsUrl = require('./utils/get-docs-url');
33

44
const isArrayFrom = node => {
5-
const callee = node.callee;
5+
const {callee} = node;
66
return (
77
callee.type === 'MemberExpression' &&
88
callee.object.type === 'Identifier' &&

rules/prefer-starts-ends-with.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const isSimpleString = string => doesNotContain(
1111
const create = context => {
1212
return {
1313
CallExpression(node) {
14-
const callee = node.callee;
14+
const {callee} = node;
1515
const prop = callee.property;
1616

1717
if (!(prop && callee.type === 'MemberExpression')) {
@@ -22,9 +22,9 @@ const create = context => {
2222

2323
let regex;
2424
if (prop.name === 'test' && callee.object.regex) {
25-
regex = callee.object.regex;
25+
({regex} = callee.object);
2626
} else if (prop.name === 'match' && args && args[0] && args[0].regex) {
27-
regex = args[0].regex;
27+
({regex} = args[0]);
2828
} else {
2929
return;
3030
}
@@ -33,7 +33,7 @@ const create = context => {
3333
return;
3434
}
3535

36-
const pattern = regex.pattern;
36+
const {pattern} = regex;
3737
if (pattern.startsWith('^') && isSimpleString(pattern.slice(1))) {
3838
context.report({
3939
node,

rules/regex-shorthand.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const create = context => {
88
return {
99
'Literal[regex]': node => {
1010
const oldPattern = node.regex.pattern;
11-
const flags = node.regex.flags;
11+
const {flags} = node.regex;
1212

1313
const newPattern = cleanRegexp(oldPattern, flags);
1414

test/prefer-type-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,6 @@ ruleTester.run('prefer-type-error', rule, {
304304
errors
305305
}
306306
].concat(
307-
Array.from(tcIdentifiers).map(identifier => tcIdentifierInvalidTest(identifier))
307+
[...tcIdentifiers].map(identifier => tcIdentifierInvalidTest(identifier))
308308
)
309309
});

0 commit comments

Comments
 (0)