微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

忽略或防止 ESLint 错误破坏 React webpack 项目中的构建

如何解决忽略或防止 ESLint 错误破坏 React webpack 项目中的构建

问题是,在我开发过程中,每次 ESLint 出现问题时,构建都会中断并且无法编译代码

我设置了emitWarning:true,但不起作用。 我的 React 项目是用 webpack、neutrino JS、esLint、airbnb 开发的。

运行构建时出现错误

./src/index.jsx 中的错误 模块构建失败(来自 ./node_modules/eslint-loader/dist/cjs.js): 由于 eslint 错误,模块失败。

.neutrinorc.js 文件中的代码结构

const path = require("path");
const airbnb = require("@neutrinojs/airbnb");
const react = require("@neutrinojs/react");

module.exports = {
  options: {
    root: __dirname,},use: [
    (neutrino) => {
      neutrino.config.resolve.modules
        .add("node_modules")
        .add(path.resolve(__dirname,"src"));

      neutrino.config.resolve.extensions.add(".jsx");

      neutrino.config.resolve.alias.set("react-dom","@hot-loader/react-dom");
    },airbnb({
      eslint: {
        emitWarning: true,baseConfig: {
          settings: {
            "import/resolver": "webpack",rules: {
            radix: "off","comma-dangle": "off","react/no-danger": "off","react/button-has-type": "off","react/no-find-dom-node": "off","react/jsx-filename-extension": "off","no-console": [
              "error",{
                allow: ["warn","error"],],"no-alert": "off","no-plusplus": "off","no-else-return": "off","no-nested-ternary": "off","no-underscore-dangle": "off","no-restricted-Syntax": "off","max-len": 0,"quote-props": "off","default-case": "off","class-methods-use-this": "off","import/prefer-default-export": "off","react/no-array-index-key": "off","jsx-a11y/click-events-have-key-events": "off","jsx-a11y/label-has-for": [
              "error",{
                required: {
                  some: ["nesting","id"],}),

解决方法

您需要将 failOnWarning 添加为 false

emitWarning: true,failOnWarning: false,

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。