Skip to content

ZhongAnTech/eslint-config-za

Repository files navigation

eslint-config-za

npm version

众安 ESLint 规则
基于airbnb的 ESLint 规则,进行二次定制。

使用

JavaScrip

npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-import eslint-config-za
{
  "root": true,
  "extends": "za"
}

React

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"
}

Vue

npm install --save-dev eslint babel-eslint eslint-plugin-babel eslint-plugin-import eslint-plugin-vue eslint-config-za
{
  "root": true,
  "extends": "za/vue"
}

TypeScript

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 中使用

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

规则链接

eslint
import
jsx-a11y
react
react-hooks
typescript