eslint-plugin-angular icon indicating copy to clipboard operation
eslint-plugin-angular copied to clipboard

Implement arguments check in checkArgumentPositionInFunction()

Open zkwsk opened this issue 6 years ago • 3 comments

I was experiencing the error below when trying to run eslint on my project.

I found that at one point the function checkArgumentPositionInFunction() was being called without any arguments. I don't understand why that would happen in the first place, but I decided that it could not hurt to implement a check and exit the function if no arguments where provided.

Let me know if you want to debug the root cause and need more info.

Error message:

Cannot read property 'params' of undefined
TypeError: Cannot read property 'params' of undefined
    at checkArgumentPositionInFunction (/Users/learningbank/Projects/app/node_modules/eslint-plugin-angular/rules/one-dependency-per-line.js:26:23)
    at /Users/learningbank/Projects/app/node_modules/eslint-plugin-angular/rules/one-dependency-per-line.js:59:21
    at Array.forEach (<anonymous>)
    at checkArgumentPositionArrayExpression (/Users/learningbank/Projects/app/node_modules/eslint-plugin-angular/rules/one-dependency-per-line.js:50:32)
    at CallExpression (/Users/learningbank/Projects/app/node_modules/eslint-plugin-angular/rules/one-dependency-per-line.js:135:28)
    at listeners.(anonymous function).forEach.listener (/Users/learningbank/Projects/app/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/learningbank/Projects/app/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Users/learningbank/Projects/app/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/learningbank/Projects/app/node_modules/eslint/lib/util/node-event-generator.js:280:22)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] eslint: `eslint src/**`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] eslint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/learningbank/.npm/_logs/2019-02-19T15_03_26_043Z-debug.log

zkwsk avatar Feb 19 '19 15:02 zkwsk

@zkwsk Thanks for your contribution. Could you add also a small unit test ?

EmmanuelDemey avatar Feb 21 '19 14:02 EmmanuelDemey

Yes, sure. I'll have a look at it.

I re-read the readme file looking for contribution guidelines and only read the "Need your help" section, but now I notice that there was something more under the "How to create a new rule"-section, including opening your pull request against development rather than master. I suppose I should do that as well, right?

zkwsk avatar Feb 25 '19 16:02 zkwsk

Do not worry. I have just changed the target git branch

EmmanuelDemey avatar Feb 25 '19 17:02 EmmanuelDemey