Skip to content
← Back to rules

unicorn/no-unnecessary-array-flat-depth Pedantic

💡 A suggestion is available for this rule.

作用

不允许向 Array.prototype.flat 传入 1

为什么这不好?

传入 1 是不必要的。

示例

以下是此规则的错误代码示例:

js
foo.flat(1);

以下是此规则的正确代码示例:

js
foo.flat();

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "unicorn/no-unnecessary-array-flat-depth": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "unicorn/no-unnecessary-array-flat-depth": "error",
  },
});
bash
oxlint --deny unicorn/no-unnecessary-array-flat-depth

版本

此规则于 v0.16.12 中加入。

参考资料