eslint-webpack-plugin

说明:现在eslint已经弃用了eslint-loader,如果要安装来使用的话,会报错,烦死人

大概的报错信息如下:

ERROR in ./src/index.js

Module build failed (from ./node_modules/eslint-loader/dist/cjs.js):

TypeError: Cannot read property 'getFormatter' of undefined

那么我们现在一般使用eslint提供的eslint-webpack-plugin插件对语法进行校验

安装:

npm i eslint-webpack-plugin -D

使用:

javascript 复制代码
const path = require("path");
const ESLintPlugin = require("eslint-webpack-plugin");
module.exports = {
  entry: "./src/index.js",
  output: {
    filename: "js/bundle.js",
    path: path.resolve(__dirname, "./build"),
  },
  mode: "development",
  devtool: "source-map",
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules$/,
        use: ["babel-loader"],
      },
    ],
  },
  plugins: [new ESLintPlugin()],
};
相关推荐
anyup_前端梦工厂23 分钟前
深入理解 JavaScript 三大作用域:全局作用域、函数作用域、块级作用域
前端·javascript·html
等你许久_孟然1 小时前
【webpack4系列】设计可维护的webpack4.x+vue构建配置(终极篇)
前端·javascript·vue.js
我的运维人生1 小时前
Nginx:高性能Web服务器与反向代理的深度解析
服务器·前端·nginx·运维开发·技术共享
小白小白从不日白1 小时前
react hooks--useMemo
前端·javascript·react.js
资深前端之路1 小时前
react 创建react项目
前端·javascript·react.js
森叶2 小时前
webpack4 target:“electron-renderer“ 打包加速配置
前端·javascript·electron
三生有幸遇见你°2 小时前
双击热备 Electron网页客户端
前端·javascript·electron
前端开发菜鸟的自我修养2 小时前
HTML5 Video标签的属性、方法和事件汇总,以及常用视频插件推荐
前端·javascript·svn·html·音视频·html5·video-codec
孙俊熙2 小时前
React项目实战(React后台管理系统、TypeScript+React18)
前端·react.js·typescript
蓝莓味柯基3 小时前
React——setState 新旧值复用问题
前端·javascript·react.js