Typescript-eslint
lastmod 2022-04-11created 2022-04-078 edits
Monorepo for all the tooling which enables ESLint to support TypeScript
@typescript-eslint/parser
Used to parse Typescript. Must be put in the parser entry when configuring eslint.
@typescript-eslint/eslint-plugin
Plugin that configures Typescript-related linting rules.
Installation
- Linting your TypeScript Codebase | TypeScript ESLint
- Applying ESLint and Prettier to a Typescript project
Add the following to .eslintrc:
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
env: {
browser: true,
}
};
-
root: Set this, because if it is not set to true, ESLint searches up into parent folders of the file system. -
parser: Applies the parser installed above. -
plugin: Applies the plugin installed above. -
extends- Applying
eslint:recommendedlets you use ESLint's built-in recommended settings. -
@typescript-eslint/recommendedis similar toeslint:recommended. Applying it gives you additional TypeScript-specific rules.
- Applying
env: Sets the environment to lint in. Defines predefined global variables.-
browser: true: Browser environment.
Run: