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

Option to run only on files in module graph #23

Closed
martinkadlec0 opened this issue Oct 12, 2020 · 9 comments
Closed

Option to run only on files in module graph #23

martinkadlec0 opened this issue Oct 12, 2020 · 9 comments

Comments

@martinkadlec0
Copy link

  • Operating System: Windows 10
  • Node Version: 12.19.0
  • NPM Version: 6.14.8
  • webpack Version: 5.0.0
  • eslint-webpack-plugin Version: 2.1.0

Feature Proposal

One thing I liked about eslint-loader is that it was run only on files in the graph module of the build. That is, if a file wasn't imported anywhere it was ignored.

With eslint-webpack-plugin I need to set up separate files/extensions configuration instead of simply relying on webpack to provide the files.

Feature Use Case

This is very useful whenever you don't have time to deal with files that are currently not part of the build.

@jsg2021
Copy link
Contributor

jsg2021 commented Oct 12, 2020

I second this. I'm struggling to configure this plugin to match the efficacy of the loader.

@jsg2021
Copy link
Contributor

jsg2021 commented Oct 12, 2020

My original assumption about this plugin was that it would lint files matched by 'files'/'context' when referenced by webpack... It is counter-intuitive to me that it would just run eslint on the context blindly... I get that's what the command line does, but the webpack build environment is more complex than that.

@jsg2021
Copy link
Contributor

jsg2021 commented Oct 12, 2020

I'm researching how to do this. I'll open a PR if I find a way.

@martinkadlec0
Copy link
Author

martinkadlec0 commented Oct 13, 2020

@jsg2021 My understanding of webpack internals is only very basic, but here are me thoughts. You need the plugin to get access to the full webpack api (and the advantages this plugin has over the loader), but you also need a mechanism to gather the relevant files, which happens to be pretty much what loaders do.

So perhaps the solution is to do something similar to what https://webpack.js.org/plugins/mini-css-extract-plugin/ does? That is having something like ESLintPlugin.loader that you could put to rules to gather the files.

Then you could establish reference access through NormalModule.getCompilationHooks(compilation).loader to pass the list of files to the plugin.

I hope I am not pointing you to completely wrong direction though O:)

@ricardogobbosouza
Copy link
Collaborator

@evilebottnawi
What is your opinion of having a loader inside this plugin? As @martinkadlec0 said
Ex: ESLintPlugin.loader

@alexander-akait
Copy link
Member

We don't need loader, because we can do same logic inside plugin without a loader 😄

@martinkadlec0
Copy link
Author

I mean, loaders are handled just by another plugin, so it makes sense you can do without it, but the reason I suggested using a loader is that it has already familiar established interface. It would also allow you to put the loader in between other loaders for some rarer use cases 🤔

@jsg2021
Copy link
Contributor

jsg2021 commented Oct 14, 2020

Yeah, we can get the file names from events in just the Plug-in. We won't lint transformed code, so we don't need to use a loader. 😊

@ricardogobbosouza
Copy link
Collaborator

Resolve on v2.2.0
Thanks @jsg2021

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

No branches or pull requests

4 participants