chax-at/slint-配置
类型描述项目的基础 eslint 配置
安装
npm install @chax-at/eslint-config --save-dev
同伴依赖关系
默认 ts 工程 :
npm install eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser --save-dev
反应 ts 工程 :
npm install eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-react eslint-plugin-react-hooks --save-dev
使用量
将配置添加到您的扩展规则部分 .eslintrc
{
"extends": [
"@chax-at/eslint-config"
]
}
示例配置
默认 ts 工程 :
{
"env": {
"browser": true,
"es6": true,
"mocha": true,
"node": true
},
"extends": [
"@chax-at/eslint-config"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"legacyDecorators": true,
"modules": true
},
"ecmaVersion": 6,
"project": "./tsconfig.json",
"sourceType": "module",
"tsconfigRootDir": "./"
},
"plugins": [
"@typescript-eslint",
"mocha"
]
}
反应工程 :
{
"env": {
"browser": true,
"es6": true,
"mocha": false
},
"extends": [
"@chax-at/eslint-config/react"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"legacyDecorators": true,
"modules": true
},
"ecmaVersion": 6,
"project": "./tsconfig.json",
"sourceType": "module",
"tsconfigRootDir": "./"
},
"plugins": [
"@typescript-eslint",
"mocha",
"react",
"react-hooks"
],
"settings": {
"react": {
"version": "detect"
}
},
"overrides": [
{
"files": [
"**/*.spec.ts",
"**/*.spec.tsx"
],
"env": {
"mocha": true
}
}
]
}
开发者
要测试本地变化 :
- 运行
npm link在已克隆的 eslint 配置工程目录中 - 运行
npm link @chax-at/eslint-config您想要测试您的配置的工程 - 确定您在操作后重运行以上命令
npm install - 运行
npm unlink @chax-at/eslint-config在你完成之后