codelyzer icon indicating copy to clipboard operation
codelyzer copied to clipboard

TypeError: Cannot read property 'AbstractRule' of undefined

Open loicsalou opened this issue 9 years ago • 12 comments

facing blocking issue when trying to use codelyzer in my projects. Stack is TypeError: Cannot read property 'AbstractRule' of undefined at Object. (C:\tools\Workspaces\Angular2\zas-angular2-starter\node_modules\codelyzer\propertyDecoratorBase.js:34:13) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (C:\tools\Workspaces\Angular2\zas-angular2-starter\node_modules\codelyzer\useInputPropertyDecoratorRule.js:7:31) at Module._compile (module.js:570:32)

I'm using libraries as described in attached package.zip

loicsalou avatar Dec 26 '16 10:12 loicsalou

can't seem to be able to attach zip I'm afraid. So here's my package.json deps part:

"dependencies": { "@angular/common": "~2.4", "@angular/compiler": "~2.4", "@angular/core": "~2.4", "@angular/forms": "~2.4", "@angular/http": "~2.4", "@angular/platform-browser": "~2.4", "@angular/platform-browser-dynamic": "~2.4", "@angular/router": "~3.4", "core-js": "~2.4.1", "lodash": "~4", "ng2-translate": "~5", "oblique-ui": "1.3.0", "rxjs": "~5.0", "ts-helpers": "~1.1", "zas-web-components": "~0", "zone.js": "~0.7" }

Question is "is it a known bug ? maybe tslint / codelyzer don't support angular 2.4 yet ?" Thanks !

loicsalou avatar Dec 26 '16 10:12 loicsalou

It does, you need codelyzer 2.0.0-beta.4.

mgechev avatar Dec 26 '16 11:12 mgechev

that's the one I'm using... Any clue / adivce I can investigate in order to solve this ? Thanks

loicsalou avatar Dec 26 '16 11:12 loicsalou

You need tslint@^4.0.0.

mgechev avatar Dec 26 '16 11:12 mgechev

using 4.2.0. my command-line: "tslint "components/**/*.ts" -o linters/tslint.txt -t verbose"

loicsalou avatar Dec 26 '16 12:12 loicsalou

Use ./node_modules/.bin/tslint "components/**/*.ts" -o linters/tslint.txt -t verbose

or

npm i -g tslint@^4.2.0 and run tslint "components/**/*.ts" -o linters/tslint.txt -t verbose.

Most likely your global tslint is older version.

mgechev avatar Dec 26 '16 13:12 mgechev

exactly the same result (tslint is installed globally and same version locally). As you closed the issue I suppose I have missed something. Still got the issue on 2 projects. Will note here if I can find a solution.

loicsalou avatar Dec 26 '16 14:12 loicsalou

It's a version mismatch between codelyzer and tslint.

You can try the "Custom setup" in another directory and verify if everything works together.

mgechev avatar Dec 26 '16 14:12 mgechev

So this is the end. Thanks for helping you are totally right I had a version mismatch with tslint. I ended specifying tslint+codelyzer in the dev dependencies of my projects in order to make sure each of them is using consistent versions in all linters. my current versions are tslint 4.2.0 and codelyzer-2.0.0-beta.4.

loicsalou avatar Dec 28 '16 09:12 loicsalou

Awesome! I am glad it worked in the end.

mgechev avatar Dec 28 '16 13:12 mgechev

I was seeing this issue with the atom-typescript plugin, every time i typed a key an error message appeared which was more than a little annoying

You solution worked for me, thanks

grahamfowles avatar Mar 07 '17 09:03 grahamfowles

config.zip Facing the same issue with the following configuration in my package.json. Developing angular application with Gulp Build tool and systemjs config.

shortthirdman avatar Jan 17 '18 08:01 shortthirdman