Skip to content
← Back to rules

oxc/only-used-in-recursion Корректность

This rule is turned on by default.
⚠️ 🛠️ A dangerous auto-fix is available for this rule.

Что делает правило

Checks for arguments that are only used in recursion with no side-effects.

Inspired by the only_used_in_recursion rule in Clippy.

Почему это плохо?

Supplying an argument that is only used in recursive calls is likely a mistake.

It increases cognitive complexity and may impact performance.

Примеры

Примеры некорректного кода для этого правила:

ts
function test(onlyUsedInRecursion) {
  return test(onlyUsedInRecursion);
}

Примеры корректного кода для этого правила:

ts
function f(a: number): number {
  if (a == 0) {
    return 1;
  } else {
    return f(a - 1);
  }
}

Как использовать

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

json
{
  "rules": {
    "oxc/only-used-in-recursion": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  rules: {
    "oxc/only-used-in-recursion": "error",
  },
});
bash
oxlint --deny oxc/only-used-in-recursion

Версия

Правило добавлено в v0.1.1.

Ссылки