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

The "--format" flag of the "ng lint"-command produces invalid output. #12674

Closed
Nols1000 opened this issue Oct 21, 2018 · 7 comments · Fixed by #12936
Closed

The "--format" flag of the "ng lint"-command produces invalid output. #12674

Nols1000 opened this issue Oct 21, 2018 · 7 comments · Fixed by #12936
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@Nols1000
Copy link

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [X] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 7.0.2
Node: 8.11.1
OS: linux x64 (Debian 9)
Angular: 7.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... http, language-service, material, platform-browser
... platform-browser-dynamic, router

@angular-devkit/architect 0.10.2
@angular-devkit/build-angular 0.10.2
@angular-devkit/build-optimizer 0.10.2
@angular-devkit/build-webpack 0.10.2
@angular-devkit/core 7.0.2
@angular-devkit/schematics 7.0.2
@angular/cli 7.0.2
@ngtools/webpack 7.0.2
@schematics/angular 7.0.2
@schematics/update 0.10.2
rxjs 6.3.3
typescript 3.1.3
webpack 4.19.1

Description

The --format flag produces invalid output.

Repro steps

  1. Create a new angular project
  2. Execute ng lint --format checkstyle [name of the angular project]

The log given by the failure

Linting "[name of the angular project]"...
<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3"></checkstyle>

Desired functionality

The output should not contain Linting "[name of the angular project]"...

@tolgaozkan
Copy link

I faced the exact problem, this started to appear after angular 7 update for me.

@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely severity3: broken area: devkit/build-angular labels Oct 22, 2018
@ngbot ngbot bot added this to the needsTriage milestone Oct 22, 2018
@Nols1000
Copy link
Author

It seems that the commit aa25a33 is the problem

@pathurs
Copy link

pathurs commented Nov 9, 2018

The problem is caused by

aa25a33#diff-de67da9e5a0afd9e30e8fa8a17ada2ceR18

protected async runSingleTarget(targetSpec: TargetSpecifier, options: string[]) {
    this.logger.info(`Linting ${JSON.stringify(targetSpec.project)}...`);

    return super.runSingleTarget(targetSpec, options);
}

Specifically

this.logger.info(`Linting ${JSON.stringify(targetSpec.project)}...`);

Output (ng lint --format=json):

Linting "app"...
[]

Solution:
Only log when the format is one of the non-parseable formats.

@corvinrok
Copy link

corvinrok commented Nov 12, 2018

this problem breaks several of my builds currently, as well...

parseable output formats should never have this kind of text injection.. at the very least, they should have a switch to allow us to exempt our output from such things. For example, making the --silent switch (which already exists on this command) force this text logging to be quiet.

As a temporary workaround, the following two things worked for me:

ng lint --force --format=checkstyle | sed 's/Linting.*$//' > ../ci/output-tslint.xml

or

ng lint --force --format=checkstyle | sed '1d' > ../ci/output-tslint.xml

where ../ci/output-tslint.xml is the generated checkstyle format file you are needing for your build process or whatnot..

@rtaft
Copy link

rtaft commented Nov 20, 2018

I also see 'All files pass linting.' at the end of the output

@philipooo
Copy link

The workaround from @corvinrok ported to windows systems:

@powershell -NoProfile -ExecutionPolicy Unrestricted -Command "& { ng lint --force --format=checkstyle  | %{$_ -replace 'Linting.*$', ''} | sc ../ci/output-tslint.xml }"

or

@powershell -NoProfile -ExecutionPolicy Unrestricted -Command "& { ng lint --force --format=checkstyle  | select -Skip 1 | sc ../ci/output-tslint.xml }"

alexeagle pushed a commit that referenced this issue Dec 6, 2018
alexeagle pushed a commit that referenced this issue Dec 6, 2018
@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
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants