no-useless-rename

Disallow renaming an import, export, or destructured value to the same name

fixable

import { user as user } and const { id: id } = user rename something to the name it already has. The short form means the same thing.

--fix removes the rename.

Configure#

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"no-useless-rename" = "error" # or "warn"

Every option, set to its default:

bunfig.toml
[lint.rules]
"no-useless-rename" = ["error", {
  ignoreImport = false,
  ignoreExport = false,
  ignoreDestructuring = false,
}]

Examples#

example.js3 problems
import { load as load } from "./store.js";

const { id: id } = load();

export { id as id };
example.jsNo problems
import { load } from "./store.js";
import { save as saveUser } from "./users.js";

const { id, name: userName } = load();

export { id, userName as name };

Options#

OptionDefaultWhat it does
ignoreImportfalseDon't check imports.
ignoreExportfalseDon't check exports.
ignoreDestructuringfalseDon't check destructuring.
example.jswith { "ignoreDestructuring": true }No problems
const { id: id } = user;