Skip to content

Commit

Permalink
Merge branch 'v8' of github.com:typescript-eslint/typescript-eslint i…
Browse files Browse the repository at this point in the history
…nto remove-deprecated-context-helpers
  • Loading branch information
abrahamguo committed Apr 30, 2024
2 parents ccaabf1 + 72d1066 commit 0578169
Show file tree
Hide file tree
Showing 51 changed files with 657 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
- name: Build
uses: ./.github/actions/prepare-build

- name: Run integrations tests
- name: Run integration tests
run: yarn test-integration
env:
CI: true
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
## 7.8.0 (2024-04-29)


### 🚀 Features

- **rule-tester:** assert suggestion messages are unique ([#8995](https://github.com/typescript-eslint/typescript-eslint/pull/8995))
- **typescript-estree:** add maximumDefaultProjectFileMatchCount and wide allowDefaultProjectForFiles glob restrictions ([#8925](https://github.com/typescript-eslint/typescript-eslint/pull/8925))

### 🩹 Fixes

- **eslint-plugin:** [no-unsafe-argument] handle tagged templates ([#8746](https://github.com/typescript-eslint/typescript-eslint/pull/8746))
- **eslint-plugin:** [prefer-optional-chain] suggests optional chaining during strict null equality check ([#8717](https://github.com/typescript-eslint/typescript-eslint/pull/8717))
- **eslint-plugin:** [consistent-type-assertions] handle tagged templates ([#8993](https://github.com/typescript-eslint/typescript-eslint/pull/8993))
- **eslint-plugin:** [no-unsafe-return] handle union types ([#9001](https://github.com/typescript-eslint/typescript-eslint/pull/9001))
- **eslint-plugin:** [no-unused-vars] clear error report range ([#8640](https://github.com/typescript-eslint/typescript-eslint/pull/8640))
- **utils:** export ESLint backwards-compat functions ([#8976](https://github.com/typescript-eslint/typescript-eslint/pull/8976))

### ❤️ Thank You

- auvred @auvred
- Josh Goldberg ✨
- jsfm01 @jsfm01
- Kim Sang Du @developer-bandi
- 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.7.1 (2024-04-22)


Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
<p align="center">
👆
</p>
<p align="center">
Using ESLint v9? See: <a href="https://github.com/typescript-eslint/typescript-eslint/issues/8211">ESLint v9 Support</a>.
</p>
<!-- markdownlint-enable MD033 -->

## Code Contributors
Expand Down
61 changes: 52 additions & 9 deletions docs/maintenance/Releases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,69 @@ Per [Users > Releases > Major Releases](../users/Releases.mdx#major-releases), w
1. Create a milestone by the name of the release [example: [Milestone 6.0.0](https://github.com/typescript-eslint/typescript-eslint/milestone/8)].
1. If an issue for changes to recommended rule configs doesn't yet exist, create one [example: [Changes to the `recommended` sets for 5.0.0](https://github.com/typescript-eslint/typescript-eslint/issues/5900)].
1. Add any breaking changes intended for the release to that milestone.
1. Search for source code comments (excluding `CHANGELOG.md` files) that mention deprecated code and/or a todo for the new major version, and create corresponding issues in that milestone.
- For example, for a new major version 8, searches might include:
- `/deprecated|todo/i`
- `/v8/i`
- `/todo.*v?8/i`
1. Create an issue to raise the minimum versions of dependencies [example: [Enhancement: Raise minimum versions of dependencies for v8](https://github.com/typescript-eslint/typescript-eslint/issues/8929)]
1. Create two new branches off `main` in the project repository (not a personal fork):
- `v${major}`
- `v${major}-canary-auto-release`
1. Raise a PR from `v${major}-canary-auto-release` to `main` modifying the [`ci.yml` workflow](https://github.com/typescript-eslint/typescript-eslint/blob/main/.github/workflows/ci.yml) [example: [chore: add auto-canary release for v6](https://github.com/typescript-eslint/typescript-eslint/pull/5883)]:
- Under `push:` > `branches:` at the beginning of the file, add an `- v${major}` list item.
- Add a `publish_canary_version_v${major}` step the same as `publish_canary_version` except:
- Change the `if` condition's branch check to: `if: github.ref == 'refs/heads/v${major}'`.
- Its publish command should be `npx nx release publish --tag rc-v${major} --verbose`.
1. Raise a PR from `v${major}-canary-auto-release` to `main` modifying [`ci.yml` workflow](https://github.com/typescript-eslint/typescript-eslint/blob/main/.github/workflows/ci.yml) and README.md [example: [chore: add auto-canary release for v6](https://github.com/typescript-eslint/typescript-eslint/pull/5883)]:
- `ci.yml`:
- Under `push:` > `branches:` at the beginning of the file, add a `- v${major}` list item.
- Add a `publish_canary_version_v${major}` step the same as `publish_canary_version` except:
- Change the `if` condition's branch check to: `if: github.ref == 'refs/heads/v${major}'`.
- Its publish command should be `npx nx release publish --tag rc-v${major} --verbose`.
- `README.md`:
- Add a link to a `v${major}--typescript-eslint.netlify.app` preview deploy environment on Netlify that you create for the branch.
- Merge this into `main` once reviewed and rebase the `v${major}` branch.

#### 1a. Shared Config Changes

Major versions are our only real chance to change the values in our stable `recommended*` and `stylistic*` configs.
In parallel to the general PR flow of the major version:

1. Create a `v${major}` channel on the typescript-eslint Discord
1. Create a discussion with a table summarizing any proposed rule changes [example: [Changes to configurations for 6.0.0](https://github.com/typescript-eslint/typescript-eslint/discussions/6014)]
1. Post that discussion on the typescript-eslint Discord and on social media
1. Once the greater of (1 month) and (discussion settling down) has passed, file an issue and send a corresponding PR to the `v${major}` branch making the corresponding changes [example: [Configs: Apply changes to config presets for v6](https://github.com/typescript-eslint/typescript-eslint/issues/6759)]

#### 1b. Voluntary Community Testing

In parallel to the shared config changes work, make sure to test out the beta version on popular community projects willing to try it out.

1. Create a pinned issue offering to try out the new version's beta for consumers [example: [Try out v6 beta on various important community repos](https://github.com/typescript-eslint/typescript-eslint/issues/6760)]
- Ask each community project if they'd be interested in trying out the new version, such as in their Discord or on their issue tracker.
- Each community project that's indicated willingness to receive a PR should have one.
1. Once the proposed _Shared Config Changes_ are merged into the `v${major}` branch, send a draft PR to each project with the new beta version.

#### 1c. Post Community Testing Config Touchups

There may be additional changes to preset configs discovered as part of the community testing.
If that's the case:

1. Create a discussion describing the suggested changes [example: [Configs: Last round of "final" changes to configs for v6](https://github.com/typescript-eslint/typescript-eslint/discussions/7130)].
1. Post this new discussion in the previous config changes one, in the typescript-eslint Discord, and on social media.
1. Once the greater of (2 weeks) and (discussion settling down) has passed

If possible, we prefer to avoid making a second round of config changes.
These should only be done for feedback that consistently comes up in community testing.

### 2. Merging Breaking Changes

1. Send a PR from `v${major}` to `main` [example: [v6.0.0](https://github.com/typescript-eslint/typescript-eslint/pull/5886)].
1. Change all [breaking change PRs](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aissue+is%3Aopen+label%3A%22breaking+change%22) to target the `v${major}` branch.
- To signify these changes as breaking, the first line of the PR description must read as `BREAKING CHANGE:`, and second line should briefly summarize the changes.
- It is important to note that when merged the commit message must also include `BREAKING CHANGE:` as the first line in order for nx to recognize it as a breaking change in the release notes. If you miss this it just means more manual work when writing the release documentation.
- It is important to note that when merged the commit message must also include `BREAKING CHANGE:` as the first line in order for `nx release` to recognize it as a breaking change in the release notes. If you miss this it just means more manual work when writing the release documentation.
1. Write and share out a blog post announcing the new beta [example: [Docs: Blog post describing changes & migration strategy for v5->v6](https://github.com/typescript-eslint/typescript-eslint/issues/6466)].
- Keep this post up-to-date as changes land in the `v${major}` branch.
1. Wait until all required PRs have been merged
1. Write a blog post announcing the new release [example: [Docs: Release blog post for v6](https://github.com/typescript-eslint/typescript-eslint/issues/7153)], and land it in the `v${major}` branch.
1. Let the release wait for **at least 1 week** to allow time for early adopters to help test it and discuss the changes.
- Promote it on the [`@tseslint`](https://twitter.com/tseslint) twitter to get some additional attention.
1. Once discussions have settled, rebase merge the PR on top of `main`.
1. Once discussions have settled, traditional merge commit the PR on top of `main` by temporarily enabling that merge setting for the repo.

:::note
_Non_-breaking changes can be merged to `main` or the major branch.
Expand All @@ -46,8 +89,8 @@ They don't need any special treatment.
### 3. Releasing the Version

1. Discuss with the maintainers to be ready for an [out-of-band](#out-of-band-releases) release. Doing this manually helps ensure someone is on-hand to action any issues that might arise from the major release.
1. Prepare the release notes. nx will automatically generate the release notes on GitHub, however this will be disorganized and unhelpful for users. We need to reorganize the release notes so that breaking changes are placed at the top to make them most visible. If any migrations are required, we must list the steps to make it easy for users.
- Example release notes: [`v5.0.0`](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v5.0.0), [`v4.0.0`](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v4.0.0), [`v3.0.0`](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v3.0.0)
1. Prepare the release notes. `nx release` will automatically generate the release notes on GitHub, however this will be disorganized and unhelpful for users. We need to reorganize the release notes so that breaking changes are placed at the top to make them most visible. If any migrations are required, we must list the steps to make it easy for users.
- Example release notes: [`v6.0.0`](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v6.0.0), [`v5.0.0`](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v5.0.0)
1. Finally, tweet the release on the `@tseslint` twitter with a link to the GitHub release. Make sure you include additional information about the highlights of the release!

## Out-of-Band Releases
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.8.0 (2024-04-29)

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.7.1 (2024-04-22)

This was a version bump only for ast-spec to align it with other projects, there were no code changes.
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.7.1",
"version": "7.8.0",
"description": "Complete specification for the TypeScript-ESTree AST",
"private": true,
"keywords": [
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin-internal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 7.8.0 (2024-04-29)

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.7.1 (2024-04-22)

This was a version bump only for eslint-plugin-internal to align it with other projects, there were no code changes.
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-plugin-internal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin-internal",
"version": "7.7.1",
"version": "7.8.0",
"private": true,
"main": "dist/index.js",
"types": "index.d.ts",
Expand All @@ -15,10 +15,10 @@
},
"dependencies": {
"@prettier/sync": "^0.5.1",
"@typescript-eslint/rule-tester": "7.7.1",
"@typescript-eslint/scope-manager": "7.7.1",
"@typescript-eslint/type-utils": "7.7.1",
"@typescript-eslint/utils": "7.7.1",
"@typescript-eslint/rule-tester": "7.8.0",
"@typescript-eslint/scope-manager": "7.8.0",
"@typescript-eslint/type-utils": "7.8.0",
"@typescript-eslint/utils": "7.8.0",
"prettier": "^3.2.5"
},
"devDependencies": {
Expand Down
26 changes: 26 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## 7.8.0 (2024-04-29)


### 🩹 Fixes

- **eslint-plugin:** [no-unsafe-argument] handle tagged templates

- **eslint-plugin:** [prefer-optional-chain] suggests optional chaining during strict null equality check

- **eslint-plugin:** [consistent-type-assertions] handle tagged templates

- **eslint-plugin:** [no-unsafe-return] handle union types

- **eslint-plugin:** [no-unused-vars] clear error report range


### ❤️ Thank You

- auvred
- Josh Goldberg ✨
- jsfm01
- Kim Sang Du
- 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.7.1 (2024-04-22)


Expand Down
14 changes: 7 additions & 7 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
"version": "7.7.1",
"version": "7.8.0",
"description": "TypeScript plugin for ESLint",
"files": [
"dist",
Expand Down Expand Up @@ -62,10 +62,10 @@
},
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "7.7.1",
"@typescript-eslint/type-utils": "7.7.1",
"@typescript-eslint/utils": "7.7.1",
"@typescript-eslint/visitor-keys": "7.7.1",
"@typescript-eslint/scope-manager": "7.8.0",
"@typescript-eslint/type-utils": "7.8.0",
"@typescript-eslint/utils": "7.8.0",
"@typescript-eslint/visitor-keys": "7.8.0",
"debug": "^4.3.4",
"graphemer": "^1.4.0",
"ignore": "^5.3.1",
Expand All @@ -78,8 +78,8 @@
"@types/marked": "*",
"@types/mdast": "^4.0.3",
"@types/natural-compare": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "7.7.1",
"@typescript-eslint/rule-tester": "7.7.1",
"@typescript-eslint/rule-schema-to-typescript-types": "7.8.0",
"@typescript-eslint/rule-tester": "7.8.0",
"ajv": "^6.12.6",
"chalk": "^5.3.0",
"cross-env": "^7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-unsafe-return.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default createRule({
// If there is an explicit type annotation *and* that type matches the actual
// function return type, we shouldn't complain (it's intentional, even if unsafe)
if (functionTSNode.type) {
for (const signature of functionType.getCallSignatures()) {
for (const signature of tsutils.getCallSignaturesOfType(functionType)) {
if (
returnNodeType === signature.getReturnType() ||
isTypeFlagSet(
Expand Down
19 changes: 16 additions & 3 deletions packages/eslint-plugin/src/rules/no-unused-vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,23 @@ export default createRule<Options, MessageIds>({
ref.from.variableScope === unusedVar.scope.variableScope,
);

const id = writeReferences.length
? writeReferences[writeReferences.length - 1].identifier
: unusedVar.identifiers[0];

const { start } = id.loc;
const idLength = id.name.length;

const loc = {
start,
end: {
line: start.line,
column: start.column + idLength,
},
};

context.report({
node: writeReferences.length
? writeReferences[writeReferences.length - 1].identifier
: unusedVar.identifiers[0],
loc,
messageId: 'unusedVar',
data: unusedVar.references.some(ref => ref.isWrite())
? getAssignedMessageData(unusedVar)
Expand Down
22 changes: 22 additions & 0 deletions packages/eslint-plugin/tests/rules/no-unsafe-return.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ function foo() {
function foo(): any {
return {} as any;
}
`,
`
declare function foo(arg: () => any): void;
foo((): any => 'foo' as any);
`,
`
declare function foo(arg: null | (() => any)): void;
foo((): any => 'foo' as any);
`,
// explicit any array return type is allowed, if you want to be unsafe like that
`
Expand Down Expand Up @@ -408,5 +416,19 @@ function bar() {
},
],
},
{
code: `
declare function foo(arg: null | (() => any)): void;
foo(() => 'foo' as any);
`,
errors: [
{
messageId: 'unsafeReturn',
line: 3,
column: 11,
endColumn: 23,
},
],
},
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import { RuleTester } from '@typescript-eslint/rule-tester';
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import type { MessageIds } from '../../../src/rules/no-unused-vars';
import rule from '../../../src/rules/no-unused-vars';
Expand Down Expand Up @@ -40,7 +39,6 @@ ruleTester.defineRule('use-every-a', context => {
function definedError(
varName: string,
additional = '',
type = AST_NODE_TYPES.Identifier,
): TSESLint.TestCaseError<MessageIds> {
return {
messageId: 'unusedVar',
Expand All @@ -49,7 +47,6 @@ function definedError(
action: 'defined',
additional,
},
type,
};
}

Expand All @@ -63,7 +60,6 @@ function definedError(
function assignedError(
varName: string,
additional = '',
type = AST_NODE_TYPES.Identifier,
): TSESLint.TestCaseError<MessageIds> {
return {
messageId: 'unusedVar',
Expand All @@ -72,7 +68,6 @@ function assignedError(
action: 'assigned a value',
additional,
},
type,
};
}

Expand Down Expand Up @@ -1235,7 +1230,7 @@ function f() {
},
{
code: '/*global a */',
errors: [definedError('a', '', AST_NODE_TYPES.Program)],
errors: [definedError('a', '')],
},
{
code: `
Expand Down Expand Up @@ -1344,7 +1339,6 @@ function foo() {
messageId: 'unusedVar',
data: { varName: 'foo', action: 'defined', additional: '' },
line: 2,
type: AST_NODE_TYPES.Identifier,
},
],
},
Expand Down

0 comments on commit 0578169

Please sign in to comment.