Pass --project and --type-check parameters to tslint #75
Comments
Can't just now - I can probably add a configuration parameter to allow extra arguments to be sent. Or specifically add configuration options for those two params... I should have a little time over Christmas while hiding from the in-laws to have a look. |
So this is an interesting one - there's an outstanding defect on tslint that essentially means that if you supply both the --project parameter and a list of files, the list of files is ignored and tslint only pays attention to the files listed in the project json file. This is tricky for us for two reasons:
Any feeling on what a sensible approach would be? Best thinking I have so far is, if you've specified a path to tsconfig.json:
|
Also - what would you want to achieve by passing --type-check to tslint that your existing CI build isn't capturing? There's no output from tslint that I can supply to SonarQube if a type-check fails, so far as I know, so it'll just abort the SQ analysis entirely if there are any typing errors. Might be fine, just wondering what the use-case is? |
Hi there, thank you for your work @Pablissimo. "--type-check" with "--project" is required for alot of rules that exists in tslint now. As I know tslint supports glob pattern for files from cli (e.g tslint './**/*.ts') as mentioned there palantir/tslint#827, so it is not required to specify files directly. |
Got it. Have started along the lines of my original proposal since it seems to fit well enough - travelling the next week but should have time in airports and the like to bash through I reckon. |
Give this a bash - will become v0.99 (or v1.0 /o) and get merged to trunk if it works well enough for you - seems to for my local test projects. sonar-typescript-plugin-0.99-SNAPSHOT.zip New parameters are required:
A note on its behaviour at the minute - if the project fails to type-check you'll not get any issues reported just now, because tslint just fails hard. I need to tidy up that handling before things go live for real, I think. |
do you set a default value for this parameter? |
And what about to use camelCase for parameters' names? :) |
Didn't set a default for it, because I can't then tell whether or not to use it if it happens to exist on disk (for example, I've got projects with a tsconfig.json that I'd sooner not use for linting at the mo). Essentially it prevents changing the plugin's behaviour without the user intervening if they upgrade. Holding off on re-casing the names because I think I'm going to restructure them - they follow the JavaScript plugin naming by and large, which I never really liked. When I do that, I'll probably revisit the above. |
(The above changes would be probably what tip us into v1.0 territory really - tidy up, obvious version bump to indicate the changed behaviour, refresh all the docs and put some better examples of usage in) |
Fix issue #75: adds support for two new options: - ```sonar.ts.tslintprojectpath``` - set to 'tsconfig.json' or similar, the path to your TypeScript configuration file describing what files to compile and lint - ```sonar.ts.tslinttypecheck``` - true/false, defaults to false - if true, requests ```tslint``` perform a type-check too, which allows certain rules requiring type information to work
Released as v0.99 |
@Pablissimo
|
Noticed that last night, looks like a local merge gone wrong. Work without it, but you can't set the values in the SonarQube admin panel. Will raise an issue to fix.
…-------- Original message --------
From: Nikita <notifications@github.com>
Date: 19/01/2017 08:46 (GMT+00:00)
To: Pablissimo/SonarTsPlugin <SonarTsPlugin@noreply.github.com>
Cc: Pablissimo <turnacre@hotmail.com>, Mention <mention@noreply.github.com>
Subject: Re: [Pablissimo/SonarTsPlugin] Pass --project and --type-check parameters to tslint (#75)
@Pablissimo<https://github.com/Pablissimo>
Why did you commented this part of code?
/*,
@Property(
key = TypeScriptPlugin.SETTING_TS_LINT_TYPECHECK,
defaultValue = "false",
type = PropertyType.BOOLEAN,
name = "Forces tslint to run a type-check",
description = "Equivalent to --type-check tslint argument - requires tslintconfigpath also set",
project = true,
global = false
),
@Property(
key = TypeScriptPlugin.SETTING_TS_LINT_TSCONFIG_PATH,
defaultValue = "",
type = PropertyType.STRING,
name = "Path to tsconfig.json file, if required",
description = "Required if tslinttypecheck parameter specified, the path to the tsconfig.json file that describes the files to lint and build",
project = true,
global = false
)*/
-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#75 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABZvgFUKQWDErDhTdzZSNrYmgotCgbVpks5rTyLGgaJpZM4LLw6B>.
|
@Pablissimo
I've got it
|
When you pass a project file to tslint it ignores any specific file paths you send it on the command line, so the plug in no longer bothers in that case.
Trick though is that the set of .ts files to be linted as configured by tsconfig.json may not be the same as those under analysis as defined by sonar-project.properties. That warning is just a signal that tslint has reported a lint error against a file that wasn't captured by the sonar runner as part of the analysis set.
That make any sense?
…-------- Original message --------
From: Nikita <notifications@github.com>
Date: 19/01/2017 09:12 (GMT+00:00)
To: Pablissimo/SonarTsPlugin <SonarTsPlugin@noreply.github.com>
Cc: Pablissimo <turnacre@hotmail.com>, Mention <mention@noreply.github.com>
Subject: Re: [Pablissimo/SonarTsPlugin] Pass --project and --type-check parameters to tslint (#75)
2017-01-19T09:07:06.9993123Z ##[error]09:07:06.887 WARN: TsLint reported issues against a file that wasn't sent to it - will be ignored: ****.ts 2017-01-19T09:07:07.0002889Z ##[error]09:07:06.887 WARN: TsLint reported issues against a file that wasn't
sent to it - will be ignored: ****.ts 2017-01-19T09:07:07.0002889Z ##[error]09:07:06.887 WARN: TsLint reported issues against a file that wasn't sent to it - will be ignored: ****.ts
-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#75 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABZvgNRsr-EKAyeV3OaRxAU4ZAPj-ombks5rTyj6gaJpZM4LLw6B>.
|
@Pablissimo
Because
|
Yeah that ain't gonna fly! Shall amend, there was some thinking to it but need to see all of it to remember!
…-------- Original message --------
From: Nikita <notifications@github.com>
Date: 19/01/2017 10:56 (GMT+00:00)
To: Pablissimo/SonarTsPlugin <SonarTsPlugin@noreply.github.com>
Cc: Pablissimo <turnacre@hotmail.com>, Mention <mention@noreply.github.com>
Subject: Re: [Pablissimo/SonarTsPlugin] Pass --project and --type-check parameters to tslint (#75)
@Pablissimo<https://github.com/Pablissimo>
Now I change TsLintSensor.execute
String pathAdjusted = file.absolutePath().replace('\\', '/').toLowerCase(); //!!!!
paths.add(pathAdjusted);
...
for (String filePath : issues.keySet()) {
List<TsLintIssue> batchIssues = issues.get(filePath);
if (batchIssues == null || batchIssues.size() == 0) {
continue;
}
String lowerFilePath = filePath.toLowerCase(); //!!!!
if (!fileMap.containsKey(lowerFilePath)) { //!!!!
LOG.warn("TsLint reported issues against a file that wasn't sent to it - will be ignored: " + lowerFilePath);
continue;
}
InputFile file = fileMap.get(lowerFilePath); //!!!!
Because
if (!fileMap.containsKey(lowerFilePath)) { //!!!!
LOG.warn("TsLint reported issues against a file that wasn't sent to it - will be ignored: " + lowerFilePath);
continue; //!!!!!!!!!!!!!!!!!!
}
-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#75 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABZvgPiOmlATk5AHDaQ_CnwjljiQBGdYks5rT0FVgaJpZM4LLw6B>.
|
How can i pass --project and --type-check to tslint?
The text was updated successfully, but these errors were encountered: