EmmanuelDemey / EmmanuelDemey/eslint-plugin-angular
di rule crashes on correct file
- Dominant language
- JavaScript
- Stars
- 620
- Forks
- 127
- PR merge metrics
- No merged PRs in 30d
Description
Configuring the di rule to `array` made eslint crash on me. The file is fine (and runs without problems), the error message looks like whatever it assumes to be an injection array is actually `undefined`. Setup:
Versions:
```
"eslint": "^3.19.0",
"eslint-config-angular": "^0.5.0",
"eslint-plugin-angular": "^2.2.1"
```
.eslintrc.json:
```json
{
"extends": "angular",
"settings": {
"angular": 1
},
"rules": {
"angular/log": "warn",
"angular/controller-as-vm": [ "error", "self" ],
"angular/function-type": [ "error", "named" ],
"angular/di": [ "error", "array" ],
"angular/no-service-method": "off"
}
}
```
the angular file:
```javascript
angular.module('myapp')
.provider('loadingInterceptor', [
'$httpProvider',
loadingInterceptorProvider
])
function loadingInterceptorProvider($httpProvider) {
var self = this
$httpProvider.interceptors.push('loadingInterceptor')
self.$get = [
'Loading',
$get
]
function $get(Loading) {
function startLoading(config) {
Loading.startLoading()
return config
}
function stopLoading(response) {
Loading.stopLoading()
return response
}
return {
request: startLoading,
requestError: stopLoading,
response: stopLoading,
responseError: stopLoading
}
}
}
```
error:
```shell
$ ./node_modules/.bin/eslint -c ./.eslintrc.json ./scripts/components/loading/loading.interceptor.js
The rule `angular/service-name` will be split up to different rules in the next version. Please read the docs for more information
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at checkDi (/Users/LionC/Projects/acomodeo/onboarding-webapp/node_modules/eslint-plugin-angular/rules/di.js:63:68)
at Object.angular?provider (/Users/LionC/Projects/acomodeo/onboarding-webapp/node_modules/eslint-plugin-angular/rules/di.js:131:17)
at /Users/LionC/Projects/acomodeo/onboarding-webapp/node_modules/eslint-plugin-angular/rules/utils/angular-rule.js:234:16
at Array.forEach (native)
at callAngularRules (/Users/LionC/Projects/acomodeo/onboarding-webapp/node_modules/eslint-plugin-angular/rules/utils/angular-rule.js:228:27)
at EventEmitter.callBoth (/Users/LionC/Projects/acomodeo/onboarding-webapp/node_modules/eslint-plugin-angular/rules/utils/angular-rule.js:86:13)
at emitOne (events.js:101:20)
at EventEmitter.emit (events.js:188:7)
at NodeEventGenerator.applySelector (/Users/LionC/Projects/acomodeo/onboarding-webapp/node_modules/eslint/lib/util/node-event-generator.js:265:26)
at NodeEventGenerator.applySelectors (/Users/LionC/Projects/acomodeo/onboarding-webapp/node_modules/eslint/lib/util/node-event-generator.js:294:22)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.