Bug: `ng lint -fix`
OS
Windows 7 Professional
Version
1.0.0-rc1
Repro steps
ng lint --fix
The log given by the failure
No error in logs,
--fixis zealous for semicolons producing things like this:r;eturn; true;
🤖 ; 🤖 ; 🤖 ; 😱🌬
Similar problem here. ng lint --fix broke literally every file it "fixed".
For example it changed double quotes like this: key: ["some", "valeus"] => key: [" 'some value'
It deleted brackets, commas and added random spaces.
Here's a real example:
Before:
tags: ["concert", "festival", "band", "live"],
blurb: "Music festivals, live sets and cozy concerts."
},
After:
tags: ["c'concert'"f'festival'"b'band'"l'live'
blurb: "M'Music festivals, live sets and cozy concerts.' },
@mikeumus or @mikeeus, if you can give me a repo that reproduces this issue, I'll take a look at it this weekend and see what I can do to solve this issue.
I cannot reproduce this. On src/app/app.component.ts I added:
function func() {
var str = "str";
var obj = {
tags: ["concert", "festival", "band", "live"],
blurb: "Music festivals, live sets and cozy concerts."
}
return true;
}
And ng lint --fix changed it to:
function func() {
const str = 'str';
const obj = {
tags: ['concert', 'festival', 'band', 'live'],
blurb: 'Music festivals, live sets and cozy concerts.'
};
return true;
}
Cannot see any mangling of the return statement or strings. If I had to bet, it was a bug on a specific version of tslint.
If you can produce a simple repo we can look at it.
I can't share my project, @mikeeus can you share yours?
Maybe Windows 7 is the culprit. @mikeeus which OS are you on?
I've seen this happen on macOS as well, but it was on a friends project and I thought it was related to TSLint rather than the CLI.
I don't need the entire project. If you can get it to happen on a new project while editing the app.component.ts, that should be plenty to go off of.
I tried my repro on win10.
Here's my package.json and .angular-cli.json as snippets in this Stack Overflow question:
- http://stackoverflow.com/q/42846582/1762493
Can get my app.component.ts later.
Thanks to @intellix, we found a project that has this problem. There is a strange interaction between --fix and --type-check. There will be an issue filed with TSLint once we have a slimmed down project to find the exact issue.
That said, we agreed on a --type-check flag for ng lint (#5589). This should take care of the problem. The flag is going to be set to false by default so that this error doesn't happen again.
It will be in before the final release. Hope this helps!
Very cool. Good work @delasteve and @intellix ! :smile:
I still see this behavior when running ng lint --fix.
Here's my version: @angular/cli: 1.0.3 node: 6.9.1 os: win32 x64 @angular/cli: 1.0.3
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.