禁止导入断言
注意:此规则是
recommended
规则集的一部分。在
deno.json
中启用完整集合{ "lint": { "rules": { "tags": ["recommended"] } } }
使用 Deno CLI 启用完整集合
deno lint --rules-tags=recommended
通过在
deno.json
中将其添加到 include
或 exclude
数组中,可以明确地将此规则包含或排除于当前标签中的规则集。{ "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" } });