tkqubo / codeclimate-tslint

Code Climate TSLint-Engine
40 stars 20 forks source link

Engine encountered error #19

Closed marcojahn closed 7 years ago

marcojahn commented 7 years ago

Hi there,

using your engine encounters an error on code climate.

My codeclimate.yml file https://github.com/MehlboxKonsole/mk2-ng-app/blob/master/.codeclimate.yml

The codeclimate build https://codeclimate.com/github/MehlboxKonsole/mk2-ng-app/builds/25 Error message

/usr/src/app/node_modules/rx/dist/rx.js:77
    throw e;
    ^

Error
    at new FatalError (/usr/src/app/node_modules/tslint/lib/error.js:40:23)
    at Object.findConfiguration (/usr/src/app/node_modules/tslint/lib/configuration.js:56:15)
    at TsLinter.doLint (/usr/src/app/dist/tsLinter.js:64:51)
    at listFiles.flatMap (/usr/src/app/dist/tsLinter.js:20:37)
    at tryCatcher (/usr/src/app/node_modules/rx/dist/rx.js:63:31)
    at InnerObserver.Rx.FlatMapObservable.InnerObserver.next     (/usr/src/app/node_modules/rx/dist/rx.js:2140:43)
    at InnerObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext     (/usr/src/app/node_modules/rx/dist/rx.js:1762:31)
    at InnerObserver.tryCatcher (/usr/src/app/node_modules/rx/dist/rx.js:63:31)
    at AutoDetachObserverPrototype.next (/usr/src/app/node_modules/rx/dist/rx.js:5883:51)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext     (/usr/src/app/node_modules/rx/dist/rx.js:1762:31)
tkqubo commented 7 years ago

Sorry for inconvenience. But thanks for reporting, I will investigate on this 👀

tkqubo commented 7 years ago

Did you try tslint src/*? It also fails with error, emitting the same error message above.

And after removing directive-selector and component-selector rule, it worked. And codeclimate analyze the same.

https://asciinema.org/a/44rxcf0n3w4g81x4p22m0s8pd

I haven't checked inside those rules, but is it possible that wrong arguments are passed to them?

marcojahn commented 7 years ago

Did as you mentioned but nothing changes. Please find both lint actions below (ng lint && tslint)

A PR with removing these two lines will break too:

Using yarn or plain NPM results in the same behaviour (working on my machine...)

I was wondering why a tslint src/* is working because it shoul not ?!

$ ./node_modules/.bin/tslint src/*
/Users/mjahn/Projects/mk2/mk2-ng-app/node_modules/tslint/lib/runner.js:118
            throw error;
            ^

Error: 
Invalid source file: src/favicon.ico. Ensure that the files supplied to lint have a .ts, .tsx, .js or .jsx extension.

    at Linter.getSourceFile (/Users/mjahn/Projects/mk2/mk2-ng-app/node_modules/tslint/lib/linter.js:186:19)
    at Linter.lint (/Users/mjahn/Projects/mk2/mk2-ng-app/node_modules/tslint/lib/linter.js:79:31)
    at Runner.processFiles (/Users/mjahn/Projects/mk2/mk2-ng-app/node_modules/tslint/lib/runner.js:161:20)
    at Runner.run (/Users/mjahn/Projects/mk2/mk2-ng-app/node_modules/tslint/lib/runner.js:110:18)
    at Object.<anonymous> (/Users/mjahn/Projects/mk2/mk2-ng-app/node_modules/tslint/lib/tslint-cli.js:139:6)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

Please be aware that additional ng lint finding is because ng lint does check e2e/*/.ts too.

$ ./node_modules/.bin/tslint src/**/*.ts
src/app/auth-guard.service.ts[19, 9]: Identifier 'url' is never reassigned; use 'const' instead of 'let'.
src/app/auth.service.ts[10, 12]: Type boolean trivially inferred from a boolean literal, remove type annotation
src/app/auth.service.ts[11, 15]: Type boolean trivially inferred from a boolean literal, remove type annotation
src/app/home/home-routing.module.ts[1, 20]: Too many spaces before 'from'
src/app/konsole/konsole.component.ts[4, 5]: comment must start with a space
src/app/login/login.component.ts[37, 11]: comment must start with a space
src/app/login/login.component.ts[12, 12]: Type string trivially inferred from a string literal, remove type annotation

$ ng lint
/Users/mjahn/Projects/mk2/mk2-ng-app/src/app/auth.service.ts[10, 12]: Type boolean trivially inferred from a boolean literal, remove type annotation
/Users/mjahn/Projects/mk2/mk2-ng-app/src/app/auth.service.ts[11, 15]: Type boolean trivially inferred from a boolean literal, remove type annotation
/Users/mjahn/Projects/mk2/mk2-ng-app/src/app/auth-guard.service.ts[19, 9]: Identifier 'url' is never reassigned; use 'const' instead of 'let'.
/Users/mjahn/Projects/mk2/mk2-ng-app/src/app/login/login.component.ts[37, 11]: comment must start with a space
/Users/mjahn/Projects/mk2/mk2-ng-app/src/app/login/login.component.ts[12, 12]: Type string trivially inferred from a string literal, remove type annotation
src/app/home/home-routing.module.ts[1, 20]: Too many spaces before 'from'
/Users/mjahn/Projects/mk2/mk2-ng-app/src/app/konsole/konsole.component.ts[4, 5]: comment must start with a space
e2e/app.e2e-spec.ts[12, 7]: comment must start with a space
tkqubo commented 7 years ago

