Tuesday, 6 August 2019

Don't auto-lint my tests! 🥴

VSCode, ESLint and Prettier = LIFE 💧

Hopefully all of you know this. I have recently moved over to VSCode from Sublime Text 3, and I must say that my developer quality of life has changed immeasurably as a result.

I have editor.formatOnSave set to true, so this means that Prettier will automatically correct any style problems in my JS code. This is very useful, and has enabled me to write better JSX and JS!

However, the one bug bear with this is that Prettier will also automatically correct ESLint violations in Jest specs as you're writing them. This is definitely sub-optimal, so I discovered that you can optionally make use of an .eslintignore in the root of your project directory. You can specify any number of glob patterns in this file, and ESLint (and as a result Prettier) will respect your sanity and not try to autocorrect any of the files matched under the glob.

I tend to setup my new JS projects to ignore these patterns:

# .eslintignore
© 2 0 2 1