:sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
Monorepo for all the tooling which enables ESLint to support TypeScript
work and why do you have multiple packages?](https://github.com/typescript-eslint/typescript-eslint/blob/master/#how-does-typescript-eslint-work-and-why-do-you-have-multiple-packages)
The documentation below will give you an overview of what this project is, why it exists and how it works at a high level.
It is crucial that you are familiar with these concepts before reporting issues, so it is a good idea to read them before raising issues.
As covered by the previous section, both ESLint and TypeScript rely on turning your source code into a data format called an AST in order to do their jobs.
However, it turns out that ESLint and TypeScript use different ASTs to each other.
The reason for this difference is not so interesting or important and is simply the result of different evolutions, priorities, and timelines of the projects.
, exists primarily because of this major difference between the projects.
exists so that you can use ESLint and TypeScript together, without needing to worry about implementation detail differences wherever possible.
TSLint is a fantastic tool. It is a linter that was written specifically to work based on the TypeScript AST format mentioned above. This has advantages and disadvantages, as with most decisions we are faced with in software engineering!
Palantir, the backers behind TSLint announced in 2019 that **they would be deprecating TSLint in favor of supporting
typescript-eslint ```** in order to benefit the community. You can read more about that here: https://medium.com/palantir/tslint-in-2019-1a144c2317a9 The TypeScript Team themselves also announced their plans to move the TypeScript codebase from TSLint to
, and they have been big supporters of this project. More details at https://github.com/microsoft/TypeScript/issues/30553 ### Migrating from TSLint to ESLint If you are looking for help in migrating from TSLint to ESLint, you can check out this project: https://github.com/typescript-eslint/tslint-to-eslint-config You can look at [
the plugin ROADMAP.md
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/eslint-plugin/ROADMAP.md) for an up to date overview of how TSLint rules compare to the ones in this package. There is also the ultimate fallback option of using both linters together for a while during your transition if you absolutely have to by using TSLint _within_ ESLint. For this option, check out [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/eslint-plugin-tslint/). ## How does
var x: number = 1;
syntax will be represented in the tree, and this is simply not something that ESLint can understand without additional help. However, we can leverage the fact that ESLint has been designed with these use-cases in mind! It turns out that ESLint is not just one library. Instead, it is composed of a few important moving parts. One of those moving parts is **the parser**. ESLint ships with a built-in parser (called [
, as mentioned above). The [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/parser/) package in this monorepo is, in fact, the custom ESLint parser implementation we provide to ESLint in this scenario. The flow and transformations that happen look a little something like this: - ESLint invokes the
specified in your ESLint config ([
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/parser/)) - [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/parser/) deals with all the ESLint specific configuration and then invokes [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/typescript-estree/), an agnostic package that is only concerned with taking TypeScript source code and producing an appropriate AST. - [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/typescript-estree/) works by invoking the TypeScript Compiler on the given source code in order to produce a TypeScript AST and then converting that AST into a format that ESLint expects. **Note**: This AST format is more broadly used than just for ESLint. It even has its own spec and is known as **[ESTree](https://github.com/estree/estree)**, which is why our package is called
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/eslint-plugin/). ## Can we write rules which leverage type information? Yes! One of the huge benefits of using TypeScript is the fact that type information can be used to assert expected behaviors. When the transformation steps outlined above take place, we keep references to the original TypeScript AST and associated parser services, and so ESLint rules authors can access them in their rules. We already do this in numerous rules within [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/eslint-plugin/), for example,
. ## What about Babel and
? Babel does now support parsing (but not type-checking) TypeScript source code. This is as an alternative to using the TypeScript Compiler. It also supports many other syntaxes, via plugins, which are not supported by the TypeScript Compiler. As mentioned above,
is powered by the TypeScript Compiler, so we support whatever it does. The key trade-off can be summarized as
supports additional syntax which TypeScript itself does not, but
supports creating rules based on type information, which is not available to babel because there is no type-checker. Because they are separate projects powered by different underlying tooling, they are currently not intended to be used together. Some of the people involved in
are also involved in Babel and
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/typescript-estree/) - An entirely generic TypeScript parser which takes TypeScript source code and produces an [ESTree](https://github.com/estree/estree)-compatible AST - This package is also used to power the amazing opinionated code formatter [Prettier](https://prettier.io)'s own TypeScript use-case. - [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/parser/) - An ESLint-specific parser which leverages
and is designed to be used as a replacement for ESLint's default parser,
. - [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/eslint-plugin/) - An ESLint-specific plugin which, when used in conjunction with
, allows for TypeScript-specific linting rules to run. - [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/eslint-plugin-tslint) - An ESLint-specific plugin that runs an instance of TSLint within your ESLint setup to allow for users to more easily migrate from TSLint to ESLint. ## Package Versions All of the packages are published with the same version number to make it easier to coordinate both releases and installations. We publish a canary release on every successful merge to master, so **you never need to wait for a new stable version to make use of any updates**. Additionally, we promote the to the
tag on NPM once per week, **on Mondays at 1 pm Eastern**. The latest version under the
tag is: [![NPM Version](https://img.shields.io/npm/v/@typescript-eslint/parser/latest.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/parser) The latest version under the
tag **(latest commit to master)** is: [![NPM Version](https://img.shields.io/npm/v/@typescript-eslint/parser/canary.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/parser) (Note: The only exception to the automated publishes described above is when we are in the final phases of creating the next major version of the libraries - e.g. going from
. During these periods, we manually publish
releases until we are happy with the release and promote it to
.) ## Supported TypeScript Version **The version range of TypeScript currently supported by this parser is
.** These versions are what we test against. We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript. In some cases, we may even be able to support additional pre-releases (i.e. betas and release candidates) of TypeScript, but only if doing so does not require us to compromise on support for the latest stable version. Note that our packages have an open
requirement in order to allow for experimentation on newer/beta versions of TypeScript. If you use a non-supported version of TypeScript, the parser will log a warning to the console. If you want to disable this warning, you can configure this in your
. See: [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/parser/) and [
](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/typescript-estree/). **Please ensure that you are using a supported version before submitting any issues/bug reports.** ## Supported ESLint version See the value of
's [package.json](https://github.com/typescript-eslint/typescript-eslint/blob/master/./packages/eslint-plugin/package.json). ## Supported Node version This project makes an effort to support Active LTS and Maintenance LTS release statuses of Node according to [Node's release document](https://nodejs.org/en/about/releases/). Support for specific Current status releases are considered periodically. ## License TypeScript ESLint inherits from the the original TypeScript ESLint Parser license, as the majority of the work began there. It is licensed under a permissive BSD 2-clause license. ## Code Contributors This project exists thanks to every one of the awesome people who contribute code and documentation: [!(https://opencollective.com/typescript-eslint/contributors.svg?width=890&button=false)](https://github.com/typescript-eslint/typescript-eslint/graphs/contributors) 🙏 An extra special thanks goes out to the wonderful people listed in [
In addition to submitting code and documentation updates, you can help us sustain our community by becoming a financial contributor [Click here to contribute - every little bit helps!]
Support this project with your organization. Your logo will show up here with a link to your website. [Click here to contribute - every little bit helps!]