Skip to content

unicorn/require-module-specifiers Suspicious

🛠️ An auto-fix is available for this rule.

What it does

Enforce non-empty specifier list in import and export statements.

Why is this bad?

Empty import/export specifiers add no value and can be confusing. If you want to import a module for side effects, use import 'module' instead.

Examples

Examples of incorrect code for this rule:

js
import {} from "foo";
import foo, {} from "foo";
export {} from "foo";
export {};

Examples of correct code for this rule:

js
import "foo";
import foo from "foo";

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny unicorn/require-module-specifiers
json
{
  "rules": {
    "unicorn/require-module-specifiers": "error"
  }
}

References

Released under the MIT License.