没有-
使用
表格
in that is to be in theconsole什么意思,最好避免使用 on 。这些是为了而不是运送到 .在 , 调用使用 be being to 。
console.log("Made it here.");
console.error("That shouldn't have happened.");
规则
此规则调用或到的。
此规则的代码:
/* eslint no-console: "error" */
console.log("Log a debug level message.");
console.warn("Log a warn level message.");
console.error("Log an error level message.");
console.log = foo();
此规则的代码:
/* eslint no-console: "error" */
// custom console
Console.log("Hello world!");
这条规则有一个 for :
此规则的代码带有 { “allow”: [“warn”, “error”] } :
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
console.warn("Log a warn level message.");
console.error("Log an error level message.");
什么时候不使用它
如果您使用的是 Node.js,则 , 用于用户,因此不用于 .如果你是 Node.js,那么你最不想要这条规则。
你可能不使用这个规则的情况是你想打电话而不是。对于:
/* eslint no-console: ["error", { allow: ["warn"] }] */
console.error = function (message) {
throw new Error(message);
};
上面的no-ruleconsole什么意思,会报错。对于上述,你可以规则:
// eslint-disable-next-line no-console
console.error = function (message) {
throw new Error(message);
};
// or
console.error = function (message) { // eslint-disable-line no-console
throw new Error(message);
};
,您可能不想添加–next-line 或–line。你可以只使用 no– 规则来调用:
{
"rules": {
"no-console": "off",
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(log|warn|error|info|trace)$/]",
"message": "Unexpected property on console object was called"
}
]
}
}
这条规则在 v0.0.2.
本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 gointa@126.com 举报,一经查实,本站将立刻删除。