Eslint-plugin-import: import/default failing on import of json file

Created on 9 Jul 2016  路  5Comments  路  Source: benmosher/eslint-plugin-import

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.

accepted enhancement help wanted semver-minor

Most helpful comment

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.

All 5 comments

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.

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

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.

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.

Was this page helpful?
0 / 5 - 0 ratings