From 1fb8319366e0d6bb463c3e2d0d1648bbfdbcfb78 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 21 Jul 2023 13:39:49 -0400 Subject: [PATCH 01/15] fix: blog typo --- .../2023-07-09-announcing-typescript-eslint-v6.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index e79664a58748..f69e7aa6d2b4 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -619,7 +619,7 @@ For more information, see: ### Package Exports -The v5 `@typescript-eslint/` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), so anyone can import any file in any package by directly referencing a path within the dist folder. +The v5 `@typescript-eslint/` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), which allows someone to import any file in any package by directly referencing a path within the `dist` directory. For example: ```ts @@ -628,19 +628,21 @@ import * as TSESLint from '@typescript-eslint/utils/dist/ts-eslint'; That presents a few issues for developers: -- It can be unclear which of many potential import paths to use -- TypeScript sometimes suggests importing types or values meant to be private -- Consumers using deep import paths can be broken by internal refactors that rename files +- It can be unclear which of many potential import paths to use. +- TypeScript sometimes suggests importing types or values meant to be private. +- Consumers using deep import paths might get broken code after internal refactors rename files. As of [feat: add package.json exports for public packages](https://github.com/typescript-eslint/typescript-eslint/pull/6458), `@typescript-eslint/*` packages now use `exports` to prevent importing internal file paths. -Developers must now mostly import directly from the package names, e.g.: +Developers must now mostly import directly from the package names. For example, to fix the code from the previous example, you would use the following: ```ts -import * as TSESLint from '@typescript-eslint/ts-eslint'; +import * as TSESLint from '@typescript-eslint/utils'; ``` See [RFC: Use package.json exports to "hide" the dist folder for packages and control our exported surface-area](https://github.com/typescript-eslint/typescript-eslint/discussions/6015) for more backing context. +Note that if you update your imports and you still get an error from TypeScript saying "Cannot find module '@typescript-eslint/utils' or its corresponding type declarations", then you might need to change the value of `moduleResolution` to `node16` in your TypeScript config, as detailed in [this issue](https://github.com/typescript-eslint/typescript-eslint/issues/7279). + ### Other Developer-Facing Breaking Changes - [feat(utils): remove (ts-)eslint-scope types](https://github.com/typescript-eslint/typescript-eslint/pull/5256): Removes no-longer-useful `TSESLintScope` types from the `@typescript-eslint/utils` package. Use `@typescript-eslint/scope-manager` directly instead. From 40dd58c23c03e6e6f1b1e592e7df76627cd6d247 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:15:24 -0400 Subject: [PATCH 02/15] Update packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Josh Goldberg ✨ --- .../blog/2023-07-09-announcing-typescript-eslint-v6.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index f69e7aa6d2b4..b67f9a93d684 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -641,7 +641,9 @@ import * as TSESLint from '@typescript-eslint/utils'; See [RFC: Use package.json exports to "hide" the dist folder for packages and control our exported surface-area](https://github.com/typescript-eslint/typescript-eslint/discussions/6015) for more backing context. -Note that if you update your imports and you still get an error from TypeScript saying "Cannot find module '@typescript-eslint/utils' or its corresponding type declarations", then you might need to change the value of `moduleResolution` to `node16` in your TypeScript config, as detailed in [this issue](https://github.com/typescript-eslint/typescript-eslint/issues/7279). +:::note +If you update your imports and you still get an error from TypeScript saying _`"Cannot find module '@typescript-eslint/...' or its corresponding type declarations"`_, then you might need to change the value of `moduleResolution` in your TypeScript config. See [this tracking issue for `package.json` exports types](https://github.com/typescript-eslint/typescript-eslint/issues/7284). +::: ### Other Developer-Facing Breaking Changes From 7a7b78d8ca411169610ee4c3dcd3f24465750e2f Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:16:54 -0400 Subject: [PATCH 03/15] Update packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Josh Goldberg ✨ --- .../website/blog/2023-07-09-announcing-typescript-eslint-v6.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index b67f9a93d684..ebea7c87894d 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -619,7 +619,7 @@ For more information, see: ### Package Exports -The v5 `@typescript-eslint/` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), which allows someone to import any file in any package by directly referencing a path within the `dist` directory. +The v5 `@typescript-eslint/*` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), which allows importing any file in any package by directly referencing a path within the package's `dist/` directory. For example: ```ts From 72ebf533b7b5052b4e2691375796ec30f93bea78 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:19:06 -0400 Subject: [PATCH 04/15] Update 2023-07-09-announcing-typescript-eslint-v6.md --- .../website/blog/2023-07-09-announcing-typescript-eslint-v6.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index ebea7c87894d..87c1bd4619a9 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -630,7 +630,7 @@ That presents a few issues for developers: - It can be unclear which of many potential import paths to use. - TypeScript sometimes suggests importing types or values meant to be private. -- Consumers using deep import paths might get broken code after internal refactors rename files. +- Consumers using deep import paths can be broken by internal refactors that rename files. As of [feat: add package.json exports for public packages](https://github.com/typescript-eslint/typescript-eslint/pull/6458), `@typescript-eslint/*` packages now use `exports` to prevent importing internal file paths. Developers must now mostly import directly from the package names. For example, to fix the code from the previous example, you would use the following: From 9bd6f5492f5ad5c6b79c6f72c63715913d616f63 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:21:00 -0400 Subject: [PATCH 05/15] Update 2023-07-09-announcing-typescript-eslint-v6.md --- .../website/blog/2023-07-09-announcing-typescript-eslint-v6.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index 87c1bd4619a9..6054595c7b27 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -633,7 +633,7 @@ That presents a few issues for developers: - Consumers using deep import paths can be broken by internal refactors that rename files. As of [feat: add package.json exports for public packages](https://github.com/typescript-eslint/typescript-eslint/pull/6458), `@typescript-eslint/*` packages now use `exports` to prevent importing internal file paths. -Developers must now mostly import directly from the package names. For example, to fix the code from the previous example, you would use the following: +Developers must now import directly from the package names. e.g.: ```ts import * as TSESLint from '@typescript-eslint/utils'; From 9d9e4bf81f0d7c515eea6e179db7d8c975971ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Wed, 26 Jul 2023 07:51:53 -0500 Subject: [PATCH 06/15] Update packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md --- .../website/blog/2023-07-09-announcing-typescript-eslint-v6.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index 6054595c7b27..45582ed6e778 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -633,7 +633,7 @@ That presents a few issues for developers: - Consumers using deep import paths can be broken by internal refactors that rename files. As of [feat: add package.json exports for public packages](https://github.com/typescript-eslint/typescript-eslint/pull/6458), `@typescript-eslint/*` packages now use `exports` to prevent importing internal file paths. -Developers must now import directly from the package names. e.g.: +Developers must now mostly import directly from the package names, e.g.: ```ts import * as TSESLint from '@typescript-eslint/utils'; From 71330dded99169435e1c0360f3ce82cbc5bc6094 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 28 Jul 2023 17:55:04 -0400 Subject: [PATCH 07/15] docs: add typescript warning --- package.json | 3 ++- packages/eslint-plugin/docs/rules/no-dupe-class-members.md | 6 ++++++ packages/eslint-plugin/docs/rules/no-invalid-this.md | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e93d904d0d6d..8c58d5de7d22 100644 --- a/package.json +++ b/package.json @@ -144,5 +144,6 @@ "pretty-format": "^29", "tsx": "^3.12.7", "typescript": "5.1.6" - } + }, + "packageManager": "yarn@1.22.19" } diff --git a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md index 3b0f00d33bc9..4bf0a6f4bc63 100644 --- a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md +++ b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md @@ -6,5 +6,11 @@ description: 'Disallow duplicate class members.' > > See **https://typescript-eslint.io/rules/no-dupe-class-members** for documentation. +:::danger + +The code problem checked by this ESLint rule is automatically checked by the TypeScript compiler. Thus, it is not recommended to turn on this rule in new TypeScript projects. You only need to enable this rule if you prefer the ESLint error messages over the TypeScript compiler error messages. (When this rule was originally written, the TypeScript compiler checks did not exist.) + +::: + This rule extends the base [`eslint/no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) rule. It adds support for TypeScript's method overload definitions. diff --git a/packages/eslint-plugin/docs/rules/no-invalid-this.md b/packages/eslint-plugin/docs/rules/no-invalid-this.md index 9ce45891fb5d..b9de1fc53e88 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-this.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-this.md @@ -6,5 +6,11 @@ description: 'Disallow `this` keywords outside of classes or class-like objects. > > See **https://typescript-eslint.io/rules/no-invalid-this** for documentation. +:::danger + +The code problem checked by this ESLint rule is automatically checked by the TypeScript compiler (as long as you have the `strict` or `noImplicitThis` compiler flags enabled). Thus, it is not recommended to turn on this rule in new TypeScript projects. You only need to enable this rule if you prefer the ESLint error messages over the TypeScript compiler error messages. (When this rule was originally written, the TypeScript compiler checks did not exist.) + +::: + This rule extends the base [`eslint/no-invalid-this`](https://eslint.org/docs/rules/no-invalid-this) rule. It adds support for TypeScript's `this` parameters. From 2c061db2c1efa8bf207b1ffe44d9cad56269dfd6 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 28 Jul 2023 17:56:43 -0400 Subject: [PATCH 08/15] Update package.json --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 8c58d5de7d22..e93d904d0d6d 100644 --- a/package.json +++ b/package.json @@ -144,6 +144,5 @@ "pretty-format": "^29", "tsx": "^3.12.7", "typescript": "5.1.6" - }, - "packageManager": "yarn@1.22.19" + } } From 5bbf10fc8a14895df6e6092f37a8cc665ace2301 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 28 Jul 2023 17:57:23 -0400 Subject: [PATCH 09/15] Update 2023-07-09-announcing-typescript-eslint-v6.md --- ...2023-07-09-announcing-typescript-eslint-v6.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index 7d0ad7bc3c36..8f34626fe7e3 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -63,7 +63,7 @@ As a result, we've reworked the configurations provided by typescript-eslint int - 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. + - **`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: @@ -620,7 +620,7 @@ For more information, see: ### Package Exports -The v5 `@typescript-eslint/*` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), which allows importing any file in any package by directly referencing a path within the package's `dist/` directory. +The v5 `@typescript-eslint/` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), so anyone can import any file in any package by directly referencing a path within the dist folder. For example: ```ts @@ -629,23 +629,19 @@ import * as TSESLint from '@typescript-eslint/utils/dist/ts-eslint'; That presents a few issues for developers: -- It can be unclear which of many potential import paths to use. -- TypeScript sometimes suggests importing types or values meant to be private. -- Consumers using deep import paths can be broken by internal refactors that rename files. +- It can be unclear which of many potential import paths to use +- TypeScript sometimes suggests importing types or values meant to be private +- Consumers using deep import paths can be broken by internal refactors that rename files As of [feat: add package.json exports for public packages](https://github.com/typescript-eslint/typescript-eslint/pull/6458), `@typescript-eslint/*` packages now use `exports` to prevent importing internal file paths. Developers must now mostly import directly from the package names, e.g.: ```ts -import * as TSESLint from '@typescript-eslint/utils'; +import * as TSESLint from '@typescript-eslint/utils/ts-eslint'; ``` See [RFC: Use package.json exports to "hide" the dist folder for packages and control our exported surface-area](https://github.com/typescript-eslint/typescript-eslint/discussions/6015) for more backing context. -:::note -If you update your imports and you still get an error from TypeScript saying _`"Cannot find module '@typescript-eslint/...' or its corresponding type declarations"`_, then you might need to change the value of `moduleResolution` in your TypeScript config. See [this tracking issue for `package.json` exports types](https://github.com/typescript-eslint/typescript-eslint/issues/7284). -::: - ### Other Developer-Facing Breaking Changes - [feat(utils): remove (ts-)eslint-scope types](https://github.com/typescript-eslint/typescript-eslint/pull/5256): Removes no-longer-useful `TSESLintScope` types from the `@typescript-eslint/utils` package. Use `@typescript-eslint/scope-manager` directly instead. From 91b8263713f86cbe1e0d1a314684863d5010ae48 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Wed, 9 Aug 2023 10:52:14 -0400 Subject: [PATCH 10/15] Update packages/eslint-plugin/docs/rules/no-dupe-class-members.md Co-authored-by: Brad Zacher --- packages/eslint-plugin/docs/rules/no-dupe-class-members.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md index 4bf0a6f4bc63..30ca19894689 100644 --- a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md +++ b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md @@ -8,7 +8,7 @@ description: 'Disallow duplicate class members.' :::danger -The code problem checked by this ESLint rule is automatically checked by the TypeScript compiler. Thus, it is not recommended to turn on this rule in new TypeScript projects. You only need to enable this rule if you prefer the ESLint error messages over the TypeScript compiler error messages. (When this rule was originally written, the TypeScript compiler checks did not exist.) +The code problem checked by this ESLint rule is automatically checked by the TypeScript compiler. Thus, it is not recommended to turn on this rule in new TypeScript projects. You only need to enable this rule if you prefer the ESLint error messages over the TypeScript compiler error messages. ::: From c44d1c38b03555214b099d052880379178802661 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Wed, 9 Aug 2023 10:52:24 -0400 Subject: [PATCH 11/15] Update packages/eslint-plugin/docs/rules/no-invalid-this.md Co-authored-by: Brad Zacher --- packages/eslint-plugin/docs/rules/no-invalid-this.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/no-invalid-this.md b/packages/eslint-plugin/docs/rules/no-invalid-this.md index b9de1fc53e88..0fe086648467 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-this.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-this.md @@ -8,7 +8,7 @@ description: 'Disallow `this` keywords outside of classes or class-like objects. :::danger -The code problem checked by this ESLint rule is automatically checked by the TypeScript compiler (as long as you have the `strict` or `noImplicitThis` compiler flags enabled). Thus, it is not recommended to turn on this rule in new TypeScript projects. You only need to enable this rule if you prefer the ESLint error messages over the TypeScript compiler error messages. (When this rule was originally written, the TypeScript compiler checks did not exist.) +The code problem checked by this ESLint rule is automatically checked by the TypeScript compiler (as long as you have the `strict` or `noImplicitThis` compiler flags enabled). Thus, it is not recommended to turn on this rule in new TypeScript projects. You only need to enable this rule if you prefer the ESLint error messages over the TypeScript compiler error messages. ::: From 9341a303e342d2efb279fd44ed7a048a38cac7f3 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 25 Aug 2023 20:06:13 -0400 Subject: [PATCH 12/15] fix: weird whitespace --- ...3-07-09-announcing-typescript-eslint-v6.md | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index 8f34626fe7e3..09e103c6c4fe 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -63,7 +63,7 @@ As a result, we've reworked the configurations provided by typescript-eslint int - 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. + - **`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: @@ -620,7 +620,7 @@ For more information, see: ### Package Exports -The v5 `@typescript-eslint/` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), so anyone can import any file in any package by directly referencing a path within the dist folder. +The v5 `@typescript-eslint/*` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), which allows importing any file in any package by directly referencing a path within the package's `dist/` directory. For example: ```ts @@ -629,19 +629,36 @@ import * as TSESLint from '@typescript-eslint/utils/dist/ts-eslint'; That presents a few issues for developers: -- It can be unclear which of many potential import paths to use -- TypeScript sometimes suggests importing types or values meant to be private -- Consumers using deep import paths can be broken by internal refactors that rename files +- It can be unclear which of many potential import paths to use. +- TypeScript sometimes suggests importing types or values meant to be private. +- Consumers using deep import paths can be broken by internal refactors that rename files. As of [feat: add package.json exports for public packages](https://github.com/typescript-eslint/typescript-eslint/pull/6458), `@typescript-eslint/*` packages now use `exports` to prevent importing internal file paths. -Developers must now mostly import directly from the package names, e.g.: +Developers must now import directly from the package names, e.g.: ```ts -import * as TSESLint from '@typescript-eslint/utils/ts-eslint'; +// import * as TSESLint from '@typescript-eslint/utils/dist/ts-eslint'; +// --> +import { TSESLint } from '@typescript-eslint/utils'; +// The following would also work and be equivalent: +// import * as TSESLint from '@typescript-eslint/utils/ts-eslint'; +// But explicit importing should be generally favored over star imports. + +// import { RuleModule } from '@typescript-eslint/utils/dist/ts-eslint'; +// --> +import { RuleModule } from '@typescript-eslint/utils/ts-eslint'; + +// import { AST_NODE_TYPES } from "@typescript-eslint/types/dist/generated/ast-spec"; +// --> +import { AST_NODE_TYPES } from "@typescript-eslint/types"; ``` See [RFC: Use package.json exports to "hide" the dist folder for packages and control our exported surface-area](https://github.com/typescript-eslint/typescript-eslint/discussions/6015) for more backing context. +:::note +If you update your imports and you still get an error from TypeScript saying _`"Cannot find module '@typescript-eslint/...' or its corresponding type declarations"`_, then you might need to change the value of `moduleResolution` in your TypeScript config. See [this tracking issue for `package.json` exports types](https://github.com/typescript-eslint/typescript-eslint/issues/7284). +::: + ### Other Developer-Facing Breaking Changes - [feat(utils): remove (ts-)eslint-scope types](https://github.com/typescript-eslint/typescript-eslint/pull/5256): Removes no-longer-useful `TSESLintScope` types from the `@typescript-eslint/utils` package. Use `@typescript-eslint/scope-manager` directly instead. From 48387e1878ec5871c47bf695509888d2b5ac660c Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 25 Aug 2023 20:51:45 -0400 Subject: [PATCH 13/15] feat: typescript mdx component --- .../docs/rules/no-dupe-class-members.md | 6 ++-- .../docs/rules/no-invalid-this.md | 6 ++-- .../eslint-plugin/docs/rules/no-redeclare.md | 4 +++ .../components/TypeScriptOverlap/index.tsx | 32 +++++++++++++++++++ 4 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 packages/website/src/components/TypeScriptOverlap/index.tsx diff --git a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md index 30ca19894689..cc67ddad93a7 100644 --- a/packages/eslint-plugin/docs/rules/no-dupe-class-members.md +++ b/packages/eslint-plugin/docs/rules/no-dupe-class-members.md @@ -6,11 +6,9 @@ description: 'Disallow duplicate class members.' > > See **https://typescript-eslint.io/rules/no-dupe-class-members** for documentation. -:::danger +import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap"; -The code problem checked by this ESLint rule is automatically checked by the TypeScript compiler. Thus, it is not recommended to turn on this rule in new TypeScript projects. You only need to enable this rule if you prefer the ESLint error messages over the TypeScript compiler error messages. - -::: + This rule extends the base [`eslint/no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) rule. It adds support for TypeScript's method overload definitions. diff --git a/packages/eslint-plugin/docs/rules/no-invalid-this.md b/packages/eslint-plugin/docs/rules/no-invalid-this.md index 0fe086648467..a9e8bcaeb52f 100644 --- a/packages/eslint-plugin/docs/rules/no-invalid-this.md +++ b/packages/eslint-plugin/docs/rules/no-invalid-this.md @@ -6,11 +6,9 @@ description: 'Disallow `this` keywords outside of classes or class-like objects. > > See **https://typescript-eslint.io/rules/no-invalid-this** for documentation. -:::danger +import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap"; -The code problem checked by this ESLint rule is automatically checked by the TypeScript compiler (as long as you have the `strict` or `noImplicitThis` compiler flags enabled). Thus, it is not recommended to turn on this rule in new TypeScript projects. You only need to enable this rule if you prefer the ESLint error messages over the TypeScript compiler error messages. - -::: + This rule extends the base [`eslint/no-invalid-this`](https://eslint.org/docs/rules/no-invalid-this) rule. It adds support for TypeScript's `this` parameters. diff --git a/packages/eslint-plugin/docs/rules/no-redeclare.md b/packages/eslint-plugin/docs/rules/no-redeclare.md index 5496aa9053f5..6d3ffe97e5bb 100644 --- a/packages/eslint-plugin/docs/rules/no-redeclare.md +++ b/packages/eslint-plugin/docs/rules/no-redeclare.md @@ -6,6 +6,10 @@ description: 'Disallow variable redeclaration.' > > See **https://typescript-eslint.io/rules/no-redeclare** for documentation. +import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap"; + + + This rule extends the base [`eslint/no-redeclare`](https://eslint.org/docs/rules/no-redeclare) rule. It adds support for TypeScript function overloads, and declaration merging. diff --git a/packages/website/src/components/TypeScriptOverlap/index.tsx b/packages/website/src/components/TypeScriptOverlap/index.tsx new file mode 100644 index 000000000000..57bc37513386 --- /dev/null +++ b/packages/website/src/components/TypeScriptOverlap/index.tsx @@ -0,0 +1,32 @@ +import Admonition from '@theme/Admonition'; +import React from 'react'; + +export default function TypeScriptOverlap({ + strict, +}: { + strict?: string; +}): React.JSX.Element { + return ( +
+ +

