我正在使用Nodejs,Eslint ^7和Mongoose ^5. 我已經eslint-plugin-security ^1向我的.eslintrc.js添加了推薦規則,如下所示:
parserOptions: {
ecmaVersion: 2021,
},
env: {
commonjs: true,
es6: true,
browser: false,
node: true,
},
plugins: ['security'],
extends: [
'plugin:security/recommended',
],
當我運行 eslint 時,我得到以下 TypeError :
Oops! Something went wrong! :(
ESLint: 7.30.0
TypeError: Cannot read property 'type' of undefined
Occurred while linting /app/api/src/Repository/AppLog.js:38
at MemberExpression (/app/api/node_modules/eslint-plugin-security/rules/detect-child-process.js:34:87)
at /app/api/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/app/api/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/app/api/node_modules/eslint/lib/linter/node-event-generator.js:293:26)
at NodeEventGenerator.applySelectors (/app/api/node_modules/eslint/lib/linter/node-event-generator.js:322:22)
at NodeEventGenerator.enterNode (/app/api/node_modules/eslint/lib/linter/node-event-generator.js:336:14)
at CodePathAnalyzer.enterNode (/app/api/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
at /app/api/node_modules/eslint/lib/linter/linter.js:960:32
at Array.forEach (<anonymous>)
我檢查了錯誤指向的行,但我沒有發現任何問題。
這是我的代碼/app/api/src/Repository/AppLog.js:38:
async list() {
return this.LogModel.find().exec();
}
當我洗掉eslint-plugin-security插件時,一切正常。我猜圖書館本身有問題。
解決這個問題的任何想法?
uj5u.com熱心網友回復:
也是我的問題。我還在其存盤庫中為此創建了一個問題,
當 eslint在與Node.js 方法同名的代碼中遇到任何Query.prototype.exec()時,就會發生錯誤child_process.exec()。
我在這里描述了這個問題的可能解決方案,但它仍然是開放的,我不知道如何以另一種和/或更好的方式解決它。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/348843.html
上一篇:findOne在貓鼬中給我和錯誤
下一篇:MongooseServerSelectionError:connectECONNREFUSED::1:27017不會得到修復
