eslint-config-moresec
Install
js
yarn add eslint babel-eslint @moresec/eslint-config-moresec -D
// or
npm i eslint babel-eslint @moresec/eslint-config-moresec -D
vue
yarn add\
eslint\
babel-eslint\
eslint-plugin-vue\
vue-eslint-parser\
@moresec/eslint-config-moresec\
-D
react
yarn add\
eslint\
babel-eslint\
eslint-plugin-react\
@moresec/eslint-config-moresec\
-D
typescript
yarn add\
eslint\
babel-eslint\
@typescript-eslint/parser\
@typescript-eslint/eslint-plugin\
@moresec/eslint-config-moresec\
-D
Usage
通过 .eslintrc 相关文件里的 extends
字段引入。
js
{
extends: ["@moresec/moresec"]
}
vue
{
extends: ["@moresec/moresec/vue"]
}
react
{
extends: ["@moresec/moresec/react"]
}
typescript
{
extends: ["@moresec/moresec/typescript"]
}
Integrating with Prettier
// 1. 安装 Prettier
yarn add prettier --dev --exact
yarn add eslint-plugin-prettier eslint-config-prettier --dev
// 2. 配置 .eslintrc 相关文件
{
extends: [
"@moresec/moresec",
"plugin:prettier/recommended"
]
}
// 3. 配置 .prettierrc 相关文件
// semi、singleQuote、trailingComma 这三项规则保持和 eslint 一致
{
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
// 4. 例子:react + typescript 项目
// 安装
yarn add\
eslint\
babel-eslint\
eslint-plugin-react\
@typescript-eslint/parser\
@typescript-eslint/eslint-plugin\
@moresec/eslint-config-moresec\
eslint-plugin-prettier\
eslint-config-prettier\
-D
yarn add prettier --dev --exact
// .eslintrc
{
"extends": [
"@moresec/moresec/react",
"@moresec/moresec/typescript",
"plugin:prettier/recommended"
]
}
Refers
https://github.com/ElemeFE/eslint-config-elemefe
https://github.com/AlloyTeam/eslint-config-alloy
https://github.com/vuejs/eslint-plugin-vue
https://github.com/yannickcr/eslint-plugin-react
https://github.com/typescript-eslint/typescript-eslint
Environment
Node.js >= 8