Create-react-app: Enable linting rules for ES6 imports

Created on 25 Jul 2016  路  8Comments  路  Source: facebook/create-react-app

I wanted to use eslint-plugin-import but I had to disable it because it doesn鈥檛 seem to work very well with eslint-loader workflow.

I would very much welcome help in fixing this. I鈥檓 not sure if it鈥檚 possible, but it would be awesome to display good errors when users import something that doesn鈥檛 exist, or confuse named with default imports.

cc @benmosher and @MoOx as maintainers of the corresponding projects

up for grabs! enhancement

All 8 comments

Oh man, that sounds really cool. I'm not sure exactly how that would work... some secret collaboration between the import plugin and eslint-loader to notify that dependencies have been changed?

Would want to avoid re-linting dependents unless there are import errors from one of the handful that does deep parsing, or I can imagine eslint-loader doing a lot of extra work.

I'm very interested in this. Will reflect on it. I'm interested to hear from @MoOx as well, I think we might need to cooperate via some secret internal APIs.

Actually, isn't this a consequence of the way Webpack works? Loaders are only invoked for files that change, right?

Yes, but I think loaders can specify dependencies or something like this. To be honest I鈥檓 not very familiar with what loaders can do, but since webpack is crazy configurable, I would expect that this is possible in some hacky way. Also maybe it could be possible with a custom webpack plugin.

Ah, right... interesting. Yeah, I'm not super-familiar with loaders, either. Good opportunity to get into it 馃槑

@benmosher you do have the ability to access the compiler instance from a loader function (this._compiler). This could allow you to plugin to that compiler.

The Typescript loaders do this to perform type checking and diagnostics when the loaders finish. https://github.com/s-panferov/awesome-typescript-loader/blob/master/src/instance.ts Has a good example of this. @benmosher Hopefully this gives you some good direction.

For postcss-import we got a similar issue. I solved this by providing an option to specify dependencies, see https://github.com/postcss/postcss-import#adddependencyto
I don't have much time now so a PR is welcome for eslint-loader.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dualcnhq picture dualcnhq  路  3Comments

stopachka picture stopachka  路  3Comments

DaveLindberg picture DaveLindberg  路  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments

wereHamster picture wereHamster  路  3Comments