ESLint
You’ve probably used ESLint (or at least heard of it) in your JavaScript or TypeScript projects. It’s a great tool for keeping your code consistent and error-free, but setting it up isn’t that simple.
I wanted to share a cool little tool I found that allows you to configure eslint in your project with just one command!
Why ESLint? 🤔
ESLint can help you:
- Catch errors early: It flags issues in your code before they become real problems.
- Keep things consistent: Everyone on the team writes code the same way.
- Write better code: Cleaner, more maintainable code is always a win.
Strict rules are great for catching problems early, but how do you get them right? This is where things get tricky.
ESLint setup is difficult
ESLint has so many rules, and while that’s great, it also makes setting it up a bit of a headache. You must:
- Take the time to figure out what rules to use.
- Test them to make sure they fit your code base.
- Deal with the sheer number of options (which can be quite intimidating).
Meet do-me-lint
🪄
do-me-lint
is a script that can be run in the project and will generate a .eslintrc.yml
Archived for you. The cool thing is that it analyzes your project and chooses rules that actually make sense. Of course, this is opinionated (in a good way), but the author spent a lot of time researching and testing these rules to make sure they work for most projects.
How to use it:
- Execute this command in your terminal (in your existing project):
npx do-me-lint
That’s it! you will get a solid .eslintrc.yml
The files are ready, along with all the necessary ESLint packages installed to simplify the selected rules.
Adjust the rules🔨
Of course, no one setting fits everyone. Sometimes you’ll want to tone down a rule or turn it off entirely. Do this in do-me-lint configuration:
-
Change errors to warnings: create
.domelintrc.yml
and add the rule belowrelaxedRules:
.
relaxedRules:
- import/no-default-export
-
To disable the rule completely: Add rules to
ignoredRules:
.
ignoredRules:
- import/no-default-export
- '@typescript-eslint/class-methods-use-this'
next time you go for a run do-me-lint
which will apply your changes.
Is it a hidden gem? 💎
honestly, do-me-lint
Feels like a hidden gem. It gets the job done and saves you a lot of time. If you’ve ever felt overwhelmed by ESLint setup, give this a try. It might become one of your favorite tools 👍.
That’s all for now – happy linting! 🚀
link
Project in GitHub.