Skip to content

noDeprecatedImports

¥Summary

¥How to configure

biome.json
{
"linter": {
"rules": {
"nursery": {
"noDeprecatedImports": "error"
}
}
}
}

¥Description

限制导入已弃用的导出项。

¥Restrict imports of deprecated exports.

此规则标记所有使用包含 “@deprecated” 注解的 JSDoc 注释进行文档化的符号导入(例如类型、函数或任何其他可导入的内容)。

¥This rule flags any imports for symbols (such as types, functions, or anything else that can be imported), that are documented with a JSDoc comment that contains an “@deprecated” annotation.

¥Examples

¥Invalid

foo.js
import { oldUtility } from "./utils.js";
/foo.js:1:10 lint/nursery/noDeprecatedImports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Deprecated import.

> 1 │ import { oldUtility } from “./utils.js”;
^^^^^^^^^^
2 │

An @deprecated annotation indicates the author doesn’t want you to rely on this import anymore.

You should probably import a different symbol instead.

utils.js
/**
* @deprecated
*/
export function oldUtility() {}

¥Valid

foo.js
import { newUtility, oldUtility } from "./utils.js";
utils.js
export function newUtility() {}
// @deprecated (this is not a JSDoc comment)
export function oldUtility() {}

¥Related links