Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add --out flag to ng lint #4959

Closed
philipooo opened this issue Feb 23, 2017 · 16 comments
Closed

Feature: Add --out flag to ng lint #4959

philipooo opened this issue Feb 23, 2017 · 16 comments

Comments

@philipooo
Copy link

Use-case

In our CI we use SonarQube and the TypeScript plugin which can parse the tslint output and translate it into issues. To generate the output I want to use ng lint.

Request

Because there is no way to store the output of ng lint --format json into a valid json file it would be useful to add the --out argument and pass it to tslint.

@clydin
Copy link
Member

clydin commented Feb 23, 2017

The next release will allow you to properly redirect the output to a file.
ref: #4917

@filipesilva
Copy link
Contributor

Closing as answered. Thanks to @moritz-h for implementing it!

@philipooo
Copy link
Author

Awesome. Thank you!

@moritz-h
Copy link
Contributor

@filipesilva @clydin @philipooo
Thanks for mentioning my fix. But this was only the easy small part I did. There is a even bigger issue for using ng lint formatted output in CI. See #4849. There I found the error source, but I don't know how it could be fixed. I just have a workaround for pmd format:

ng lint --format pmd > result.xml
tr -d '\n' < result.xml > result-fix.xml # all text in one line for sed
sed -i -e 's/<\/pmd><pmd version="tslint">//g' result-fix.xml # fix xml

@denisharder
Copy link

Hello, which release has the --out option in? I can't seem to find it in the code.
I don't see it within the latest beta tag:
https://github.com/angular/angular-cli/blob/v1.5.0-beta.2/packages/%40angular/cli/commands/lint.ts

@LayZeeDK
Copy link

LayZeeDK commented Nov 6, 2017

Thanks for the workaround, @moritz-h. I had some trouble on Windows but got it working with two commands:

ng lint --format pmd > result.xml
sed -i -r -n -e "/<pmd version=\"tslint\">/,${p}" result.xml

@moritz-h
Copy link
Contributor

moritz-h commented Nov 6, 2017

@LayZeeDK The problem with messed up xml is fixed long time ago. See the issue I referenced above.
The tr and sed workaround is not needed anymore, just do:

ng lint --format pmd > result.xml

@siegenthalerroger
Copy link

This was never actually added from what I can see, please revisit this. It would be a great simplification.

@GregorioPerego
Copy link

It would be really great to have that "--output" option.

Right now the only possibility to store the tslint result in a file is by redirecting standard output stream to a file, but it sometimes includes the ANSI escapes (colors) in the generated file, making the file not well-formatted. Example:
ng lint wp --format checkstyle --force > ../target/tslint-result.xml

Thanks

@westonpace
Copy link

@GregorioPerego It appears redirecting to a file is the intended way to do this. The fix mentioned above by @moritz-h was to enable that. If the format is non-human readable and there are illegal characters in the output then that would be a separate bug on it's own.

@rtaft
Copy link

rtaft commented Nov 20, 2018

ng lint --format json > lint.json
The content of the file is not json as all the other log output is there. --silent hides the json and leaves the debug output.

@westonpace
Copy link

@rtaft I think you are encoutnering #12674

@rtaft
Copy link

rtaft commented Nov 20, 2018

@westonpace yes, that sounds about right, thank you

@leandro-manifesto
Copy link

Hey guys, I think you should reconsider this issue.

Given the default setup creates two projects ("example" and "example-e2e") when we run

ng lint --format junit > lint.xml

the result file ends up containing both xml documents like so

<?xml version="1.0" encoding="utf-8"?><testsuites package="tslint"></testsuites>
<?xml version="1.0" encoding="utf-8"?><testsuites package="tslint"></testsuites>

@clydin
Copy link
Member

clydin commented Jan 4, 2019

@leandro-manifesto that's a separate defect that needs to be fixed.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests