Create a react app
npx create-react-app project_name
Start development server
cd project_name npm start
See ESLin configurations
npm ls eslint
Installing and configuring Airbnb’s EsLint (version updated frequently)
npm install eslint-config-airbnb@19.0.4
Running ESLint manually
node_modules/.bin/eslint src --max-warnings=0
Adding ESLint to package.json script
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"lint": "eslint src --max-warnings=10",
"eject": "react-scripts eject"
}
then you can do npm run lint to invoke the linter
Run linter to fix errors
npm run lint -- --fix
Disable linter for one line of code or the entire file:
eslint-disable-next-line [rule-name] eslint-disable [rule-name]
In VS code open action menu Command-shift-P (Ctrl-Shift-P)
>eslint
VS code see/add keyboard short cut: Code->settings->keyboard shortcut
Installing the prop-types library
npm install --save prop-types@15.7.2