SonarTsPlugin icon indicating copy to clipboard operation
SonarTsPlugin copied to clipboard

Required to point to the tslint-cli.js file when running on windows

Open ghost opened this issue 8 years ago • 6 comments

In order to get tslint working I have had to set the path directly to the javascript file for the CLI

It looks like it maybe should call tslint as an executable on windows using the .cmd wrapper instead of prefixing it with node.

Updating the config to this resolved the issue for me

sonar.ts.tslint.path=node_modules\tslint\lib\tslint-cli.js

Otherwise just fails silently, it looks like it is sucessful, but no issues are imported

Running SonarQube Version 6.5 (build 27846) and v1.1.0 of the SonarTsPlugin

ghost avatar Aug 10 '17 13:08 ghost

I had the same issue. I tried to run lint with the produced command (-X switch). TSLint complained about a missing file or directory:

      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open '<project-path>\target\sonar\.sonartmp\8843665497511539779.tmp'
    at Error (native)

I run it again and changed the --out parameter to something like <project-path>\target\sonar\tslint-result.json that was working. It seems that the .sonartmp directory needs to be created before tslint is started.

mkdir target\sonar\.sonartmp

node D:\<...>\node_modules\tslint\bin\tslint --format json --out D:\<...>\target\sonar\.sonartmp\8843665497511539779.tmp --config D:\<...>\tslint.json 

It is working also with the solution described by @kingsleymasters .

habbo656 avatar Aug 23 '17 06:08 habbo656

So @habbo656 I think your issue is different, in that it looks like maybe the user account running the scanner doesn't have permissions to create folders and write to the filesystem? I've seen similar on TFS installs before - the plugin relies on the scanner having created the temporary folder for it and that it can write to it so I'd check permissioning first.

@kingsleymasters I'm not sure why you're seeing that unless there's been a change to how tslint's getting installed with newer versions. Failing silently is rubbish, sorry about that - what version of tslint do you have in use? And what version of Node?

Pablissimo avatar Aug 23 '17 06:08 Pablissimo

I forgot to mention that I'm using maven-sonar-plugin. I don't think that this are permission issues.

habbo656 avatar Aug 23 '17 06:08 habbo656

Does everything up to the .sonartmp path component exist on disk?

Pablissimo avatar Aug 23 '17 07:08 Pablissimo

Yes, I run mvn clean sonar:sonar it created /target/sonar/ directories.

habbo656 avatar Aug 23 '17 08:08 habbo656

@Pablissimo

I have a reproduction for you I am using node 6.10.2 and tslint 5.5.0. I've taken these command lines from the sonarqube logs.

Succeeds

node C:\Users\[REMOVED]\AppData\Roaming\npm\node_modules\tslint\lib\tslint-cli.js --format json --out D:\TeamCity\buildAgent\work\1f282a2c9f5495cf\.scannerwork\.sonartmp\2766165142984384394.tmp --config D:\TeamCity\buildAgent\work\1f282a2c9f5495cf\[REMOVED]\app\tslint.json D:/TeamCity/buildAgent/work/1f282a2c9f5495cf/REMOVED]/app/src/client/app/app.module.ts

Fails

node C:\Users\[REMOVED]\AppData\Roaming\npm\tslint --format json --out D:\TeamCity\buildAgent\work\1f282a2c9f5495cf\.scannerwork\.sonartmp\2766165142984384394.tmp --config D:\TeamCity\buildAgent\work\1f282a2c9f5495cf\[REMOVED]\app\tslint.json D:/TeamCity/buildAgent/work/1f282a2c9f5495cf/REMOVED]/app/src/client/app/app.module.ts

I think it fails as its trying to call tslint using node, but on windows tslint is a batch file, workaround works perfectly so maybe just needs documenting...

ghost avatar Aug 23 '17 13:08 ghost