跳到主要内容

React-Mini

2023年11月09日
柏拉文
越努力,越幸运

一、安装


pnpm add eslint -D -w
pnpm add @typescript-eslint/parser @typescript-eslint/eslint-plugin -D -w
pnpm add eslint-config-prettier eslint-plugin-prettier -D -w
pnpm add prettier -D -w

二、初始化


npx eslint --init

三、配置


3.1 .eslintrc.json

{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommend"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"prettier/prettier": "error",
"no-case-declarations": "off",
"no-constant-condition": "off",
"@typescript-eslint/ban-ts-comment": "off"
}
}

3.2 vscode setting.json

"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",