---
url: /docs/guide/usage/linter/rules/unicorn/require-module-attributes.md
---

### 它的作用

此规则强制 `import`/`export` 语句和 `import()` 表达式中的属性列表不能为空。

### 为什么这不好？

导入属性旨在提供有关模块应如何加载的元数据
（例如，`with { type: "json" }`）。空的属性对象不提供任何信息，
应将其移除。

### 示例

以下是此规则的**错误**代码示例：

```js
import foo from "foo" with {};

export { foo } from "foo" with {};

const foo = await import("foo", {});

const foo = await import("foo", { with: {} });
```

以下是此规则的**正确**代码示例：

```js
import foo from "foo";

export { foo } from "foo";

const foo = await import("foo");

const foo = await import("foo");
```

## 如何使用

## 版本

此规则在 v1.35.0 中新增。

## 参考资料
