If you have a tslint.json file, it means your project uses TSLint, a deprecated linter for TypeScript. While TSLint is no longer maintained (as of 2019), you can still run it if your project hasn’t migrated to ESLint yet. Here’s how to proceed:
✅ 1. Run TSLint (Deprecated but still functional)
a. Install TSLint (if not already installed)
If you don’t have TSLint installed locally, run:
npm install tslint typescript --save-dev
b. Run TSLint
Use the tslint CLI with your tslint.json config:
npx tslint --project . --config tslint.json --ext .ts
--project .: Uses your tsconfig.json for project context.
--config tslint.json: Explicitly specifies your config file.
--ext .ts: Lints .ts files (adjust if you have .tsx or other extensions).
c. Add a Script to package.json
For convenience, add a script to your package.json:
"scripts": {
"lint": "tslint --project . --config tslint.json --ext .ts"
}
Then run:
npm run lint
🚨 2. Migrate to ESLint (Recommended)
TSLint was deprecated in favor of ESLint, which supports TypeScript via the @typescript-eslint plugin. Here’s how to migrate:
a. Install ESLint and TypeScript Plugins
npm install eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser typescript --save-dev
b. Convert tslint.json to ESLint Config
Use the TSLint-to-ESLint migration tool:
npx tslint-to-eslint-config
This creates an .eslintrc.js file based on your tslint.json.
c. Run ESLint
Add a script to package.json:
"scripts": {
"lint": "eslint --ext .ts ."
}
Run it:
npm run lint
📝 Example .eslintrc.js After Migration
module.exports = {
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"rules": {
// Converted rules from tslint.json
"no-console": ["warn"]
}
};
🔍 Why Migrate to ESLint?
- Active development: ESLint is the de facto standard for JavaScript/TypeScript linting.
- Better performance: ESLint is faster and more extensible.
- Shared ecosystem: Works with tools like Prettier, React, Vue, etc.
❗ When to Stick with TSLint
Only continue using TSLint if:
- Your project is too large/time-consuming to migrate.
- You rely on TSLint-specific rules with no ESLint equivalents (rare).
Let me know if you want help migrating your tslint.json config to ESLint! 🚀