我们用 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 } }
网友评论