[英]eslint-webpack-plugin not displaying errors or warnings
与 webpack 一起使用时,Eslint 似乎无法正常工作。 我不太确定为什么它没有显示任何内容。 我正在使用未使用的变量对其进行测试。 如果您有任何提示,将不胜感激。 谢谢
webpack 一切正常,只是不掉毛而且很烦人。
webpack 配置:
const path = require('path');
const webpack = require('webpack');
const ESLintPlugin = require('eslint-webpack-plugin');
module.exports = (options) => ({
mode: options.mode,
entry: options.entry,
output: {
path: path.resolve(process.cwd(), 'build'),
filename: '[name].js',
},
stats: {
preset: 'normal',
moduleTrace: true,
errorDetails: true,
},
module: {
rules: [
{
test: /\.(ts|js)x?$/i,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
],
},
},
],
},
{
test: /\.html$/,
exclude: /node_modules/,
use: 'html-loader',
},
{
test: /\.(mp4|webm)$/,
exclude: /node_modules/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
},
},
},
],
},
plugins: options.plugins.concat([
// Always expose NODE_ENV to webpack, in order to use `process.env.NODE_ENV`
// inside your code for any environment checks; Terser will automatically
// drop any unreachable code.
// new ESLintPlugin(options),
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
}),
new ESLintPlugin({ extensions: ['js', 'jsx', 'ts', 'tsx'] }),
]),
devServer: {
historyApiFallback: true,
compress: true,
open: true,
overlay: true,
},
resolve: {
extensions: ['.js', '.jsx', '.react.js'],
},
});
基本的eslint:
.eslintrc
{
"parser": "@babel/eslint-parser",
"extends": [
"airbnb",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
"env": {
"browser": true
},
"rules": {
"react/jsx-filename-extension": [
1,
{
"extensions": [
".js",
".jsx"
]
}
],
"import/no-cycle": "off"
}
}
问题与方括号有关。 我在目录路径中的文件夹周围加上方括号,这似乎导致 eslint 中断。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.