英文:
How do I run auto-corrections for lint in an Angular 14 project?
问题
我正在使用Angular 14和相应的lint版本。在我的package.json中,我有以下内容...
"name": "my-project",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
...
"lint": "ng lint"
},
当我运行"npm run lint"时,我会得到如下错误信息:
42:10 error Type number trivially inferred from a number literal, remove type annotation @typescript-eslint/no-inferrable-types
这个错误指的是我的代码中的这部分...
run(myParam: number = 0): Observable<any> {
这似乎是lint可以自动修复的问题,但是当我运行
npm run lint --fix
什么都不会发生,实际上,在最后会打印出这条消息:
2 errors and 0 warnings potentially fixable with the --fix option.
在Angular中运行lint的自动修复选项的正确方式是什么?
英文:
I'm using Angular 14 and the corresponding lint version. I hvae this in my package.json ...
"name": "my-project",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
...
"lint": "ng lint"
},
When I run "npm run lint," I get errors like
42:10 error Type number trivially inferred from a number literal, remove type annotation @typescript-eslint/no-inferrable-types
Referring to this error in my code ...
run(myParam: number = 0): Observable<any> {
This seems like the kind of issue lint coudl auto-correct, but when I run
npm run lint --fix
Nothing happens, and in fact, this message is printed out at the end
2 errors and 0 warnings potentially fixable with the `--fix` option.
What is the proper way to run the auto-fix option for lint in Angular?
答案1
得分: -1
npm run lint -- --fix
这样运行可能会有帮助:
英文:
It might help to run it like this:
npm run lint -- --fix
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论