Skip to main content

Typed Linting with Project Service

· 8 min read
Josh Goldberg
typescript-eslint Maintainer

"Typed linting", or enabling ESLint rules to understand TypeScript types, is one of the best parts of typescript-eslint. It enables a slew of more powerful lint rules that check for nuanced bugs, best practice violations, and other code issues that can only be detected using type information.

Typed linting hasn't always been straightforward to configure or performant at runtime. We've seen users have to manage separate tsconfig.eslint.json files to enable typed linting — sometimes with different compiler options than the rest of the project. Not ideal.

In typescript-eslint 8.0, we stabilized a parserOptions.projectService option that uses more powerful, streamlined TypeScript APIs than before. The "Project Service" brings several benefits:

  • ✍️ Configuration: simpler ESLint configs for typed linting with no ESLint-specific TSConfig files
  • 🧠 Predictability: uses the same type information services as editors, including more reliability
  • 🚀 Scalability: supporting TypeScript project references for larger repositories (i.e. monorepos)

This blog post will cover how parserOptions.projectService simplifies configurations and aligns linting type information to what editors such as VS Code run with.

tip

See Getting Started to learn how to lint JavaScript and TypeScript code with typescript-eslint, then Linting with Type Information to onboard to typed linting.

Avoiding anys with Linting and TypeScript

· 9 min read
Josh Goldberg
typescript-eslint Maintainer

TypeScript's any type is, by design, the single most unsafe part of its type system. The any type indicates a type that can be anything and can be used in place of any other type. Using any is unsafe because the type disables many of TypeScript's type-checking features and hampers TypeScript's ability to provide developer assistance.

typescript-eslint includes several lint rules that help prevent unsafe practices around the any type. These rules flag uses of any or code patterns that sneakily introduce it.

In this blog post, we'll show you those lint rules and several other handy ways to prevent anys from sneaking into your code.

Typed Linting: The Most Powerful TypeScript Linting Ever

· 9 min read
Josh Goldberg
typescript-eslint Maintainer

Linting with type information, also called "typed linting" or "type-aware linting", is the act of writing lint rules that use type information to understand your code. Typed linting rules as provided by typescript-eslint are the most powerful JavaScript/TypeScript linting in common use today.

In this blog post, we'll give a high-level overview of how linting with type information works, why it's so much more powerful than traditional linting, and some of the useful rules you can enable that use it.

Announcing typescript-eslint v8

· 17 min read
Josh Goldberg
typescript-eslint Maintainer

typescript-eslint is the tooling that enables standard JavaScript tools such as ESLint and Prettier to support TypeScript code. We've been working on a set of breaking changes and general features that we're excited to get in front of users. And now, we're excited to say that typescript-eslint v8 is released as stable! 🎉

We'd previously blogged about v8 in Announcing typescript-eslint v8 Beta. This blog post contains much of the same information as that one, and includes the list of steps you'll need to take to upgrade.

Announcing typescript-eslint v8 Beta

· 15 min read
Josh Goldberg
typescript-eslint Maintainer
Newer Information Available

This blog post is now out of date, as we've released typescript-eslint v8! 🚀 Please see Announcing typescript-eslint v8 for the latest information.

typescript-eslint is the tooling that enables standard JavaScript tools such as ESLint and Prettier to support TypeScript code. We've been working on a set of breaking changes and general features that we're excited to get in front of users soon. And now, we're excited to say that typescript-eslint v8 is ready for public beta testing! 🎉

Our plan for typescript-eslint v8 is to:

  1. Have users try out betas starting in May of 2024
  2. Respond to user feedback for the next ~1-2 months
  3. Release a stable version within the next ~1-2 months

Nothing mentioned in this blog post is set in stone. If you feel passionately about any of the choices we've made here — positively or negatively — then do let us know on the typescript-eslint Discord's #v8 channel!

Changes to consistent-type-imports with Legacy Decorators and Decorator Metadata

· 7 min read
Brad Zacher
typescript-eslint Maintainer

We've made some changes to the consistent-type-imports rule to fix some long-standing issues when used alongside experimentalDecorators: true and emitDecoratorMetadata: true. These changes increase safety and prevent invalid fixes when using decorator metadata.

Announcing typescript-eslint v7

· 3 min read
Brad Zacher
typescript-eslint Maintainer

typescript-eslint is the tooling that enables standard JavaScript tools such as ESLint and Prettier to support TypeScript code.

We've been working on infrastructure improvements that will help ensuring long-term interoperability with other tools in the ecosystem. In particular this major release tightens our dependency requirements to help set us up for ESLint v9 and includes a new package typescript-eslint providing full support for flat config files!

Breaking Changes

This is a small major release with just three breaking changes:

  1. Update Node.js engine requirement to ^18.18.0 || >=20.0.0. This means we are dropping support for Node 16, 19, and Node 18 versions prior to 18.18.0. Note that this is the same requirement that ESLint v9 will impose.
  2. Update the TypeScript peer dependency requirement to >=4.7.4.
  3. Update the ESLint peer dependency requirement to ^8.56.0.

For most users this means that an upgrade from v6 should just look like this:

npm i eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin

Relative TSConfig Projects with parserOptions.project = true

· 6 min read
Josh Goldberg
typescript-eslint Maintainer

"Typed linting", or enabling ESLint rules to tap into the power of the TypeScript type checker, is one of the best parts of typescript-eslint. But enabling the type checker in repositories with multiple tsconfig.json files can be annoying to set up. Even worse, specifying the wrong include paths could result in incorrect rule reports and/or unexpectedly slow lint times.

Improving the setup experience for typed lint rules has been a long-standing goal for typescript-eslint. One long-standing feature request for that experience has been to support automatically detecting TSConfigs for developers. We're happy to say that we now support that by setting parserOptions.project equal to true in ESLint configurations.

This post will explain what life was like before, what's changed, and what's coming next. 🎉

Announcing typescript-eslint v6

· 18 min read
Josh Goldberg
typescript-eslint Maintainer

typescript-eslint is the tooling that enables standard JavaScript tools such as ESLint and Prettier to support TypeScript code. We've been working on a set of breaking changes and general features that we're excited to get released! 🎉

We'd previously blogged about v6 in Announcing typescript-eslint v6 Beta. This blog post contains much of the same information as that one, but updated for changes made since the beta - including a few breaking changes.