💼 This rule is enabled in the ✅ recommended
config.
🔧💡 This rule is automatically fixable by the --fix
CLI option and manually fixable by editor suggestions.
When re-exporting from a module, it's unnecessary to import and then export. It can be done in a single export…from
declaration.
import defaultExport from './foo.js';
export default defaultExport;
import {named} from './foo.js';
export {named};
import * as namespace from './foo.js';
export {namespace};
import defaultExport, {named} from './foo.js';
export default defaultExport;
export {
defaultExport as renamedDefault,
named,
named as renamedNamed,
};
export {default} from './foo.js';
export {named} from './foo.js';
export * as namespace from './foo.js';
export {
default,
default as renamedDefault,
named,
named as renamedNamed,
} from './foo.js';
// There is no substitution
import * as namespace from './foo.js';
export default namespace;
Type: boolean
Default: false
When true
, if an import is used in other places than just a re-export, all variables in the import declaration will be ignored.
// eslint unicorn/prefer-export-from: ["error", {"ignoreUsedVariables": false}]
import {named1, named2} from './foo.js';
use(named1);
export {named1, named2};
// eslint unicorn/prefer-export-from: ["error", {"ignoreUsedVariables": true}]
import {named1, named2} from './foo.js';
use(named1);
export {named1, named2};