[no-restricted-exports] Fails on `export { default } from ...`
As the title states. Fails when re-exporting the default from another module.
export { default } from 'another-module';
This feels like it should pass, since this is not a named export. https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/es6.js#L67
You're right, it definitely should be acceptable. This seems like a bug in eslint itself, given https://eslint.org/docs/rules/no-restricted-exports#default-exports
Can you file that on eslint?
Filed! :) https://github.com/eslint/eslint/issues/15617
just FTR, a quick workaround for me was adding
"no-restricted-exports": ["error", {
"restrictedNamedExports": [
"then"
]
}],
to rules object in my .eslintrc.json file
it would have been quicker to just add
"no-restricted-exports": "off"
but I just wanted to remove the default keyword and keep the rest of the restricted
https://github.com/eslint/eslint/pull/16785 has now resolved https://github.com/eslint/eslint/issues/15617 with a fix available upstream by disabling defaultFrom for no-restricted-exports.
We can remove the needs eslint rule change/addition label, as that change has been made.
@ljharb would you accept a PR changing this config in the rules in this repo?
Edit: I'm not quite sure to handle backwards compatibility with older eslint versions when a new configuration option like this is added though, are there some examples I can refer to?
@elyobo if we enabled the option, it would break on eslint versions older than the one that added it - so, it's a breaking change to do so. This means that there should be a "TODO" comment above the rule, describing it as semver-major, and what change to make - that way, when we next have a breaking change, I'll do a sweep through the comments for any rules that are waiting to be enabled.
OK, thanks for the explanation, I've opened https://github.com/airbnb/javascript/pull/2721.
~I've also flagged on https://github.com/eslint/eslint/pull/16785#issuecomment-1413236227 but it looks like the change included arguably breaking changes to the option validating by banning the string default in restrictedNamedExports as is used in the airbnb configs. This might bite users of existing airbnb config releases that ugprade to eslint 8.33.0+~ Edit: I misunderstood the implementation there and there is no BC break, default is only prohibited if restrictedNamedExports is defined..
Thanks, that's great.