import/unambiguous Restriction
What it does
Warn if a module could be mistakenly parsed as a script and not pure ESM module
Why is this bad?
For ESM-only environments helps to determine files that not pure ESM modules
Examples
Examples of incorrect code for this rule:
js
function x() {}
(function x() {
return 42;
})();Examples of correct code for this rule:
js
import "foo";
function x() {
return 42;
}
export function x() {
return 42;
}
(function x() {
return 42;
})();
export {}; // simple way to mark side-effects-only file as 'module' without any imports/exportsHow to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny import/unambiguous --import-pluginjson
{
"plugins": ["import"],
"rules": {
"import/unambiguous": "error"
}
}