在将 Babel
从 6
升级到 7
后,我的 eslint
开始在 node_modules
中发出警告:
因此,据我理解,node_modules
文件夹未被忽略,这就是问题出现的原因。因此,通过阅读 eslint
文档:
https://eslint.org/docs/user-guide/configuring
我尝试将 "ignorePatterns": ["node_modules/"],
添加到 .eslintrc
文件中,但收到以下错误信息:
Module build failed: Error: ESLint configuration in /Users/vlasenkona/Desktop/gris-seqr2/ui/.eslintrc is invalid: - Unexpected top-level property "ignorePatterns".
因此,我尝试创建 .eslintignore
文件,并仅添加了 node_modules/
,但警告仍然存在。如何忽略 node_modules
文件夹?我使用的软件包版本如下:
"eslint": "^5.16.0",
"babel-eslint": "^9.0.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-import-resolver-babel-module": "^5.1.2",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.1.0",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react-perf": "^2.0.8",
.eslintrc
看起来像这样:
{
"extends": [
"airbnb",
"plugin:react-perf/recommended"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"env": {
"mocha": true,
"es6": true,
"browser": true,
"node": true,
"jest": true
},
"settings": {
"import/resolver": {
"babel-module": {}
}
},
"rules": {
"semi": [2, "never"],
"no-shadow": ["error", { "allow": ["error"] }],
"arrow-body-style": 0,
"func-names": 0,
"function-paren-newline": 0,
"max-len": 0, //["warn", 80, 2],
"no-console": 0,
"no-multi-str": 0,
"no-param-reassign": 0,
"no-plusplus": 0,
"brace-style": 0,
"object-curly-newline": 0,
"padded-blocks": 0,
"react/jsx-first-prop-new-line": 0,
"react/jsx-wrap-multilines": 0,
"react/prefer-stateless-function": 0,
"react/sort-comp": 0, // more freedom in arranging class functions
"import/prefer-default-export": 0,
"react/forbid-prop-types": 0,
"no-class-assign": 0,
"react/jsx-filename-extension": [ 1, { "extensions": [".js", ".jsx"]} ],
"react/require-default-props": 0,
"react/require-optimization": 2,
"react/jsx-max-props-per-line": 0,
"react/jsx-no-target-blank": 0,
"spaced-comment": 0,
"jsx-a11y/iframe-has-title": 0,
"jsx-a11y/tabindex-no-positive": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/anchor-is-valid": 0
}
}
更新
我尝试将以下内容添加到新创建的.eslintignore
文件中:
node_modules/*
./node_modules/**
**/node_modules/**
但是两者都不起作用。有趣的是,如果我打开 ./node_modules/draftjs-md-converter/dist/index.js
并在文件的开头和结尾加上 /*eslint-disable */
,警告仍然存在,所以也许这不是一个 eslint
的问题:只是完全误导性的警告?..
.eslintignore
文件中添加node_modules/*
来忽略所有的node_modules
文件夹。 - Tomas Vancoillieeslint
降级到版本4.19.1
,但没有成功。 - Nikita Vlasenko> log.txt
命令运行eslint,然后检查日志文件,我知道了这个文件夹。在我移除它或修复了 .eslintignore 文件之后,问题得到了解决! - phuwin