简体   繁体   中英

How to run eslint in create react app

Help to run eslint in create react app.

I created react app with tutorial

Then I installed

babel-eslint

standard

snazzy

and then I added to script in package.json next line

"lint": "standart --verbose | snazzy"

and now I tried to run eslint with command: npm run lint

but I have an error Parsing error: Unexpected token = null

My full package.json is below

 { "name": "square_app_react", "version": "0.1.0", "private": true, "dependencies": { "react": "^15.6.1", "react-dom": "^15.6.1", "react-scripts": "1.0.10" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", "lint": "standart --verbose | snazzy" }, "devDependencies": { "babel-eslint": "^7.2.3", "standard": "^10.0.2" } }

Please help to understand how to fix it or how to correct run eslint in my situation.

Thank you in advance.

Your spelling is off in your package.json script. It should be:

"lint": "standard --verbose | snazzy"

You also need to configure standard to use babel-eslint. Make sure to add this to your package.json.

{
  "standard": {
    "parser": "babel-eslint"
  }
}

To run EsLint inside src folder:

./node_modules/react-scripts/node_modules/.bin/eslint src

Recent React scripts (version 5 at least, it appears) install eslint directly, so you can add the following line to the "scripts" section of package.json :

"lint": "eslint",

I added this following script to scripts in package.json:

"lint": "eslint src --ext .js,.jsx,.ts,.tsx",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM