Announcing typescript-eslint v6 Beta
This blog post is now out of date, as we've released typescript-eslint v6! ๐ Please see Announcing typescript-eslint v6 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, after over two years of development, we're excited to say that typescript-eslint v6 is ready for public beta testing! ๐
Our plan for typescript-eslint v6 is to:
- Have users try out betas starting in early March of 2023
- Respond to user feedback for the next 1-3 months
- Release a stable version summer of 2023
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 #v6 channel!
Trying Out v6โ
Please do try out the typescript-eslint v6 beta!
As A New Userโ
If you don't yet use typescript-eslint, you can go through our configuration steps on the v6 Getting Started docs. It'll walk you through setting up typescript-eslint in a project.
To use v6 specifically, see the following section for an updated install command.
As An Existing Userโ
If you already use typescript-eslint, you'll need to first replace your package's previous versions of @typescript-eslint/eslint-plugin and @typescript-eslint/parser with @rc-v6 versions:
npm i @typescript-eslint/eslint-plugin@rc-v6 @typescript-eslint/parser@rc-v6 --save-dev
We highly recommend then basing your ESLint configuration on the reworked typescript-eslint recommended configurations mentioned later in this post โ especially if it's been a while since you've reworked your linter config.
User-Facing Breaking Changesโ
These are the changes that users of typescript-eslint -generally, any developer running ESLint on TypeScript code- should pay attention to when upgrading typescript-eslint from v5 to v6.
โณ indicates a change that has been scheduled for v6 but not yet released. We'll update this blog post as the corresponding pull requests land.
Reworked Configuration Namesโ
The biggest configuration change in typescript-eslint v6 is that we've reworked the names of our provided user configuration files. typescript-eslint v5 provided three recommended configurations:
recommended: Recommended rules for code correctness that you can drop in without additional configuration.recommended-requiring-type-checking: Additional recommended rules that require type information.strict: Additional strict rules that can also catch bugs but are more opinionated than recommended rules.
Those configurations worked well for most projects. However, some users correctly noted two flaws in that approach:
- Strict rules that didn't require type checking were lumped in with those that did.
- Stylistic best practices were lumped in with rules that actually find bugs.
As a result, we've reworked the configurations provided by typescript-eslint into these two groups:
- Functional rule configurations, for best best practices and code correctness:
recommended: Recommended rules that you can drop in without additional configuration.recommended-type-checked:ย Additional recommended rules that require type information.strict: Additional strict rules that can also catch bugs but are more opinionated than recommended rules (without type information).strict-type-checked: Additional strict rules that do require type information.
- Stylistic rule configurations, for consistent and predictable syntax usage:
stylistic: Stylistic rules you can drop in without additional configuration.stylistic-type-checked: Additional stylistic rules that require type information.
recommended-requiring-type-checkingis now an alias forrecommended-type-checked. The alias will be removed in a future major version.
As of v6, we recommend that projects enable two configs from the above:
- If you are not using typed linting, enable
stylisticand eitherrecommendedorstrict, depending on how intensely you'd like your lint rules to scrutinize your code. - If you are using typed linting, enable
stylistic-type-checkedand eitherrecommended-type-checkedorstrict-type-checked, depending on how intensely you'd like your lint rules to scrutinize your code.
For example, a typical project that enables typed linting might have an ESLint configuration file that changes like:
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
project: true,
tsconfigRootDir: __dirname,
},
root: true,
};
See Configurations on the v6 docs site preview for the updated documentation on configurations provided by typescript-eslint.
For more information on these changes, see:
- Configs: Have recommended/strict configs include lesser configs, and simplify type checked names for the discussion leading up to these configuration changes.
- feat(eslint-plugin): rework configs: recommended, strict, stylistic; -type-checked for the pull request implementing the changes.
Updated Configuration Rulesโ
Every new major version of typescript-eslint comes with changes to which rules are enabled in the preset configurations - and with which options. Because this release also includes a reworking of the configurations themselves, the list of changes is too large to put in this blog post. Instead see the table in Changes to configurations for 6.0.0 for a full list of the changes.
Please do try out the new rule configurations presets and let us know in that discussion!
If your ESLint configuration contains many rules configurations, we suggest the following strategy to start anew:
- Remove all your rules configurations
- Extend from the preset configs that make sense for you
- Run ESLint on your project
- In your ESLint configuration, turn off any rules creating errors that don't make sense for your project - with comments explaining why
- In your ESLint configuration and/or with inline
eslint-disablecomments, turn off any rules creating too many errors for you to fix - with "TODO" comments linking to tracking issues/tickets to re-enable them
Miscellaneous changes to all shared configurations include:
- fix(eslint-plugin): remove valid-typeof disable in eslint-recommended: Removes the disabling of ESLint's
valid-typeofrule from our preset configs.
Rule Breaking Changesโ
This section is now out of date, as we've released typescript-eslint v6! ๐ Please see Announcing typescript-eslint v6 > Rule Breaking Changes for the latest information.
Several rules were changed in significant enough ways to be considered breaking changes:
- Previously deprecated rules are deleted (chore(eslint-plugin): remove deprecated rules for v6):
@typescript-eslint/no-duplicate-imports@typescript-eslint/no-implicit-any-catch@typescript-eslint/no-parameter-properties@typescript-eslint/sort-type-union-intersection-members
- feat(eslint-plugin): [prefer-nullish-coalescing]: add support for assignment expressions: Enhances the
@typescript-eslint/prefer-nullish-coalescingrule to also check||=expressions. - feat(eslint-plugin): [prefer-optional-chain] use type checking for strict falsiness: Rewrites the
@typescript-eslint/prefer-optional-chainrule to fix numerous false positives, at the cost of making it require type information.
Tooling Breaking Changesโ
This section is now out of date, as we've released typescript-eslint v6! ๐ Please see Announcing typescript-eslint v6 > Tooling Breaking Changes for the latest information.
- feat(typescript-estree): deprecate createDefaultProgram: Renames
createDefaultProgramtodeprecated__createDefaultProgram, with associated@deprecatedTSDoc tags and warnings. - feat: drop support for node v12
- feat: drop support for node v14
- feat: bump minimum supported TS version to 4.3.5: this matches DefinitelyTyped's 2-year support window.
- chore: drop support for ESLint v6
- feat(eslint-plugin): [prefer-readonly-parameter-types] added an optional type allowlist: changes the public
isTypeReadonlyArrayOrTuplefunction's first argument from achecker: ts.TypeCheckerto a fullprogram: ts.Program
Developer-Facing Changesโ
typescript-eslint v6 comes with a suite of cleanups and improvements for developers as well. If you author any ESLint plugins or other tools that interact with TypeScript syntax, then we recommend you try out typescript-eslint v6 soon. It includes some breaking changes that you may need to accommodate for.
If you're having trouble working with the changes, please let us know on the typescript-eslint Discord's #v6 channel!
