Skip to content

eslint/no-useless-rename Correctness

This rule is turned on by default.

What it does

Disallow renaming import, export, and destructured assignments to the same name.

Why is this bad?

It is unnecessary to rename a variable to the same name.

Example

Examples of incorrect code for this rule:

javascript
import { foo as foo } from "foo";
const { bar: bar } = obj;
export { baz as baz };

Examples of correct code for this rule:

javascript
import { foo } from "foo";
const { bar: renamed } = obj;
export { baz };

How to use

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

bash
oxlint --deny no-useless-rename
json
{
  "rules": {
    "no-useless-rename": "error"
  }
}

References

Released under the MIT License.