TypeScript ESLint Language Service Plugin
typescript-eslint-language-service is a TypeScript language service plugin designed to integrate ESLint functionality directly into TypeScript-aware IDEs. It reports ESLint errors as TypeScript semantic diagnostics and offers code-fixes for applicable ESLint issues, providing a unified linting experience. The current stable version is 5.0.5, with releases typically driven by bug fixes and updates to its peer dependencies, notably `eslint` and `@typescript-eslint/parser`. Key differentiators include its seamless integration into the TypeScript language service, allowing real-time feedback and quick fixes for ESLint rule violations without needing separate build steps or processes for linting, treating lint errors as native compiler errors within the IDE. It relies on peer dependencies `typescript`, `@typescript-eslint/parser`, and `eslint` for its operation.
Common errors
-
Cannot find package 'eslint' or package '@typescript-eslint/parser'
cause Missing or incompatible peer dependencies preventing the plugin from loading or functioning correctly.fixRun `npm install -D eslint@^8 @typescript-eslint/parser@^5 typescript@^4` to install the required peer dependencies matching the `typescript-eslint-language-service@5.x.x` version. -
Language service plugin 'typescript-eslint-language-service' could not be loaded.
cause Incorrect configuration in `tsconfig.json`, an incompatible Node.js/TypeScript version, or issues with peer dependency resolution.fixVerify that the plugin name in `tsconfig.json` is exactly `"typescript-eslint-language-service"`. Confirm all peer dependencies (`eslint`, `@typescript-eslint/parser`, `typescript`) are correctly installed and meet the minimum version requirements. Check your IDE's logs for more specific error details. -
ESLint rules are not being applied, or configuration changes are not picked up after `eslint@8.35.0`.
cause Compatibility issues with newer ESLint versions (e.g., specific bug fixed in plugin version 5.0.4) or incorrect `watchDirs` configuration.fixUpgrade to `typescript-eslint-language-service@5.0.4` or newer to resolve known compatibility issues with `eslint@8.35.0`. Also, ensure any custom ESLint config file locations are included in the `watchDirs` plugin option in `tsconfig.json`.
Warnings
- breaking Version 5.0.0 introduced breaking changes, requiring `eslint` version `8.0.0` or higher and `@typescript-eslint/parser` version `5.0.0` or higher as peer dependencies.
- breaking Version 4.0.0 introduced breaking changes, requiring `@typescript-eslint/parser` version `4.0.0` or higher as a peer dependency.
- gotcha The plugin's functionality can be disabled by setting the `TS_ESLINT_SERVICE_DISABLED` environment variable, which might lead to unexpected lack of ESLint feedback in your IDE.
- gotcha By default, the plugin only watches `.eslintrc.*` files in the project root. If your ESLint configuration files are located elsewhere, changes to them might not be immediately reflected.
Install
-
npm install typescript-eslint-language-service -
yarn add typescript-eslint-language-service -
pnpm add typescript-eslint-language-service
Imports
- typescript-eslint-language-service
import { PluginName } from 'typescript-eslint-language-service'; const plugin = require('typescript-eslint-language-service');{ "compilerOptions": { "plugins": [ { "name": "typescript-eslint-language-service", "watchDirs": ["src"] } ] } } - PluginOptions
type PluginOptions = { name: "typescript-eslint-language-service"; watchDirs?: string[]; };
Quickstart
{
"compilerOptions": {
"target": "es2020",
"module": "esnext",
"lib": ["es2020", "dom"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
// Configure the TypeScript ESLint Language Service plugin
// This enables ESLint errors and fixes to appear directly in your IDE
"plugins": [
{
"name": "typescript-eslint-language-service",
// Optionally, specify additional directories to watch for ESLint config changes.
// By default, only .eslintrc.* files in the project root are watched.
// Example: "watchDirs": ["config", "eslint-rules"]
}
]
},
"include": ["src/**/*.ts", "src/**/*.tsx", ".eslintrc.js"],
"exclude": ["node_modules", "dist"]
}