In this setup guide you will learn how to use Prettier to take care of your code formatting and ESLint to take care of your code style in an Angula...
For further actions, you may consider blocking this person and/or reporting abuse
Hi dude, thanks you for pro tips !
But with ng new command it will create
karma.conf.js
andprotractor.conf.js
that are not compatible with somes eslint rules likeno-empty-function
orno-var-require
. I must add them to eslintignore.Except this, everything is fine. :)
I've been looking for a guide like this. Thank you for putting this together.
Only things I changed from your article was
1: the addition of a .prettierignore file to format package.json, package-lock.json or the dist folder.
2: I added "trailingComma": "none" to the .prettierrc.json file.
3: I really don't like how prettier formats HTML files, so I changed up settings.json with this:
"[html]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "vscode.html-language-features"
},
I'm glad you found it useful :D
How to configure specific rules? If I add "no-empty-function": "off" to .eslintrc.json it won't be recognized. I still get the warning in my code. Where to set it then or why does it not work? Nice tutorial anyway but that's a problem for me. The warning in the code is: Unexpected empty method 'ngOnInit'.eslint@typescript-eslint/no-empty-function
I had the same problem! To resolve, I actually had to add "@typescript-eslint/no-empty-function": "off" to the .eslintrc.json file. The "@typescript-eslint/" was the important missing bit. You probably figured this out ages ago but wanted to add it here in case anyone else has this same problem.
Thank you Jared! Thank you so so much. Love you man.
Hi, there seems to be a problem with your instructions.
It would be nice to get links for all the features assignable in Prettier and in EsLint. Especially the former, as the latter can be googled easier.
Also, I'm not sure how they relate to each other. What if I set the first to allow quotation marks and the other to only accept apostrophes? Kind of confusing at the moment.
It does not work or I have not been able to make it work with the html files.
In my example I added a component called test and it made errors executing the lint.
As I read in the Prettier documentation, the --fix parameter should automatically correct html as well.
drive.google.com/file/d/1GHIMYOMu6...
When I setup these details and tried to run
npm run lint
, I receive below error -No files matching the pattern "*/.{ts}" were found.
I will update the article, just to have time for it, things have changed, new version of eslint and prettier got out :D
Edit: Updated the article 😉
Hi Andrei, Thanks for your article. But I get the following error:
ESLint couldn't find the config "prettier/@typescript-eslint" to extend from. Please check that the name of the config is correct.
Thanks man!
What is the prettier-eslint package used for? I see you added it to the dev dependencies, but I don't see it being used anywhere.
Thanks for the knowledge man, I was looking for this a couple of weeks ago. Now I am using your advice on every pre-commit hook.