eslint 2.11.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/README.md +24 -0
- package/conf/eslint-all.js +29 -0
- package/conf/eslint.json +10 -6
- package/lib/ast-utils.js +91 -0
- package/lib/config/config-file.js +9 -4
- package/lib/config/config-ops.js +27 -2
- package/lib/eslint.js +34 -15
- package/lib/file-finder.js +3 -59
- package/lib/ignored-paths.js +38 -4
- package/lib/options.js +1 -1
- package/lib/rules/accessor-pairs.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/arrow-body-style.js +57 -15
- package/lib/rules/callback-return.js +25 -3
- package/lib/rules/default-case.js +1 -1
- package/lib/rules/eqeqeq.js +1 -1
- package/lib/rules/func-names.js +15 -4
- package/lib/rules/max-len.js +3 -2
- package/lib/rules/max-lines.js +148 -0
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/newline-per-chained-call.js +16 -1
- package/lib/rules/no-extra-parens.js +1 -92
- package/lib/rules/no-extra-semi.js +10 -1
- package/lib/rules/no-mixed-operators.js +212 -0
- package/lib/rules/no-multiple-empty-lines.js +40 -9
- package/lib/rules/no-prototype-builtins.js +1 -1
- package/lib/rules/no-script-url.js +1 -1
- package/lib/rules/no-unsafe-finally.js +1 -1
- package/lib/rules/no-useless-rename.js +11 -3
- package/lib/rules/object-curly-newline.js +209 -0
- package/lib/rules/object-shorthand.js +75 -5
- package/lib/rules/one-var.js +3 -0
- package/lib/rules/padded-blocks.js +19 -1
- package/lib/rules/rest-spread-spacing.js +107 -0
- package/lib/rules/unicode-bom.js +1 -1
- package/lib/util/glob-util.js +2 -1
- package/package.json +4 -2
@@ -23,6 +23,8 @@ module.exports = {
|
|
23
23
|
recommended: false
|
24
24
|
},
|
25
25
|
|
26
|
+
fixable: "code",
|
27
|
+
|
26
28
|
schema: {
|
27
29
|
anyOf: [
|
28
30
|
{
|
@@ -132,12 +134,36 @@ module.exports = {
|
|
132
134
|
// if we're "never" and concise we should warn now
|
133
135
|
if (APPLY_NEVER && isConciseProperty) {
|
134
136
|
type = node.method ? "method" : "property";
|
135
|
-
context.report(
|
137
|
+
context.report({
|
138
|
+
node: node,
|
139
|
+
message: "Expected longform " + type + " syntax.",
|
140
|
+
fix: function(fixer) {
|
141
|
+
if (node.method) {
|
142
|
+
if (node.value.generator) {
|
143
|
+
return fixer.replaceTextRange([node.range[0], node.key.range[1]], node.key.name + ": function*");
|
144
|
+
}
|
145
|
+
|
146
|
+
return fixer.insertTextAfter(node.key, ": function");
|
147
|
+
}
|
148
|
+
|
149
|
+
return fixer.insertTextAfter(node.key, ": " + node.key.name);
|
150
|
+
}
|
151
|
+
});
|
136
152
|
}
|
137
153
|
|
138
154
|
// {'xyz'() {}} should be written as {'xyz': function() {}}
|
139
155
|
if (AVOID_QUOTES && isStringLiteral(node.key) && isConciseProperty) {
|
140
|
-
context.report(
|
156
|
+
context.report({
|
157
|
+
node: node,
|
158
|
+
message: "Expected longform method syntax for string literal keys.",
|
159
|
+
fix: function(fixer) {
|
160
|
+
if (node.computed) {
|
161
|
+
return fixer.insertTextAfterRange([node.key.range[0], node.key.range[1] + 1], ": function");
|
162
|
+
}
|
163
|
+
|
164
|
+
return fixer.insertTextAfter(node.key, ": function");
|
165
|
+
}
|
166
|
+
});
|
141
167
|
}
|
142
168
|
|
143
169
|
// at this point if we're concise or if we're "never" we can leave
|
@@ -160,16 +186,60 @@ module.exports = {
|
|
160
186
|
return;
|
161
187
|
}
|
162
188
|
|
189
|
+
// {[x]: function(){}} should be written as {[x]() {}}
|
190
|
+
if (node.computed) {
|
191
|
+
context.report({
|
192
|
+
node: node,
|
193
|
+
message: "Expected method shorthand.",
|
194
|
+
fix: function(fixer) {
|
195
|
+
if (node.value.generator) {
|
196
|
+
return fixer.replaceTextRange(
|
197
|
+
[node.key.range[0], node.value.range[0] + "function*".length],
|
198
|
+
"*[" + node.key.name + "]"
|
199
|
+
);
|
200
|
+
}
|
201
|
+
|
202
|
+
return fixer.removeRange([node.key.range[1] + 1, node.value.range[0] + "function".length]);
|
203
|
+
}
|
204
|
+
});
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
|
163
208
|
// {x: function(){}} should be written as {x() {}}
|
164
|
-
context.report(
|
209
|
+
context.report({
|
210
|
+
node: node,
|
211
|
+
message: "Expected method shorthand.",
|
212
|
+
fix: function(fixer) {
|
213
|
+
if (node.value.generator) {
|
214
|
+
return fixer.replaceTextRange(
|
215
|
+
[node.key.range[0], node.value.range[0] + "function*".length],
|
216
|
+
"*" + node.key.name
|
217
|
+
);
|
218
|
+
}
|
219
|
+
|
220
|
+
return fixer.removeRange([node.key.range[1], node.value.range[0] + "function".length]);
|
221
|
+
}
|
222
|
+
});
|
165
223
|
} else if (node.value.type === "Identifier" && node.key.name === node.value.name && APPLY_TO_PROPS) {
|
166
224
|
|
167
225
|
// {x: x} should be written as {x}
|
168
|
-
context.report(
|
226
|
+
context.report({
|
227
|
+
node: node,
|
228
|
+
message: "Expected property shorthand.",
|
229
|
+
fix: function(fixer) {
|
230
|
+
return fixer.replaceText(node, node.value.name);
|
231
|
+
}
|
232
|
+
});
|
169
233
|
} else if (node.value.type === "Identifier" && node.key.type === "Literal" && node.key.value === node.value.name && APPLY_TO_PROPS) {
|
170
234
|
|
171
235
|
// {"x": x} should be written as {x}
|
172
|
-
context.report(
|
236
|
+
context.report({
|
237
|
+
node: node,
|
238
|
+
message: "Expected property shorthand.",
|
239
|
+
fix: function(fixer) {
|
240
|
+
return fixer.replaceText(node, node.value.name);
|
241
|
+
}
|
242
|
+
});
|
173
243
|
}
|
174
244
|
}
|
175
245
|
};
|
package/lib/rules/one-var.js
CHANGED
@@ -286,6 +286,9 @@ module.exports = {
|
|
286
286
|
context.report(node, "Combine this with the previous '" + type + "' statement with initialized variables.");
|
287
287
|
}
|
288
288
|
if (options[type].uninitialized === MODE_ALWAYS) {
|
289
|
+
if (node.parent.left === node && (node.parent.type === "ForInStatement" || node.parent.type === "ForOfStatement")) {
|
290
|
+
return;
|
291
|
+
}
|
289
292
|
context.report(node, "Combine this with the previous '" + type + "' statement with uninitialized variables.");
|
290
293
|
}
|
291
294
|
}
|
@@ -17,6 +17,8 @@ module.exports = {
|
|
17
17
|
recommended: false
|
18
18
|
},
|
19
19
|
|
20
|
+
fixable: "whitespace",
|
21
|
+
|
20
22
|
schema: [
|
21
23
|
{
|
22
24
|
oneOf: [
|
@@ -164,6 +166,9 @@ module.exports = {
|
|
164
166
|
context.report({
|
165
167
|
node: node,
|
166
168
|
loc: { line: openBrace.loc.start.line, column: openBrace.loc.start.column },
|
169
|
+
fix: function(fixer) {
|
170
|
+
return fixer.insertTextAfter(openBrace, "\n");
|
171
|
+
},
|
167
172
|
message: ALWAYS_MESSAGE
|
168
173
|
});
|
169
174
|
}
|
@@ -171,23 +176,36 @@ module.exports = {
|
|
171
176
|
context.report({
|
172
177
|
node: node,
|
173
178
|
loc: {line: closeBrace.loc.end.line, column: closeBrace.loc.end.column - 1 },
|
179
|
+
fix: function(fixer) {
|
180
|
+
return fixer.insertTextBefore(closeBrace, "\n");
|
181
|
+
},
|
174
182
|
message: ALWAYS_MESSAGE
|
175
183
|
});
|
176
184
|
}
|
177
185
|
} else {
|
178
186
|
if (blockHasTopPadding) {
|
187
|
+
var nextToken = sourceCode.getTokenOrCommentAfter(openBrace);
|
188
|
+
|
179
189
|
context.report({
|
180
190
|
node: node,
|
181
191
|
loc: { line: openBrace.loc.start.line, column: openBrace.loc.start.column },
|
192
|
+
fix: function(fixer) {
|
193
|
+
return fixer.replaceTextRange([openBrace.end, nextToken.start - nextToken.loc.start.column], "\n");
|
194
|
+
},
|
182
195
|
message: NEVER_MESSAGE
|
183
196
|
});
|
184
197
|
}
|
185
198
|
|
186
199
|
if (blockHasBottomPadding) {
|
200
|
+
var previousToken = sourceCode.getTokenOrCommentBefore(closeBrace);
|
201
|
+
|
187
202
|
context.report({
|
188
203
|
node: node,
|
189
204
|
loc: {line: closeBrace.loc.end.line, column: closeBrace.loc.end.column - 1 },
|
190
|
-
message: NEVER_MESSAGE
|
205
|
+
message: NEVER_MESSAGE,
|
206
|
+
fix: function(fixer) {
|
207
|
+
return fixer.replaceTextRange([previousToken.end, closeBrace.start - closeBrace.loc.start.column], "\n");
|
208
|
+
}
|
191
209
|
});
|
192
210
|
}
|
193
211
|
}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Enforce spacing between rest and spread operators and their expressions.
|
3
|
+
* @author Kai Cataldo
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
// Rule Definition
|
10
|
+
//------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
module.exports = {
|
13
|
+
meta: {
|
14
|
+
docs: {
|
15
|
+
description: "enforce spacing between rest and spread operators and their expressions",
|
16
|
+
category: "ECMAScript 6",
|
17
|
+
recommended: false
|
18
|
+
},
|
19
|
+
fixable: "whitespace",
|
20
|
+
schema: [
|
21
|
+
{
|
22
|
+
enum: ["always", "never"]
|
23
|
+
}
|
24
|
+
]
|
25
|
+
},
|
26
|
+
|
27
|
+
create: function(context) {
|
28
|
+
var sourceCode = context.getSourceCode(),
|
29
|
+
alwaysSpace = context.options[0] === "always";
|
30
|
+
|
31
|
+
//--------------------------------------------------------------------------
|
32
|
+
// Helpers
|
33
|
+
//--------------------------------------------------------------------------
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Checks whitespace between rest/spread operators and their expressions
|
37
|
+
* @param {ASTNode} node - The node to check
|
38
|
+
* @returns {void}
|
39
|
+
*/
|
40
|
+
function checkWhiteSpace(node) {
|
41
|
+
var operator = sourceCode.getFirstToken(node),
|
42
|
+
nextToken = sourceCode.getTokenAfter(operator),
|
43
|
+
hasWhitespace = sourceCode.isSpaceBetweenTokens(operator, nextToken),
|
44
|
+
type;
|
45
|
+
|
46
|
+
switch (node.type) {
|
47
|
+
case "SpreadElement":
|
48
|
+
type = "spread";
|
49
|
+
break;
|
50
|
+
case "RestElement":
|
51
|
+
type = "rest";
|
52
|
+
break;
|
53
|
+
case "ExperimentalSpreadProperty":
|
54
|
+
type = "spread property";
|
55
|
+
break;
|
56
|
+
case "ExperimentalRestProperty":
|
57
|
+
type = "rest property";
|
58
|
+
break;
|
59
|
+
default:
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
|
63
|
+
if (alwaysSpace && !hasWhitespace) {
|
64
|
+
context.report({
|
65
|
+
node: node,
|
66
|
+
loc: {
|
67
|
+
line: operator.loc.end.line,
|
68
|
+
column: operator.loc.end.column
|
69
|
+
},
|
70
|
+
message: "Expected whitespace after {{type}} operator",
|
71
|
+
data: {
|
72
|
+
type: type
|
73
|
+
},
|
74
|
+
fix: function(fixer) {
|
75
|
+
return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " ");
|
76
|
+
}
|
77
|
+
});
|
78
|
+
} else if (!alwaysSpace && hasWhitespace) {
|
79
|
+
context.report({
|
80
|
+
node: node,
|
81
|
+
loc: {
|
82
|
+
line: operator.loc.end.line,
|
83
|
+
column: operator.loc.end.column
|
84
|
+
},
|
85
|
+
message: "Unexpected whitespace after {{type}} operator",
|
86
|
+
data: {
|
87
|
+
type: type
|
88
|
+
},
|
89
|
+
fix: function(fixer) {
|
90
|
+
return fixer.removeRange([operator.range[1], nextToken.range[0]]);
|
91
|
+
}
|
92
|
+
});
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
//--------------------------------------------------------------------------
|
97
|
+
// Public
|
98
|
+
//--------------------------------------------------------------------------
|
99
|
+
|
100
|
+
return {
|
101
|
+
SpreadElement: checkWhiteSpace,
|
102
|
+
RestElement: checkWhiteSpace,
|
103
|
+
ExperimentalSpreadProperty: checkWhiteSpace,
|
104
|
+
ExperimentalRestProperty: checkWhiteSpace
|
105
|
+
};
|
106
|
+
}
|
107
|
+
};
|
package/lib/rules/unicode-bom.js
CHANGED
package/lib/util/glob-util.js
CHANGED
@@ -154,7 +154,8 @@ function listFilesToProcess(globPatterns, options) {
|
|
154
154
|
ignoredPaths = new IgnoredPaths(options);
|
155
155
|
globOptions = {
|
156
156
|
nodir: true,
|
157
|
-
cwd: cwd
|
157
|
+
cwd: cwd,
|
158
|
+
ignore: ignoredPaths.getIgnoredFoldersGlobPatterns()
|
158
159
|
};
|
159
160
|
|
160
161
|
debug("Creating list of files to process.");
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.13.1",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"doctrine": "^1.2.2",
|
43
43
|
"es6-map": "^0.1.3",
|
44
44
|
"escope": "^3.6.0",
|
45
|
-
"espree": "3.1.
|
45
|
+
"espree": "^3.1.6",
|
46
46
|
"estraverse": "^4.2.0",
|
47
47
|
"esutils": "^2.0.2",
|
48
48
|
"file-entry-cache": "^1.1.1",
|
@@ -55,6 +55,7 @@
|
|
55
55
|
"is-resolvable": "^1.0.0",
|
56
56
|
"js-yaml": "^3.5.1",
|
57
57
|
"json-stable-stringify": "^1.0.0",
|
58
|
+
"levn": "^0.3.0",
|
58
59
|
"lodash": "^4.0.0",
|
59
60
|
"mkdirp": "^0.5.0",
|
60
61
|
"optionator": "^0.8.1",
|
@@ -93,6 +94,7 @@
|
|
93
94
|
"load-perf": "^0.2.0",
|
94
95
|
"markdownlint": "^0.1.0",
|
95
96
|
"mocha": "^2.4.5",
|
97
|
+
"mock-fs": "^3.9.0",
|
96
98
|
"npm-license": "^0.3.2",
|
97
99
|
"phantomjs-prebuilt": "^2.1.7",
|
98
100
|
"proxyquire": ">=1.0.0 <1.7.5",
|