Skip to content
← Back to rules

unicorn/no-unnecessary-array-flat-depth 严格

An auto-fix is available for this rule.

它的作用

禁止向 Array.prototype.flat 传递 1

为什么这是不好的?

传递 1 是不必要的。

示例

此规则的 错误 代码示例:

js
foo.flat(1);

此规则的 正确 代码示例:

js
foo.flat();

如何使用

通过配置文件或在 CLI 中启用此规则,可以使用:

json
{
  "rules": {
    "unicorn/no-unnecessary-array-flat-depth": "error"
  }
}
bash
oxlint --deny unicorn/no-unnecessary-array-flat-depth

参考资料