Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run eslint --fix from npm script

I am trying to add lint-fix in my package.json. My basic lint is "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"

I did try "lint-fix": "eslint --fix --ext .js,.vue src test/unit/specs test/e2e/specs" but it is throwing my errors but not fixing them.

What do I have to change?

The error from NPM is:

217 problems (217 errors, 0 warnings) npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "lint-fix" npm ERR! node v5.10.1 npm ERR! npm v3.8.3 npm ERR! code ELIFECYCLE npm ERR! [email protected] lint-fix: eslint --fix --ext .js,.vue src npm ERR! Exit status 1 npm ERR! but it is caused by exit code 1 which is result of finding errors. 
like image 964
Marek Urbanowicz Avatar asked Oct 26 '16 20:10

Marek Urbanowicz


People also ask

How do I automatically fix ESLint errors?

If you have the ESLint extension installed you can use CTRL+SHIFT+P to open the Command Palette. Then search for ESLint: Fix all auto-fixable Problems and press ENTER (or RETURN ). You are free from counting indentation and checking for quotation marks and semicolons!

What does npm run ESLint do?

NPM — How to Run ESLint --fix From npm Script json file. These scripts allow you to run commands for the current project. A typical command is to run the test suite for the project. You can also combine scripts or add CLI flags to individual commands.


1 Answers

You can run below command:

npm run lint -- --fix 
like image 148
kallayya Hiremath Avatar answered Sep 21 '22 09:09

kallayya Hiremath