noUselessRename
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/complexity/noUselessRename
Since: v1.0.0
Sources:
- Same as:
no-useless-rename
Disallow renaming import, export, and destructured assignments to the same name.
ES2015 allows for the renaming of references in import and export statements as well as destructuring assignments. This gives programmers a concise syntax for performing these operations while renaming these references:
With this syntax, it is possible to rename a reference to the same name. This is a completely redundant operation, as this is the same as not renaming at all.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:10 lint/complexity/noUselessRename FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Useless rename.
> 1 │ import { foo as foo } from “bar”;
│ ^^^^^^^^^^
2 │
ℹ Safe fix: Remove the renaming.
1 │ import·{·foo·as·foo·}·from·“bar”;
│ -------
code-block.js:1:10 lint/complexity/noUselessRename FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Useless rename.
> 1 │ export { foo as foo };
│ ^^^^^^^^^^
2 │
ℹ Safe fix: Remove the renaming.
1 │ export·{·foo·as·foo·};
│ -------
code-block.js:1:7 lint/complexity/noUselessRename FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Useless rename.
> 1 │ let { foo: foo } = bar;
│ ^^^^^^^^
2 │
ℹ Safe fix: Remove the renaming.
1 │ let·{·foo:·foo·}·=·bar;
│ -----