@vue/cli 3.0 eslint 转成tslint

43 篇文章 2 订阅

我们用 vue/cli 创建新项目的时候,通常会选择代码检查工具 [eslint|tslint],有的时候难免会选错,这个时候想要替换,怎么办

场景再现

  • vue create lint-vue
  • 为了方便查看,每个选项的结果做了换行, 和原脚本生成排版有一些不同
```
Vue CLI v3.0.0-rc.3
? Please pick a preset: 
  Manually select features
? Check the features needed for your project: 
  Babel, TS, Router, Vuex, CSS Pre-processors, Linter
? Use class-style component syntax? 
  Yes
? Use Babel alongside TypeScript for auto-detected polyfills? 
  Yes
? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): 
  SCSS/SASS
? Pick a linter / formatter config: 
  Standard
? Pick additional lint features: 
  Lint on save
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? 
  In dedicated config files
? Save this as a preset for future projects? 
  No
```

问题

  • 这个时候想要换成tslint 检测怎么办呢?

解法

  • 删除 .eslintrc
  • 删除 eslint 相关的 node-modules,
    npm rm -D @vue/cli-plugin-eslint @vue/eslint-config-standard @vue/eslint-config-typescript
  • 在项目根目录添加 tslint.json 文件
    {
      "defaultSeverity": "warning",
      "extends": [
        "tslint:recommended"
      ],
      "linterOptions": {
        "exclude": [
          "node_modules/**"
        ]
      },
      "rules": {
        "quotemark": [true, "single"],
        "indent": [true, "spaces", 2],
        "interface-name": false,
        "ordered-imports": false,
        "object-literal-sort-keys": false,
        "no-consecutive-blank-lines": false,
        "no-debugger": false,
        "no-console": false
      }
    }
    

 



作者:kakaka0234
链接:https://www.jianshu.com/p/269ab7d568b1
来源:简书

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值