I'm using the Angular starter kit
and I'm trying to get tslint to autofix all my lint problems with the --fix flag.
I'm running the script:
npm run tslint --fix src/**/*.ts
It just generates the same error that I'm already being told about in tslint and not autofixing it:
console output:
ERROR: src/app/app-routing.module.ts[10, 5]: comment must start with a space
ERROR: src/app/app-routing.module.ts[2, 20]: Too many spaces before 'from'
Am I missing something that allows it to implement the changes?
My versions are:
"tslint": "^5.6.0"
"codelyzer": "^3.1.2"
Question: How can I get tslint to implement autofix to my lint errors?
Unfortunately, not all linting violations are auto-fixable. You can see which rules are auto-fixable here by looking for the
Has Fixertag.My guess is that "comment must start with a space" is governed by the
comment-formatrule, which is not auto-fixable.I'm not sure which rule is causing your second error, but it is most likely also not auto-fixable.
Here's a snippet you can run
tslint --fixagainst to verify that some violations are fixed, and others are not.Rules to include when linting the above file:
It's tempting to think that all whitespace errors would be auto-fixable, and perhaps they should be. Sadly, they're not.