Skip to content

Latest commit

 

History

History
71 lines (51 loc) · 1.42 KB

no-named-default.md

File metadata and controls

71 lines (51 loc) · 1.42 KB

Disallow named usage of default import and export

💼 This rule is enabled in the ✅ recommended config.

🔧 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.

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