From 51ac8d942b486869be15a66edcf31c72ce052186 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 7 Feb 2024 16:25:46 +1030 Subject: [PATCH 1/3] docs: blog post for v7 --- docs/packages/TypeScript_ESLint.mdx | 16 +++- ...4-02-12-announcing-typescript-eslint-v7.md | 94 +++++++++++++++++++ packages/website/docusaurusConfig.ts | 4 +- 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md diff --git a/docs/packages/TypeScript_ESLint.mdx b/docs/packages/TypeScript_ESLint.mdx index 8f0463620e89..5bd5e38c1f77 100644 --- a/docs/packages/TypeScript_ESLint.mdx +++ b/docs/packages/TypeScript_ESLint.mdx @@ -18,9 +18,23 @@ This package exports the following: | `parser` | [Our parser](./Parser.mdx) | | `plugin` | [Our plugin](./ESLint_Plugin.mdx) | +## Installation + +```bash npm2yarn +npm i typescript-eslint +``` + +### Migrating from "legacy" config setups + +If you're migrating from a "legacy" `.eslintrc` configuration setup you likely have our plugin and parser installed separately. This package includes these as dependencies so you can freely uninstall your local references: + +```bash npm2yarn +npm un @typescript-eslint/parser @typescript-eslint/eslint-plugin +``` + ## Usage -The `tseslint.config` function is a simple utility which does a few things. First and foremost it is a strictly typed function - meaning it allows you to write type-safe configs! +The `config` function is a simple utility which does a few things. First and foremost it is a strictly typed function - meaning it allows you to write type-safe configs! The simplest usage would be: diff --git a/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md b/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md new file mode 100644 index 000000000000..e11bf35a8e1e --- /dev/null +++ b/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md @@ -0,0 +1,94 @@ +--- +authors: + - image_url: /img/team/bradzacher.jpg + name: Brad Zacher + title: typescript-eslint Maintainer + url: https://github.com/bradzacher +description: Announcing the release of typescript-eslint's stable v7 release +slug: announcing-typescript-eslint-v7 +tags: [breaking changes, typescript-eslint, v6, v7, flat configs] +title: Announcing typescript-eslint v7 +--- + +[typescript-eslint](https://typescript-eslint.io) is the tooling that enables standard JavaScript tools such as [ESLint](https://eslint.org) and [Prettier](https://prettier.io) to support TypeScript code. + +## Breaking Changes + +This is a small major release with just three breaking changes: + +1. Update NodeJS 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. +1. Update the TypeScript peer dependency requirement to `>=4.7.4`. +1. 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: + +```bash npm2yarn +npm i 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 - meaning we can migrate without needing to build and test for backwards compatibility. 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](https://eslint.org/docs/latest/use/configure/configuration-files-new) to access our configs, plugin, and parser. This package also exports a utility function which will allow you to write type-checked configuration files! + +Because this new package includes dependencies on our plugin and parser meaning you can replace those dependencies entirely: + +```bash npm2yarn +npm un @typescript-eslint/parser @typescript-eslint/eslint-plugin +npm i typescript-eslint +``` + +The simplest of this new tooling would be: + +```js title="eslint.config.js" +// @ts-check + +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.recommended, +); +``` + +You can also declare our plugin and parser in your config via 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: + +```js title="eslint.config.js" +// @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', + }, +}); +``` + +For more information check out: + +- [ESLint's docs on flat configs](https://eslint.org/docs/latest/use/configure/configuration-files-new) +- [ESLint's docs on migrating to flat configs](https://eslint.org/docs/latest/use/configure/migration-guide) +- [The `typescript-eslint` package documentation](/packages/typescript-eslint) diff --git a/packages/website/docusaurusConfig.ts b/packages/website/docusaurusConfig.ts index 3b0f04dbe801..2ee976cf08cc 100644 --- a/packages/website/docusaurusConfig.ts +++ b/packages/website/docusaurusConfig.ts @@ -21,6 +21,8 @@ const githubUrl = 'https://github.com/typescript-eslint/typescript-eslint'; const presetClassicOptions: PresetClassicOptions = { blog: { blogSidebarCount: 'ALL', + beforeDefaultRemarkPlugins: [...beforeDefaultRemarkPlugins], + remarkPlugins, }, docs: { id: 'rules-docs', @@ -32,7 +34,7 @@ const presetClassicOptions: PresetClassicOptions = { ...beforeDefaultRemarkPlugins, generatedRuleDocs, ], - remarkPlugins: remarkPlugins, + remarkPlugins, exclude: ['TEMPLATE.md'], breadcrumbs: false, }, From 5ef625ae29a8e1dda2d91cd41592ea4ef603e931 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 9 Feb 2024 15:43:44 +1030 Subject: [PATCH 2/3] review --- .../blog/2024-02-12-announcing-typescript-eslint-v7.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md b/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md index e11bf35a8e1e..84d9aad38d5e 100644 --- a/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md +++ b/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md @@ -12,11 +12,13 @@ title: Announcing typescript-eslint v7 [typescript-eslint](https://typescript-eslint.io) is the tooling that enables standard JavaScript tools such as [ESLint](https://eslint.org) and [Prettier](https://prettier.io) 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 NodeJS 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. +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. 1. Update the TypeScript peer dependency requirement to `>=4.7.4`. 1. Update the ESLint peer dependency requirement to `^8.56.0`. @@ -37,7 +39,7 @@ The intent behind this release is for us to constrain variance in our dependenci 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](https://eslint.org/docs/latest/use/configure/configuration-files-new) to access our configs, plugin, and parser. This package also exports a utility function which will allow you to write type-checked configuration files! +With v7 we're releasing a new package - `typescript-eslint`. This package can be imported within your [flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) 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! Because this new package includes dependencies on our plugin and parser meaning you can replace those dependencies entirely: @@ -46,7 +48,7 @@ npm un @typescript-eslint/parser @typescript-eslint/eslint-plugin npm i typescript-eslint ``` -The simplest of this new tooling would be: +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): ```js title="eslint.config.js" // @ts-check @@ -60,7 +62,7 @@ export default tseslint.config( ); ``` -You can also declare our plugin and parser in your config via 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: +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: ```js title="eslint.config.js" // @ts-check From 064a142e150cb1941fda5e6fc58d9a1171a981f7 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 10 Feb 2024 07:41:19 +1030 Subject: [PATCH 3/3] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Josh Goldberg ✨ --- .../2024-02-12-announcing-typescript-eslint-v7.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md b/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md index 84d9aad38d5e..960431248d95 100644 --- a/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md +++ b/packages/website/blog/2024-02-12-announcing-typescript-eslint-v7.md @@ -32,16 +32,18 @@ npm i eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plug ### 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 - meaning we can migrate without needing to build and test for backwards compatibility. This significantly reduces our maintenance burden and should mean we can release v9 support sooner and with less pain and effort. +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](https://eslint.org/docs/latest/use/configure/configuration-files-new) 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! +With v7 we're releasing a new package, **`typescript-eslint`**. This package can be imported within your [flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) 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! -Because this new package includes dependencies on our plugin and parser meaning you can replace those dependencies entirely: +### Switching to `typescript-eslint` + +Because this new package includes dependencies on our plugin and parser, you can replace those dependencies entirely: ```bash npm2yarn npm un @typescript-eslint/parser @typescript-eslint/eslint-plugin @@ -89,6 +91,9 @@ export default tseslint.config({ }); ``` +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: - [ESLint's docs on flat configs](https://eslint.org/docs/latest/use/configure/configuration-files-new)