DEV Community

Discussion on: Migrating and configuring Eslint with Angular 11

Collapse
 
ben_howl profile image
Ben

Hello Giovanni ! Thank you for this complete, up-to-date and beginner-friendly tutorial !

I followed the whole tutorial, but here :

"Test the configuration
Check to see if everything is working. For example, in your configuration above, the no unused variables is enabled, so open a Typescript file and create a new variable and check if the linting works."

I installed ESLint VSCode extension wrote an unused var in order to test my config (same as yours), and it didn't get red, so I couldn't check if the linting works . Maybe you could know why it didn't work for me ?

Thanks a lot,

Ben

Collapse
 
gsarciotto profile image
Giovanni Sarciotto

Hi Ben, thanks for the compliments!

Hmm, thats odd, try running the ng lint command. If it works then there is some setting in the extension that you need to see (probably the lint on save one). If it doesn't then reply and I will be glad to help

Collapse
 
ben_howl profile image
Ben

Hi Giovanni, thank you for your quick reply !
When I run ng lint, I do have errors and warnings, and unused vars belong to the warning category - that might be the reason why it doesn't get red when I write an unused var. That's weird anyway, because I just followed your tuto.

Thread Thread
 
gsarciotto profile image
Giovanni Sarciotto

Yeah, in the config above unused vars is a warning. You can make it an error in the rules section, see this. I don't think you will need to disable the core ESLint rule since @typescript-eslint/recommended already does this, so just add the "@typescript-eslint/no-unused-vars": ["error"] line