Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically fix lint problems only on a specific file

I am running npm run lint -- --fix from command line to automatically fix lint errors, but this command creates fixes on the entire project.

I've been searching the documentation to find out how to run the automatic fix on a specific file instead of the entire project, but I couldn't find a way.

Is this possible?

like image 841
iusting Avatar asked Jul 06 '18 15:07

iusting


2 Answers

Using ESLint from the CLI should fix it:

eslint --fix "C:\code\hello-world.js"

ESLint CLI documentation

like image 139
Jesper Wilfing Avatar answered Dec 03 '22 17:12

Jesper Wilfing


The solution works great, this is just a quick tip for yarn/mac users:

yarn eslint --fix "src/ui/screens/HelloWorld.js"
like image 36
JosephA91 Avatar answered Dec 03 '22 18:12

JosephA91