Skip to content

Commit

Permalink
Merge branch 'main' into 8428-export-utility-to-remove-type-info
Browse files Browse the repository at this point in the history
  • Loading branch information
fpapado committed Jun 5, 2024
2 parents 8e62e0b + 2d03140 commit 35a3d4b
Show file tree
Hide file tree
Showing 160 changed files with 2,794 additions and 824 deletions.
6 changes: 5 additions & 1 deletion .github/ISSUE_TEMPLATE/06-bug-report-other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
6 changes: 3 additions & 3 deletions docs/Contributing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
7 changes: 7 additions & 0 deletions docs/contributing/Issues.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 👎.
Expand All @@ -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

Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/ESLint_Plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sidebar_label: eslint-plugin

# `@typescript-eslint/eslint-plugin`

<PackageLink packageName="eslint-plugin" scope="@typescript-eslint" />

> The TypeScript plugin for ESLint. ✨
:::info
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/ESLint_Plugin_TSLint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sidebar_label: eslint-plugin-tslint

# `@typescript-eslint/eslint-plugin-tslint`

<PackageLink packageName="eslint-plugin-tslint" scope="@typescript-eslint" />

> ESLint plugin that allows running TSLint rules within ESLint to help you migrate from TSLint to ESLint. ✨
:::caution
Expand Down
51 changes: 49 additions & 2 deletions docs/packages/Parser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ id: parser
sidebar_label: parser
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# `@typescript-eslint/parser`

<PackageLink packageName="parser" scope="@typescript-eslint" />

> 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.
Expand Down Expand Up @@ -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
<Tabs groupId="eslint-config">
<TabItem value="Flat Config">

```js title="eslint.config.js"
export default [
{
languageOptions: {
parserOptions: {
EXPERIMENTAL_useProjectService: true,
},
},
},
];
```

</TabItem>
<TabItem value="Legacy Config">

```js title=".eslintrc.js"
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
Expand All @@ -319,6 +342,9 @@ module.exports = {
};
```

</TabItem>
</Tabs>

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
Expand Down Expand Up @@ -346,6 +372,24 @@ declare function createProgram(

Example usage:

<Tabs groupId="eslint-config">
<TabItem value="Flat Config">

```js title="eslint.config.js"
import * as parser from '@typescript-eslint/parser';

export default [
{
parserOptions: {
programs: [parser.createProgram('tsconfig.json')],
},
},
];
```

</TabItem>
<TabItem value="Legacy Config">

```js title=".eslintrc.js"
const parser = require('@typescript-eslint/parser');

Expand All @@ -356,6 +400,9 @@ module.exports = {
};
```

</TabItem>
</Tabs>

### `withoutProjectParserOptions(parserOptions)`

Removes options that prompt the parser to parse the project with type information.
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/Rule_Tester.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import CodeBlock from '@theme/CodeBlock';

# `@typescript-eslint/rule-tester`

<PackageLink packageName="rule-tester" scope="@typescript-eslint" />

> 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.
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/Scope_Manager.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sidebar_label: scope-manager

# `@typescript-eslint/scope-manager`

<PackageLink packageName="scope-manager" scope="@typescript-eslint" />

> 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.
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/TypeScript_ESLint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import TabItem from '@theme/TabItem';

# `typescript-eslint`

<PackageLink packageName="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.
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/TypeScript_ESTree.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sidebar_label: typescript-estree

# `@typescript-eslint/typescript-estree`

<PackageLink packageName="typescript-estree" scope="@typescript-eslint" />

> The underlying code used by [`@typescript-eslint/parser`](./Parser.mdx) that converts TypeScript source code into an <a href="https://github.com/estree/estree">ESTree</a>-compatible form. ✨
This parser is designed to be generic and robust.
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/Utils.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sidebar_label: utils

# `@typescript-eslint/utils`

<PackageLink packageName="utils" scope="@typescript-eslint" />

> Utilities for working with TypeScript + ESLint together. ✨
This package contains public utilities for writing custom rules and plugins in TypeScript.
Expand Down
3 changes: 3 additions & 0 deletions docs/users/Shared_Configurations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions packages/ast-spec/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
2 changes: 1 addition & 1 deletion packages/ast-spec/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
6 changes: 2 additions & 4 deletions packages/ast-spec/src/base/UnaryExpressionBase.ts
Original file line number Diff line number Diff line change
@@ -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;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 35a3d4b

Please sign in to comment.