从 JSLint 获取错误 "Wrap the parameter in parens",为什么?
Getting the error "Wrap the parameter in parens" from JSLint, why?
执行 JSLint 后,我收到以下消息:
Wrap the parameter in parens.
1 Expected '(' before 'info'. const valueArr = (info => { // Line 6,
Pos 19
我已经阅读了 Lint paren rules 但我仍然不确定问题是什么以及如何处理它。我的代码:
const valueArr = (info => {
items.forEach(function(item) {
try {
var xhr = new XMLHttpRequest();
.....
} catch (e) {
console.log(e);
}
});
});
已更新:
我已经尝试将它与括号放在一起,但出现了另一个警告:
"Expected 'function' and instead saw '=>'. const valueArr = ((info) =>
{".
const valueArr = ((info) => {
items.forEach(function(item) {
try {
var xhr = new XMLHttpRequest();
} catch (e) {
console.log(e);
}
});
});
This rule enforces parentheses around arrow function parameters regardless of arity.
(source)
该规则决定了这一行:
const valueArr = (info => {
应改为:
const valueArr = ((info) => {
因为箭头函数的参数必须用括号括起来
执行 JSLint 后,我收到以下消息:
Wrap the parameter in parens.
1 Expected '(' before 'info'. const valueArr = (info => { // Line 6, Pos 19
我已经阅读了 Lint paren rules 但我仍然不确定问题是什么以及如何处理它。我的代码:
const valueArr = (info => {
items.forEach(function(item) {
try {
var xhr = new XMLHttpRequest();
.....
} catch (e) {
console.log(e);
}
});
});
已更新:
我已经尝试将它与括号放在一起,但出现了另一个警告:
"Expected 'function' and instead saw '=>'. const valueArr = ((info) => {".
const valueArr = ((info) => {
items.forEach(function(item) {
try {
var xhr = new XMLHttpRequest();
} catch (e) {
console.log(e);
}
});
});
This rule enforces parentheses around arrow function parameters regardless of arity.
(source)
该规则决定了这一行:
const valueArr = (info => {
应改为:
const valueArr = ((info) => {
因为箭头函数的参数必须用括号括起来