Announcing typescript-eslint v7
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:
- 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 to18.18.0
. Note that this is the same requirement that ESLint v9 will impose. - Update the TypeScript peer dependency requirement to
>=4.7.4
. - 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
- Yarn
- pnpm
npm i eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
yarn add eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
pnpm add eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
Into the Futureโ
The intent behind this release is for us to constrain variance in our dependencies to help set us up for the future. The upcoming ESLint v9 release will contain many API removals - all of which had replacements added in some of the latest ESLint v8 releases. By enforcing that you have the latest ESLint v8 release we ensure that you have the replacement APIs. This significantly reduces our maintenance burden and should mean we can release v9 support sooner and with less pain and effort.
New Features - Flat Config Supportโ
There is one big feature that's also shipping with this release:
๐ Official support for ESLint Flat Configs! ๐
With v7 we're releasing a new package, typescript-eslint
. This package can be imported within your flat config to access our configs, plugin, and parser. This package also exports a utility function called config
which will allow you to write type-checked configuration files!
Switching to typescript-eslint
โ
Because this new package includes dependencies on our plugin and parser, you can replace those dependencies entirely:
- npm
- Yarn
- pnpm
npm un @typescript-eslint/parser @typescript-eslint/eslint-plugin
npm i typescript-eslint
yarn remove @typescript-eslint/parser @typescript-eslint/eslint-plugin
yarn add typescript-eslint
pnpm remove @typescript-eslint/parser @typescript-eslint/eslint-plugin
pnpm add typescript-eslint
The simplest of this new tooling would be the following which will enable the ESLint recommended config and our recommended config (including turning on our plugin and parser):
// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
);
If you're into having a bit more control then you can also declare our plugin and parser in your config - both are exported from this package! For example this config would enable our plugin, our parser, and type-aware linting with a few of our popular type-aware rules:
// @ts-check
import tseslint from 'typescript-eslint';
export default tseslint.config({
plugins: {
'@typescript-eslint': tseslint.plugin,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true,
},
},
rules: {
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
},
});
You don't have to use this package if you haven't yet migrated to flat configs. But once you do, this is our recommend way to set up our tooling.
For more information check out: