TSLint not working in VS Code
Asked Answered
B

3

27

I added TSLint to my React/TypeScript project using the tslint VSCode extension. I also installed both typescript and tslint globally according to TSLint docs npm install -g tslint typescript

This is my tslint.json file:

{
  "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
  }
}
Bureaucratize answered 11/4, 2018 at 23:5 Comment(1)
If either answer helped, can you please mark one as accepted? (or comment if you'd like clarification)Lavender
L
17

tslint-react is a tslint extension which has to be installed separately: npm install -g tslint-react. After installing, reload your VS Code window, and linting should work.


How I found the problem: I copied your config file into a project, went to View > Output to check for errors from the tslint process, and saw this. (be sure to select tslint from the dropdown near the top right)

Invalid "extends" configuration value - could not require "tslint-react"

Lavender answered 12/4, 2018 at 2:37 Comment(2)
Thanks for sharing the output tslint trick. Found an issue there and fixed my tslint.json.Overwinter
I dont have the tslint option in outputs.Lailalain
S
2

Include the dependency in the package.json

This is package.json and its working for me.

{
  "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
}
Stoneblind answered 12/4, 2018 at 2:49 Comment(1)
not worked for me, installed tslint, and there is tslint.jsonBaseman
Q
1

Add the following in package.json "lint": "tslint --project tslint.json" fixed the issue for me.

Questionary answered 5/7, 2018 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.