1.0.2 • Published 5 years ago
dxcare-typescript v1.0.2
eslint配置
- react/vue 项目的eslint配置
- 默认支持typescript
- 支持prettier
Installation
npm i -D dxcare-typescript
或者
yarn add -D dxcare-typescript
Usage
tsconfig.json
{
"extends": "./node_modules/dxcare-typescript/tsconfig.json",
"compilerOptions": {
// you can further customize options here
}
}
eslintrc.js
module.exports = {
extends: [
// 默认的eslint配置,默认支持typescript
"./node_modules/dxcare-typescript/tslint.js",
//react/vue 项目配置,如果是vue项目,替换为tslint-vue
"./node_modules/dxcare-typescript/tslint-react.js",
// prettier配置
"./node_modules/dxcare-typescript/tslint-prettier.js",
],
rules:{
// you can further customize options here
}
}
如果配置了prettier,需要在项目的根目录添加 .vscode/settings.json 文件,
- 保存自动修复eslint
- 阻止同时运行javascript和typescript 2个保存格式化的指令
{
"eslint.validate": [
"javascript",
"javascriptreact",
"html",
{
"language": "typescript",
"autoFix": true
},
{
"language": "typescriptreact",
"autoFix": true
}
],
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
"[typescript]": {
"editor.formatOnSave": false
},
"[typescriptreact]": {
"editor.formatOnSave": false
},
}