Skip to content

Commit 9e01d43

Browse files
committed
Replace deprecated eslint-loader by eslint-webpack-plugin
1 parent d5c0fe2 commit 9e01d43

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

packages/react-scripts/config/webpack.config.js

+14-23
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
2727
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
2828
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
2929
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
30+
const ESLintPlugin = require('eslint-webpack-plugin');
3031
const paths = require('./paths');
3132
const modules = require('./modules');
3233
const getClientEnvironment = require('./env');
@@ -351,29 +352,6 @@ module.exports = function (webpackEnv) {
351352
rules: [
352353
// Disable require.ensure as it's not a standard language feature.
353354
{ parser: { requireEnsure: false } },
354-
355-
// First, run the linter.
356-
// It's important to do this before Babel processes the JS.
357-
{
358-
test: /\.(js|mjs|jsx|ts|tsx)$/,
359-
enforce: 'pre',
360-
use: [
361-
{
362-
options: {
363-
cache: true,
364-
cwd: paths.appPath,
365-
formatter: require.resolve('react-dev-utils/eslintFormatter'),
366-
eslintPath: require.resolve('eslint'),
367-
resolvePluginsRelativeTo: __dirname,
368-
baseConfig: {
369-
extends: [require.resolve('eslint-config-react-app/base')],
370-
},
371-
},
372-
loader: require.resolve('eslint-loader'),
373-
},
374-
],
375-
include: paths.appSrc,
376-
},
377355
{
378356
// "oneOf" will traverse all following loaders until one will
379357
// match the requirements. When no loader matches it will fall
@@ -742,6 +720,19 @@ module.exports = function (webpackEnv) {
742720
// The formatter is invoked directly in WebpackDevServerUtils during development
743721
formatter: isEnvProduction ? typescriptFormatter : undefined,
744722
}),
723+
new ESLintPlugin({
724+
// Plugin options
725+
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
726+
formatter: require.resolve('react-dev-utils/eslintFormatter'),
727+
eslintPath: require.resolve('eslint'),
728+
context: paths.appSrc,
729+
// ESLint class options
730+
cwd: paths.appPath,
731+
resolvePluginsRelativeTo: __dirname,
732+
baseConfig: {
733+
extends: [require.resolve('eslint-config-react-app/base')],
734+
},
735+
}),
745736
].filter(Boolean),
746737
// Some libraries import Node modules but don't use them in the browser.
747738
// Tell webpack to provide empty mocks for them so importing them works.

packages/react-scripts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
"dotenv-expand": "5.1.0",
4747
"eslint": "^7.9.0",
4848
"eslint-config-react-app": "^5.2.1",
49-
"eslint-loader": "^4.0.2",
5049
"eslint-plugin-flowtype": "^5.2.0",
5150
"eslint-plugin-import": "^2.22.0",
5251
"eslint-plugin-jest": "^24.0.1",
5352
"eslint-plugin-jsx-a11y": "^6.3.1",
5453
"eslint-plugin-react": "^7.20.6",
5554
"eslint-plugin-react-hooks": "^4.1.2",
55+
"eslint-webpack-plugin": "^2.1.0",
5656
"file-loader": "6.1.0",
5757
"fs-extra": "^9.0.0",
5858
"html-webpack-plugin": "4.4.1",

0 commit comments

Comments
 (0)