Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-restricted-exports] Fails on export { default } from ... #2500

Open
milesj opened this issue Nov 10, 2021 · 7 comments
Open

[no-restricted-exports] Fails on export { default } from ... #2500

milesj opened this issue Nov 10, 2021 · 7 comments

Comments

@milesj
Copy link

milesj commented Nov 10, 2021

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

@ljharb
Copy link
Collaborator

ljharb commented Nov 10, 2021

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?

@patcon
Copy link

patcon commented Feb 17, 2022

Filed! :) eslint/eslint#15617

@tincho
Copy link

tincho commented Jul 28, 2022

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

@elyobo
Copy link

elyobo commented Feb 2, 2023

eslint/eslint#16785 has now resolved eslint/eslint#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?

@ljharb
Copy link
Collaborator

ljharb commented Feb 2, 2023

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

elyobo added a commit to elyobo/javascript that referenced this issue Feb 2, 2023
…no-restricted-exports

Records breaking configuration changes to permit `export { default } from`
style exports as of eslint 8.33.0.

See airbnb#2500
@elyobo
Copy link

elyobo commented Feb 2, 2023

OK, thanks for the explanation, I've opened #2721.

I've also flagged on eslint/eslint#16785 (comment) 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..

@ljharb
Copy link
Collaborator

ljharb commented Feb 2, 2023

Thanks, that's great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants