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 loadImport load unnecessarily renamed. } from "./store.js";
const { id: idDestructuring assignment id unnecessarily renamed. } = load();
export { id as idExport id unnecessarily renamed. };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#
| Option | Default | What it does |
|---|---|---|
ignoreImport | false | Don't check imports. |
ignoreExport | false | Don't check exports. |
ignoreDestructuring | false | Don't check destructuring. |
example.jswith
{ "ignoreDestructuring": true }No problemsconst { id: id } = user;