众安 ESLint 规则
基于airbnb的 ESLint 规则,进行二次定制。
npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-import eslint-config-za
{
"root": true,
"extends": "za"
}
npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-import eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y eslint-config-za
{
"root": true,
"extends": "za/react"
}
npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-import eslint-plugin-vue eslint-config-za
{
"root": true,
"extends": "za/vue"
}
npm install --save-dev eslint typescript eslint-plugin-babel eslint-plugin-import @typescript-eslint/eslint-plugin eslint-config-za
{
"root": true,
"extends": "za/typescript"
}
VSCode 的 ESLint 插件默认并不支持 vue
ts
tsx
,需要自行修改插件配置。配置参考如下
{
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue"
]
}
eslint-config-za 定义了相应的 peerDependencies
。因此选择不同规则时需要自行安装对应的依赖。具体参考使用说明。
npm info "eslint-config-za@latest" peerDependencies
npx install-peerdeps --dev eslint-config-za
npx eslint --print-config .eslintrc > /path/you/file