簡體   English   中英

eslint-webpack-plugin 不顯示錯誤或警告

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM