Skip to content

Latest commit

Β 

History

History
75 lines (53 loc) Β· 1.6 KB

no-named-default.md

File metadata and controls

75 lines (53 loc) Β· 1.6 KB

no-named-default

πŸ“ 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.

Examples

// ❌
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);
}