noUselessRename
诊断类别:lint/complexity/noUselessRename
¥Diagnostic Category: lint/complexity/noUselessRename
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
no-useless-rename
¥Same as:
no-useless-rename
禁止将导入、导出和解构分配重命名为同一名称。
¥Disallow renaming import, export, and destructured assignments to the same name.
ES2015 允许重命名 import 和 export 语句中的引用以及解构赋值。这为程序员在重命名这些引用时提供了执行这些操作的简洁语法:
¥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
¥Invalid
code-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;
│ -----
¥Valid
¥Related links