I love to use @StandardJS to enforce consistent code style in all my #JavaScript / #NodeJS projects. You can easily do that with:
```
npx standard
```
But I prefer to setup @geteslint for more extensibility.
🧵 Here's how I do it... 👇
1. Initialize a new project with:
```
mkdir new-project
cd new-project
npm init -y
```
2. install #eslint with the following command:
```
npm i --save-dev eslint
```
3. initialize #eslint using the guided procedure:
```
node_modules/.bin/eslint --init
```
4. Now you can easily validate your code with:
```
node_modules/.bin/eslint src
```
You could also create a shortcut script in your package.json
5. [BONUS] if you want your code to be validated before every commit you can do that with the help of `lint-staged` (github.com/okonet/lint-st…):
Just install it into your project with:
```
npx mrm lint-staged
```
6. [BONUS 2] You can install the eslint plugin for your favourite editor and enable the option "Format on save" to have your code automatically fixed as you type! ✨👨💻
I hope this is useful! Let me know what your setup looks like 🤓
(apparently this time I managed not to break the thread, SUCCESS 🥳)
Credits to @romMiraballes for showing me this one! 🙏
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.
