- npx create-react-app react-eslint --template typescript
- cd react-eslint
- npm start
- npm i eslint -D
- npx eslint --init
- How would you like to use ESLint? ...
7. What type of modules does your project use? ...
- Which framework does your project use? ...
9.Does your project use TypeScript? » No / Yes
- Where does your code run? ...
- How would you like to define a style for your project? ...
- Which style guide do you want to follow? ...
- What format do you want your config file to be in? ...
- The style guide "standard" requires eslint@^7.12.1. You are currently using eslint@8.12.0. Do you want to downgrade?
- Would you like to install them now with npm?
- Would you like to install them now with npm ?
- npm start
- settings.json
{
"eslint.enable": true,
"eslint.run": "onType",
"eslint.options": {
"extensions": [
".js",
".vue",
".jsx",
".tsx"
]
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
- Open your project,you'll find some errors. You can use "Ctrl + S" to achieve autosave.But,there is a problem such as ......
- You can add rules in the file of .eslintrc.js
rules: {
'react/react-in-jsx-scope': 'off',
// 'react/react-in-jsx-scope': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
'no-use-before-define': 'off'
}
- Or choose what you want.
- Last,choose "Always show the Eslint status bar item"