webpack-contrib / eslint-webpack-plugin

A ESLint plugin for webpack
MIT License
257 stars 49 forks source link

Add new option `flatConfigFile` #239

Closed ricardogobbosouza closed 6 months ago

ricardogobbosouza commented 9 months ago

Waiting #238 Simplify the use of flat config

// before
const ESLintPlugin = require('eslint-webpack-plugin');

module.exports = {
  // ...
  plugins: [new ESLintPlugin({
    configType: 'flat',
    eslintPath: 'eslint/use-at-your-own-risk',
    overrideConfigFile: 'flat-config.js',
  })],
  // ...
};
// after
const ESLintPlugin = require('eslint-webpack-plugin');

module.exports = {
  // ...
  plugins: [new ESLintPlugin({
    flatConfigFile: 'flat-config.js',
  })],
  // ...
};
  1. Create a flatConfigFile option that will define:
  1. Automatically define flatConfigFile if there is an eslint.config.js file in the project root
  2. Add a section in the readme about flatConfigFile
onigoetz commented 9 months ago

Hi @ricardogobbosouza

I have the impression that the addition of this option will become a problem once ESLint 9 is released

My current understanding, as per these blog posts:

The ESLint class will now be equivalent to the FlatESLint class in v8.x. With the exception of a few options, this should mostly be a transparent change.

So that means that the import that's done right now will suddenly handle flatConfig instead of eslintrc-style config

So maybe there is something to do with imports to auto-detect ESLint's version or imports to differentiate which one we have loaded? I expect this part of the logic to become more complicated once ESLint 9 is released

alexander-akait commented 6 months ago

Fixed https://github.com/webpack-contrib/eslint-webpack-plugin/releases/tag/v4.1.0