noUnresolvedImports
¥Summary
-
规则生效日期:
v2.0.0¥Rule available since:
v2.0.0 -
诊断类别:
lint/nursery/noUnresolvedImports¥Diagnostic Category:
lint/nursery/noUnresolvedImports -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
-
灵感来自
import/named¥Inspired from
import/named
-
¥How to configure
{ "linter": { "rules": { "nursery": { "noUnresolvedImports": "error" } } }}¥Description
导入不存在的导出文件时会发出警告。
¥Warn when importing non-existing exports.
导入不存在的导出会在运行时或构建时导致错误。Biome 可以检测此类不正确的导入并报告错误。
¥Importing a non-existing export is an error at runtime or build time. Biome can detect such incorrect imports and report errors for them.
请注意,如果你使用 TypeScript,则可能不希望使用此规则,因为 TypeScript 已经为你执行了此类检查。
¥Note that if you use TypeScript, you probably don’t want to use this rule, since TypeScript already performs such checks for you.
¥Known Limitations
-
此规则不验证通过动态
import()表达式或 CommonJSrequire()调用导入的内容。¥This rule does not validate imports through dynamic
import()expressions or CommonJSrequire()calls.
¥Examples
¥Invalid
export function foo() {};// Attempt to import symbol with a typo:import { fooo } from "./foo.js";/bar.js:2:10 lint/nursery/noUnresolvedImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ The path ./foo.js has no export named fooo.
1 │ // Attempt to import symbol with a typo:
> 2 │ import { fooo } from “./foo.js”;
│ ^^^^
3 │
ℹ Make sure that the path is correct and that you’re importing the right symbol.
¥Valid
export function foo() {};// Fixed typo:import { foo } from "./foo.js";¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号