+ The code problem checked by this ESLint rule is automatically checked + by the TypeScript compiler. Thus, it is not recommended to turn on + this rule in new TypeScript projects. You only need to enable this + rule if you prefer the ESLint error messages over the TypeScript + compiler error messages. +

+ {strict === undefined ? ( + <> + ) : ( +

+ (Note that technically, TypeScript will only catch this if you have + the strict or noImplicitThis flags + enabled. These are enabled in most TypeScript projects, since they + are considered to be best practice.) +

+ )} +
+
+ ); +} From 755c2a07e270f224525107db603c96c746389e9d Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:04:31 -0400 Subject: [PATCH 14/15] fix: overlapping pr --- ...3-07-09-announcing-typescript-eslint-v6.md | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md index 09e103c6c4fe..c4a5d6b7d3b5 100644 --- a/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md +++ b/packages/website/blog/2023-07-09-announcing-typescript-eslint-v6.md @@ -620,7 +620,7 @@ For more information, see: ### Package Exports -The v5 `@typescript-eslint/*` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), which allows importing any file in any package by directly referencing a path within the package's `dist/` directory. +The v5 `@typescript-eslint/` packages don't use [Node.js package.json exports](https://nodejs.org/api/packages.html#package-entry-points), so anyone can import any file in any package by directly referencing a path within the dist folder. For example: ```ts @@ -629,36 +629,19 @@ import * as TSESLint from '@typescript-eslint/utils/dist/ts-eslint'; That presents a few issues for developers: -- It can be unclear which of many potential import paths to use. -- TypeScript sometimes suggests importing types or values meant to be private. -- Consumers using deep import paths can be broken by internal refactors that rename files. +- It can be unclear which of many potential import paths to use +- TypeScript sometimes suggests importing types or values meant to be private +- Consumers using deep import paths can be broken by internal refactors that rename files As of [feat: add package.json exports for public packages](https://github.com/typescript-eslint/typescript-eslint/pull/6458), `@typescript-eslint/*` packages now use `exports` to prevent importing internal file paths. -Developers must now import directly from the package names, e.g.: +Developers must now mostly import directly from the package names, e.g.: ```ts -// import * as TSESLint from '@typescript-eslint/utils/dist/ts-eslint'; -// --> -import { TSESLint } from '@typescript-eslint/utils'; -// The following would also work and be equivalent: -// import * as TSESLint from '@typescript-eslint/utils/ts-eslint'; -// But explicit importing should be generally favored over star imports. - -// import { RuleModule } from '@typescript-eslint/utils/dist/ts-eslint'; -// --> -import { RuleModule } from '@typescript-eslint/utils/ts-eslint'; - -// import { AST_NODE_TYPES } from "@typescript-eslint/types/dist/generated/ast-spec"; -// --> -import { AST_NODE_TYPES } from "@typescript-eslint/types"; +import * as TSESLint from '@typescript-eslint/utils/ts-eslint'; ``` See [RFC: Use package.json exports to "hide" the dist folder for packages and control our exported surface-area](https://github.com/typescript-eslint/typescript-eslint/discussions/6015) for more backing context. -:::note -If you update your imports and you still get an error from TypeScript saying _`"Cannot find module '@typescript-eslint/...' or its corresponding type declarations"`_, then you might need to change the value of `moduleResolution` in your TypeScript config. See [this tracking issue for `package.json` exports types](https://github.com/typescript-eslint/typescript-eslint/issues/7284). -::: - ### Other Developer-Facing Breaking Changes - [feat(utils): remove (ts-)eslint-scope types](https://github.com/typescript-eslint/typescript-eslint/pull/5256): Removes no-longer-useful `TSESLintScope` types from the `@typescript-eslint/utils` package. Use `@typescript-eslint/scope-manager` directly instead. From 2d54363144ab229ef5f734fe5b796a9c6d0c2dc8 Mon Sep 17 00:00:00 2001 From: James <5511220+Zamiell@users.noreply.github.com> Date: Sat, 26 Aug 2023 12:04:02 -0400 Subject: [PATCH 15/15] fix: lint --- .markdownlint.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.markdownlint.json b/.markdownlint.json index f5b6d46d80e5..71abe85dea29 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -73,7 +73,8 @@ "summary", "sup", "TabItem", - "Tabs" + "Tabs", + "TypeScriptOverlap" ] }, // MD034/no-bare-urls - Bare URL used