Skip to content

Option to run only on files in module graph #23

Closed

Description

@martinkadlec0
  • 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.

Activity

  1. jsg2021 commented on Oct 12, 2020

    @jsg2021
    Contributor

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

  2. jsg2021 commented on Oct 12, 2020

    @jsg2021
    Contributor

    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.

  3. jsg2021 commented on Oct 12, 2020

    @jsg2021
    Contributor

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

  4. martinkadlec0 commented on Oct 13, 2020

    @martinkadlec0
    Author

    @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:)

  5. ricardogobbosouza commented on Oct 14, 2020

    @ricardogobbosouza
    Contributor

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

  6. alexander-akait commented on Oct 14, 2020

    @alexander-akait
    Member

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

  7. martinkadlec0 commented on Oct 14, 2020

    @martinkadlec0
    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 🤔

  8. jsg2021 commented on Oct 14, 2020

    @jsg2021
    Contributor

    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. 😊

  9. ricardogobbosouza commented on Nov 4, 2020

    @ricardogobbosouza
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions