我們用 vue/cli 創(chuàng)建新項(xiàng)目的時(shí)候,通常會(huì)選擇代碼檢查工具 [
eslint
|tslint
],有的時(shí)候難免會(huì)選錯(cuò),這個(gè)時(shí)候想要替換昧穿,怎么辦
場景再現(xiàn)
vue create lint-vue
- 為了方便查看,每個(gè)選項(xiàng)的結(jié)果做了換行橙喘, 和原腳本生成排版有一些不同
```
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
```
問題
- 這個(gè)時(shí)候想要換成tslint 檢測怎么辦呢时鸵?
解法
- 刪除
.eslintrc
- 刪除 eslint 相關(guān)的 node-modules,
npm rm -D @vue/cli-plugin-eslint @vue/eslint-config-standard @vue/eslint-config-typescript
- 在項(xiàng)目根目錄添加
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 } }