π Disallow named usage of default import and export.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
Enforces the use of the default import and default export syntax instead of named syntax.
The named form is easy to mistake for a named specifier during refactors; dedicated default syntax makes the binding's intent explicit.
// β
import {default as foo} from 'foo';
// β
import foo from 'foo';// β
import {default as foo, bar} from 'foo';
// β
import foo, {bar} from 'foo';// β
export {foo as default};
// β
export default foo;// β
export {foo as default, bar};
// β
export default foo;
export {bar};// β
import foo, {default as anotherFoo} from 'foo';
function bar(foo) {
doSomeThing(anotherFoo, foo);
}
// β
import foo from 'foo';
import anotherFoo from 'foo';
function bar(foo) {
doSomeThing(anotherFoo, foo);
}
// β
import foo from 'foo';
const anotherFoo = foo;
function bar(foo) {
doSomeThing(anotherFoo, foo);
}