diff --git a/.github/ISSUE_TEMPLATE/06-bug-report-other.yaml b/.github/ISSUE_TEMPLATE/06-bug-report-other.yaml
index ee44e376f65..3eb5e066206 100644
--- a/.github/ISSUE_TEMPLATE/06-bug-report-other.yaml
+++ b/.github/ISSUE_TEMPLATE/06-bug-report-other.yaml
@@ -20,7 +20,11 @@ body:
- label: I have [read the FAQ](https://typescript-eslint.io/linting/troubleshooting) and my problem is not listed.
required: true
- type: markdown
- id: complexity-note
+ attributes:
+ value: |
+ **All typescript-eslint bug reports need an isolated reproduction** we can clone locally and get running without other projects or existing knowledge of your project.
+ If you can't provide one, your report will likely be closed without action.
+ - type: markdown
attributes:
value: |
### Note For Complex Issues
diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml
index 202088e5b17..ae557bfdd43 100644
--- a/.github/workflows/lock.yml
+++ b/.github/workflows/lock.yml
@@ -14,8 +14,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: dessant/lock-threads@v4
+ - uses: dessant/lock-threads@v5.0.1
with:
+ add-issue-labels: 'locked due to age'
github-token: ${{ github.token }}
issue-inactive-days: '7'
issue-lock-reason: 'resolved'
diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml
new file mode 100644
index 00000000000..3ede15e7894
--- /dev/null
+++ b/.github/workflows/pr-labels.yml
@@ -0,0 +1,25 @@
+name: Pull Request Labels
+
+on:
+ pull_request:
+ types: [labeled, opened, synchronize, unlabeled]
+
+jobs:
+ label:
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ pull-requests: write
+ steps:
+ - id: changed-stable-configs
+ uses: tj-actions/changed-files@v44.5.2
+ with:
+ files: packages/{eslint-plugin,typescript-eslint}/src/configs/{recommended,stylistic}*
+ - if: steps.changed-stable-configs.outputs.any_changed == 'true'
+ uses: mheap/github-action-required-labels@v5.4.1
+ with:
+ add_comment: true
+ count: 1
+ labels: breaking change
+ message: '🤖 Beep boop! PRs that change our stable preset configs must be labeled with `breaking change`.'
+ mode: minimum
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 31e01fdba81..3df5919aff6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,36 @@
+## 7.12.0 (2024-06-03)
+
+
+### 🚀 Features
+
+- **eslint-plugin:** [no-useless-template-literals] rename to `no-useless-template-expression` (deprecate `no-useless-template-literals`) ([#8821](https://github.com/typescript-eslint/typescript-eslint/pull/8821))
+- **eslint-plugin:** [no-floating-promises] add option 'allowForKnownSafePromises' ([#9186](https://github.com/typescript-eslint/typescript-eslint/pull/9186))
+- **rule-tester:** check for parsing errors in suggestion fixes ([#9052](https://github.com/typescript-eslint/typescript-eslint/pull/9052))
+- **rule-tester:** port `checkDuplicateTestCases` from ESLint ([#9026](https://github.com/typescript-eslint/typescript-eslint/pull/9026))
+
+### 🩹 Fixes
+
+- no-useless-template-expression -> no-unnecessary-template-expression ([#9174](https://github.com/typescript-eslint/typescript-eslint/pull/9174))
+- **eslint-plugin:** [no-unnecessary-type-assertion] combine template literal check with `const` variable check ([#8820](https://github.com/typescript-eslint/typescript-eslint/pull/8820))
+- **eslint-plugin:** [dot-notation] fix false positive when accessing private/protected property with optional chaining ([#8851](https://github.com/typescript-eslint/typescript-eslint/pull/8851))
+- **eslint-plugin:** [explicit-member-accessibility] refine report locations ([#8869](https://github.com/typescript-eslint/typescript-eslint/pull/8869))
+- **eslint-plugin:** [no-unnecessary-type-assertion] declares are always defined, so always check `declare`s ([#8901](https://github.com/typescript-eslint/typescript-eslint/pull/8901))
+- **eslint-plugin:** [prefer-literal-enum-member] allow using member it self on allowBitwiseExpressions ([#9114](https://github.com/typescript-eslint/typescript-eslint/pull/9114))
+- **eslint-plugin:** [return-await] clean up in-try-catch detection and make autofixes safe ([#9031](https://github.com/typescript-eslint/typescript-eslint/pull/9031))
+- **eslint-plugin:** [member-ordering] also TSMethodSignature can be get/set ([#9193](https://github.com/typescript-eslint/typescript-eslint/pull/9193))
+- **types:** correct typing ParserOptions ([#9202](https://github.com/typescript-eslint/typescript-eslint/pull/9202))
+
+### ❤️ Thank You
+
+- Abraham Guo
+- Han Yeong-woo @nix6839
+- Joshua Chen
+- Kim Sang Du @developer-bandi
+- Kirk Waiblinger
+- YeonJuan @yeonjuan
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
diff --git a/docs/Contributing.mdx b/docs/Contributing.mdx
index 67f28ca8c34..062477b1fed 100644
--- a/docs/Contributing.mdx
+++ b/docs/Contributing.mdx
@@ -16,6 +16,6 @@ If you're new to open source, you may also find the [How to Contribute to Open S
## Next Steps
-1. [Finding or opening an issue](./contributing/Issues.mdx): In the issue tab, find the pr currently tagged with `accepting prs` or create a new issue.
-2. [Setting up a local environment](./contributing/Local_Development.mdx): Let's learn how to set up the local environment to start development.
-3. [Making a PR](./contributing/Pull_Requests.mdx): you've got changes locally that address an issue, take a look at that topic.
+1. [Finding or opening an issue](./contributing/Issues.mdx): In the issue tab, finding or creating an issue to work on.
+2. [Setting up a local environment](./contributing/Local_Development.mdx): Learning how to set up the local environment to start development.
+3. [Making a PR](./contributing/Pull_Requests.mdx): Sending in your changes to resolve an accepted issue.
diff --git a/docs/contributing/Issues.mdx b/docs/contributing/Issues.mdx
index 879600ae5d8..6a2861dfbeb 100644
--- a/docs/contributing/Issues.mdx
+++ b/docs/contributing/Issues.mdx
@@ -34,6 +34,13 @@ We've found in the past that they result in accidental ["licked cookie"](https:/
If an issue has been marked as `accepting prs` and an open PR does not exist, feel free to send a PR.
You don't need to ask for permission.
+## Finding Issues
+
+Consider searching through:
+
+1. [Unassigned user-facing marked as `accepting prs` and `good first issue`](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+label%3A%22accepting+prs%22+-label%3A%22repo+maintenance%22+no%3Aassignee): to find issues marked as good for a first-timer
+2. [Unassigned user-facing marked as `accepting prs` without `good first issue`](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aopen+is%3Aissue+label%3A%22accepting+prs%22+-label%3A%22good+first+issue%22+-label%3A%22repo+maintenance%22+no%3Aassignee): once you've finished a few issues, to find more intermediate-level issues
+
## Questions and Support Requests
The issue tracker is not an appropriate place for questions or support requests.
diff --git a/docs/maintenance/issues/Rule_Deprecations.mdx b/docs/maintenance/issues/Rule_Deprecations_And_Deletions.mdx
similarity index 59%
rename from docs/maintenance/issues/Rule_Deprecations.mdx
rename to docs/maintenance/issues/Rule_Deprecations_And_Deletions.mdx
index 1e89880390b..34715e9e73c 100644
--- a/docs/maintenance/issues/Rule_Deprecations.mdx
+++ b/docs/maintenance/issues/Rule_Deprecations_And_Deletions.mdx
@@ -1,6 +1,6 @@
---
-id: rule-deprecations
-title: Rule Deprecations
+id: rule-deprecations-and-deletions
+title: Rule Deprecations, Renames, And Deletions
---
Sometimes a rule that used to be 👍 does not age well and becomes 👎.
@@ -14,12 +14,12 @@ In these cases, we aim to remove the old rule with minimal user disruption.
## Filing the Issue
-Rule deprecations can be filed as a [new issue bypassing templates](https://github.com/typescript-eslint/typescript-eslint/issues/new).
+Rule deprecations and renames can be filed as a [new issue bypassing templates](https://github.com/typescript-eslint/typescript-eslint/issues/new).
Provide it an `## Overview` containing:
- The rule name & link to its documentation page
-- A clear explanation of why you believe it should be deprecated
+- A clear explanation of why you believe it should be deprecated and/or renamed
- Whether it exists in popular configs such as `eslint-config-airbnb-typescript` and `eslint-config-standard-with-typescript`
- Sourcegraph queries showing how often it appears in user configs
@@ -30,5 +30,8 @@ Provide it an `## Overview` containing:
1. In any minor/patch version, add [rule `meta` properties](https://eslint.org/docs/latest/developer-guide/working-with-rules#rule-basics):
- `deprecated: true`
- `replacedBy`, if applicable
-2. In the next major version, you may delete the rule
- - If the rule is relatively popular with users, consider leaving a documentation page as a tombstone pointing to the new relevant rule or docs (see [`camelcase`](/rules/camelcase/) as an example)
+2. Search through open issues and PRs, and update the name in them accordingly:
+ - Deletions: close them with a link to the issue and deprecation PR
+ - Renames: update their title and explicitly mention in a comment that the rule has been renamed
+3. In the next major version, you may delete the deprecated rule
+ - Leave a documentation page as a tombstone pointing to the new relevant rule or docs (see [`camelcase`](/rules/camelcase) as an example)
diff --git a/docs/maintenance/pull-requests/Dependency_Version_Upgrades.mdx b/docs/maintenance/pull-requests/Dependency_Version_Upgrades.mdx
index c184221d1e6..15ae0340c35 100644
--- a/docs/maintenance/pull-requests/Dependency_Version_Upgrades.mdx
+++ b/docs/maintenance/pull-requests/Dependency_Version_Upgrades.mdx
@@ -134,6 +134,7 @@ We generally start the process of supporting a new TypeScript version just after
- Whenever a PR is merged, change the respective heading's emoji from 🏗 to ✅
1. Create a PR with a title like `feat: update TypeScript to X.Y-rc` and the following changes:
- In the root `package.json`, add `|| X.Y.1-rc2` to the `devDependency` on `typescript`
+ - In the parser's `getLib`, update the `switch (target)` and its preceding comment as needed (see [#6782](https://github.com/typescript-eslint/typescript-eslint/pull/6782))
- Change the `SUPPORTED_TYPESCRIPT_VERSIONS` constant's `<` version to the next version of TypeScript
- Change the `SUPPORTED_PRERELEASE_RANGES` constant to equal `['X.Y.1-rc']`
- Rename and update `patches/typescript*` to the new TypeScript version
diff --git a/docs/packages/ESLint_Plugin.mdx b/docs/packages/ESLint_Plugin.mdx
index bf0777a005d..263d7e4123a 100644
--- a/docs/packages/ESLint_Plugin.mdx
+++ b/docs/packages/ESLint_Plugin.mdx
@@ -5,6 +5,8 @@ sidebar_label: eslint-plugin
# `@typescript-eslint/eslint-plugin`
+
+
> The TypeScript plugin for ESLint. ✨
:::info
diff --git a/docs/packages/ESLint_Plugin_TSLint.mdx b/docs/packages/ESLint_Plugin_TSLint.mdx
index f8f3d8dc811..91cea06c45a 100644
--- a/docs/packages/ESLint_Plugin_TSLint.mdx
+++ b/docs/packages/ESLint_Plugin_TSLint.mdx
@@ -5,6 +5,8 @@ sidebar_label: eslint-plugin-tslint
# `@typescript-eslint/eslint-plugin-tslint`
+
+
> ESLint plugin that allows running TSLint rules within ESLint to help you migrate from TSLint to ESLint. ✨
:::caution
diff --git a/docs/packages/Parser.mdx b/docs/packages/Parser.mdx
index 2233461d39c..d9f46936de1 100644
--- a/docs/packages/Parser.mdx
+++ b/docs/packages/Parser.mdx
@@ -3,8 +3,13 @@ id: parser
sidebar_label: parser
---
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
# `@typescript-eslint/parser`
+
+
> An [ESLint parser](https://eslint.org/docs/user-guide/configuring/plugins#specifying-parser) used to parse TypeScript code into ESLint-compatible nodes, as well as provide backing TypeScript programs. ✨
This is necessary because TypeScript produces a different, incompatible AST format to the one that ESLint requires to work.
@@ -310,7 +315,25 @@ An experimental alternative to `parserOptions.project`.
This directs the parser to use a more seamless TypeScript API to generate type information for rules.
It will automatically detect the TSConfig for each file (like `project: true`), and will also allow type information to be computed for JavaScript files without the `allowJs` compiler option (unlike `project: true`).
-```js
+
+
+
+```js title="eslint.config.js"
+export default [
+ {
+ languageOptions: {
+ parserOptions: {
+ EXPERIMENTAL_useProjectService: true,
+ },
+ },
+ },
+];
+```
+
+
+
+
+```js title=".eslintrc.js"
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
@@ -319,6 +342,9 @@ module.exports = {
};
```
+
+
+
This option should bring two main benefits:
- Simpler configurations: most projects shouldn't need to explicitly configure `project` paths or create `tsconfig.eslint.json`s
@@ -346,6 +372,24 @@ declare function createProgram(
Example usage:
+
+
+
+```js title="eslint.config.js"
+import * as parser from '@typescript-eslint/parser';
+
+export default [
+ {
+ parserOptions: {
+ programs: [parser.createProgram('tsconfig.json')],
+ },
+ },
+];
+```
+
+
+
+
```js title=".eslintrc.js"
const parser = require('@typescript-eslint/parser');
@@ -356,6 +400,9 @@ module.exports = {
};
```
+
+
+
### `withoutProjectParserOptions(parserOptions)`
Removes options that prompt the parser to parse the project with type information.
@@ -371,7 +418,7 @@ declare function withoutProjectParserOptions(
Example usage:
-```js title=".eslintrc.js"
+```js title="somePlugin.js"
const parser = require('@typescript-eslint/parser');
function parse(path, content, context) {
diff --git a/docs/packages/Rule_Tester.mdx b/docs/packages/Rule_Tester.mdx
index 4c62d391c7e..3d1f085c235 100644
--- a/docs/packages/Rule_Tester.mdx
+++ b/docs/packages/Rule_Tester.mdx
@@ -7,6 +7,8 @@ import CodeBlock from '@theme/CodeBlock';
# `@typescript-eslint/rule-tester`
+
+
> A utility for testing ESLint rules
This is a fork of ESLint's built-in `RuleTester` to provide some better types and additional features for testing TypeScript rules.
diff --git a/docs/packages/Scope_Manager.mdx b/docs/packages/Scope_Manager.mdx
index cd33ac0fc75..0afbdd4690c 100644
--- a/docs/packages/Scope_Manager.mdx
+++ b/docs/packages/Scope_Manager.mdx
@@ -5,6 +5,8 @@ sidebar_label: scope-manager
# `@typescript-eslint/scope-manager`
+
+
> A fork of [`eslint-scope`](https://github.com/eslint/eslint-scope), enhanced to support TypeScript functionality. ✨
A "scope analyser" traverses an AST and builds a model of how variables (and in our case, types) are defined and consumed by the source code.
diff --git a/docs/packages/TypeScript_ESLint.mdx b/docs/packages/TypeScript_ESLint.mdx
index 5e910850b80..379c939c0be 100644
--- a/docs/packages/TypeScript_ESLint.mdx
+++ b/docs/packages/TypeScript_ESLint.mdx
@@ -8,6 +8,8 @@ import TabItem from '@theme/TabItem';
# `typescript-eslint`
+
+
> Tooling which enables you to use TypeScript with ESLint
This package is the main entrypoint that you can use to consume our tooling with ESLint.
diff --git a/docs/packages/TypeScript_ESTree.mdx b/docs/packages/TypeScript_ESTree.mdx
index eb6a49c8a1b..516148c4fde 100644
--- a/docs/packages/TypeScript_ESTree.mdx
+++ b/docs/packages/TypeScript_ESTree.mdx
@@ -5,6 +5,8 @@ sidebar_label: typescript-estree
# `@typescript-eslint/typescript-estree`
+
+
> The underlying code used by [`@typescript-eslint/parser`](./Parser.mdx) that converts TypeScript source code into an ESTree-compatible form. ✨
This parser is designed to be generic and robust.
diff --git a/docs/packages/Utils.mdx b/docs/packages/Utils.mdx
index df05daa7690..ea702046632 100644
--- a/docs/packages/Utils.mdx
+++ b/docs/packages/Utils.mdx
@@ -5,6 +5,8 @@ sidebar_label: utils
# `@typescript-eslint/utils`
+
+
> Utilities for working with TypeScript + ESLint together. ✨
This package contains public utilities for writing custom rules and plugins in TypeScript.
diff --git a/docs/users/Shared_Configurations.mdx b/docs/users/Shared_Configurations.mdx
index 5b52521eea0..c9a1325a8dc 100644
--- a/docs/users/Shared_Configurations.mdx
+++ b/docs/users/Shared_Configurations.mdx
@@ -14,6 +14,9 @@ import TabItem from '@theme/TabItem';
## Getting Started
+See [Getting Started > Quickstart](../getting-started/Quickstart.mdx) first to set up your ESLint configuration file.
+[Packages > typescript-eslint](../packages/TypeScript_ESLint.mdx) includes more documentation on the `tseslint` helper.
+
### Projects Without Type Checking
If your project does not enable [typed linting](../getting-started/Typed_Linting.mdx), we suggest enabling the [`recommended`](#recommended) and [`stylistic`](#stylistic) configurations to start:
diff --git a/eslint.config.mjs b/eslint.config.mjs
index bb2c0c49104..5e32e82438f 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -103,9 +103,8 @@ export default tseslint.config(
// make sure we're not leveraging any deprecated APIs
'deprecation/deprecation': 'error',
- // TODO(#7130): Investigate changing these in or removing these from presets
+ // TODO: https://github.com/typescript-eslint/typescript-eslint/issues/8538
'@typescript-eslint/no-confusing-void-expression': 'off',
- '@typescript-eslint/prefer-string-starts-ends-with': 'off',
//
// our plugin :D
@@ -142,6 +141,12 @@ export default tseslint.config(
allowBitwiseExpressions: true,
},
],
+ '@typescript-eslint/prefer-string-starts-ends-with': [
+ 'error',
+ {
+ allowSingleElementEquality: 'always',
+ },
+ ],
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/restrict-template-expressions': [
'error',
diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md
index 020eb19247c..65da4a57e52 100644
--- a/packages/ast-spec/CHANGELOG.md
+++ b/packages/ast-spec/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for ast-spec to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json
index 49cfcf39bae..1c304c93981 100644
--- a/packages/ast-spec/package.json
+++ b/packages/ast-spec/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/ast-spec",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "Complete specification for the TypeScript-ESTree AST",
"private": true,
"keywords": [
diff --git a/packages/ast-spec/src/base/UnaryExpressionBase.ts b/packages/ast-spec/src/base/UnaryExpressionBase.ts
index feb681ccbc3..6401c7e73fb 100644
--- a/packages/ast-spec/src/base/UnaryExpressionBase.ts
+++ b/packages/ast-spec/src/base/UnaryExpressionBase.ts
@@ -1,10 +1,8 @@
-import type { UnaryExpression } from '../expression/UnaryExpression/spec';
-import type { LeftHandSideExpression } from '../unions/LeftHandSideExpression';
-import type { Literal } from '../unions/Literal';
+import type { Expression } from '../unions/Expression';
import type { BaseNode } from './BaseNode';
export interface UnaryExpressionBase extends BaseNode {
operator: string;
prefix: boolean;
- argument: LeftHandSideExpression | Literal | UnaryExpression;
+ argument: Expression;
}
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-Error.shot
index 79f1c74928b..b2dfc1ae3ec 100644
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-Error.shot
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-Error.shot
@@ -1,3 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`AST Fixtures declaration TSDeclareFunction _error_ async TSESTree - Error 1`] = `"NO ERROR"`;
+exports[`AST Fixtures declaration TSDeclareFunction _error_ async TSESTree - Error 1`] = `
+"TSError
+> 1 | declare async function foo();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 'async' modifier cannot be used in an ambient context.
+ 2 |"
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/3-Alignment-Error.shot
index 1f36cb0955f..67e64f02351 100644
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/3-Alignment-Error.shot
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/3-Alignment-Error.shot
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`AST Fixtures declaration TSDeclareFunction _error_ async Error Alignment 1`] = `"Babel errored but TSESTree didn't"`;
+exports[`AST Fixtures declaration TSDeclareFunction _error_ async Error Alignment 1`] = `"Both errored"`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/1-TSESTree-Error.shot
index ca0dba2a0c3..c8a50d813ca 100644
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/1-TSESTree-Error.shot
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/1-TSESTree-Error.shot
@@ -1,3 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`AST Fixtures declaration TSDeclareFunction _error_ declare-with-body TSESTree - Error 1`] = `"NO ERROR"`;
+exports[`AST Fixtures declaration TSDeclareFunction _error_ declare-with-body TSESTree - Error 1`] = `
+"TSError
+> 1 | declare function foo(): void {};
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ An implementation cannot be declared in ambient contexts.
+ 2 |"
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/3-Alignment-Error.shot
index 22b125b5643..5bb32677684 100644
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/3-Alignment-Error.shot
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/3-Alignment-Error.shot
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`AST Fixtures declaration TSDeclareFunction _error_ declare-with-body Error Alignment 1`] = `"Babel errored but TSESTree didn't"`;
+exports[`AST Fixtures declaration TSDeclareFunction _error_ declare-with-body Error Alignment 1`] = `"Both errored"`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/fixture.ts
new file mode 100644
index 00000000000..3bc9eccf097
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/fixture.ts
@@ -0,0 +1,3 @@
+declare module "x" {
+ function* foo(): any;
+}
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/1-TSESTree-Error.shot
new file mode 100644
index 00000000000..804b5bd1e90
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/1-TSESTree-Error.shot
@@ -0,0 +1,10 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator-ambient TSESTree - Error 1`] = `
+"TSError
+ 1 | declare module "x" {
+> 2 | function* foo(): any;
+ | ^^^^^^^^^^^^^^^^^^^^^ A function signature cannot be declared as a generator.
+ 3 | }
+ 4 |"
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/2-Babel-Error.shot
new file mode 100644
index 00000000000..a91598605cd
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/2-Babel-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator-ambient Babel - Error 1`] = `"NO ERROR"`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/3-Alignment-Error.shot
new file mode 100644
index 00000000000..9a14b2e1b4b
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/snapshots/3-Alignment-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator-ambient Error Alignment 1`] = `"TSESTree errored but Babel didn't"`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/fixture.ts
new file mode 100644
index 00000000000..b3985fb6a6e
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/fixture.ts
@@ -0,0 +1,2 @@
+function* foo(): any;
+function* foo(): any {}
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/1-TSESTree-Error.shot
new file mode 100644
index 00000000000..50e0462fd03
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/1-TSESTree-Error.shot
@@ -0,0 +1,9 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator-overload TSESTree - Error 1`] = `
+"TSError
+> 1 | function* foo(): any;
+ | ^^^^^^^^^^^^^^^^^^^^^ A function signature cannot be declared as a generator.
+ 2 | function* foo(): any {}
+ 3 |"
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/2-Babel-Error.shot
new file mode 100644
index 00000000000..bf3d8c4f43d
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/2-Babel-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator-overload Babel - Error 1`] = `"NO ERROR"`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/3-Alignment-Error.shot
new file mode 100644
index 00000000000..6c2cab494ca
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator-overload/snapshots/3-Alignment-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator-overload Error Alignment 1`] = `"TSESTree errored but Babel didn't"`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/fixture.ts
similarity index 100%
rename from packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/fixture.ts
rename to packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/fixture.ts
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/1-TSESTree-Error.shot
new file mode 100644
index 00000000000..f5f1b9e0753
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/1-TSESTree-Error.shot
@@ -0,0 +1,8 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator TSESTree - Error 1`] = `
+"TSError
+> 1 | declare function* foo();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ Generators are not allowed in an ambient context.
+ 2 |"
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/2-Babel-Error.shot
new file mode 100644
index 00000000000..8cac9a65578
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/2-Babel-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator Babel - Error 1`] = `"NO ERROR"`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/3-Alignment-Error.shot
new file mode 100644
index 00000000000..c04e69e4e12
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/generator/snapshots/3-Alignment-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction _error_ generator Error Alignment 1`] = `"TSESTree errored but Babel didn't"`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/fixture.ts
new file mode 100644
index 00000000000..b7a7f4a7cd3
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/fixture.ts
@@ -0,0 +1,3 @@
+declare module 'x' {
+ async function foo(): any;
+}
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/1-TSESTree-AST.shot
new file mode 100644
index 00000000000..7d2ab1f0cd8
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/1-TSESTree-AST.shot
@@ -0,0 +1,94 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-ambient TSESTree - AST 1`] = `
+Program {
+ type: "Program",
+ body: [
+ TSModuleDeclaration {
+ type: "TSModuleDeclaration",
+ body: TSModuleBlock {
+ type: "TSModuleBlock",
+ body: [
+ TSDeclareFunction {
+ type: "TSDeclareFunction",
+ async: true,
+ declare: false,
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: "Identifier",
+ decorators: [],
+ name: "foo",
+ optional: false,
+
+ range: [38, 41],
+ loc: {
+ start: { column: 17, line: 2 },
+ end: { column: 20, line: 2 },
+ },
+ },
+ params: [],
+ returnType: TSTypeAnnotation {
+ type: "TSTypeAnnotation",
+ typeAnnotation: TSAnyKeyword {
+ type: "TSAnyKeyword",
+
+ range: [45, 48],
+ loc: {
+ start: { column: 24, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+
+ range: [43, 48],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+
+ range: [23, 49],
+ loc: {
+ start: { column: 2, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ ],
+
+ range: [19, 51],
+ loc: {
+ start: { column: 19, line: 1 },
+ end: { column: 1, line: 3 },
+ },
+ },
+ declare: true,
+ global: false,
+ id: Literal {
+ type: "Literal",
+ raw: "'x'",
+ value: "x",
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+ kind: "module",
+
+ range: [0, 51],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 1, line: 3 },
+ },
+ },
+ ],
+ sourceType: "script",
+
+ range: [0, 52],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 0, line: 4 },
+ },
+}
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/2-TSESTree-Tokens.shot
new file mode 100644
index 00000000000..6057be3fa44
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/2-TSESTree-Tokens.shot
@@ -0,0 +1,136 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-ambient TSESTree - Tokens 1`] = `
+[
+ Identifier {
+ type: "Identifier",
+ value: "declare",
+
+ range: [0, 7],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 7, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "module",
+
+ range: [8, 14],
+ loc: {
+ start: { column: 8, line: 1 },
+ end: { column: 14, line: 1 },
+ },
+ },
+ String {
+ type: "String",
+ value: "'x'",
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "{",
+
+ range: [19, 20],
+ loc: {
+ start: { column: 19, line: 1 },
+ end: { column: 20, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "async",
+
+ range: [23, 28],
+ loc: {
+ start: { column: 2, line: 2 },
+ end: { column: 7, line: 2 },
+ },
+ },
+ Keyword {
+ type: "Keyword",
+ value: "function",
+
+ range: [29, 37],
+ loc: {
+ start: { column: 8, line: 2 },
+ end: { column: 16, line: 2 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "foo",
+
+ range: [38, 41],
+ loc: {
+ start: { column: 17, line: 2 },
+ end: { column: 20, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "(",
+
+ range: [41, 42],
+ loc: {
+ start: { column: 20, line: 2 },
+ end: { column: 21, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ")",
+
+ range: [42, 43],
+ loc: {
+ start: { column: 21, line: 2 },
+ end: { column: 22, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ":",
+
+ range: [43, 44],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 23, line: 2 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "any",
+
+ range: [45, 48],
+ loc: {
+ start: { column: 24, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ";",
+
+ range: [48, 49],
+ loc: {
+ start: { column: 27, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "}",
+
+ range: [50, 51],
+ loc: {
+ start: { column: 0, line: 3 },
+ end: { column: 1, line: 3 },
+ },
+ },
+]
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/3-Babel-AST.shot
new file mode 100644
index 00000000000..c7ec3ee7ecc
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/3-Babel-AST.shot
@@ -0,0 +1,89 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-ambient Babel - AST 1`] = `
+Program {
+ type: "Program",
+ body: [
+ TSModuleDeclaration {
+ type: "TSModuleDeclaration",
+ body: TSModuleBlock {
+ type: "TSModuleBlock",
+ body: [
+ TSDeclareFunction {
+ type: "TSDeclareFunction",
+ async: true,
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: "Identifier",
+ name: "foo",
+
+ range: [38, 41],
+ loc: {
+ start: { column: 17, line: 2 },
+ end: { column: 20, line: 2 },
+ },
+ },
+ params: [],
+ returnType: TSTypeAnnotation {
+ type: "TSTypeAnnotation",
+ typeAnnotation: TSAnyKeyword {
+ type: "TSAnyKeyword",
+
+ range: [45, 48],
+ loc: {
+ start: { column: 24, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+
+ range: [43, 48],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+
+ range: [23, 49],
+ loc: {
+ start: { column: 2, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ ],
+
+ range: [19, 51],
+ loc: {
+ start: { column: 19, line: 1 },
+ end: { column: 1, line: 3 },
+ },
+ },
+ declare: true,
+ id: Literal {
+ type: "Literal",
+ raw: "'x'",
+ value: "x",
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+
+ range: [0, 51],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 1, line: 3 },
+ },
+ },
+ ],
+ sourceType: "script",
+
+ range: [0, 52],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 0, line: 4 },
+ },
+}
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/4-Babel-Tokens.shot
new file mode 100644
index 00000000000..d78930b42a7
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/4-Babel-Tokens.shot
@@ -0,0 +1,136 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-ambient Babel - Tokens 1`] = `
+[
+ Identifier {
+ type: "Identifier",
+ value: "declare",
+
+ range: [0, 7],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 7, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "module",
+
+ range: [8, 14],
+ loc: {
+ start: { column: 8, line: 1 },
+ end: { column: 14, line: 1 },
+ },
+ },
+ String {
+ type: "String",
+ value: "'x'",
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "{",
+
+ range: [19, 20],
+ loc: {
+ start: { column: 19, line: 1 },
+ end: { column: 20, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "async",
+
+ range: [23, 28],
+ loc: {
+ start: { column: 2, line: 2 },
+ end: { column: 7, line: 2 },
+ },
+ },
+ Keyword {
+ type: "Keyword",
+ value: "function",
+
+ range: [29, 37],
+ loc: {
+ start: { column: 8, line: 2 },
+ end: { column: 16, line: 2 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "foo",
+
+ range: [38, 41],
+ loc: {
+ start: { column: 17, line: 2 },
+ end: { column: 20, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "(",
+
+ range: [41, 42],
+ loc: {
+ start: { column: 20, line: 2 },
+ end: { column: 21, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ")",
+
+ range: [42, 43],
+ loc: {
+ start: { column: 21, line: 2 },
+ end: { column: 22, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ":",
+
+ range: [43, 44],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 23, line: 2 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "any",
+
+ range: [45, 48],
+ loc: {
+ start: { column: 24, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ";",
+
+ range: [48, 49],
+ loc: {
+ start: { column: 27, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "}",
+
+ range: [50, 51],
+ loc: {
+ start: { column: 0, line: 3 },
+ end: { column: 1, line: 3 },
+ },
+ },
+]
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/5-AST-Alignment-AST.shot
new file mode 100644
index 00000000000..435ae1de0ad
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/5-AST-Alignment-AST.shot
@@ -0,0 +1,98 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-ambient AST Alignment - AST 1`] = `
+"Snapshot Diff:
+- TSESTree
++ Babel
+
+ Program {
+ type: 'Program',
+ body: Array [
+ TSModuleDeclaration {
+ type: 'TSModuleDeclaration',
+ body: TSModuleBlock {
+ type: 'TSModuleBlock',
+ body: Array [
+ TSDeclareFunction {
+ type: 'TSDeclareFunction',
+ async: true,
+- declare: false,
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: 'Identifier',
+- decorators: Array [],
+ name: 'foo',
+- optional: false,
+
+ range: [38, 41],
+ loc: {
+ start: { column: 17, line: 2 },
+ end: { column: 20, line: 2 },
+ },
+ },
+ params: Array [],
+ returnType: TSTypeAnnotation {
+ type: 'TSTypeAnnotation',
+ typeAnnotation: TSAnyKeyword {
+ type: 'TSAnyKeyword',
+
+ range: [45, 48],
+ loc: {
+ start: { column: 24, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+
+ range: [43, 48],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+
+ range: [23, 49],
+ loc: {
+ start: { column: 2, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ ],
+
+ range: [19, 51],
+ loc: {
+ start: { column: 19, line: 1 },
+ end: { column: 1, line: 3 },
+ },
+ },
+ declare: true,
+- global: false,
+ id: Literal {
+ type: 'Literal',
+ raw: '\\'x\\'',
+ value: 'x',
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+- kind: 'module',
+
+ range: [0, 51],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 1, line: 3 },
+ },
+ },
+ ],
+ sourceType: 'script',
+
+ range: [0, 52],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 0, line: 4 },
+ },
+ }"
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/6-AST-Alignment-Tokens.shot
similarity index 52%
rename from packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot
rename to packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/6-AST-Alignment-Tokens.shot
index 0c5870a8a61..7dbd5a90725 100644
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-ambient/snapshots/6-AST-Alignment-Tokens.shot
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`AST Fixtures declaration TSDeclareFunction generator AST Alignment - Token 1`] = `
+exports[`AST Fixtures declaration TSDeclareFunction async-ambient AST Alignment - Token 1`] = `
"Snapshot Diff:
Compared values have no visual difference."
`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/fixture.ts
new file mode 100644
index 00000000000..31dd56160e4
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/fixture.ts
@@ -0,0 +1,2 @@
+async function foo(): any;
+async function foo(): any {}
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/1-TSESTree-AST.shot
new file mode 100644
index 00000000000..325d2fb0435
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/1-TSESTree-AST.shot
@@ -0,0 +1,114 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-overload TSESTree - AST 1`] = `
+Program {
+ type: "Program",
+ body: [
+ TSDeclareFunction {
+ type: "TSDeclareFunction",
+ async: true,
+ declare: false,
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: "Identifier",
+ decorators: [],
+ name: "foo",
+ optional: false,
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+ params: [],
+ returnType: TSTypeAnnotation {
+ type: "TSTypeAnnotation",
+ typeAnnotation: TSAnyKeyword {
+ type: "TSAnyKeyword",
+
+ range: [22, 25],
+ loc: {
+ start: { column: 22, line: 1 },
+ end: { column: 25, line: 1 },
+ },
+ },
+
+ range: [20, 25],
+ loc: {
+ start: { column: 20, line: 1 },
+ end: { column: 25, line: 1 },
+ },
+ },
+
+ range: [0, 26],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 26, line: 1 },
+ },
+ },
+ FunctionDeclaration {
+ type: "FunctionDeclaration",
+ async: true,
+ body: BlockStatement {
+ type: "BlockStatement",
+ body: [],
+
+ range: [53, 55],
+ loc: {
+ start: { column: 26, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ declare: false,
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: "Identifier",
+ decorators: [],
+ name: "foo",
+ optional: false,
+
+ range: [42, 45],
+ loc: {
+ start: { column: 15, line: 2 },
+ end: { column: 18, line: 2 },
+ },
+ },
+ params: [],
+ returnType: TSTypeAnnotation {
+ type: "TSTypeAnnotation",
+ typeAnnotation: TSAnyKeyword {
+ type: "TSAnyKeyword",
+
+ range: [49, 52],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 25, line: 2 },
+ },
+ },
+
+ range: [47, 52],
+ loc: {
+ start: { column: 20, line: 2 },
+ end: { column: 25, line: 2 },
+ },
+ },
+
+ range: [27, 55],
+ loc: {
+ start: { column: 0, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ ],
+ sourceType: "script",
+
+ range: [0, 56],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 0, line: 3 },
+ },
+}
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/2-TSESTree-Tokens.shot
new file mode 100644
index 00000000000..213de06b48f
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/2-TSESTree-Tokens.shot
@@ -0,0 +1,176 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-overload TSESTree - Tokens 1`] = `
+[
+ Identifier {
+ type: "Identifier",
+ value: "async",
+
+ range: [0, 5],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 5, line: 1 },
+ },
+ },
+ Keyword {
+ type: "Keyword",
+ value: "function",
+
+ range: [6, 14],
+ loc: {
+ start: { column: 6, line: 1 },
+ end: { column: 14, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "foo",
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "(",
+
+ range: [18, 19],
+ loc: {
+ start: { column: 18, line: 1 },
+ end: { column: 19, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ")",
+
+ range: [19, 20],
+ loc: {
+ start: { column: 19, line: 1 },
+ end: { column: 20, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ":",
+
+ range: [20, 21],
+ loc: {
+ start: { column: 20, line: 1 },
+ end: { column: 21, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "any",
+
+ range: [22, 25],
+ loc: {
+ start: { column: 22, line: 1 },
+ end: { column: 25, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ";",
+
+ range: [25, 26],
+ loc: {
+ start: { column: 25, line: 1 },
+ end: { column: 26, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "async",
+
+ range: [27, 32],
+ loc: {
+ start: { column: 0, line: 2 },
+ end: { column: 5, line: 2 },
+ },
+ },
+ Keyword {
+ type: "Keyword",
+ value: "function",
+
+ range: [33, 41],
+ loc: {
+ start: { column: 6, line: 2 },
+ end: { column: 14, line: 2 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "foo",
+
+ range: [42, 45],
+ loc: {
+ start: { column: 15, line: 2 },
+ end: { column: 18, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "(",
+
+ range: [45, 46],
+ loc: {
+ start: { column: 18, line: 2 },
+ end: { column: 19, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ")",
+
+ range: [46, 47],
+ loc: {
+ start: { column: 19, line: 2 },
+ end: { column: 20, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ":",
+
+ range: [47, 48],
+ loc: {
+ start: { column: 20, line: 2 },
+ end: { column: 21, line: 2 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "any",
+
+ range: [49, 52],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 25, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "{",
+
+ range: [53, 54],
+ loc: {
+ start: { column: 26, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "}",
+
+ range: [54, 55],
+ loc: {
+ start: { column: 27, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+]
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/3-Babel-AST.shot
new file mode 100644
index 00000000000..09174cb2b0e
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/3-Babel-AST.shot
@@ -0,0 +1,108 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-overload Babel - AST 1`] = `
+Program {
+ type: "Program",
+ body: [
+ TSDeclareFunction {
+ type: "TSDeclareFunction",
+ async: true,
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: "Identifier",
+ name: "foo",
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+ params: [],
+ returnType: TSTypeAnnotation {
+ type: "TSTypeAnnotation",
+ typeAnnotation: TSAnyKeyword {
+ type: "TSAnyKeyword",
+
+ range: [22, 25],
+ loc: {
+ start: { column: 22, line: 1 },
+ end: { column: 25, line: 1 },
+ },
+ },
+
+ range: [20, 25],
+ loc: {
+ start: { column: 20, line: 1 },
+ end: { column: 25, line: 1 },
+ },
+ },
+
+ range: [0, 26],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 26, line: 1 },
+ },
+ },
+ FunctionDeclaration {
+ type: "FunctionDeclaration",
+ async: true,
+ body: BlockStatement {
+ type: "BlockStatement",
+ body: [],
+
+ range: [53, 55],
+ loc: {
+ start: { column: 26, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: "Identifier",
+ name: "foo",
+
+ range: [42, 45],
+ loc: {
+ start: { column: 15, line: 2 },
+ end: { column: 18, line: 2 },
+ },
+ },
+ params: [],
+ returnType: TSTypeAnnotation {
+ type: "TSTypeAnnotation",
+ typeAnnotation: TSAnyKeyword {
+ type: "TSAnyKeyword",
+
+ range: [49, 52],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 25, line: 2 },
+ },
+ },
+
+ range: [47, 52],
+ loc: {
+ start: { column: 20, line: 2 },
+ end: { column: 25, line: 2 },
+ },
+ },
+
+ range: [27, 55],
+ loc: {
+ start: { column: 0, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ ],
+ sourceType: "script",
+
+ range: [0, 56],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 0, line: 3 },
+ },
+}
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/4-Babel-Tokens.shot
new file mode 100644
index 00000000000..ca4d328c84d
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/4-Babel-Tokens.shot
@@ -0,0 +1,176 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-overload Babel - Tokens 1`] = `
+[
+ Identifier {
+ type: "Identifier",
+ value: "async",
+
+ range: [0, 5],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 5, line: 1 },
+ },
+ },
+ Keyword {
+ type: "Keyword",
+ value: "function",
+
+ range: [6, 14],
+ loc: {
+ start: { column: 6, line: 1 },
+ end: { column: 14, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "foo",
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "(",
+
+ range: [18, 19],
+ loc: {
+ start: { column: 18, line: 1 },
+ end: { column: 19, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ")",
+
+ range: [19, 20],
+ loc: {
+ start: { column: 19, line: 1 },
+ end: { column: 20, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ":",
+
+ range: [20, 21],
+ loc: {
+ start: { column: 20, line: 1 },
+ end: { column: 21, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "any",
+
+ range: [22, 25],
+ loc: {
+ start: { column: 22, line: 1 },
+ end: { column: 25, line: 1 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ";",
+
+ range: [25, 26],
+ loc: {
+ start: { column: 25, line: 1 },
+ end: { column: 26, line: 1 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "async",
+
+ range: [27, 32],
+ loc: {
+ start: { column: 0, line: 2 },
+ end: { column: 5, line: 2 },
+ },
+ },
+ Keyword {
+ type: "Keyword",
+ value: "function",
+
+ range: [33, 41],
+ loc: {
+ start: { column: 6, line: 2 },
+ end: { column: 14, line: 2 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "foo",
+
+ range: [42, 45],
+ loc: {
+ start: { column: 15, line: 2 },
+ end: { column: 18, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "(",
+
+ range: [45, 46],
+ loc: {
+ start: { column: 18, line: 2 },
+ end: { column: 19, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ")",
+
+ range: [46, 47],
+ loc: {
+ start: { column: 19, line: 2 },
+ end: { column: 20, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: ":",
+
+ range: [47, 48],
+ loc: {
+ start: { column: 20, line: 2 },
+ end: { column: 21, line: 2 },
+ },
+ },
+ Identifier {
+ type: "Identifier",
+ value: "any",
+
+ range: [49, 52],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 25, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "{",
+
+ range: [53, 54],
+ loc: {
+ start: { column: 26, line: 2 },
+ end: { column: 27, line: 2 },
+ },
+ },
+ Punctuator {
+ type: "Punctuator",
+ value: "}",
+
+ range: [54, 55],
+ loc: {
+ start: { column: 27, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+]
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/5-AST-Alignment-AST.shot
new file mode 100644
index 00000000000..2515ee9a01e
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/5-AST-Alignment-AST.shot
@@ -0,0 +1,118 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-overload AST Alignment - AST 1`] = `
+"Snapshot Diff:
+- TSESTree
++ Babel
+
+ Program {
+ type: 'Program',
+ body: Array [
+ TSDeclareFunction {
+ type: 'TSDeclareFunction',
+ async: true,
+- declare: false,
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: 'Identifier',
+- decorators: Array [],
+ name: 'foo',
+- optional: false,
+
+ range: [15, 18],
+ loc: {
+ start: { column: 15, line: 1 },
+ end: { column: 18, line: 1 },
+ },
+ },
+ params: Array [],
+ returnType: TSTypeAnnotation {
+ type: 'TSTypeAnnotation',
+ typeAnnotation: TSAnyKeyword {
+ type: 'TSAnyKeyword',
+
+ range: [22, 25],
+ loc: {
+ start: { column: 22, line: 1 },
+ end: { column: 25, line: 1 },
+ },
+ },
+
+ range: [20, 25],
+ loc: {
+ start: { column: 20, line: 1 },
+ end: { column: 25, line: 1 },
+ },
+ },
+
+ range: [0, 26],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 26, line: 1 },
+ },
+ },
+ FunctionDeclaration {
+ type: 'FunctionDeclaration',
+ async: true,
+ body: BlockStatement {
+ type: 'BlockStatement',
+ body: Array [],
+
+ range: [53, 55],
+ loc: {
+ start: { column: 26, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+- declare: false,
+ expression: false,
+ generator: false,
+ id: Identifier {
+ type: 'Identifier',
+- decorators: Array [],
+ name: 'foo',
+- optional: false,
+
+ range: [42, 45],
+ loc: {
+ start: { column: 15, line: 2 },
+ end: { column: 18, line: 2 },
+ },
+ },
+ params: Array [],
+ returnType: TSTypeAnnotation {
+ type: 'TSTypeAnnotation',
+ typeAnnotation: TSAnyKeyword {
+ type: 'TSAnyKeyword',
+
+ range: [49, 52],
+ loc: {
+ start: { column: 22, line: 2 },
+ end: { column: 25, line: 2 },
+ },
+ },
+
+ range: [47, 52],
+ loc: {
+ start: { column: 20, line: 2 },
+ end: { column: 25, line: 2 },
+ },
+ },
+
+ range: [27, 55],
+ loc: {
+ start: { column: 0, line: 2 },
+ end: { column: 28, line: 2 },
+ },
+ },
+ ],
+ sourceType: 'script',
+
+ range: [0, 56],
+ loc: {
+ start: { column: 0, line: 1 },
+ end: { column: 0, line: 3 },
+ },
+ }"
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/6-AST-Alignment-Tokens.shot
new file mode 100644
index 00000000000..b6b9fa4d737
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/async-overload/snapshots/6-AST-Alignment-Tokens.shot
@@ -0,0 +1,6 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSDeclareFunction async-overload AST Alignment - Token 1`] = `
+"Snapshot Diff:
+Compared values have no visual difference."
+`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/1-TSESTree-AST.shot
deleted file mode 100644
index b621f52027b..00000000000
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/1-TSESTree-AST.shot
+++ /dev/null
@@ -1,42 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`AST Fixtures declaration TSDeclareFunction generator TSESTree - AST 1`] = `
-Program {
- type: "Program",
- body: [
- TSDeclareFunction {
- type: "TSDeclareFunction",
- async: false,
- declare: true,
- expression: false,
- generator: true,
- id: Identifier {
- type: "Identifier",
- decorators: [],
- name: "foo",
- optional: false,
-
- range: [18, 21],
- loc: {
- start: { column: 18, line: 1 },
- end: { column: 21, line: 1 },
- },
- },
- params: [],
-
- range: [0, 24],
- loc: {
- start: { column: 0, line: 1 },
- end: { column: 24, line: 1 },
- },
- },
- ],
- sourceType: "script",
-
- range: [0, 25],
- loc: {
- start: { column: 0, line: 1 },
- end: { column: 0, line: 2 },
- },
-}
-`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/2-TSESTree-Tokens.shot
deleted file mode 100644
index 42e396c0099..00000000000
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/2-TSESTree-Tokens.shot
+++ /dev/null
@@ -1,76 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`AST Fixtures declaration TSDeclareFunction generator TSESTree - Tokens 1`] = `
-[
- Identifier {
- type: "Identifier",
- value: "declare",
-
- range: [0, 7],
- loc: {
- start: { column: 0, line: 1 },
- end: { column: 7, line: 1 },
- },
- },
- Keyword {
- type: "Keyword",
- value: "function",
-
- range: [8, 16],
- loc: {
- start: { column: 8, line: 1 },
- end: { column: 16, line: 1 },
- },
- },
- Punctuator {
- type: "Punctuator",
- value: "*",
-
- range: [16, 17],
- loc: {
- start: { column: 16, line: 1 },
- end: { column: 17, line: 1 },
- },
- },
- Identifier {
- type: "Identifier",
- value: "foo",
-
- range: [18, 21],
- loc: {
- start: { column: 18, line: 1 },
- end: { column: 21, line: 1 },
- },
- },
- Punctuator {
- type: "Punctuator",
- value: "(",
-
- range: [21, 22],
- loc: {
- start: { column: 21, line: 1 },
- end: { column: 22, line: 1 },
- },
- },
- Punctuator {
- type: "Punctuator",
- value: ")",
-
- range: [22, 23],
- loc: {
- start: { column: 22, line: 1 },
- end: { column: 23, line: 1 },
- },
- },
- Punctuator {
- type: "Punctuator",
- value: ";",
-
- range: [23, 24],
- loc: {
- start: { column: 23, line: 1 },
- end: { column: 24, line: 1 },
- },
- },
-]
-`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/3-Babel-AST.shot
deleted file mode 100644
index 26ccbf892c1..00000000000
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/3-Babel-AST.shot
+++ /dev/null
@@ -1,40 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`AST Fixtures declaration TSDeclareFunction generator Babel - AST 1`] = `
-Program {
- type: "Program",
- body: [
- TSDeclareFunction {
- type: "TSDeclareFunction",
- async: false,
- declare: true,
- expression: false,
- generator: true,
- id: Identifier {
- type: "Identifier",
- name: "foo",
-
- range: [18, 21],
- loc: {
- start: { column: 18, line: 1 },
- end: { column: 21, line: 1 },
- },
- },
- params: [],
-
- range: [0, 24],
- loc: {
- start: { column: 0, line: 1 },
- end: { column: 24, line: 1 },
- },
- },
- ],
- sourceType: "script",
-
- range: [0, 25],
- loc: {
- start: { column: 0, line: 1 },
- end: { column: 0, line: 2 },
- },
-}
-`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/4-Babel-Tokens.shot
deleted file mode 100644
index 76c88da05a1..00000000000
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/4-Babel-Tokens.shot
+++ /dev/null
@@ -1,76 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`AST Fixtures declaration TSDeclareFunction generator Babel - Tokens 1`] = `
-[
- Identifier {
- type: "Identifier",
- value: "declare",
-
- range: [0, 7],
- loc: {
- start: { column: 0, line: 1 },
- end: { column: 7, line: 1 },
- },
- },
- Keyword {
- type: "Keyword",
- value: "function",
-
- range: [8, 16],
- loc: {
- start: { column: 8, line: 1 },
- end: { column: 16, line: 1 },
- },
- },
- Punctuator {
- type: "Punctuator",
- value: "*",
-
- range: [16, 17],
- loc: {
- start: { column: 16, line: 1 },
- end: { column: 17, line: 1 },
- },
- },
- Identifier {
- type: "Identifier",
- value: "foo",
-
- range: [18, 21],
- loc: {
- start: { column: 18, line: 1 },
- end: { column: 21, line: 1 },
- },
- },
- Punctuator {
- type: "Punctuator",
- value: "(",
-
- range: [21, 22],
- loc: {
- start: { column: 21, line: 1 },
- end: { column: 22, line: 1 },
- },
- },
- Punctuator {
- type: "Punctuator",
- value: ")",
-
- range: [22, 23],
- loc: {
- start: { column: 22, line: 1 },
- end: { column: 23, line: 1 },
- },
- },
- Punctuator {
- type: "Punctuator",
- value: ";",
-
- range: [23, 24],
- loc: {
- start: { column: 23, line: 1 },
- end: { column: 24, line: 1 },
- },
- },
-]
-`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/5-AST-Alignment-AST.shot
deleted file mode 100644
index f2de95210fa..00000000000
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/5-AST-Alignment-AST.shot
+++ /dev/null
@@ -1,46 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`AST Fixtures declaration TSDeclareFunction generator AST Alignment - AST 1`] = `
-"Snapshot Diff:
-- TSESTree
-+ Babel
-
- Program {
- type: 'Program',
- body: Array [
- TSDeclareFunction {
- type: 'TSDeclareFunction',
- async: false,
- declare: true,
- expression: false,
- generator: true,
- id: Identifier {
- type: 'Identifier',
-- decorators: Array [],
- name: 'foo',
-- optional: false,
-
- range: [18, 21],
- loc: {
- start: { column: 18, line: 1 },
- end: { column: 21, line: 1 },
- },
- },
- params: Array [],
-
- range: [0, 24],
- loc: {
- start: { column: 0, line: 1 },
- end: { column: 24, line: 1 },
- },
- },
- ],
- sourceType: 'script',
-
- range: [0, 25],
- loc: {
- start: { column: 0, line: 1 },
- end: { column: 0, line: 2 },
- },
- }"
-`;
diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts
index 50cc07ec424..ab75a908aa8 100644
--- a/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts
+++ b/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts
@@ -1,11 +1,55 @@
import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { FunctionBase } from '../../base/FunctionBase';
-import type { BlockStatement } from '../../statement/BlockStatement/spec';
-// TODO(#1852) - async + declare are semantically invalid together
-export interface TSDeclareFunction extends FunctionBase {
+interface TSDeclareFunctionBase extends FunctionBase {
type: AST_NODE_TYPES.TSDeclareFunction;
- body: BlockStatement | undefined;
+ /**
+ * TS1183: An implementation cannot be declared in ambient contexts.
+ */
+ body: undefined;
+ /**
+ * Whether the declaration has `declare` modifier.
+ */
declare: boolean;
expression: false;
}
+
+/**
+ * Function declaration with the `declare` keyword:
+ * ```
+ * declare function foo(): void;
+ * ```
+ */
+export interface TSDeclareFunctionWithDeclare extends TSDeclareFunctionBase {
+ /**
+ * TS1040: 'async' modifier cannot be used in an ambient context.
+ */
+ async: false;
+ declare: true;
+ /**
+ * TS1221: Generators are not allowed in an ambient context.
+ */
+ generator: false;
+}
+
+/**
+ * Function declaration without the `declare` keyword:
+ * ```
+ * function foo(): void;
+ * ```
+ * This can either be an overload signature or a declaration in an ambient context
+ * (e.g. `declare module`)
+ */
+
+export interface TSDeclareFunctionNoDeclare extends TSDeclareFunctionBase {
+ declare: false;
+ /**
+ * - TS1221: Generators are not allowed in an ambient context.
+ * - TS1222: An overload signature cannot be declared as a generator.
+ */
+ generator: false;
+}
+
+export type TSDeclareFunction =
+ | TSDeclareFunctionNoDeclare
+ | TSDeclareFunctionWithDeclare;
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/fixture.ts
new file mode 100644
index 00000000000..af81e9506a3
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/fixture.ts
@@ -0,0 +1 @@
+import F = require(1 + 1);
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/1-TSESTree-Error.shot
new file mode 100644
index 00000000000..d3ac7ccd164
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/1-TSESTree-Error.shot
@@ -0,0 +1,8 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string-2 TSESTree - Error 1`] = `
+"TSError
+> 1 | import F = require(1 + 1);
+ | ^^^^^ String literal expected.
+ 2 |"
+`;
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/2-Babel-Error.shot
new file mode 100644
index 00000000000..c665f97c9fc
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/2-Babel-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string-2 Babel - Error 1`] = `[SyntaxError: Unexpected token (1:19)]`;
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/3-Alignment-Error.shot
new file mode 100644
index 00000000000..67e53098fb9
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-2/snapshots/3-Alignment-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string-2 Error Alignment 1`] = `"Both errored"`;
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/fixture.ts
new file mode 100644
index 00000000000..fc7471ff260
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/fixture.ts
@@ -0,0 +1 @@
+import F = require(`1`);
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/1-TSESTree-Error.shot
new file mode 100644
index 00000000000..6bbae44b9c8
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/1-TSESTree-Error.shot
@@ -0,0 +1,8 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string-3 TSESTree - Error 1`] = `
+"TSError
+> 1 | import F = require(\`1\`);
+ | ^^^ String literal expected.
+ 2 |"
+`;
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/2-Babel-Error.shot
new file mode 100644
index 00000000000..705e7473716
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/2-Babel-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string-3 Babel - Error 1`] = `[SyntaxError: Unexpected token (1:19)]`;
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/3-Alignment-Error.shot
new file mode 100644
index 00000000000..ec7c941e43f
--- /dev/null
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string-3/snapshots/3-Alignment-Error.shot
@@ -0,0 +1,3 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string-3 Error Alignment 1`] = `"Both errored"`;
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/1-TSESTree-Error.shot
index 51aedf5fa31..9bb0b788a35 100644
--- a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/1-TSESTree-Error.shot
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/1-TSESTree-Error.shot
@@ -1,3 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string TSESTree - Error 1`] = `"NO ERROR"`;
+exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string TSESTree - Error 1`] = `
+"TSError
+> 1 | import F = require(1);
+ | ^ String literal expected.
+ 2 |"
+`;
diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/3-Alignment-Error.shot
index cda96c9ac3d..cefcf460893 100644
--- a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/3-Alignment-Error.shot
+++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/3-Alignment-Error.shot
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string Error Alignment 1`] = `"Babel errored but TSESTree didn't"`;
+exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string Error Alignment 1`] = `"Both errored"`;
diff --git a/packages/ast-spec/src/expression/CallExpression/spec.ts b/packages/ast-spec/src/expression/CallExpression/spec.ts
index b7569c9892e..2706ca6b4a1 100644
--- a/packages/ast-spec/src/expression/CallExpression/spec.ts
+++ b/packages/ast-spec/src/expression/CallExpression/spec.ts
@@ -2,11 +2,11 @@ import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec';
import type { CallExpressionArgument } from '../../unions/CallExpressionArgument';
-import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression';
+import type { Expression } from '../../unions/Expression';
export interface CallExpression extends BaseNode {
type: AST_NODE_TYPES.CallExpression;
- callee: LeftHandSideExpression;
+ callee: Expression;
arguments: CallExpressionArgument[];
typeArguments: TSTypeParameterInstantiation | undefined;
diff --git a/packages/ast-spec/src/expression/ClassExpression/spec.ts b/packages/ast-spec/src/expression/ClassExpression/spec.ts
index dbd4936f67c..71a7be13140 100644
--- a/packages/ast-spec/src/expression/ClassExpression/spec.ts
+++ b/packages/ast-spec/src/expression/ClassExpression/spec.ts
@@ -5,5 +5,4 @@ export interface ClassExpression extends ClassBase {
type: AST_NODE_TYPES.ClassExpression;
abstract: false;
declare: false;
- decorators: [];
}
diff --git a/packages/ast-spec/src/expression/NewExpression/spec.ts b/packages/ast-spec/src/expression/NewExpression/spec.ts
index 51aea284158..de45a835764 100644
--- a/packages/ast-spec/src/expression/NewExpression/spec.ts
+++ b/packages/ast-spec/src/expression/NewExpression/spec.ts
@@ -2,11 +2,11 @@ import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec';
import type { CallExpressionArgument } from '../../unions/CallExpressionArgument';
-import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression';
+import type { Expression } from '../../unions/Expression';
export interface NewExpression extends BaseNode {
type: AST_NODE_TYPES.NewExpression;
- callee: LeftHandSideExpression;
+ callee: Expression;
arguments: CallExpressionArgument[];
typeArguments: TSTypeParameterInstantiation | undefined;
diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/spec.ts b/packages/ast-spec/src/expression/TaggedTemplateExpression/spec.ts
index b673ca5f0db..2e2d77e68db 100644
--- a/packages/ast-spec/src/expression/TaggedTemplateExpression/spec.ts
+++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/spec.ts
@@ -1,7 +1,7 @@
import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
import type { TSTypeParameterInstantiation } from '../../special/TSTypeParameterInstantiation/spec';
-import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression';
+import type { Expression } from '../../unions/Expression';
import type { TemplateLiteral } from '../TemplateLiteral/spec';
export interface TaggedTemplateExpression extends BaseNode {
@@ -11,6 +11,6 @@ export interface TaggedTemplateExpression extends BaseNode {
/** @deprecated Use {@link `typeArguments`} instead. */
typeParameters: TSTypeParameterInstantiation | undefined;
- tag: LeftHandSideExpression;
+ tag: Expression;
quasi: TemplateLiteral;
}
diff --git a/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts b/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts
index 1efd283fd8c..debc2daff41 100644
--- a/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts
+++ b/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts
@@ -1,9 +1,8 @@
import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
-import type { Expression } from '../../unions/Expression';
+import type { StringLiteral } from '../../expression/literal/StringLiteral/spec';
export interface TSExternalModuleReference extends BaseNode {
type: AST_NODE_TYPES.TSExternalModuleReference;
- // TODO(#1852) - this must be a string
- expression: Expression;
+ expression: StringLiteral;
}
diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot
index 40921644512..fe7cf666fec 100644
--- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot
+++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot
@@ -56,8 +56,9 @@ exports[`AST Fixtures List fixtures with AST differences 1`] = `
"declaration/ImportDeclaration/fixtures/named-none/fixture.ts",
"declaration/ImportDeclaration/fixtures/named-one/fixture.ts",
"declaration/ImportDeclaration/fixtures/side-effect/fixture.ts",
+ "declaration/TSDeclareFunction/fixtures/async-ambient/fixture.ts",
+ "declaration/TSDeclareFunction/fixtures/async-overload/fixture.ts",
"declaration/TSDeclareFunction/fixtures/empty/fixture.ts",
- "declaration/TSDeclareFunction/fixtures/generator/fixture.ts",
"declaration/TSDeclareFunction/fixtures/param-many/fixture.ts",
"declaration/TSDeclareFunction/fixtures/param-one/fixture.ts",
"declaration/TSDeclareFunction/fixtures/returnType/fixture.ts",
diff --git a/packages/ast-spec/tests/fixtures-with-differences-errors.shot b/packages/ast-spec/tests/fixtures-with-differences-errors.shot
index 3baa5a85efc..76663a6ec6c 100644
--- a/packages/ast-spec/tests/fixtures-with-differences-errors.shot
+++ b/packages/ast-spec/tests/fixtures-with-differences-errors.shot
@@ -8,10 +8,7 @@ exports[`AST Fixtures List fixtures with Error differences 1`] = `
"declaration/ClassDeclaration/fixtures/_error_/missing-type-param/fixture.ts",
"declaration/ExportNamedDeclaration/fixtures/_error_/assertion/fixture.ts",
"declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/fixture.ts",
- "declaration/TSDeclareFunction/fixtures/_error_/async/fixture.ts",
- "declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/fixture.ts",
"declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/fixture.ts",
- "declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/fixture.ts",
"declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/fixture.ts",
"declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/fixture.ts",
"declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/fixture.ts",
@@ -49,6 +46,9 @@ exports[`AST Fixtures List fixtures with Error differences 1`] = `
"TSESTree errored but Babel didn't": [
"declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/fixture.ts",
"declaration/ExportNamedDeclaration/fixtures/_error_/aliased-literal/fixture.ts",
+ "declaration/TSDeclareFunction/fixtures/_error_/generator-ambient/fixture.ts",
+ "declaration/TSDeclareFunction/fixtures/_error_/generator-overload/fixture.ts",
+ "declaration/TSDeclareFunction/fixtures/_error_/generator/fixture.ts",
"element/AccessorProperty/fixtures/_error_/modifier-abstract-accessor-with-value/fixture.ts",
"legacy-fixtures/basics/fixtures/_error_/abstract-class-with-abstract-constructor/fixture.ts",
"legacy-fixtures/expressions/fixtures/_error_/instantiation-expression/fixture.ts",
diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md
index c4ba9b251b4..bf0d09df6a6 100644
--- a/packages/eslint-plugin-internal/CHANGELOG.md
+++ b/packages/eslint-plugin-internal/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for eslint-plugin-internal to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for eslint-plugin-internal to align it with other projects, there were no code changes.
diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json
index 8e787cb8719..2745f488f42 100644
--- a/packages/eslint-plugin-internal/package.json
+++ b/packages/eslint-plugin-internal/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin-internal",
- "version": "7.11.0",
+ "version": "7.12.0",
"private": true,
"main": "dist/index.js",
"types": "index.d.ts",
@@ -15,10 +15,10 @@
},
"dependencies": {
"@prettier/sync": "^0.5.1",
- "@typescript-eslint/rule-tester": "7.11.0",
- "@typescript-eslint/scope-manager": "7.11.0",
- "@typescript-eslint/type-utils": "7.11.0",
- "@typescript-eslint/utils": "7.11.0",
+ "@typescript-eslint/rule-tester": "7.12.0",
+ "@typescript-eslint/scope-manager": "7.12.0",
+ "@typescript-eslint/type-utils": "7.12.0",
+ "@typescript-eslint/utils": "7.12.0",
"prettier": "^3.2.5"
},
"devDependencies": {
diff --git a/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts b/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts
index 8ee08569518..e9cb7e31d9d 100644
--- a/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts
+++ b/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts
@@ -1,5 +1,4 @@
import type { TSESTree } from '@typescript-eslint/utils';
-import { AST_NODE_TYPES } from '@typescript-eslint/utils';
import { createRule } from '../util';
@@ -62,10 +61,7 @@ export default createRule({
node: TSESTree.TSExternalModuleReference,
): void {
const parent = node.parent as TSESTree.TSImportEqualsDeclaration;
- if (
- node.expression.type === AST_NODE_TYPES.Literal &&
- node.expression.value === 'typescript'
- ) {
+ if (node.expression.value === 'typescript') {
context.report({
node,
messageId: 'noTSDefaultImport',
diff --git a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts
index 6c0f716d79e..20a40146528 100644
--- a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts
+++ b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts
@@ -426,9 +426,7 @@ export default createRule({
}
}
- function isNoFormatTemplateTag(
- tag: TSESTree.LeftHandSideExpression,
- ): boolean {
+ function isNoFormatTemplateTag(tag: TSESTree.Expression): boolean {
return tag.type === AST_NODE_TYPES.Identifier && tag.name === 'noFormat';
}
diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md
index 6c65e67d996..63eee80759e 100644
--- a/packages/eslint-plugin/CHANGELOG.md
+++ b/packages/eslint-plugin/CHANGELOG.md
@@ -1,3 +1,47 @@
+## 7.12.0 (2024-06-03)
+
+
+### 🚀 Features
+
+- **eslint-plugin:** [no-useless-template-literals] rename to `no-useless-template-expression` (deprecate `no-useless-template-literals`)
+
+- **rule-tester:** check for parsing errors in suggestion fixes
+
+- **rule-tester:** port `checkDuplicateTestCases` from ESLint
+
+- **eslint-plugin:** [no-floating-promises] add option 'allowForKnownSafePromises'
+
+
+### 🩹 Fixes
+
+- no-useless-template-expression -> no-unnecessary-template-expression
+
+- **eslint-plugin:** [no-unnecessary-type-assertion] combine template literal check with `const` variable check
+
+- **eslint-plugin:** [dot-notation] fix false positive when accessing private/protected property with optional chaining
+
+- **eslint-plugin:** [explicit-member-accessibility] refine report locations
+
+- **eslint-plugin:** [no-unnecessary-type-assertion] declares are always defined, so always check `declare`s
+
+- **eslint-plugin:** [prefer-literal-enum-member] allow using member it self on allowBitwiseExpressions
+
+- **eslint-plugin:** [return-await] clean up in-try-catch detection and make autofixes safe
+
+- **eslint-plugin:** [member-ordering] also TSMethodSignature can be get/set
+
+
+### ❤️ Thank You
+
+- Abraham Guo
+- Han Yeong-woo
+- Joshua Chen
+- Kim Sang Du
+- Kirk Waiblinger
+- YeonJuan
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
diff --git a/packages/eslint-plugin/docs/rules/no-unused-expressions.mdx b/packages/eslint-plugin/docs/rules/no-unused-expressions.mdx
index 2f0805ba8de..8d185e92c08 100644
--- a/packages/eslint-plugin/docs/rules/no-unused-expressions.mdx
+++ b/packages/eslint-plugin/docs/rules/no-unused-expressions.mdx
@@ -10,4 +10,44 @@ import TabItem from '@theme/TabItem';
> See **https://typescript-eslint.io/rules/no-unused-expressions** for documentation.
This rule extends the base [`eslint/no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions) rule.
-It adds support for optional call expressions `x?.()`, and directive in module declarations.
+It supports TypeScript-specific expressions:
+
+- Marks directives in modules declarations (`"use strict"`, etc.) as not unused
+- Marks the following expressions as unused if their wrapped value expressions are unused:
+ - Assertion expressions: `x as number;`, `x!;`, `x;`
+ - Instantiation expressions: `Set;`
+
+Although the type expressions never have runtime side effects (that is, `x!;` is the same as `x;`), they can be used to assert types for testing purposes.
+
+## Examples
+
+
+
+
+```ts
+Set;
+1 as number;
+window!;
+```
+
+
+
+
+```ts
+function getSet() {
+ return Set;
+}
+
+// Funtion calls are allowed, so type expressions that wrap function calls are allowed
+getSet();
+getSet() as Set;
+getSet()!;
+
+// Namespaces can have directives
+namespace A {
+ 'use strict';
+}
+```
+
+
+
diff --git a/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.mdx b/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.mdx
new file mode 100644
index 00000000000..d8224c93c80
--- /dev/null
+++ b/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.mdx
@@ -0,0 +1,12 @@
+:::danger Deprecated
+
+This rule has been renamed to [`sort-type-constituents`](https://typescript-eslint.io/rules/sort-type-constituents).
+
+:::
+
+
diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json
index c173d9d653d..8bfee8c370b 100644
--- a/packages/eslint-plugin/package.json
+++ b/packages/eslint-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "TypeScript plugin for ESLint",
"files": [
"dist",
@@ -62,10 +62,10 @@
},
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
- "@typescript-eslint/scope-manager": "7.11.0",
- "@typescript-eslint/type-utils": "7.11.0",
- "@typescript-eslint/utils": "7.11.0",
- "@typescript-eslint/visitor-keys": "7.11.0",
+ "@typescript-eslint/scope-manager": "7.12.0",
+ "@typescript-eslint/type-utils": "7.12.0",
+ "@typescript-eslint/utils": "7.12.0",
+ "@typescript-eslint/visitor-keys": "7.12.0",
"graphemer": "^1.4.0",
"ignore": "^5.3.1",
"natural-compare": "^1.4.0",
@@ -76,8 +76,8 @@
"@types/marked": "^5.0.2",
"@types/mdast": "^4.0.3",
"@types/natural-compare": "*",
- "@typescript-eslint/rule-schema-to-typescript-types": "7.11.0",
- "@typescript-eslint/rule-tester": "7.11.0",
+ "@typescript-eslint/rule-schema-to-typescript-types": "7.12.0",
+ "@typescript-eslint/rule-tester": "7.12.0",
"ajv": "^6.12.6",
"cross-env": "^7.0.3",
"cross-fetch": "*",
diff --git a/packages/eslint-plugin/src/configs/all.ts b/packages/eslint-plugin/src/configs/all.ts
index cec571866d6..8c79ae1e33f 100644
--- a/packages/eslint-plugin/src/configs/all.ts
+++ b/packages/eslint-plugin/src/configs/all.ts
@@ -93,6 +93,7 @@ export = {
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
+ '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
@@ -113,7 +114,6 @@ export = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
- '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'no-throw-literal': 'off',
diff --git a/packages/eslint-plugin/src/configs/disable-type-checked.ts b/packages/eslint-plugin/src/configs/disable-type-checked.ts
index 830b5e1c0b1..8e47f9688d7 100644
--- a/packages/eslint-plugin/src/configs/disable-type-checked.ts
+++ b/packages/eslint-plugin/src/configs/disable-type-checked.ts
@@ -30,6 +30,7 @@ export = {
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unnecessary-qualifier': 'off',
+ '@typescript-eslint/no-unnecessary-template-expression': 'off',
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
@@ -39,7 +40,6 @@ export = {
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',
- '@typescript-eslint/no-unnecessary-template-expression': 'off',
'@typescript-eslint/no-useless-template-literals': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/only-throw-error': 'off',
diff --git a/packages/eslint-plugin/src/configs/strict-type-checked-only.ts b/packages/eslint-plugin/src/configs/strict-type-checked-only.ts
index 9d0caad2ef1..a17bc16c257 100644
--- a/packages/eslint-plugin/src/configs/strict-type-checked-only.ts
+++ b/packages/eslint-plugin/src/configs/strict-type-checked-only.ts
@@ -25,6 +25,7 @@ export = {
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
+ '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
@@ -33,7 +34,6 @@ export = {
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
- '@typescript-eslint/no-unnecessary-template-expression': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/prefer-includes': 'error',
diff --git a/packages/eslint-plugin/src/configs/strict-type-checked.ts b/packages/eslint-plugin/src/configs/strict-type-checked.ts
index 2cab2b5c561..cdce2e4962b 100644
--- a/packages/eslint-plugin/src/configs/strict-type-checked.ts
+++ b/packages/eslint-plugin/src/configs/strict-type-checked.ts
@@ -46,6 +46,7 @@ export = {
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
+ '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
@@ -60,7 +61,6 @@ export = {
'@typescript-eslint/no-unused-vars': 'error',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
- '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-var-requires': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
diff --git a/packages/eslint-plugin/src/rules/init-declarations.ts b/packages/eslint-plugin/src/rules/init-declarations.ts
index fabbe73898a..4debac89cb2 100644
--- a/packages/eslint-plugin/src/rules/init-declarations.ts
+++ b/packages/eslint-plugin/src/rules/init-declarations.ts
@@ -28,7 +28,51 @@ export default createRule({
},
defaultOptions: ['always'],
create(context, [mode]) {
- const rules = baseRule.create(context);
+ // Make a custom context to adjust the the loc of reports where the base
+ // rule's behavior is a bit too aggressive with TS-specific syntax (namely,
+ // type annotations).
+ function getBaseContextOverride(): typeof context {
+ const reportOverride: typeof context.report = descriptor => {
+ if ('node' in descriptor && descriptor.loc == null) {
+ const { node, ...rest } = descriptor;
+ // We only want to special case the report loc when reporting on
+ // variables declarations that are not initialized. Declarations that
+ // _are_ initialized get reported by the base rule due to a setting to
+ // prohibit initializing variables entirely, in which case underlining
+ // the whole node including the type annotation and initializer is
+ // appropriate.
+ if (
+ node.type === AST_NODE_TYPES.VariableDeclarator &&
+ node.init == null
+ ) {
+ context.report({
+ ...rest,
+ loc: getReportLoc(node),
+ });
+ return;
+ }
+ }
+
+ context.report(descriptor);
+ };
+
+ // `return { ...context, report: reportOverride }` isn't safe because the
+ // `context` object has some getters that need to be preserved.
+ //
+ // `return new Proxy(context, ...)` doesn't work because `context` has
+ // non-configurable properties that throw when constructing a Proxy.
+ //
+ // So, we'll just use Proxy on a dummy object and use the `get` trap to
+ // proxy `context`'s properties.
+ return new Proxy({} as typeof context, {
+ get: (target, prop, receiver): unknown =>
+ prop === 'report'
+ ? reportOverride
+ : Reflect.get(context, prop, receiver),
+ });
+ }
+
+ const rules = baseRule.create(getBaseContextOverride());
return {
'VariableDeclaration:exit'(node: TSESTree.VariableDeclaration): void {
@@ -65,3 +109,26 @@ export default createRule({
}
},
});
+
+/**
+ * When reporting an uninitialized variable declarator, get the loc excluding
+ * the type annotation.
+ */
+function getReportLoc(
+ node: TSESTree.VariableDeclarator,
+): TSESTree.SourceLocation {
+ const start: TSESTree.Position = structuredClone(node.loc.start);
+ const end: TSESTree.Position = {
+ line: node.loc.start.line,
+ // `if (id.type === AST_NODE_TYPES.Identifier)` is a condition for
+ // reporting in the base rule (as opposed to things like destructuring
+ // assignment), so the type assertion should always be valid.
+ column:
+ node.loc.start.column + (node.id as TSESTree.Identifier).name.length,
+ };
+
+ return {
+ start,
+ end,
+ };
+}
diff --git a/packages/eslint-plugin/src/rules/no-implied-eval.ts b/packages/eslint-plugin/src/rules/no-implied-eval.ts
index de2e0574929..dee23d62d27 100644
--- a/packages/eslint-plugin/src/rules/no-implied-eval.ts
+++ b/packages/eslint-plugin/src/rules/no-implied-eval.ts
@@ -36,9 +36,7 @@ export default createRule({
const services = getParserServices(context);
const checker = services.program.getTypeChecker();
- function getCalleeName(
- node: TSESTree.LeftHandSideExpression,
- ): string | null {
+ function getCalleeName(node: TSESTree.Expression): string | null {
if (node.type === AST_NODE_TYPES.Identifier) {
return node.name;
}
diff --git a/packages/eslint-plugin/src/rules/no-restricted-imports.ts b/packages/eslint-plugin/src/rules/no-restricted-imports.ts
index b1e2d229f6a..1bd052ab333 100644
--- a/packages/eslint-plugin/src/rules/no-restricted-imports.ts
+++ b/packages/eslint-plugin/src/rules/no-restricted-imports.ts
@@ -312,10 +312,7 @@ export default createRule({
node: TSESTree.TSImportEqualsDeclaration,
): void {
if (
- node.moduleReference.type ===
- AST_NODE_TYPES.TSExternalModuleReference &&
- node.moduleReference.expression.type === AST_NODE_TYPES.Literal &&
- typeof node.moduleReference.expression.value === 'string'
+ node.moduleReference.type === AST_NODE_TYPES.TSExternalModuleReference
) {
const synthesizedImport = {
...node,
diff --git a/packages/eslint-plugin/src/rules/no-unsafe-argument.ts b/packages/eslint-plugin/src/rules/no-unsafe-argument.ts
index d55d8f75b06..08950fa8d73 100644
--- a/packages/eslint-plugin/src/rules/no-unsafe-argument.ts
+++ b/packages/eslint-plugin/src/rules/no-unsafe-argument.ts
@@ -165,7 +165,7 @@ export default createRule<[], MessageIds>({
function checkUnsafeArguments(
args: TSESTree.Expression[] | TSESTree.CallExpressionArgument[],
- callee: TSESTree.LeftHandSideExpression,
+ callee: TSESTree.Expression,
node:
| TSESTree.CallExpression
| TSESTree.NewExpression
diff --git a/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-unused-expressions.shot b/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-unused-expressions.shot
new file mode 100644
index 00000000000..f0f2802b58a
--- /dev/null
+++ b/packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-unused-expressions.shot
@@ -0,0 +1,32 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Validating rule docs no-unused-expressions.mdx code examples ESLint output 1`] = `
+"Incorrect
+
+Set;
+~~~~~~~~~~~~ Expected an assignment or function call and instead saw an expression.
+1 as number;
+~~~~~~~~~~~~ Expected an assignment or function call and instead saw an expression.
+window!;
+~~~~~~~~ Expected an assignment or function call and instead saw an expression.
+"
+`;
+
+exports[`Validating rule docs no-unused-expressions.mdx code examples ESLint output 2`] = `
+"Correct
+
+function getSet() {
+ return Set;
+}
+
+// Funtion calls are allowed, so type expressions that wrap function calls are allowed
+getSet();
+getSet() as Set;
+getSet()!;
+
+// Namespaces can have directives
+namespace A {
+ 'use strict';
+}
+"
+`;
diff --git a/packages/eslint-plugin/tests/docs.test.ts b/packages/eslint-plugin/tests/docs.test.ts
index c3f08de4bbd..5011f902dab 100644
--- a/packages/eslint-plugin/tests/docs.test.ts
+++ b/packages/eslint-plugin/tests/docs.test.ts
@@ -133,6 +133,7 @@ describe('Validating rule docs', () => {
'camelcase.md',
'no-duplicate-imports.mdx',
'no-parameter-properties.mdx',
+ 'sort-type-union-intersection-members.mdx',
]);
const rulesWithComplexOptions = new Set(['array-type', 'member-ordering']);
diff --git a/packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts b/packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts
index 252b6fe2f32..a6ce89cc8d2 100644
--- a/packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts
+++ b/packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts
@@ -259,6 +259,11 @@ const obj = {
},
};
`,
+ `
+class Foo {
+ [x: string]: any;
+}
+ `,
],
invalid: [
{
@@ -396,5 +401,35 @@ function Foo() {}
},
],
},
+ {
+ code: `
+class Foo {
+ [x: Bar]: string;
+}
+ `,
+ errors: [
+ {
+ messageId: 'undef',
+ data: {
+ name: 'Bar',
+ },
+ },
+ ],
+ },
+ {
+ code: `
+class Foo {
+ [x: string]: Bar;
+}
+ `,
+ errors: [
+ {
+ messageId: 'undef',
+ data: {
+ name: 'Bar',
+ },
+ },
+ ],
+ },
],
});
diff --git a/packages/eslint-plugin/tests/rules/consistent-return.test.ts b/packages/eslint-plugin/tests/rules/consistent-return.test.ts
index 1489b835d8b..cb74ca29b8c 100644
--- a/packages/eslint-plugin/tests/rules/consistent-return.test.ts
+++ b/packages/eslint-plugin/tests/rules/consistent-return.test.ts
@@ -380,7 +380,7 @@ ruleTester.run('consistent-return', rule, {
},
{
code: `
- declare async function bar(): Promise;
+ declare function bar(): Promise;
function foo(flag?: boolean): Promise {
if (flag) {
return bar();
diff --git a/packages/eslint-plugin/tests/rules/init-declarations.test.ts b/packages/eslint-plugin/tests/rules/init-declarations.test.ts
index f284cd10185..2667377b2a7 100644
--- a/packages/eslint-plugin/tests/rules/init-declarations.test.ts
+++ b/packages/eslint-plugin/tests/rules/init-declarations.test.ts
@@ -1,5 +1,4 @@
import { RuleTester } from '@typescript-eslint/rule-tester';
-import { AST_NODE_TYPES } from '@typescript-eslint/utils';
import rule from '../../src/rules/init-declarations';
@@ -381,7 +380,10 @@ declare namespace myLib1 {
{
messageId: 'initialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 8,
},
],
},
@@ -392,7 +394,10 @@ declare namespace myLib1 {
{
messageId: 'initialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 23,
+ endLine: 1,
+ endColumn: 26,
},
],
},
@@ -407,12 +412,18 @@ var foo,
{
messageId: 'initialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 2,
+ column: 5,
+ endLine: 2,
+ endColumn: 8,
},
{
messageId: 'initialized',
data: { idName: 'baz' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 4,
+ column: 3,
+ endLine: 4,
+ endColumn: 6,
},
],
},
@@ -428,7 +439,10 @@ function foo() {
{
messageId: 'initialized',
data: { idName: 'bar' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 4,
+ column: 7,
+ endLine: 4,
+ endColumn: 10,
},
],
},
@@ -444,7 +458,10 @@ function foo() {
{
messageId: 'initialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 3,
+ column: 7,
+ endLine: 3,
+ endColumn: 10,
},
],
},
@@ -455,7 +472,10 @@ function foo() {
{
messageId: 'initialized',
data: { idName: 'a' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 6,
},
],
},
@@ -475,7 +495,10 @@ function foo() {
{
messageId: 'initialized',
data: { idName: 'b' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 4,
+ column: 5,
+ endLine: 4,
+ endColumn: 6,
},
],
},
@@ -492,12 +515,18 @@ function foo() {
{
messageId: 'initialized',
data: { idName: 'a' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 3,
+ column: 7,
+ endLine: 3,
+ endColumn: 8,
},
{
messageId: 'initialized',
data: { idName: 'c' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 5,
+ column: 7,
+ endLine: 5,
+ endColumn: 8,
},
],
},
@@ -508,7 +537,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 20,
},
],
},
@@ -519,7 +551,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 15,
},
],
},
@@ -534,12 +569,18 @@ var foo,
{
messageId: 'notInitialized',
data: { idName: 'bar' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 3,
+ column: 3,
+ endLine: 3,
+ endColumn: 10,
},
{
messageId: 'notInitialized',
data: { idName: 'baz' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 4,
+ column: 3,
+ endLine: 4,
+ endColumn: 10,
},
],
},
@@ -555,8 +596,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'bar' },
-
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 4,
+ column: 7,
+ endLine: 4,
+ endColumn: 16,
},
],
},
@@ -567,7 +610,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'a' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 10,
},
],
},
@@ -586,7 +632,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'a' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 3,
+ column: 7,
+ endLine: 3,
+ endColumn: 16,
},
],
},
@@ -603,7 +652,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'c' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 5,
+ column: 7,
+ endLine: 5,
+ endColumn: 12,
},
],
},
@@ -614,7 +666,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'i' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 10,
+ endLine: 1,
+ endColumn: 15,
},
],
},
@@ -628,7 +683,10 @@ for (var foo in []) {
{
messageId: 'notInitialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 2,
+ column: 10,
+ endLine: 2,
+ endColumn: 13,
},
],
},
@@ -642,7 +700,10 @@ for (var foo of []) {
{
messageId: 'notInitialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 2,
+ column: 10,
+ endLine: 2,
+ endColumn: 13,
},
],
},
@@ -657,7 +718,10 @@ function foo() {
{
messageId: 'initialized',
data: { idName: 'bar' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 3,
+ column: 7,
+ endLine: 3,
+ endColumn: 10,
},
],
},
@@ -670,7 +734,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'arr' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 34,
},
],
},
@@ -681,7 +748,10 @@ function foo() {
{
messageId: 'notInitialized',
data: { idName: 'arr' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 33,
},
],
},
@@ -698,7 +768,10 @@ const class1 = class NAME {
{
messageId: 'notInitialized',
data: { idName: 'name1' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 4,
+ column: 9,
+ endLine: 4,
+ endColumn: 32,
},
],
},
@@ -709,7 +782,10 @@ const class1 = class NAME {
{
messageId: 'initialized',
data: { idName: 'arr' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 8,
},
],
},
@@ -720,7 +796,10 @@ const class1 = class NAME {
{
messageId: 'notInitialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 1,
+ column: 13,
+ endLine: 1,
+ endColumn: 32,
},
],
},
@@ -735,7 +814,10 @@ namespace myLib {
{
messageId: 'initialized',
data: { idName: 'numberOfGreetings' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 3,
+ column: 7,
+ endLine: 3,
+ endColumn: 24,
},
],
},
@@ -750,7 +832,10 @@ namespace myLib {
{
messageId: 'notInitialized',
data: { idName: 'numberOfGreetings' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 3,
+ column: 7,
+ endLine: 3,
+ endColumn: 36,
},
],
},
@@ -771,17 +856,26 @@ namespace myLib1 {
{
messageId: 'initialized',
data: { idName: 'foo' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 3,
+ column: 9,
+ endLine: 3,
+ endColumn: 12,
},
{
messageId: 'initialized',
data: { idName: 'bar' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 5,
+ column: 9,
+ endLine: 5,
+ endColumn: 12,
},
{
messageId: 'initialized',
data: { idName: 'baz' },
- type: AST_NODE_TYPES.VariableDeclarator,
+ line: 7,
+ column: 11,
+ endLine: 7,
+ endColumn: 14,
},
],
},
diff --git a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts
index 85fa8450ad2..0f956df18c0 100644
--- a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts
+++ b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts
@@ -466,11 +466,11 @@ ruleTester.run('naming-convention', rule, {
{
const camelCaseVar = 1;
function camelCaseFunction() {}
- declare function camelCaseDeclaredFunction() {};
+ declare function camelCaseDeclaredFunction();
}
const PascalCaseVar = 1;
function PascalCaseFunction() {}
- declare function PascalCaseDeclaredFunction() {};
+ declare function PascalCaseDeclaredFunction();
`,
options: [
{ selector: 'default', format: ['camelCase'] },
@@ -1507,7 +1507,7 @@ ruleTester.run('naming-convention', rule, {
code: `
const PascalCaseVar = 1;
function PascalCaseFunction() {}
- declare function PascalCaseDeclaredFunction() {};
+ declare function PascalCaseDeclaredFunction();
`,
options: [
{ selector: 'default', format: ['snake_case'] },
diff --git a/packages/eslint-plugin/tests/rules/no-require-imports.test.ts b/packages/eslint-plugin/tests/rules/no-require-imports.test.ts
index bdfddbc25ae..49fe55f6de4 100644
--- a/packages/eslint-plugin/tests/rules/no-require-imports.test.ts
+++ b/packages/eslint-plugin/tests/rules/no-require-imports.test.ts
@@ -51,10 +51,6 @@ require('remark-preset-prettier');
code: "import pkg = require('some-package');",
options: [{ allow: ['^some-package$'] }],
},
- {
- code: 'import pkg = require(`some-package`);',
- options: [{ allow: ['^some-package$'] }],
- },
],
invalid: [
{
@@ -207,16 +203,5 @@ var lib5 = require?.('lib5'),
},
],
},
- {
- code: 'import pkg = require(`./package.json`);',
- options: [{ allow: ['^some-package$'] }],
- errors: [
- {
- line: 1,
- column: 14,
- messageId: 'noRequireImports',
- },
- ],
- },
],
});
diff --git a/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts b/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts
index c810f351c0a..364d8fbdf14 100644
--- a/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts
+++ b/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts
@@ -689,6 +689,18 @@ export type T = {
};
`,
`
+type Foo = string;
+export class Bar {
+ [x: Foo]: any;
+}
+ `,
+ `
+type Foo = string;
+export class Bar {
+ [x: Foo]: Foo;
+}
+ `,
+ `
namespace Foo {
export const Foo = 1;
}
diff --git a/packages/integration-tests/CHANGELOG.md b/packages/integration-tests/CHANGELOG.md
index aa81dfe8a09..aeb991866e7 100644
--- a/packages/integration-tests/CHANGELOG.md
+++ b/packages/integration-tests/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for integration-tests to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for integration-tests to align it with other projects, there were no code changes.
diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json
index f25227eacdf..266414ccc2d 100644
--- a/packages/integration-tests/package.json
+++ b/packages/integration-tests/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/integration-tests",
- "version": "7.11.0",
+ "version": "7.12.0",
"private": true,
"scripts": {
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md
index 7e2bb33ed1c..3bbfd8511c8 100644
--- a/packages/parser/CHANGELOG.md
+++ b/packages/parser/CHANGELOG.md
@@ -1,3 +1,22 @@
+## 7.12.0 (2024-06-03)
+
+
+### 🩹 Fixes
+
+- **types:** correct typing ParserOptions
+
+
+### ❤️ Thank You
+
+- Abraham Guo
+- Han Yeong-woo
+- Joshua Chen
+- Kim Sang Du
+- Kirk Waiblinger
+- YeonJuan
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for parser to align it with other projects, there were no code changes.
diff --git a/packages/parser/package.json b/packages/parser/package.json
index 7c72a1d0ce7..315b2521ce2 100644
--- a/packages/parser/package.json
+++ b/packages/parser/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/parser",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "An ESLint custom parser which leverages TypeScript ESTree",
"files": [
"dist",
@@ -52,10 +52,10 @@
"eslint": "^8.56.0"
},
"dependencies": {
- "@typescript-eslint/scope-manager": "7.11.0",
- "@typescript-eslint/types": "7.11.0",
- "@typescript-eslint/typescript-estree": "7.11.0",
- "@typescript-eslint/visitor-keys": "7.11.0",
+ "@typescript-eslint/scope-manager": "7.12.0",
+ "@typescript-eslint/types": "7.12.0",
+ "@typescript-eslint/typescript-estree": "7.12.0",
+ "@typescript-eslint/visitor-keys": "7.12.0",
"debug": "^4.3.4"
},
"devDependencies": {
diff --git a/packages/repo-tools/CHANGELOG.md b/packages/repo-tools/CHANGELOG.md
index 3381b3f40e1..6e50941f430 100644
--- a/packages/repo-tools/CHANGELOG.md
+++ b/packages/repo-tools/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for repo-tools to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for repo-tools to align it with other projects, there were no code changes.
diff --git a/packages/repo-tools/package.json b/packages/repo-tools/package.json
index 59932d66d58..d1155a5dc1b 100644
--- a/packages/repo-tools/package.json
+++ b/packages/repo-tools/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/repo-tools",
- "version": "7.11.0",
+ "version": "7.12.0",
"private": true,
"//": "NOTE: intentionally no build step in this package",
"scripts": {
@@ -18,11 +18,11 @@
"devDependencies": {
"@jest/types": "29.6.3",
"@nx/devkit": "*",
- "@typescript-eslint/eslint-plugin": "7.11.0",
- "@typescript-eslint/scope-manager": "7.11.0",
- "@typescript-eslint/types": "7.11.0",
- "@typescript-eslint/typescript-estree": "7.11.0",
- "@typescript-eslint/utils": "7.11.0",
+ "@typescript-eslint/eslint-plugin": "7.12.0",
+ "@typescript-eslint/scope-manager": "7.12.0",
+ "@typescript-eslint/types": "7.12.0",
+ "@typescript-eslint/typescript-estree": "7.12.0",
+ "@typescript-eslint/utils": "7.12.0",
"cross-fetch": "*",
"execa": "*",
"prettier": "^3.2.5",
diff --git a/packages/rule-schema-to-typescript-types/CHANGELOG.md b/packages/rule-schema-to-typescript-types/CHANGELOG.md
index d3353278b7d..3efe089ac8f 100644
--- a/packages/rule-schema-to-typescript-types/CHANGELOG.md
+++ b/packages/rule-schema-to-typescript-types/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for rule-schema-to-typescript-types to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for rule-schema-to-typescript-types to align it with other projects, there were no code changes.
diff --git a/packages/rule-schema-to-typescript-types/package.json b/packages/rule-schema-to-typescript-types/package.json
index d116a7cef0d..c4ebd736f08 100644
--- a/packages/rule-schema-to-typescript-types/package.json
+++ b/packages/rule-schema-to-typescript-types/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/rule-schema-to-typescript-types",
- "version": "7.11.0",
+ "version": "7.12.0",
"private": true,
"type": "commonjs",
"exports": {
@@ -34,8 +34,8 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
- "@typescript-eslint/type-utils": "7.11.0",
- "@typescript-eslint/utils": "7.11.0",
+ "@typescript-eslint/type-utils": "7.12.0",
+ "@typescript-eslint/utils": "7.12.0",
"natural-compare": "^1.4.0",
"prettier": "^3.2.5"
},
diff --git a/packages/rule-tester/CHANGELOG.md b/packages/rule-tester/CHANGELOG.md
index e3267893489..be6f45e9b9d 100644
--- a/packages/rule-tester/CHANGELOG.md
+++ b/packages/rule-tester/CHANGELOG.md
@@ -1,3 +1,24 @@
+## 7.12.0 (2024-06-03)
+
+
+### 🚀 Features
+
+- **rule-tester:** check for parsing errors in suggestion fixes
+
+- **rule-tester:** port `checkDuplicateTestCases` from ESLint
+
+
+### ❤️ Thank You
+
+- Abraham Guo
+- Han Yeong-woo
+- Joshua Chen
+- Kim Sang Du
+- Kirk Waiblinger
+- YeonJuan
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for rule-tester to align it with other projects, there were no code changes.
diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json
index 76c51382d89..6c74f3a2079 100644
--- a/packages/rule-tester/package.json
+++ b/packages/rule-tester/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/rule-tester",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "Tooling to test ESLint rules",
"files": [
"dist",
@@ -48,8 +48,8 @@
},
"//": "NOTE - AJV is out-of-date, but it's intentionally synced with ESLint - https://github.com/eslint/eslint/blob/ad9dd6a933fd098a0d99c6a9aa059850535c23ee/package.json#L70",
"dependencies": {
- "@typescript-eslint/typescript-estree": "7.11.0",
- "@typescript-eslint/utils": "7.11.0",
+ "@typescript-eslint/typescript-estree": "7.12.0",
+ "@typescript-eslint/utils": "7.12.0",
"ajv": "^6.12.6",
"json-stable-stringify-without-jsonify": "^1.0.1",
"lodash.merge": "4.6.2",
@@ -63,7 +63,7 @@
"@jest/types": "29.6.3",
"@types/json-stable-stringify-without-jsonify": "^1.0.2",
"@types/lodash.merge": "4.6.9",
- "@typescript-eslint/parser": "7.11.0",
+ "@typescript-eslint/parser": "7.12.0",
"chai": "^4.4.1",
"eslint-visitor-keys": "^4.0.0",
"espree": "^10.0.1",
diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md
index 8a5ca9398c2..54ddaa579e3 100644
--- a/packages/scope-manager/CHANGELOG.md
+++ b/packages/scope-manager/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for scope-manager to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for scope-manager to align it with other projects, there were no code changes.
diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json
index 466f183f8b6..edf542e4013 100644
--- a/packages/scope-manager/package.json
+++ b/packages/scope-manager/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/scope-manager",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "TypeScript scope analyser for ESLint",
"files": [
"dist",
@@ -46,13 +46,13 @@
"typecheck": "npx nx typecheck"
},
"dependencies": {
- "@typescript-eslint/types": "7.11.0",
- "@typescript-eslint/visitor-keys": "7.11.0"
+ "@typescript-eslint/types": "7.12.0",
+ "@typescript-eslint/visitor-keys": "7.12.0"
},
"devDependencies": {
"@jest/types": "29.6.3",
"@types/glob": "*",
- "@typescript-eslint/typescript-estree": "7.11.0",
+ "@typescript-eslint/typescript-estree": "7.12.0",
"glob": "*",
"jest-specific-snapshot": "*",
"make-dir": "*",
diff --git a/packages/scope-manager/src/referencer/ClassVisitor.ts b/packages/scope-manager/src/referencer/ClassVisitor.ts
index 94cb7ab5981..cf5d7022b25 100644
--- a/packages/scope-manager/src/referencer/ClassVisitor.ts
+++ b/packages/scope-manager/src/referencer/ClassVisitor.ts
@@ -320,6 +320,10 @@ class ClassVisitor extends Visitor {
// intentionally skip
}
+ protected TSIndexSignature(node: TSESTree.TSIndexSignature): void {
+ this.visitType(node);
+ }
+
protected StaticBlock(node: TSESTree.StaticBlock): void {
this.#referencer.scopeManager.nestClassStaticBlockScope(node);
diff --git a/packages/scope-manager/tests/fixtures/class/declaration/index-signature.ts b/packages/scope-manager/tests/fixtures/class/declaration/index-signature.ts
new file mode 100644
index 00000000000..64b3581b128
--- /dev/null
+++ b/packages/scope-manager/tests/fixtures/class/declaration/index-signature.ts
@@ -0,0 +1,7 @@
+type Bar = number;
+
+class Foo {
+ [x: string]: any;
+ [y: Bar]: string;
+ [z: symbol]: Foo;
+}
diff --git a/packages/scope-manager/tests/fixtures/class/declaration/index-signature.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/index-signature.ts.shot
new file mode 100644
index 00000000000..52fa3c5480e
--- /dev/null
+++ b/packages/scope-manager/tests/fixtures/class/declaration/index-signature.ts.shot
@@ -0,0 +1,98 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`class declaration index-signature 1`] = `
+ScopeManager {
+ variables: [
+ ImplicitGlobalConstTypeVariable,
+ Variable$2 {
+ defs: [
+ TypeDefinition$1 {
+ name: Identifier<"Bar">,
+ node: TSTypeAliasDeclaration$1,
+ },
+ ],
+ name: "Bar",
+ references: [
+ Reference$1 {
+ identifier: Identifier<"Bar">,
+ isRead: true,
+ isTypeReference: true,
+ isValueReference: false,
+ isWrite: false,
+ resolved: Variable$2,
+ },
+ ],
+ isValueVariable: false,
+ isTypeVariable: true,
+ },
+ Variable$3 {
+ defs: [
+ ClassNameDefinition$2 {
+ name: Identifier<"Foo">,
+ node: ClassDeclaration$2,
+ },
+ ],
+ name: "Foo",
+ references: [],
+ isValueVariable: true,
+ isTypeVariable: true,
+ },
+ Variable$4 {
+ defs: [
+ ClassNameDefinition$3 {
+ name: Identifier<"Foo">,
+ node: ClassDeclaration$2,
+ },
+ ],
+ name: "Foo",
+ references: [
+ Reference$2 {
+ identifier: Identifier<"Foo">,
+ isRead: true,
+ isTypeReference: true,
+ isValueReference: false,
+ isWrite: false,
+ resolved: Variable$4,
+ },
+ ],
+ isValueVariable: true,
+ isTypeVariable: true,
+ },
+ ],
+ scopes: [
+ GlobalScope$1 {
+ block: Program$3,
+ isStrict: false,
+ references: [],
+ set: Map {
+ "const" => ImplicitGlobalConstTypeVariable,
+ "Bar" => Variable$2,
+ "Foo" => Variable$3,
+ },
+ type: "global",
+ upper: null,
+ variables: [
+ ImplicitGlobalConstTypeVariable,
+ Variable$2,
+ Variable$3,
+ ],
+ },
+ ClassScope$2 {
+ block: ClassDeclaration$2,
+ isStrict: true,
+ references: [
+ Reference$1,
+ Reference$2,
+ ],
+ set: Map {
+ "Foo" => Variable$4,
+ },
+ type: "class",
+ upper: GlobalScope$1,
+ variables: [
+ Variable$4,
+ ],
+ },
+ ],
+}
+`;
diff --git a/packages/type-utils/CHANGELOG.md b/packages/type-utils/CHANGELOG.md
index 9215f93324f..9aa65def32e 100644
--- a/packages/type-utils/CHANGELOG.md
+++ b/packages/type-utils/CHANGELOG.md
@@ -1,3 +1,22 @@
+## 7.12.0 (2024-06-03)
+
+
+### 🚀 Features
+
+- **eslint-plugin:** [no-floating-promises] add option 'allowForKnownSafePromises'
+
+
+### ❤️ Thank You
+
+- Abraham Guo
+- Han Yeong-woo
+- Joshua Chen
+- Kim Sang Du
+- Kirk Waiblinger
+- YeonJuan
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for type-utils to align it with other projects, there were no code changes.
diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json
index e3663697b57..b6990c73cc4 100644
--- a/packages/type-utils/package.json
+++ b/packages/type-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/type-utils",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "Type utilities for working with TypeScript + ESLint together",
"files": [
"dist",
@@ -46,14 +46,14 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
- "@typescript-eslint/typescript-estree": "7.11.0",
- "@typescript-eslint/utils": "7.11.0",
+ "@typescript-eslint/typescript-estree": "7.12.0",
+ "@typescript-eslint/utils": "7.12.0",
"debug": "^4.3.4",
"ts-api-utils": "^1.3.0"
},
"devDependencies": {
"@jest/types": "29.6.3",
- "@typescript-eslint/parser": "7.11.0",
+ "@typescript-eslint/parser": "7.12.0",
"ajv": "^6.12.6",
"downlevel-dts": "*",
"jest": "29.7.0",
diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md
index eb16e586433..ee61d8e0315 100644
--- a/packages/types/CHANGELOG.md
+++ b/packages/types/CHANGELOG.md
@@ -1,3 +1,22 @@
+## 7.12.0 (2024-06-03)
+
+
+### 🩹 Fixes
+
+- **types:** correct typing ParserOptions
+
+
+### ❤️ Thank You
+
+- Abraham Guo
+- Han Yeong-woo
+- Joshua Chen
+- Kim Sang Du
+- Kirk Waiblinger
+- YeonJuan
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for types to align it with other projects, there were no code changes.
diff --git a/packages/types/package.json b/packages/types/package.json
index 10d1ba677c1..ea7d093fb57 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/types",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "Types for the TypeScript-ESTree AST spec",
"files": [
"dist",
diff --git a/packages/typescript-eslint/CHANGELOG.md b/packages/typescript-eslint/CHANGELOG.md
index f9dbda27dde..1c6cc5c0b95 100644
--- a/packages/typescript-eslint/CHANGELOG.md
+++ b/packages/typescript-eslint/CHANGELOG.md
@@ -1,3 +1,27 @@
+## 7.12.0 (2024-06-03)
+
+
+### 🚀 Features
+
+- **eslint-plugin:** [no-useless-template-literals] rename to `no-useless-template-expression` (deprecate `no-useless-template-literals`)
+
+
+### 🩹 Fixes
+
+- no-useless-template-expression -> no-unnecessary-template-expression
+
+
+### ❤️ Thank You
+
+- Abraham Guo
+- Han Yeong-woo
+- Joshua Chen
+- Kim Sang Du
+- Kirk Waiblinger
+- YeonJuan
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
diff --git a/packages/typescript-eslint/package.json b/packages/typescript-eslint/package.json
index 1e17ee07bc1..32ad3cda381 100644
--- a/packages/typescript-eslint/package.json
+++ b/packages/typescript-eslint/package.json
@@ -1,6 +1,6 @@
{
"name": "typescript-eslint",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "Tooling which enables you to use TypeScript with ESLint",
"files": [
"dist",
@@ -55,9 +55,9 @@
"eslint": "^8.56.0"
},
"dependencies": {
- "@typescript-eslint/eslint-plugin": "7.11.0",
- "@typescript-eslint/parser": "7.11.0",
- "@typescript-eslint/utils": "7.11.0"
+ "@typescript-eslint/eslint-plugin": "7.12.0",
+ "@typescript-eslint/parser": "7.12.0",
+ "@typescript-eslint/utils": "7.12.0"
},
"devDependencies": {
"@jest/types": "29.6.3",
diff --git a/packages/typescript-eslint/src/configs/all.ts b/packages/typescript-eslint/src/configs/all.ts
index 423ce0e03c9..ae180dee8c5 100644
--- a/packages/typescript-eslint/src/configs/all.ts
+++ b/packages/typescript-eslint/src/configs/all.ts
@@ -102,6 +102,7 @@ export default (
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
+ '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
@@ -122,7 +123,6 @@ export default (
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
- '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'no-throw-literal': 'off',
diff --git a/packages/typescript-eslint/src/configs/disable-type-checked.ts b/packages/typescript-eslint/src/configs/disable-type-checked.ts
index 6298e0cbe5d..3018fcabd9a 100644
--- a/packages/typescript-eslint/src/configs/disable-type-checked.ts
+++ b/packages/typescript-eslint/src/configs/disable-type-checked.ts
@@ -33,6 +33,7 @@ export default (
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unnecessary-qualifier': 'off',
+ '@typescript-eslint/no-unnecessary-template-expression': 'off',
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
@@ -42,7 +43,6 @@ export default (
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',
- '@typescript-eslint/no-unnecessary-template-expression': 'off',
'@typescript-eslint/no-useless-template-literals': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/only-throw-error': 'off',
diff --git a/packages/typescript-eslint/src/configs/strict-type-checked-only.ts b/packages/typescript-eslint/src/configs/strict-type-checked-only.ts
index 1ae371352e3..cd45ade64d2 100644
--- a/packages/typescript-eslint/src/configs/strict-type-checked-only.ts
+++ b/packages/typescript-eslint/src/configs/strict-type-checked-only.ts
@@ -34,6 +34,7 @@ export default (
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
+ '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
@@ -42,7 +43,6 @@ export default (
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
- '@typescript-eslint/no-unnecessary-template-expression': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/prefer-includes': 'error',
diff --git a/packages/typescript-eslint/src/configs/strict-type-checked.ts b/packages/typescript-eslint/src/configs/strict-type-checked.ts
index 840cfbe0db9..7aeb158346c 100644
--- a/packages/typescript-eslint/src/configs/strict-type-checked.ts
+++ b/packages/typescript-eslint/src/configs/strict-type-checked.ts
@@ -55,6 +55,7 @@ export default (
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
+ '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
@@ -69,7 +70,6 @@ export default (
'@typescript-eslint/no-unused-vars': 'error',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
- '@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-var-requires': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md
index 6a8e28c0e27..3658f869e8d 100644
--- a/packages/typescript-estree/CHANGELOG.md
+++ b/packages/typescript-estree/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for typescript-estree to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json
index 2a19bfc5bc3..6384bd898ce 100644
--- a/packages/typescript-estree/package.json
+++ b/packages/typescript-estree/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/typescript-estree",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "A parser that converts TypeScript source code into an ESTree compatible form",
"files": [
"dist",
@@ -54,8 +54,8 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
- "@typescript-eslint/types": "7.11.0",
- "@typescript-eslint/visitor-keys": "7.11.0",
+ "@typescript-eslint/types": "7.12.0",
+ "@typescript-eslint/visitor-keys": "7.12.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts
index 9d068cbf243..525f03481c3 100644
--- a/packages/typescript-estree/src/convert.ts
+++ b/packages/typescript-estree/src/convert.ts
@@ -963,19 +963,46 @@ export class Converter {
case SyntaxKind.FunctionDeclaration: {
const isDeclare = hasModifier(SyntaxKind.DeclareKeyword, node);
+ const isAsync = hasModifier(SyntaxKind.AsyncKeyword, node);
+ const isGenerator = !!node.asteriskToken;
+ if (isDeclare) {
+ if (node.body) {
+ this.#throwError(
+ node,
+ 'An implementation cannot be declared in ambient contexts.',
+ );
+ } else if (isAsync) {
+ this.#throwError(
+ node,
+ "'async' modifier cannot be used in an ambient context.",
+ );
+ } else if (isGenerator) {
+ this.#throwError(
+ node,
+ 'Generators are not allowed in an ambient context.',
+ );
+ }
+ } else {
+ if (!node.body && isGenerator) {
+ this.#throwError(
+ node,
+ 'A function signature cannot be declared as a generator.',
+ );
+ }
+ }
const result = this.createNode<
TSESTree.FunctionDeclaration | TSESTree.TSDeclareFunction
>(node, {
- type:
- isDeclare || !node.body
- ? AST_NODE_TYPES.TSDeclareFunction
- : AST_NODE_TYPES.FunctionDeclaration,
- async: hasModifier(SyntaxKind.AsyncKeyword, node),
+ // declare implies no body due to the invariant above
+ type: !node.body
+ ? AST_NODE_TYPES.TSDeclareFunction
+ : AST_NODE_TYPES.FunctionDeclaration,
+ async: isAsync,
body: this.convertChild(node.body) || undefined,
declare: isDeclare,
expression: false,
- generator: !!node.asteriskToken,
+ generator: isGenerator,
id: this.convertChild(node.name),
params: this.convertParameters(node.parameters),
returnType: node.type && this.convertTypeAnnotation(node.type, node),
@@ -3107,6 +3134,9 @@ export class Converter {
);
}
case SyntaxKind.ExternalModuleReference: {
+ if (node.expression.kind !== SyntaxKind.StringLiteral) {
+ this.#throwError(node.expression, 'String literal expected.');
+ }
return this.createNode(node, {
type: AST_NODE_TYPES.TSExternalModuleReference,
expression: this.convertChild(node.expression),
diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md
index 7ee741f15cb..e57bd8e2a1c 100644
--- a/packages/utils/CHANGELOG.md
+++ b/packages/utils/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for utils to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for utils to align it with other projects, there were no code changes.
diff --git a/packages/utils/package.json b/packages/utils/package.json
index 85853f7236b..333604db563 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/utils",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "Utilities for working with TypeScript + ESLint together",
"files": [
"dist",
@@ -68,9 +68,9 @@
},
"dependencies": {
"@eslint-community/eslint-utils": "^4.4.0",
- "@typescript-eslint/scope-manager": "7.11.0",
- "@typescript-eslint/types": "7.11.0",
- "@typescript-eslint/typescript-estree": "7.11.0"
+ "@typescript-eslint/scope-manager": "7.12.0",
+ "@typescript-eslint/types": "7.12.0",
+ "@typescript-eslint/typescript-estree": "7.12.0"
},
"peerDependencies": {
"eslint": "^8.56.0"
diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md
index 9dc56094f38..a657fdc03af 100644
--- a/packages/visitor-keys/CHANGELOG.md
+++ b/packages/visitor-keys/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for visitor-keys to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for visitor-keys to align it with other projects, there were no code changes.
diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json
index 26bf496b947..f8fbb8670ee 100644
--- a/packages/visitor-keys/package.json
+++ b/packages/visitor-keys/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/visitor-keys",
- "version": "7.11.0",
+ "version": "7.12.0",
"description": "Visitor keys used to help traverse the TypeScript-ESTree AST",
"files": [
"dist",
@@ -47,7 +47,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
- "@typescript-eslint/types": "7.11.0",
+ "@typescript-eslint/types": "7.12.0",
"eslint-visitor-keys": "^3.4.3"
},
"devDependencies": {
diff --git a/packages/website-eslint/CHANGELOG.md b/packages/website-eslint/CHANGELOG.md
index 1e87869a5f1..06585a2e0fc 100644
--- a/packages/website-eslint/CHANGELOG.md
+++ b/packages/website-eslint/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 7.12.0 (2024-06-03)
+
+This was a version bump only for website-eslint to align it with other projects, there were no code changes.
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for website-eslint to align it with other projects, there were no code changes.
diff --git a/packages/website-eslint/package.json b/packages/website-eslint/package.json
index 4eee27c03c2..2d3eeb77e89 100644
--- a/packages/website-eslint/package.json
+++ b/packages/website-eslint/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/website-eslint",
- "version": "7.11.0",
+ "version": "7.12.0",
"private": true,
"description": "ESLint which works in browsers.",
"files": [
@@ -24,11 +24,11 @@
},
"devDependencies": {
"@eslint/js": "*",
- "@typescript-eslint/eslint-plugin": "7.11.0",
- "@typescript-eslint/parser": "7.11.0",
- "@typescript-eslint/scope-manager": "7.11.0",
- "@typescript-eslint/typescript-estree": "7.11.0",
- "@typescript-eslint/visitor-keys": "7.11.0",
+ "@typescript-eslint/eslint-plugin": "7.12.0",
+ "@typescript-eslint/parser": "7.12.0",
+ "@typescript-eslint/scope-manager": "7.12.0",
+ "@typescript-eslint/typescript-estree": "7.12.0",
+ "@typescript-eslint/visitor-keys": "7.12.0",
"esbuild": "~0.21.0",
"eslint": "*",
"esquery": "*",
diff --git a/packages/website/CHANGELOG.md b/packages/website/CHANGELOG.md
index d6ee560e547..55f5433f65e 100644
--- a/packages/website/CHANGELOG.md
+++ b/packages/website/CHANGELOG.md
@@ -1,3 +1,22 @@
+## 7.12.0 (2024-06-03)
+
+
+### 🩹 Fixes
+
+- no-useless-template-expression -> no-unnecessary-template-expression
+
+
+### ❤️ Thank You
+
+- Abraham Guo
+- Han Yeong-woo
+- Joshua Chen
+- Kim Sang Du
+- Kirk Waiblinger
+- YeonJuan
+
+You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
+
## 7.11.0 (2024-05-27)
This was a version bump only for website to align it with other projects, there were no code changes.
diff --git a/packages/website/blog/2022-09-18-automated-rule-docs-with-docusaurus-and-remark.md b/packages/website/blog/2022-09-18-automated-rule-docs-with-docusaurus-and-remark.md
index 7606e3e9f36..8009c1f0004 100644
--- a/packages/website/blog/2022-09-18-automated-rule-docs-with-docusaurus-and-remark.md
+++ b/packages/website/blog/2022-09-18-automated-rule-docs-with-docusaurus-and-remark.md
@@ -220,9 +220,3 @@ I'm excited to focus in particular on [Docs: Proofread rule docs for clarity (#4
We'd like to extend thanks to [Joshua Chen](https://github.com/Josh-Cena), one of the Docusaurus maintainers who also has been helping us with Docusaurus — and helped proofread [this blog post's PR](https://github.com/typescript-eslint/typescript-eslint/pull/5593).
Without Joshua, this change would have taken us a great deal longer (if we'd have been able to tackle it at all).
Thanks Joshua! 🤗
-
-## Supporting typescript-eslint
-
-If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
-We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
-Thanks! 💖
diff --git a/packages/website/blog/2023-02-24-consistent-type-exports-and-imports-why-and-how.md b/packages/website/blog/2023-02-24-consistent-type-exports-and-imports-why-and-how.md
index cde68190cd4..37df608f122 100644
--- a/packages/website/blog/2023-02-24-consistent-type-exports-and-imports-why-and-how.md
+++ b/packages/website/blog/2023-02-24-consistent-type-exports-and-imports-why-and-how.md
@@ -183,9 +183,3 @@ If it detects an import that only imports specifiers with inline `type` qualifie
You can read more about the rules' configuration options in their docs pages.
See [our Getting Started docs](/getting-started) for more information on linting your TypeScript code with typescript-eslint.
-
-## Supporting typescript-eslint
-
-If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
-We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
-Thanks! 💖
diff --git a/packages/website/blog/2023-03-13-announcing-typescript-eslint-v6-beta.md b/packages/website/blog/2023-03-13-announcing-typescript-eslint-v6-beta.md
index 49d3bbf416e..a69f5f71a84 100644
--- a/packages/website/blog/2023-03-13-announcing-typescript-eslint-v6-beta.md
+++ b/packages/website/blog/2023-03-13-announcing-typescript-eslint-v6-beta.md
@@ -374,9 +374,3 @@ We'd like to extend a sincere _thank you_ to everybody who pitched in to make ty
See the [v6.0.0 milestone](https://github.com/typescript-eslint/typescript-eslint/milestone/8) for the list of issues and associated merged pull requests.
-
-## Supporting typescript-eslint
-
-If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
-We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
-Thanks! 💖
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 0920b004790..26e7f674e07 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
@@ -699,9 +699,3 @@ We'd like to extend a sincere _thank you_ to everybody who pitched in to make ty
- [TypeScript](https://github.com/microsoft/TypeScript/pull/54693)
See the [v6.0.0 milestone](https://github.com/typescript-eslint/typescript-eslint/milestone/8) for the list of issues and associated merged pull requests.
-
-## Supporting typescript-eslint
-
-If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
-We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
-Thanks! 💖
diff --git a/packages/website/blog/2023-09-18-parser-options-project-true.md b/packages/website/blog/2023-09-18-parser-options-project-true.md
index d279beae93b..e2ffd4ef6d1 100644
--- a/packages/website/blog/2023-09-18-parser-options-project-true.md
+++ b/packages/website/blog/2023-09-18-parser-options-project-true.md
@@ -144,9 +144,3 @@ We hope this option will eventually become the standard way to enable typed lint
However, because it's so new and untested, we're keeping it under the `EXPERIMENTAL_` prefix for at least all of the `6.X` versions.
See [Packages > Parser > `EXPERIMENTAL_useProjectService`](/packages/parser#experimental_useprojectservice) for more information.
-
-## Supporting typescript-eslint
-
-If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
-We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
-Thanks! 💖
diff --git a/packages/website/blog/2023-12-25-deprecating-formatting-rules.md b/packages/website/blog/2023-12-25-deprecating-formatting-rules.md
index 6767fedc990..65c2c5a3ce6 100644
--- a/packages/website/blog/2023-12-25-deprecating-formatting-rules.md
+++ b/packages/website/blog/2023-12-25-deprecating-formatting-rules.md
@@ -62,9 +62,3 @@ The equivalent stylistic rules for deprecated typescript-eslint rules are summar
| [`@typescript-eslint/space-before-function-paren`](/rules/space-before-function-paren) | [`@stylistic/space-before-function-paren`](https://eslint.style/rules/ts/space-before-function-paren) |
| [`@typescript-eslint/space-infix-ops`](/rules/space-infix-ops) | [`@stylistic/space-infix-ops`](https://eslint.style/rules/ts/space-infix-ops) |
| [`@typescript-eslint/type-annotation-spacing`](/rules/type-annotation-spacing) | [`@stylistic/type-annotation-spacing`](https://eslint.style/rules/ts/type-annotation-spacing) |
-
-## Supporting typescript-eslint
-
-If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
-We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
-Thanks! 💖
diff --git a/packages/website/blog/2024-05-27-announcing-typescript-eslint-v8-beta.mdx b/packages/website/blog/2024-05-27-announcing-typescript-eslint-v8-beta.mdx
index bb4df35009b..6348a37ddf4 100644
--- a/packages/website/blog/2024-05-27-announcing-typescript-eslint-v8-beta.mdx
+++ b/packages/website/blog/2024-05-27-announcing-typescript-eslint-v8-beta.mdx
@@ -349,9 +349,3 @@ We'd like to extend a sincere _thank you_ to everybody who pitched in to make ty
See the [v8.0.0 milestone](https://github.com/typescript-eslint/typescript-eslint/milestone/9) for the list of issues and associated merged pull requests.
-
-## Supporting typescript-eslint
-
-If you enjoyed this blog post and/or use typescript-eslint, please consider [supporting us on Open Collective](https://opencollective.com/typescript-eslint).
-We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great.
-Thanks! 💖
diff --git a/packages/website/docusaurus.config.mts b/packages/website/docusaurus.config.mts
index 9e23f2b6532..a728e223b11 100644
--- a/packages/website/docusaurus.config.mts
+++ b/packages/website/docusaurus.config.mts
@@ -9,6 +9,7 @@ import type { UserThemeConfig as AlgoliaThemeConfig } from '@docusaurus/theme-se
import type { Config } from '@docusaurus/types';
import { version } from './package.json';
+import { blogFooter } from './plugins/blog-footer';
import { generatedRuleDocs } from './plugins/generated-rule-docs';
import { rulesMeta } from './rulesMeta';
@@ -19,6 +20,8 @@ const githubUrl = 'https://github.com/typescript-eslint/typescript-eslint';
const presetClassicOptions: PresetClassicOptions = {
blog: {
blogSidebarCount: 'ALL',
+ // Allow Docusaurus TOC remark plugin to pick up the injected H2
+ beforeDefaultRemarkPlugins: [blogFooter],
remarkPlugins,
},
docs: {
@@ -287,6 +290,10 @@ const redirects: PluginRedirectOptions = {
from: '/linting/typed-linting/monorepos',
to: '/getting-started/typed-linting/monorepos',
},
+ {
+ from: '/maintenance/issues/rule-deprecations',
+ to: '/maintenance/issues/rule-deprecations-and-deletions',
+ },
],
};
diff --git a/packages/website/package.json b/packages/website/package.json
index 6f548b4703f..a5c649efedf 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -1,6 +1,6 @@
{
"name": "website",
- "version": "7.11.0",
+ "version": "7.12.0",
"private": true,
"scripts": {
"build": "docusaurus build",
@@ -23,8 +23,9 @@
"@docusaurus/preset-classic": "^3.2.1",
"@docusaurus/remark-plugin-npm2yarn": "^3.2.1",
"@docusaurus/theme-common": "^3.2.1",
- "@typescript-eslint/parser": "7.11.0",
- "@typescript-eslint/website-eslint": "7.11.0",
+ "@typescript-eslint/parser": "7.12.0",
+ "@typescript-eslint/website-eslint": "7.12.0",
+ "@uiw/react-shields": "2.0.1",
"clsx": "^2.1.0",
"eslint": "*",
"json5": "^2.2.3",
@@ -46,12 +47,12 @@
"@types/mdast": "^4.0.3",
"@types/react": "*",
"@types/unist": "^3.0.2",
- "@typescript-eslint/eslint-plugin": "7.11.0",
- "@typescript-eslint/rule-schema-to-typescript-types": "7.11.0",
- "@typescript-eslint/scope-manager": "7.11.0",
- "@typescript-eslint/types": "7.11.0",
- "@typescript-eslint/typescript-estree": "7.11.0",
- "@typescript-eslint/utils": "7.11.0",
+ "@typescript-eslint/eslint-plugin": "7.12.0",
+ "@typescript-eslint/rule-schema-to-typescript-types": "7.12.0",
+ "@typescript-eslint/scope-manager": "7.12.0",
+ "@typescript-eslint/types": "7.12.0",
+ "@typescript-eslint/typescript-estree": "7.12.0",
+ "@typescript-eslint/utils": "7.12.0",
"copy-webpack-plugin": "^12.0.0",
"cross-fetch": "*",
"history": "^4.9.0",
diff --git a/packages/website/plugins/blog-footer.ts b/packages/website/plugins/blog-footer.ts
new file mode 100644
index 00000000000..e943ea59328
--- /dev/null
+++ b/packages/website/plugins/blog-footer.ts
@@ -0,0 +1,52 @@
+import type * as mdast from 'mdast';
+import type { Plugin } from 'unified';
+
+import { nodeIsParent } from './utils/nodes';
+
+export const blogFooter: Plugin = () => {
+ return (root, file) => {
+ if (
+ !nodeIsParent(root) ||
+ !(file.value as string).includes('')
+ ) {
+ return;
+ }
+
+ root.children.push(
+ {
+ children: [
+ {
+ type: 'text',
+ value: 'Supporting typescript-eslint',
+ },
+ ],
+ depth: 2,
+ type: 'heading',
+ } as mdast.Heading,
+ {
+ children: [
+ {
+ type: 'text',
+ value:
+ 'If you enjoyed this blog post and/or use typescript-eslint, please consider ',
+ },
+ {
+ children: [
+ {
+ type: 'text',
+ value: 'supporting us on Open Collective',
+ },
+ ],
+ url: 'https://opencollective.com/typescript-eslint',
+ type: 'link',
+ },
+ {
+ type: 'text',
+ value: `. We're a small volunteer team and could use your support to make the ESLint experience on TypeScript great. Thanks! 💖`,
+ },
+ ],
+ type: 'paragraph',
+ } as mdast.Paragraph,
+ );
+ };
+};
diff --git a/packages/website/plugins/generated-rule-docs/RuleDocsPage.ts b/packages/website/plugins/generated-rule-docs/RuleDocsPage.ts
index 8c1d317bdc9..ea16781aec4 100644
--- a/packages/website/plugins/generated-rule-docs/RuleDocsPage.ts
+++ b/packages/website/plugins/generated-rule-docs/RuleDocsPage.ts
@@ -1,7 +1,7 @@
import type * as unist from 'unist';
-import type { RuleModuleWithMetaDocs, VFileWithStem } from './utils';
-import { findH2Index } from './utils';
+import type { RuleModuleWithMetaDocs, VFileWithStem } from '../utils/rules';
+import { findH2Index } from '../utils/rules';
export interface RequiredHeadingIndices {
howToUse: number;
diff --git a/packages/website/plugins/generated-rule-docs/addESLintHashToCodeBlocksMeta.ts b/packages/website/plugins/generated-rule-docs/addESLintHashToCodeBlocksMeta.ts
index ac59bea5355..636a14aa30c 100644
--- a/packages/website/plugins/generated-rule-docs/addESLintHashToCodeBlocksMeta.ts
+++ b/packages/website/plugins/generated-rule-docs/addESLintHashToCodeBlocksMeta.ts
@@ -1,8 +1,9 @@
import type { MdxJsxFlowElement } from 'mdast-util-mdx';
import type * as unist from 'unist';
+import { nodeIsCode } from '../utils/nodes';
+import { convertToPlaygroundHash } from '../utils/rules';
import type { RuleDocsPage } from './RuleDocsPage';
-import { convertToPlaygroundHash, nodeIsCode } from './utils';
const optionRegex = /option='(?