eslint 5.4.0 → 5.5.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 +11 -0
- package/lib/formatters/codeframe.js +2 -2
- package/lib/rules/camelcase.js +1 -1
- package/lib/rules/for-direction.js +5 -2
- package/lib/rules/func-call-spacing.js +7 -3
- package/lib/rules/func-name-matching.js +12 -6
- package/lib/rules/func-names.js +7 -3
- package/lib/rules/func-style.js +8 -4
- package/lib/rules/function-paren-newline.js +11 -5
- package/lib/rules/generator-star-spacing.js +18 -9
- package/lib/rules/getter-return.js +7 -5
- package/lib/rules/max-params.js +2 -1
- package/lib/rules/no-magic-numbers.js +7 -3
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
v5.5.0 - August 31, 2018
|
2
|
+
|
3
|
+
* 6e110e6 Fix: camelcase duplicate warning bug (fixes #10801) (#10802) (Julian Rosse)
|
4
|
+
* 5103ee7 Docs: Add Brackets integration (#10813) (Jan Pilzer)
|
5
|
+
* b61d2cd Update: max-params to only highlight function header (#10815) (Ian Obermiller)
|
6
|
+
* 2b2f11d Upgrade: babel-code-frame to version 7 (#10808) (Rouven Weßling)
|
7
|
+
* 2824d43 Docs: fix comment placement in a code example (#10799) (Vse Mozhet Byt)
|
8
|
+
* 10690b7 Upgrade: devdeps and deps to latest (#10622) (薛定谔的猫)
|
9
|
+
* 80c8598 Docs: gitignore syntax updates (fixes #8139) (#10776) (Gustavo Santana)
|
10
|
+
* cb946af Chore: use meta.messages in some rules (1/4) (#10764) (薛定谔的猫)
|
11
|
+
|
1
12
|
v5.4.0 - August 17, 2018
|
2
13
|
|
3
14
|
* a70909f Docs: Add jscs-dev.github.io links (#10771) (Gustavo Santana)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
"use strict";
|
6
6
|
|
7
7
|
const chalk = require("chalk");
|
8
|
-
const
|
8
|
+
const { codeFrameColumns } = require("@babel/code-frame");
|
9
9
|
const path = require("path");
|
10
10
|
|
11
11
|
//------------------------------------------------------------------------------
|
@@ -63,7 +63,7 @@ function formatMessage(message, parentResult) {
|
|
63
63
|
|
64
64
|
if (sourceCode) {
|
65
65
|
result.push(
|
66
|
-
|
66
|
+
codeFrameColumns(sourceCode, { start: { line: message.line, column: message.column } }, { highlightCode: false })
|
67
67
|
);
|
68
68
|
}
|
69
69
|
|
package/lib/rules/camelcase.js
CHANGED
@@ -145,7 +145,7 @@ module.exports = {
|
|
145
145
|
const assignmentKeyEqualsValue = node.parent.key.name === node.parent.value.name;
|
146
146
|
|
147
147
|
// prevent checking righthand side of destructured object
|
148
|
-
if (
|
148
|
+
if (node.parent.key === node && node.parent.value !== node) {
|
149
149
|
return;
|
150
150
|
}
|
151
151
|
|
@@ -18,7 +18,10 @@ module.exports = {
|
|
18
18
|
url: "https://eslint.org/docs/rules/for-direction"
|
19
19
|
},
|
20
20
|
fixable: null,
|
21
|
-
schema: []
|
21
|
+
schema: [],
|
22
|
+
messages: {
|
23
|
+
incorrectDirection: "The update clause in this loop moves the variable in the wrong direction."
|
24
|
+
}
|
22
25
|
},
|
23
26
|
|
24
27
|
create(context) {
|
@@ -31,7 +34,7 @@ module.exports = {
|
|
31
34
|
function report(node) {
|
32
35
|
context.report({
|
33
36
|
node,
|
34
|
-
|
37
|
+
messageId: "incorrectDirection"
|
35
38
|
});
|
36
39
|
}
|
37
40
|
|
@@ -57,6 +57,10 @@ module.exports = {
|
|
57
57
|
maxItems: 2
|
58
58
|
}
|
59
59
|
]
|
60
|
+
},
|
61
|
+
messages: {
|
62
|
+
unexpected: "Unexpected newline between function name and paren.",
|
63
|
+
missing: "Missing space between function name and paren."
|
60
64
|
}
|
61
65
|
},
|
62
66
|
|
@@ -116,7 +120,7 @@ module.exports = {
|
|
116
120
|
context.report({
|
117
121
|
node,
|
118
122
|
loc: lastCalleeToken.loc.start,
|
119
|
-
|
123
|
+
messageId: "unexpected",
|
120
124
|
fix(fixer) {
|
121
125
|
|
122
126
|
/*
|
@@ -134,7 +138,7 @@ module.exports = {
|
|
134
138
|
context.report({
|
135
139
|
node,
|
136
140
|
loc: lastCalleeToken.loc.start,
|
137
|
-
|
141
|
+
messageId: "missing",
|
138
142
|
fix(fixer) {
|
139
143
|
return fixer.insertTextBefore(parenToken, " ");
|
140
144
|
}
|
@@ -143,7 +147,7 @@ module.exports = {
|
|
143
147
|
context.report({
|
144
148
|
node,
|
145
149
|
loc: lastCalleeToken.loc.start,
|
146
|
-
|
150
|
+
messageId: "unexpected",
|
147
151
|
fix(fixer) {
|
148
152
|
return fixer.replaceTextRange([prevToken.range[1], parenToken.range[0]], " ");
|
149
153
|
}
|
@@ -87,6 +87,12 @@ module.exports = {
|
|
87
87
|
additionalItems: false,
|
88
88
|
items: [optionsObject]
|
89
89
|
}]
|
90
|
+
},
|
91
|
+
messages: {
|
92
|
+
matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`",
|
93
|
+
matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`",
|
94
|
+
notMatchProperty: "Function name `{{funcName}}` should not match property name `{{name}}`",
|
95
|
+
notMatchVariable: "Function name `{{funcName}}` should not match variable name `{{name}}`"
|
90
96
|
}
|
91
97
|
},
|
92
98
|
|
@@ -132,20 +138,20 @@ module.exports = {
|
|
132
138
|
* @returns {void}
|
133
139
|
*/
|
134
140
|
function report(node, name, funcName, isProp) {
|
135
|
-
let
|
141
|
+
let messageId;
|
136
142
|
|
137
143
|
if (nameMatches === "always" && isProp) {
|
138
|
-
|
144
|
+
messageId = "matchProperty";
|
139
145
|
} else if (nameMatches === "always") {
|
140
|
-
|
146
|
+
messageId = "matchVariable";
|
141
147
|
} else if (isProp) {
|
142
|
-
|
148
|
+
messageId = "notMatchProperty";
|
143
149
|
} else {
|
144
|
-
|
150
|
+
messageId = "notMatchVariable";
|
145
151
|
}
|
146
152
|
context.report({
|
147
153
|
node,
|
148
|
-
|
154
|
+
messageId,
|
149
155
|
data: {
|
150
156
|
name,
|
151
157
|
funcName
|
package/lib/rules/func-names.js
CHANGED
@@ -37,7 +37,11 @@ module.exports = {
|
|
37
37
|
{
|
38
38
|
enum: ["always", "as-needed", "never"]
|
39
39
|
}
|
40
|
-
]
|
40
|
+
],
|
41
|
+
messages: {
|
42
|
+
unnamed: "Unexpected unnamed {{name}}.",
|
43
|
+
named: "Unexpected named {{name}}."
|
44
|
+
}
|
41
45
|
},
|
42
46
|
|
43
47
|
create(context) {
|
@@ -96,7 +100,7 @@ module.exports = {
|
|
96
100
|
if (hasName) {
|
97
101
|
context.report({
|
98
102
|
node,
|
99
|
-
|
103
|
+
messageId: "named",
|
100
104
|
data: { name }
|
101
105
|
});
|
102
106
|
}
|
@@ -104,7 +108,7 @@ module.exports = {
|
|
104
108
|
if (!hasName && (asNeeded ? !hasInferredName(node) : !isObjectOrClassMethod(node))) {
|
105
109
|
context.report({
|
106
110
|
node,
|
107
|
-
|
111
|
+
messageId: "unnamed",
|
108
112
|
data: { name }
|
109
113
|
});
|
110
114
|
}
|
package/lib/rules/func-style.js
CHANGED
@@ -30,7 +30,11 @@ module.exports = {
|
|
30
30
|
},
|
31
31
|
additionalProperties: false
|
32
32
|
}
|
33
|
-
]
|
33
|
+
],
|
34
|
+
messages: {
|
35
|
+
expression: "Expected a function expression.",
|
36
|
+
declaration: "Expected a function declaration."
|
37
|
+
}
|
34
38
|
},
|
35
39
|
|
36
40
|
create(context) {
|
@@ -45,7 +49,7 @@ module.exports = {
|
|
45
49
|
stack.push(false);
|
46
50
|
|
47
51
|
if (!enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration") {
|
48
|
-
context.report({ node,
|
52
|
+
context.report({ node, messageId: "expression" });
|
49
53
|
}
|
50
54
|
},
|
51
55
|
"FunctionDeclaration:exit"() {
|
@@ -56,7 +60,7 @@ module.exports = {
|
|
56
60
|
stack.push(false);
|
57
61
|
|
58
62
|
if (enforceDeclarations && node.parent.type === "VariableDeclarator") {
|
59
|
-
context.report({ node: node.parent,
|
63
|
+
context.report({ node: node.parent, messageId: "declaration" });
|
60
64
|
}
|
61
65
|
},
|
62
66
|
"FunctionExpression:exit"() {
|
@@ -79,7 +83,7 @@ module.exports = {
|
|
79
83
|
const hasThisExpr = stack.pop();
|
80
84
|
|
81
85
|
if (enforceDeclarations && !hasThisExpr && node.parent.type === "VariableDeclarator") {
|
82
|
-
context.report({ node: node.parent,
|
86
|
+
context.report({ node: node.parent, messageId: "declaration" });
|
83
87
|
}
|
84
88
|
};
|
85
89
|
}
|
@@ -41,7 +41,13 @@ module.exports = {
|
|
41
41
|
}
|
42
42
|
]
|
43
43
|
}
|
44
|
-
]
|
44
|
+
],
|
45
|
+
messages: {
|
46
|
+
expectedBefore: "Expected newline before ')'.",
|
47
|
+
expectedAfter: "Expected newline after '('.",
|
48
|
+
unexpectedBefore: "Unexpected newline before '('.",
|
49
|
+
unexpectedAfter: "Unexpected newline after ')'."
|
50
|
+
}
|
45
51
|
},
|
46
52
|
|
47
53
|
create(context) {
|
@@ -99,7 +105,7 @@ module.exports = {
|
|
99
105
|
if (hasLeftNewline && !needsNewlines) {
|
100
106
|
context.report({
|
101
107
|
node: leftParen,
|
102
|
-
|
108
|
+
messageId: "unexpectedAfter",
|
103
109
|
fix(fixer) {
|
104
110
|
return sourceCode.getText().slice(leftParen.range[1], tokenAfterLeftParen.range[0]).trim()
|
105
111
|
|
@@ -111,7 +117,7 @@ module.exports = {
|
|
111
117
|
} else if (!hasLeftNewline && needsNewlines) {
|
112
118
|
context.report({
|
113
119
|
node: leftParen,
|
114
|
-
|
120
|
+
messageId: "expectedAfter",
|
115
121
|
fix: fixer => fixer.insertTextAfter(leftParen, "\n")
|
116
122
|
});
|
117
123
|
}
|
@@ -119,7 +125,7 @@ module.exports = {
|
|
119
125
|
if (hasRightNewline && !needsNewlines) {
|
120
126
|
context.report({
|
121
127
|
node: rightParen,
|
122
|
-
|
128
|
+
messageId: "unexpectedBefore",
|
123
129
|
fix(fixer) {
|
124
130
|
return sourceCode.getText().slice(tokenBeforeRightParen.range[1], rightParen.range[0]).trim()
|
125
131
|
|
@@ -131,7 +137,7 @@ module.exports = {
|
|
131
137
|
} else if (!hasRightNewline && needsNewlines) {
|
132
138
|
context.report({
|
133
139
|
node: rightParen,
|
134
|
-
|
140
|
+
messageId: "expectedBefore",
|
135
141
|
fix: fixer => fixer.insertTextBefore(rightParen, "\n")
|
136
142
|
});
|
137
143
|
}
|
@@ -55,7 +55,13 @@ module.exports = {
|
|
55
55
|
}
|
56
56
|
]
|
57
57
|
}
|
58
|
-
]
|
58
|
+
],
|
59
|
+
messages: {
|
60
|
+
missingBefore: "Missing space before *.",
|
61
|
+
missingAfter: "Missing space after *.",
|
62
|
+
unexpectedBefore: "Unexpected space before *.",
|
63
|
+
unexpectedAfter: "Unexpected space after *."
|
64
|
+
}
|
59
65
|
},
|
60
66
|
|
61
67
|
create(context) {
|
@@ -119,6 +125,15 @@ module.exports = {
|
|
119
125
|
);
|
120
126
|
}
|
121
127
|
|
128
|
+
/**
|
129
|
+
* capitalize a given string.
|
130
|
+
* @param {string} str the given string.
|
131
|
+
* @returns {string} the capitalized string.
|
132
|
+
*/
|
133
|
+
function capitalize(str) {
|
134
|
+
return str[0].toUpperCase() + str.slice(1);
|
135
|
+
}
|
136
|
+
|
122
137
|
/**
|
123
138
|
* Checks the spacing between two tokens before or after the star token.
|
124
139
|
*
|
@@ -135,17 +150,11 @@ module.exports = {
|
|
135
150
|
const after = leftToken.value === "*";
|
136
151
|
const spaceRequired = modes[kind][side];
|
137
152
|
const node = after ? leftToken : rightToken;
|
138
|
-
const
|
139
|
-
const message = "{{type}} space {{side}} *.";
|
140
|
-
const data = {
|
141
|
-
type,
|
142
|
-
side
|
143
|
-
};
|
153
|
+
const messageId = `${spaceRequired ? "missing" : "unexpected"}${capitalize(side)}`;
|
144
154
|
|
145
155
|
context.report({
|
146
156
|
node,
|
147
|
-
|
148
|
-
data,
|
157
|
+
messageId,
|
149
158
|
fix(fixer) {
|
150
159
|
if (spaceRequired) {
|
151
160
|
if (after) {
|
@@ -61,7 +61,11 @@ module.exports = {
|
|
61
61
|
},
|
62
62
|
additionalProperties: false
|
63
63
|
}
|
64
|
-
]
|
64
|
+
],
|
65
|
+
messages: {
|
66
|
+
expected: "Expected to return a value in {{name}}.",
|
67
|
+
expectedAlways: "Expected {{name}} to always return a value."
|
68
|
+
}
|
65
69
|
},
|
66
70
|
|
67
71
|
create(context) {
|
@@ -93,9 +97,7 @@ module.exports = {
|
|
93
97
|
context.report({
|
94
98
|
node,
|
95
99
|
loc: getId(node).loc.start,
|
96
|
-
|
97
|
-
? "Expected {{name}} to always return a value."
|
98
|
-
: "Expected to return a value in {{name}}.",
|
100
|
+
messageId: funcInfo.hasReturn ? "expectedAlways" : "expected",
|
99
101
|
data: {
|
100
102
|
name: astUtils.getFunctionNameWithKind(funcInfo.node)
|
101
103
|
}
|
@@ -161,7 +163,7 @@ module.exports = {
|
|
161
163
|
if (!options.allowImplicit && !node.argument) {
|
162
164
|
context.report({
|
163
165
|
node,
|
164
|
-
|
166
|
+
messageId: "expected",
|
165
167
|
data: {
|
166
168
|
name: astUtils.getFunctionNameWithKind(funcInfo.node)
|
167
169
|
}
|
package/lib/rules/max-params.js
CHANGED
@@ -53,7 +53,7 @@ module.exports = {
|
|
53
53
|
},
|
54
54
|
|
55
55
|
create(context) {
|
56
|
-
|
56
|
+
const sourceCode = context.getSourceCode();
|
57
57
|
const option = context.options[0];
|
58
58
|
let numParams = 3;
|
59
59
|
|
@@ -76,6 +76,7 @@ module.exports = {
|
|
76
76
|
function checkFunction(node) {
|
77
77
|
if (node.params.length > numParams) {
|
78
78
|
context.report({
|
79
|
+
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
|
79
80
|
node,
|
80
81
|
message: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}.",
|
81
82
|
data: {
|
@@ -39,7 +39,11 @@ module.exports = {
|
|
39
39
|
}
|
40
40
|
},
|
41
41
|
additionalProperties: false
|
42
|
-
}]
|
42
|
+
}],
|
43
|
+
messages: {
|
44
|
+
useConst: "Number constants declarations must use 'const'.",
|
45
|
+
noMagic: "No magic number: {{raw}}."
|
46
|
+
}
|
43
47
|
},
|
44
48
|
|
45
49
|
create(context) {
|
@@ -136,7 +140,7 @@ module.exports = {
|
|
136
140
|
if (enforceConst && parent.parent.kind !== "const") {
|
137
141
|
context.report({
|
138
142
|
node: fullNumberNode,
|
139
|
-
|
143
|
+
messageId: "useConst"
|
140
144
|
});
|
141
145
|
}
|
142
146
|
} else if (
|
@@ -145,7 +149,7 @@ module.exports = {
|
|
145
149
|
) {
|
146
150
|
context.report({
|
147
151
|
node: fullNumberNode,
|
148
|
-
|
152
|
+
messageId: "noMagic",
|
149
153
|
data: {
|
150
154
|
raw
|
151
155
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.5.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -35,8 +35,8 @@
|
|
35
35
|
"homepage": "https://eslint.org",
|
36
36
|
"bugs": "https://github.com/eslint/eslint/issues/",
|
37
37
|
"dependencies": {
|
38
|
-
"
|
39
|
-
"
|
38
|
+
"@babel/code-frame": "^7.0.0",
|
39
|
+
"ajv": "^6.5.3",
|
40
40
|
"chalk": "^2.1.0",
|
41
41
|
"cross-spawn": "^6.0.5",
|
42
42
|
"debug": "^3.1.0",
|
@@ -51,11 +51,11 @@
|
|
51
51
|
"functional-red-black-tree": "^1.0.1",
|
52
52
|
"glob": "^7.1.2",
|
53
53
|
"globals": "^11.7.0",
|
54
|
-
"ignore": "^4.0.
|
54
|
+
"ignore": "^4.0.6",
|
55
55
|
"imurmurhash": "^0.1.4",
|
56
|
-
"inquirer": "^
|
56
|
+
"inquirer": "^6.1.0",
|
57
57
|
"is-resolvable": "^1.1.0",
|
58
|
-
"js-yaml": "^3.
|
58
|
+
"js-yaml": "^3.12.0",
|
59
59
|
"json-stable-stringify-without-jsonify": "^1.0.1",
|
60
60
|
"levn": "^0.3.0",
|
61
61
|
"lodash": "^4.17.5",
|
@@ -68,7 +68,7 @@
|
|
68
68
|
"progress": "^2.0.0",
|
69
69
|
"regexpp": "^2.0.0",
|
70
70
|
"require-uncached": "^1.0.3",
|
71
|
-
"semver": "^5.5.
|
71
|
+
"semver": "^5.5.1",
|
72
72
|
"strip-ansi": "^4.0.0",
|
73
73
|
"strip-json-comments": "^2.0.1",
|
74
74
|
"table": "^4.0.3",
|
@@ -80,7 +80,7 @@
|
|
80
80
|
"babel-preset-es2015": "^6.24.1",
|
81
81
|
"babelify": "^8.0.0",
|
82
82
|
"beefy": "^2.1.8",
|
83
|
-
"brfs": "^
|
83
|
+
"brfs": "^2.0.0",
|
84
84
|
"browserify": "^16.2.2",
|
85
85
|
"chai": "^4.0.1",
|
86
86
|
"cheerio": "^0.22.0",
|
@@ -93,19 +93,19 @@
|
|
93
93
|
"eslint-release": "^0.11.1",
|
94
94
|
"eslint-rule-composer": "^0.3.0",
|
95
95
|
"eslump": "^1.6.2",
|
96
|
-
"esprima": "^4.0.
|
96
|
+
"esprima": "^4.0.1",
|
97
97
|
"istanbul": "^0.4.5",
|
98
98
|
"jsdoc": "^3.5.5",
|
99
|
-
"karma": "^
|
99
|
+
"karma": "^3.0.0",
|
100
100
|
"karma-babel-preprocessor": "^7.0.0",
|
101
101
|
"karma-mocha": "^1.3.0",
|
102
102
|
"karma-mocha-reporter": "^2.2.3",
|
103
103
|
"karma-phantomjs-launcher": "^1.0.4",
|
104
104
|
"leche": "^2.2.3",
|
105
105
|
"load-perf": "^0.2.0",
|
106
|
-
"markdownlint": "^0.
|
106
|
+
"markdownlint": "^0.11.0",
|
107
107
|
"mocha": "^5.0.5",
|
108
|
-
"mock-fs": "^4.
|
108
|
+
"mock-fs": "^4.6.0",
|
109
109
|
"npm-license": "^0.3.3",
|
110
110
|
"phantomjs-prebuilt": "^2.1.16",
|
111
111
|
"proxyquire": "^2.0.1",
|