Skip to content

Latest commit

Β 

History

History
62 lines (45 loc) Β· 1.18 KB

File metadata and controls

62 lines (45 loc) Β· 1.18 KB

Disallow anonymous functions and classes as the default export

πŸ’Ό This rule is enabled in the following configs: βœ… recommended, β˜‘οΈ unopinionated.

πŸ’‘ This rule is manually fixable by editor suggestions.

Naming default exports improves codebase searchability by ensuring consistent identifier use for a module's default export, both where it's declared and where it's imported.

Examples

// ❌
export default class {}

// βœ…
export default class Foo {}
// ❌
export default function () {}

// βœ…
export default function foo () {}
// ❌
export default () => {};

// βœ…
const foo = () => {};
export default foo;
// ❌
module.exports = class {};

// βœ…
module.exports = class Foo {};
// ❌
module.exports = function () {};

// βœ…
module.exports = function foo () {};
// ❌
module.exports = () => {};

// βœ…
const foo = () => {};
module.exports = foo;