簡體   English   中英

TSLint 在 VS Code 中不起作用

[英]TSLint not working in VS Code

我使用 tslint VSCode 擴展將 TSLint 添加到我的 React/TypeScript 項目中。 我還根據 TSLint docs npm install -g tslint typescript typescript 全局安裝了 typescript 和 tslint

這是我的 tslint.json 文件:

{
  "extends": ["tslint:latest", "tslint-react"],
  "rules": {
    // override tslint-react rules here
    "jsx-wrap-multiline": false,
    "max-line-length": false,
    "no-implicit-dependencies": [true, "dev"],
    "no-var-requires": false,
    "indent": false
  }
}

tslint-react是一個 tslint 擴展,必須單獨安裝: npm install -g tslint-react 安裝后,重新加載 VS Code 窗口,linting 應該可以工作了。


我是如何發現問題的:我將您的配置文件復制到一個項目中,轉到“查看”>“輸出”以檢查 tslint 進程中的錯誤,並看到了這一點。 (一定要從靠近右上角的下拉菜單中選擇 tslint)

無效的“擴展”配置值 - 不能要求“tslint-react”

在 package.json 中包含依賴項

這是 package.json 並且它對我有用。

{
  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase experimental:functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "~5.11.0",
    "firebase-functions": "^1.0.0"
  },
  "devDependencies": {
    "tslint": "^5.8.0",
    "typescript": "^2.5.3"
  },
  "private": true
}

在 package.json "lint": "tslint --project tslint.json"添加以下內容"lint": "tslint --project tslint.json"為我解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM