问题描述
问题是,在我开发过程中,每次 ESLint 出现问题时,构建都会中断并且无法编译代码。
我设置了emitWarning:true,但不起作用。 我的 React 项目是用 webpack、neutrino JS、esLint、airbnb 开发的。
运行构建时出现错误
./src/index.jsx 中的错误 模块构建失败(来自 ./node_modules/eslint-loader/dist/cjs.js): 由于 eslint 错误,模块失败。
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,