How to show all files errors in react app with eslint by one line code in scripts in package.json?

35 Views Asked by At

I want it to show all errors for all files in react/next app in command line with eslint when i write (for example) "npm run errors" or "npm run lint".

I tried searching for eslint but couldn't find anything!

1

There are 1 best solutions below

0
0xKevin On BEST ANSWER

You can use something like below in your package.json:

"scripts": {
    ...
    "lint:check": "eslint ./src --ext .jsx,.js,.ts,.tsx --ignore-path ./.gitignore",
    "lint:fix": "eslint ./src --ext .jsx,.js,.ts,.tsx --quiet --fix --ignore-path ./.gitignore"
}

So, you can view all eslint errors/warnings using npm run lint:check and fix them using npm run lint:fix

You can adjust these commands for your needs, and you will also have to set up the eslint configurations through .eslintrc.js or .eslintrc.json file to define what eslint errors/warnings to show up or ignore, etc.