You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code中TSLint无法正常工作问题咨询

Fixing TSLint Not Working in VS Code for React/TypeScript Projects

Let’s walk through the most likely fixes to get TSLint working properly in your setup:

  • Install local dependencies (critical!)
    Global installs of tslint and typescript aren’t enough—VS Code’s TSLint extension prioritizes project-local packages for compatibility. Run this in your project root:

    npm install --save-dev tslint tslint-react typescript
    
  • Fix your tslint.json syntax
    JSON files don’t support single-line // comments, which is breaking your configuration file. Remove those comments and use valid JSON:

    {
      "extends": ["tslint:latest", "tslint-react"],
      "rules": {
        "jsx-wrap-multiline": false,
        "max-line-length": false,
        "no-implicit-dependencies": [true, "dev"],
        "no-var-requires": false,
        "indent": false
      }
    }
    
  • Verify VS Code extension status
    Open the Extensions panel (Ctrl+Shift+X), search for the TSLint extension, and make sure it’s enabled. If it shows any error badges, try disabling and re-enabling it, or reinstalling the extension entirely.

  • Check VS Code settings for TSLint
    Open your settings (Ctrl+,), search for "tslint", and confirm these key settings:

    • tslint.enable is set to true
    • typescript.tsdk points to your local TypeScript installation (e.g., ./node_modules/typescript/lib relative to your project root)
  • Reload the VS Code window
    Sometimes extensions need a refresh to pick up new dependencies or config changes. Press Ctrl+Shift+P, type "Reload Window", and run the command.

  • Check version compatibility
    TSLint is no longer maintained, and newer TypeScript versions (4.0+) aren’t supported by TSLint 6.x. Run these commands to check your versions:

    tslint --version
    tsc --version
    

    If your TypeScript version is too new, you’ll need to either downgrade TypeScript to 3.9.x or migrate to ESLint (the recommended linter for modern TypeScript/React projects).

  • Inspect the TSLint output for errors
    Open the VS Code Output panel (Ctrl+Shift+U), select "TSLint" from the dropdown menu. Any errors here (like config parsing failures or missing dependencies) will point you directly to the issue.

内容的提问来源于stack exchange,提问作者blankface

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:59:04