eslint 3.18.0 → 3.19.0
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 +39 -0
- package/README.md +1 -0
- package/lib/config/config-rule.js +14 -10
- package/lib/config/plugins.js +19 -8
- package/lib/eslint.js +6 -5
- package/lib/formatters/codeframe.js +4 -9
- package/lib/rules/arrow-body-style.js +2 -2
- package/lib/rules/arrow-parens.js +9 -3
- package/lib/rules/comma-dangle.js +3 -2
- package/lib/rules/comma-spacing.js +4 -14
- package/lib/rules/comma-style.js +8 -14
- package/lib/rules/curly.js +2 -2
- package/lib/rules/dot-notation.js +12 -6
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/new-parens.js +7 -21
- package/lib/rules/no-cond-assign.js +4 -17
- package/lib/rules/no-else-return.js +6 -3
- package/lib/rules/no-extra-parens.js +47 -103
- package/lib/rules/no-extra-semi.js +3 -2
- package/lib/rules/no-implicit-coercion.js +21 -8
- package/lib/rules/no-native-reassign.js +1 -1
- package/lib/rules/no-negated-in-lhs.js +1 -1
- package/lib/rules/no-param-reassign.js +8 -1
- package/lib/rules/no-restricted-syntax.js +33 -6
- package/lib/rules/no-sequences.js +2 -2
- package/lib/rules/no-unsafe-negation.js +1 -1
- package/lib/rules/no-useless-computed-key.js +12 -1
- package/lib/rules/object-curly-spacing.js +2 -2
- package/lib/rules/object-shorthand.js +8 -2
- package/lib/rules/operator-assignment.js +20 -3
- package/lib/rules/prefer-const.js +1 -1
- package/lib/rules/quotes.js +1 -0
- package/lib/rules/semi-spacing.js +2 -15
- package/lib/rules/semi.js +4 -12
- package/lib/rules/space-before-function-paren.js +53 -77
- package/lib/rules/space-in-parens.js +4 -8
- package/lib/util/glob-util.js +1 -1
- package/package.json +29 -29
@@ -51,31 +51,9 @@ module.exports = {
|
|
51
51
|
},
|
52
52
|
|
53
53
|
create(context) {
|
54
|
-
|
55
|
-
const
|
56
|
-
|
57
|
-
let requireAnonymousFunctionSpacing = true,
|
58
|
-
forbidAnonymousFunctionSpacing = false,
|
59
|
-
requireNamedFunctionSpacing = true,
|
60
|
-
forbidNamedFunctionSpacing = false,
|
61
|
-
requireArrowFunctionSpacing = false,
|
62
|
-
forbidArrowFunctionSpacing = false;
|
63
|
-
|
64
|
-
if (typeof configuration === "object") {
|
65
|
-
requireAnonymousFunctionSpacing = (
|
66
|
-
!configuration.anonymous || configuration.anonymous === "always");
|
67
|
-
forbidAnonymousFunctionSpacing = configuration.anonymous === "never";
|
68
|
-
requireNamedFunctionSpacing = (
|
69
|
-
!configuration.named || configuration.named === "always");
|
70
|
-
forbidNamedFunctionSpacing = configuration.named === "never";
|
71
|
-
requireArrowFunctionSpacing = configuration.asyncArrow === "always";
|
72
|
-
forbidArrowFunctionSpacing = configuration.asyncArrow === "never";
|
73
|
-
} else if (configuration === "never") {
|
74
|
-
requireAnonymousFunctionSpacing = false;
|
75
|
-
forbidAnonymousFunctionSpacing = true;
|
76
|
-
requireNamedFunctionSpacing = false;
|
77
|
-
forbidNamedFunctionSpacing = true;
|
78
|
-
}
|
54
|
+
const sourceCode = context.getSourceCode();
|
55
|
+
const baseConfig = typeof context.options[0] === "string" ? context.options[0] : "always";
|
56
|
+
const overrideConfig = typeof context.options[0] === "object" ? context.options[0] : {};
|
79
57
|
|
80
58
|
/**
|
81
59
|
* Determines whether a function has a name.
|
@@ -100,69 +78,67 @@ module.exports = {
|
|
100
78
|
}
|
101
79
|
|
102
80
|
/**
|
103
|
-
*
|
104
|
-
* @param {ASTNode} node The node
|
105
|
-
* @returns {
|
81
|
+
* Gets the config for a given function
|
82
|
+
* @param {ASTNode} node The function node
|
83
|
+
* @returns {string} "always", "never", or "ignore"
|
106
84
|
*/
|
107
|
-
function
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
85
|
+
function getConfigForFunction(node) {
|
86
|
+
if (node.type === "ArrowFunctionExpression") {
|
87
|
+
|
88
|
+
// Always ignore non-async functions and arrow functions without parens, e.g. async foo => bar
|
89
|
+
if (node.async && astUtils.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) {
|
90
|
+
|
91
|
+
// For backwards compatibility, the base config does not apply to async arrow functions.
|
92
|
+
return overrideConfig.asyncArrow || "ignore";
|
93
|
+
}
|
94
|
+
} else if (isNamedFunction(node)) {
|
95
|
+
return overrideConfig.named || baseConfig;
|
96
|
+
|
97
|
+
// `generator-star-spacing` should warn anonymous generators. E.g. `function* () {}`
|
98
|
+
} else if (!node.generator) {
|
99
|
+
return overrideConfig.anonymous || baseConfig;
|
120
100
|
}
|
121
101
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
102
|
+
return "ignore";
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Checks the parens of a function node
|
107
|
+
* @param {ASTNode} node A function node
|
108
|
+
* @returns {void}
|
109
|
+
*/
|
110
|
+
function checkFunction(node) {
|
111
|
+
const functionConfig = getConfigForFunction(node);
|
112
|
+
|
113
|
+
if (functionConfig === "ignore") {
|
114
|
+
return;
|
131
115
|
}
|
132
116
|
|
133
117
|
const rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
|
134
118
|
const leftToken = sourceCode.getTokenBefore(rightToken);
|
135
|
-
const
|
136
|
-
|
137
|
-
if (
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
node,
|
152
|
-
loc: location,
|
153
|
-
message: "Missing space before function parentheses.",
|
154
|
-
fix(fixer) {
|
155
|
-
return fixer.insertTextAfter(leftToken, " ");
|
156
|
-
}
|
157
|
-
});
|
158
|
-
}
|
119
|
+
const hasSpacing = sourceCode.isSpaceBetweenTokens(leftToken, rightToken);
|
120
|
+
|
121
|
+
if (hasSpacing && functionConfig === "never") {
|
122
|
+
context.report({
|
123
|
+
node,
|
124
|
+
loc: leftToken.loc.end,
|
125
|
+
message: "Unexpected space before function parentheses.",
|
126
|
+
fix: fixer => fixer.removeRange([leftToken.range[1], rightToken.range[0]])
|
127
|
+
});
|
128
|
+
} else if (!hasSpacing && functionConfig === "always") {
|
129
|
+
context.report({
|
130
|
+
node,
|
131
|
+
loc: leftToken.loc.end,
|
132
|
+
message: "Missing space before function parentheses.",
|
133
|
+
fix: fixer => fixer.insertTextAfter(leftToken, " ")
|
134
|
+
});
|
159
135
|
}
|
160
136
|
}
|
161
137
|
|
162
138
|
return {
|
163
|
-
|
164
|
-
|
165
|
-
|
139
|
+
ArrowFunctionExpression: checkFunction,
|
140
|
+
FunctionDeclaration: checkFunction,
|
141
|
+
FunctionExpression: checkFunction
|
166
142
|
};
|
167
143
|
}
|
168
144
|
};
|
@@ -128,7 +128,7 @@ module.exports = {
|
|
128
128
|
}
|
129
129
|
|
130
130
|
if (ALWAYS) {
|
131
|
-
if (
|
131
|
+
if (astUtils.isClosingParenToken(right)) {
|
132
132
|
return false;
|
133
133
|
}
|
134
134
|
return !isOpenerException(right);
|
@@ -144,7 +144,7 @@ module.exports = {
|
|
144
144
|
* @returns {boolean} True if the paren should have a space
|
145
145
|
*/
|
146
146
|
function shouldCloserHaveSpace(left, right) {
|
147
|
-
if (
|
147
|
+
if (astUtils.isOpeningParenToken(left)) {
|
148
148
|
return false;
|
149
149
|
}
|
150
150
|
|
@@ -192,7 +192,7 @@ module.exports = {
|
|
192
192
|
* @returns {boolean} True if the paren should reject the space
|
193
193
|
*/
|
194
194
|
function shouldCloserRejectSpace(left, right) {
|
195
|
-
if (
|
195
|
+
if (astUtils.isOpeningParenToken(left)) {
|
196
196
|
return false;
|
197
197
|
}
|
198
198
|
|
@@ -224,11 +224,7 @@ module.exports = {
|
|
224
224
|
const prevToken = tokens[i - 1];
|
225
225
|
const nextToken = tokens[i + 1];
|
226
226
|
|
227
|
-
if (token
|
228
|
-
return;
|
229
|
-
}
|
230
|
-
|
231
|
-
if (token.value !== "(" && token.value !== ")") {
|
227
|
+
if (!astUtils.isOpeningParenToken(token) && !astUtils.isClosingParenToken(token)) {
|
232
228
|
return;
|
233
229
|
}
|
234
230
|
|
package/lib/util/glob-util.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.19.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -71,42 +71,42 @@
|
|
71
71
|
"user-home": "^2.0.0"
|
72
72
|
},
|
73
73
|
"devDependencies": {
|
74
|
-
"babel-polyfill": "^6.
|
75
|
-
"babel-preset-es2015": "^6.
|
74
|
+
"babel-polyfill": "^6.23.0",
|
75
|
+
"babel-preset-es2015": "^6.24.0",
|
76
76
|
"babelify": "^7.3.0",
|
77
|
-
"beefy": "^2.
|
78
|
-
"brfs": "
|
79
|
-
"browserify": "^
|
77
|
+
"beefy": "^2.1.8",
|
78
|
+
"brfs": "1.4.3",
|
79
|
+
"browserify": "^14.1.0",
|
80
80
|
"chai": "^3.5.0",
|
81
|
-
"cheerio": "^0.
|
82
|
-
"coveralls": "^2.
|
83
|
-
"dateformat": "^
|
84
|
-
"ejs": "^2.
|
81
|
+
"cheerio": "^0.22.0",
|
82
|
+
"coveralls": "^2.12.0",
|
83
|
+
"dateformat": "^2.0.0",
|
84
|
+
"ejs": "^2.5.6",
|
85
85
|
"eslint-plugin-eslint-plugin": "^0.7.1",
|
86
|
-
"eslint-plugin-node": "^4.1
|
87
|
-
"eslint-release": "^0.10.
|
88
|
-
"esprima": "^
|
86
|
+
"eslint-plugin-node": "^4.2.1",
|
87
|
+
"eslint-release": "^0.10.1",
|
88
|
+
"esprima": "^3.1.3",
|
89
89
|
"esprima-fb": "^15001.1001.0-dev-harmony-fb",
|
90
|
-
"istanbul": "^0.4.
|
91
|
-
"jsdoc": "^3.3
|
92
|
-
"karma": "^
|
90
|
+
"istanbul": "^0.4.5",
|
91
|
+
"jsdoc": "^3.4.3",
|
92
|
+
"karma": "^1.5.0",
|
93
93
|
"karma-babel-preprocessor": "^6.0.1",
|
94
|
-
"karma-mocha": "^1.0
|
95
|
-
"karma-mocha-reporter": "^2.
|
96
|
-
"karma-phantomjs-launcher": "^1.0.
|
97
|
-
"leche": "^2.1.
|
94
|
+
"karma-mocha": "^1.3.0",
|
95
|
+
"karma-mocha-reporter": "^2.2.2",
|
96
|
+
"karma-phantomjs-launcher": "^1.0.4",
|
97
|
+
"leche": "^2.1.2",
|
98
98
|
"load-perf": "^0.2.0",
|
99
|
-
"markdownlint": "^0.
|
100
|
-
"mocha": "^2.
|
99
|
+
"markdownlint": "^0.4.0",
|
100
|
+
"mocha": "^3.2.0",
|
101
101
|
"mock-fs": "^4.2.0",
|
102
|
-
"npm-license": "^0.3.
|
103
|
-
"phantomjs-prebuilt": "^2.1.
|
104
|
-
"proxyquire": "^1.7.
|
105
|
-
"semver": "^5.0
|
106
|
-
"shelljs-nodecli": "~0.1.
|
107
|
-
"sinon": "^
|
102
|
+
"npm-license": "^0.3.3",
|
103
|
+
"phantomjs-prebuilt": "^2.1.14",
|
104
|
+
"proxyquire": "^1.7.11",
|
105
|
+
"semver": "^5.3.0",
|
106
|
+
"shelljs-nodecli": "~0.1.1",
|
107
|
+
"sinon": "^2.0.0",
|
108
108
|
"temp": "^0.8.3",
|
109
|
-
"through": "^2.3.
|
109
|
+
"through": "^2.3.8"
|
110
110
|
},
|
111
111
|
"keywords": [
|
112
112
|
"ast",
|