简体   繁体   中英

Run ESLint during commit on Angular projects

I configured Eslint on an Angular project to check the code during commits. I made an error on purpouse to test if my configuration works: I set the rule "no-console":"error" and I left a console.log() inside the code.

When committing ESLint gives me this error:

...
✖ eslint --fix:

C:\project\src\app\app.component.ts
  12:5  error  Unexpected console statement  no-console

✖ 1 problem (1 error, 0 warnings)

husky - pre-commit hook exited with code 1 (error)

My doubt is about the fact that I see 2 lines signed with ✖.

They refer to the same error (console.log) or one of them refers to an ESLint configuration problem?

Thank for you help,

In Your example ESLint is saying that there is exactly one problem in file C:\project\src\app\app.component.ts - 12:5 error Unexpected console statement no-console

About the ✖ eslint --fix: - ESLint is just suggesting to run the command to automatically fix the files.

However, fix command only takes care of formatting, oyu would have to manually remove the console.log() call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM