no-import-assertions
NOTE: this rule is part of the
推荐 rule set.Enable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["推荐"]
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=推荐
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["no-import-assertions"],
"exclude": ["no-import-assertions"]
}
}
}不允许在导入属性中使用 assert 关键字。
ES 导入属性(以前称为导入断言)已更改为使用 with 关键字。使用 assert 的旧语法仍然被支持,但已被弃用。
无效:
import obj from "./obj.json" assert { type: "json" };
import("./obj2.json", { assert: { type: "json" } });
有效:
import obj from "./obj.json" with { type: "json" };
import("./obj2.json", { with: { type: "json" } });