I am using tslint 5.0.0. This works but 4.5.1 doesn't.

https://asciinema.org/a/ecjtrxybvbbiev2c468omezg8

marcojahn commented 7 years ago

4.5.1 is working on my machine and travis-ci... any chances to see what is happening on code climate ?

 ./node_modules/.bin/tslint --version && ./node_modules/.bin/tslint src/**/*.ts
4.5.1

src/app/auth-guard.service.ts[19, 9]: Identifier 'url' is never reassigned; use 'const' instead of 'let'.
src/app/auth.service.ts[10, 12]: Type boolean trivially inferred from a boolean literal, remove type annotation
src/app/auth.service.ts[11, 15]: Type boolean trivially inferred from a boolean literal, remove type annotation
src/app/home/home-routing.module.ts[1, 20]: Too many spaces before 'from'
src/app/konsole/konsole.component.ts[4, 5]: comment must start with a space
src/app/login/login.component.ts[37, 11]: comment must start with a space
src/app/login/login.component.ts[12, 12]: Type string trivially inferred from a string literal, remove type annotation
marcojahn commented 7 years ago

ok, just removed nearly anything from tslint.json file and the processing now works... :(

https://codeclimate.com/github/MehlboxKonsole/mk2-ng-app/builds/33

tslint https://github.com/MehlboxKonsole/mk2-ng-app/pull/9/commits/70d89aa6bf97c9627801a262b329056a47e37ca5

Will add rules one by one again to see what exactly is breaking the codeclimate process...

Will head back when I was successfull...

Kind regards for the help so far.

marcojahn commented 7 years ago

Ok, seems I got it...

Using a "plugin" like codealyzer seems to break the process. Any ideas on how I can use additional tslint plugins ?

Removing these things will make the process run as expected...

{
  "rulesDirectory": [
    "node_modules/codelyzer"
  ],
  "rules": {

    "directive-selector": [true, "attribute", "mk2", "camelCase"],
    "component-selector": [true, "element", "mk2", "kebab-case"],
    "use-input-property-decorator": true,
    "use-output-property-decorator": true,
    "use-host-property-decorator": true,
    "no-input-rename": true,
    "no-output-rename": true,
    "use-life-cycle-interface": true,
    "use-pipe-transform-interface": true,
    "component-class-suffix": true,
    "directive-class-suffix": true,
    "no-access-missing-member": true,
    "templates-use-public": true,
    "invoke-injectable": true
  }
}
tkqubo commented 7 years ago

And how about adding node_modules in exclude_paths? You don't need lint against modules outside your project.

engines:
  tslint:
    enabled: true
    channel: beta
  csslint:
    enabled: true
  #duplication:
  #  enabled: true
  #  config:
  #    languages:
  #    - javascript
ratings:
  paths:
  - src/**
  - e2e/**
  #- "**.rb"
  #- "**.go"
exclude_paths:
  - node_modules/
#- spec/**/*
#- "**/vendor/**/*"
tkqubo commented 7 years ago

Anyway at least in my environment, codeclimate analyze worked after doing them:

marcojahn commented 7 years ago

Hi,

at first I shoud clarify that I am only talking about the codeclimate cloud service, not the local tool chain.

Adding node_modules would not change anything (in the codeclimate cloud). What is unhandled by codeclimate is the tslint dependency to the tslint plugin "codelyzer". https://github.com/mgechev/codelyzer

This module is not in the tslint standard and is the cause why codeclimate (the cloud service) fails.

Here is a discussion on eslint causing the exact error 2 years ago where codeclimate was not able to use engine plugins (https://github.com/codeclimate/codeclimate-eslint/issues/10)

I'm not sure atm who is the correct responsible for that problem as codeclimate handed me over to you regarding tslint problems and stated that you will contact them if necessary. And I think in this case you will not be able to solve that cause without them.

marcojahn commented 7 years ago

Ok,

thought about it...

Codelyzer is currently not supporting tslint 5. The upcoming 3.0.0 branch will add support for tslint 5.

Would it be possible to have codelyzer added to your project like you did with tslint-config-standard ?

Then it would be possible for Angular 2(/4) projects to use the plugin with codeclimate as well.

Kind regards.

tkqubo commented 7 years ago

Sure, if it helps you and other Angular developers, I'll be glad to do that.

marcojahn commented 7 years ago

Thank you. I will have a look at the required dependencies and will create a new feature request or pull request once available and working.

tkqubo commented 7 years ago

👍