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

import/default failing on import of json file #429

Open
kentcdodds opened this issue Jul 9, 2016 · 5 comments
Open

import/default failing on import of json file #429

kentcdodds opened this issue Jul 9, 2016 · 5 comments

Comments

@kentcdodds
Copy link
Contributor

Code:

import data from './data'

Relevant config:

"import/default": 2,

Error:

error  No default export found in module

I'm not 100% certain, but I believe that node will allow importing of json files when the new module syntax is implemented. So this appears to be an error.

@kentcdodds
Copy link
Contributor Author

For more info: nodejs/node-eps#34

@benmosher
Copy link
Member

You can use the import/extensions setting to restrict parsing (and thus, reported errors) to just .js files.

That said, I should dig into that issue and see what the json import behavior will be.

@benmosher
Copy link
Member

BTW, #267 for more context on why it is what it is, today.

@benmosher
Copy link
Member

Just read the linked node-eps issue. Should be easy enough to allow a single default export for JSON and go from there, though if you set import/extensions to ['.js'] it's roughly the same user experience.

@kentcdodds
Copy link
Contributor Author

though if you set import/extensions to ['.js'] it's roughly the same user experience.

Not exactly. Because if someone tries to pull out properties as named exports then this could warn for that.

@ljharb ljharb reopened this Oct 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants