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
  }
}
Gama11
  • 31,714
  • 9
  • 78
  • 100
blankface
  • 5,757
  • 19
  • 67
  • 114

3 Answers3

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"

ecraig12345
  • 2,328
  • 1
  • 19
  • 26
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
}
badarshahzad
  • 1,227
  • 16
  • 25
1

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

Mahbubur Rahman
  • 4,961
  • 2
  • 39
  • 46
Tharun208
  • 103
  • 7