I'm using Nodejs
, Eslint ^7
and Mongoose ^5
. I have added eslint-plugin-security ^1
recommended rules to my .eslintrc.js as below :
parserOptions: {
ecmaVersion: 2021,
},
env: {
commonjs: true,
es6: true,
browser: false,
node: true,
},
plugins: ['security'],
extends: [
'plugin:security/recommended',
],
When I run eslint, I get the below 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>)
I checked the line that the error points to, But I didn't find any problem with that.
Here is my code on /app/api/src/Repository/AppLog.js:38
:
async list() {
return this.LogModel.find().exec();
}
everything works fine when I remove the eslint-plugin-security plugin. I guess there is a problem with the library itself.
Any idea for solve this problem ?
CodePudding user response:
It is my problem too. I have also created an issue for that on its repository,
The error occurs when eslint faces any Query.prototype.exec() in the code that is namesake with child_process.exec()
method of Node.js.
There is a possible solution to this problem which I have described here, But it's still open and I have no other idea how to fix it another and/or better way.