preface
Eslint is an essential part of building a mature project template using WebPack. Eslint can be used in one of two ways:
- Don’t combine
webpack
To use, only the corresponding configurationnpm scripts
In this way, errors cannot be found in time during the project development. In the final submission, format verification and modification may resultreworkOf course, noeslint
Error prompt, can be developed quickly, thinking is not easy to be interrupted by the format problem; - In combination with
webpack
The simple configuration is as follows:module.exports = { // ... module: { rules: [{test: /.js$/, exclude: /node_modules/, loader: 'eslint-loader'.options: { // eslint options (if necessary)}},],},// ... }; Copy the code
Is eslint-Loader deprecated?
When I opened it skillfullyeslint-loader
I knew something was wrong when I saw a big red sign as I was filing.Indeed,eslint-loader
About to be scrapped.
Eslint-webpack-plugin yes, I’m that guy
However, with my English, I used eslint-webpack-plugin and found that the number of downloads of eslint-webpack-plugin was already high.
So many people already know, alas, that I go?? .
What is the eslint-webpack-plugin?
Look at the documentation.
Before:
module.exports = {
// ...
module: {
rules: [{test: /.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'.options: {
// eslint options (if necessary)}},],},// ...
};
Copy the code
After:
const ESLintPlugin = require('eslint-webpack-plugin');
module.exports = {
// ...
plugins: [new ESLintPlugin(options)],
// ...
};
Copy the code
Options for the eslint-webpack-plugin are basically the same as those for the eslint-Loader, including that we often use eslint-Loader friendly to display error formatter, Eslint – friendly – the formatter, etc.
Welcome to discuss
Why should the eslint-webpack-plugin be deprecated? Doesn’t the way to use loader smell good? Why change to using plugins? Welcome to the discussion.
Reference documentation
- www.npmjs.com/package/esl…
- www.npmjs.com/package/esl…
- www.npmjs.com/package/esl…