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

Unable to access imported items dynamically #456

Closed
rhys-vdw opened this issue Jul 26, 2016 · 3 comments
Closed

Unable to access imported items dynamically #456

rhys-vdw opened this issue Jul 26, 2016 · 3 comments

Comments

@rhys-vdw
Copy link

rhys-vdw commented Jul 26, 2016

Sorry, don't know the correct jargon for this issue title. Issue I'm hitting:

import * as Module from './Module';

function getItem(name) {
  const item = Module[name];
}

error:

error    Unable to validate computed reference to imported namespace 'Module'  import/namespace

So I don't know if this is legal by the spec. Babel doesn't object. Perhaps this kind of property access should have its own rule. If it is not permitted by the spec, then it could be an error. If it is legal, then it could be a warning by default? As it is I need to disable import/namespace entirely to allow this.

@benmosher
Copy link
Member

Ah, yeah... it's valid, but the rule is basically saying "you're on your own, I can't lint computed references".

Should probably be a separate rule entirely, as some users (certainly you!) would want static reference linting without getting tripped on this.

I think I'll split this out as a separate rule in v2, but for now as a workaround you can // eslint-disable-line import/namespace? How does that sound?

@rhys-vdw
Copy link
Author

but for now as a workaround you can // eslint-disable-line import/namespace? How does that sound?

Perfect!

@benmosher benmosher modified the milestones: soon, 2.0.0 Jul 26, 2016
@benmosher benmosher added this to the 1.13.0 milestone Jul 27, 2016
@benmosher
Copy link
Member

Just published the allowComputed rule option with v1.13.0 😎

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

No branches or pull requests

2 participants