noUselessRename
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/complexity/noUselessRename¥Diagnostic Category:
lint/complexity/noUselessRename -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 safe 修复程序。
¥This rule has a safe fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
来源:
¥Sources:
-
与
no-useless-rename相同¥Same as
no-useless-rename
-
¥How to configure
{ "linter": { "rules": { "complexity": { "noUselessRename": "error" } } }}¥Description
禁止将导入、导出和解构分配重命名为同一名称。
¥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:
import { foo as bar } from "baz";export { foo as bar };let { foo: bar } = baz;使用此语法,可以将引用重命名为相同的名称。这是一个完全多余的操作,因为这与根本不重命名相同。
¥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
import { foo as foo } from "bar";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”;
│ -------
export { foo as foo };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·};
│ -------
let { foo: foo } = bar;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
import { foo as bar } from "baz";export { foo as bar };let { foo: bar } = baz;¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号