Skip to content

no-debugger

禁止使用debugger

为什么

生产代码如果包含debugger,会导致浏览器停止执行代码,遇到那种不会关调试功能的人,整个网页就相当于挂掉了。

建议

直接在浏览器的源代码中打断点

错误示例

js
function isTruthy(x) {
  debugger;
  return Boolean(x);
}
function isTruthy(x) {
  debugger;
  return Boolean(x);
}

正确示例

js
function isTruthy(x) {
  return Boolean(x);
}
function isTruthy(x) {
  return Boolean(x);
}

参考