diff --git a/.cspell.json b/.cspell.json index 096ee7574a46..c9be4caedb7a 100644 --- a/.cspell.json +++ b/.cspell.json @@ -115,7 +115,8 @@ "unoptimized", "unprefixed", "upsert", - "Zacher" + "Zacher", + "tseslint" ], "overrides": [ { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e3c54674c48..0d47090d6344 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,9 @@ defaults: # 3) Run the steps that depend on the build # +permissions: + contents: read # to fetch code (actions/checkout) + jobs: install: name: Checkout and Install @@ -170,6 +173,10 @@ jobs: retention-days: 1 website_tests: + permissions: + contents: read # to fetch code (actions/checkout) + actions: read # to correctly identify workflow run (cypress-io/github-action) + name: Website tests needs: [build] runs-on: ubuntu-latest diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 4b73d71b7a02..fc8cea8a8ac1 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -4,8 +4,14 @@ on: schedule: - cron: '0 0 * * *' +permissions: {} + jobs: lock: + permissions: + issues: write # to lock issues (dessant/lock-threads) + pull-requests: write # to lock PRs (dessant/lock-threads) + runs-on: ubuntu-latest steps: - uses: dessant/lock-threads@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index bb32e840f083..26669379fd4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + + +### Features + +* **eslint-plugin:** allow using void as a default type for a generic argument if allowInGenericTypeArguments is specified ([#5671](https://github.com/typescript-eslint/typescript-eslint/issues/5671)) ([bb46ef0](https://github.com/typescript-eslint/typescript-eslint/commit/bb46ef0817fe03ef71f8e0f3df0cf96bc355e068)) + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/typescript-eslint diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c147ef537fcb..30d344ca965b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,25 +4,32 @@ Feel free to raise an issue if you have a question, an enhancement, or a bug report. -Use the issue search functionality to search all **_opened and closed_** issues before raising a new issue. If you raise a duplicate issue, you're just creating noise for everyone watching this repo. +Use the issue search functionality to search all **_opened and closed_** [issues](https://github.com/typescript-eslint/typescript-eslint/issues) before raising a new issue. If you raise a duplicate issue, you're just creating noise for everyone watching this repo. Before raising a bug, ensure you are using the latest version of our packages. We release every week, so there's a good chance your issue might have already been fixed. -Finally, when raising a new issue, please fill out the issue template - **_please don't skip sections_**. +Finally, when raising a new issue, please fill out the [issue template](https://github.com/typescript-eslint/typescript-eslint/issues/new/choose) - **_please don't skip sections_**. Please provide **_as much information as possible_**. This project is maintained by volunteers, so the more information you provide, the less likely we will have to waste everyone's time in asking you for more information. -If you have a particularly complex issue - consider creating a small, self-contained reproduction repo. This will help you in figuring out the exact problem, and will help us in reproducing and diagnosing the bug. +If you have a particularly complex issue that can't be reproduced on [our playground](https://typescript-eslint.io/play) - consider creating a small, self-contained reproduction repo. This will help you in figuring out the exact problem, and will help us in reproducing and diagnosing the bug. **_Help us to help you_** +## Questions and requests for support + +Questions and requests for support should not be opened as issues and should be handled in the following ways: + +- Ask a question on [StackOverflow](https://stackoverflow.com/questions/tagged/typescript-eslint) using the `typescript-eslint` tag. +- Publicly tweet [@tseslint on Twitter](https://twitter.com/tseslint). + ## Commenting Feel free to comment on any open issue if you have more information that you feel like you can provide. If you don't have more information, instead use the "reaction" feature on the root comment for the issue. We use reactions to help gauge which issues are important to the community, so these are the best way to show us an issue is important. Please refrain from leaving useless comments on issues. Comments like "+1", or "when's this getting fixed", or "any progress on this" just serve as spam, and annoy every single person subscribed to the issue. Generally we will just delete those comments, so save everyone time and think twice. -Please refrain from commenting on old, closed issues and PRs. Your issue is rarely related enough to a closed issue to warrant "necroing" a dead thread - raising a new issue means you can fill in the template, and make it easier for us to help you. Often times if you comment on a closed issue, we will just ask you to open a new issue, so please save everyone's time, and **_help us to help you_**. +Please refrain from commenting on old, closed issues and PRs. Your issue is rarely related enough to a closed issue to warrant "necroing" a dead thread - raising a new issue means you can fill in the [template](<(https://github.com/typescript-eslint/typescript-eslint/issues/new/choose)>), and make it easier for us to help you. Often times if you comment on a closed issue, we will just ask you to open a new issue, so please save everyone's time, and **_help us to help you_**. Please refrain from commenting on `main` commits. Commit comments are not searchable, meaning that nobody else can discover your comments. Raise an issue and reference the commit instead so that everyone can see your comment, and you can fill out the template. @@ -70,10 +77,22 @@ We have a sophisticated CI process setup which gets run on every PR. You must pa Once your changes are ready, you can raise a PR. The title of your PR should match the following format: ```text -(): +(): ``` -Where `` is one of: +You can find more samples of good past PR titles in [recent commits to `main`](https://github.com/typescript-eslint/typescript-eslint/commits/main)) + +```text +fix(scope-manager): correct handling for class static blocks +``` + +```text +docs: Fix links to getting started in README.md +``` + +### Type + +Must be one of the following: - `feat` - for any new functionality additions - `fix` - for any bug fixes that don't add new functionality @@ -81,7 +100,11 @@ Where `` is one of: - `docs` - if you only change documentation, and not shipped code - `chore` - anything else -And `` is the name of the package you have made changes within (`eslint-plugin`, `parser`, `typescript-estree`, etc). If you make significant changes across multiple packages, you can omit this (i.e. `feat: foo bar`). +### package + +`` is the name of the package you have made changes within (`eslint-plugin`, `parser`, `typescript-estree`, etc). If you make significant changes across multiple packages, you can omit this (i.e. `feat: foo bar`). + +### short description And `` is a succinct title for the PR. diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8da67fb31f76..3d6d37b2190c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -9,85 +9,85 @@ Thanks goes to these wonderful people:
James Henry

Brad Zacher

Armano
-
Oleksandr T.

Josh Goldberg
+
Reyad Attiyat
-
Michaël De Boey
-
Reyad Attiyat
-
Gareth Jones

Patricio Trevino

Sosuke Suzuki
- -
Joshua Chen

Nicholas C. Zakas

Jed Fox
-
YeonJuan
-
Rafael Santana
+
YeonJuan
+
Rafael Santana

Ben Lichtman
-
Taeheon Kim

Nikita
-
Scott O'Hara
-
Retsam
+
Taeheon Kim
+
Scott O'Hara
+
Retsam

Kai Cataldo

Rasmus Eneman
-
Rebecca Stevens

Toru Nagashima
-
Yosuke Ota
+
Yosuke Ota

JounQin

Lucas Azzola

Danny Fritz

Ika
-
mackie
+
mackie

Simen Bekkhus

Kanitkorn Sujautra

cherryblossom

Zzzen
-
Anix
-
Daniil Dubrava
+
Anix

Pete Gonzalez

ldrick

Susisu
-
G r e y
+
Gavin Barron
-
Gavin Barron

Kevin Partington

Lucas Duailibe

Niles Salter
-
Pavel Birukov
- - -
Shahar Dawn Or

SHIMA RYUHEI

koooge
-
thomas michael wallace
-
ulrichb
+
thomas michael wallace
+
ulrichb

Juan García

Bryan Mishkin

Daniel Cassidy
-
Daniel Nixon
-
Denys Kniazevych
+
Daniel Nixon
+
Denys Kniazevych

Dimitri Mitropoulos

Ian MacLeod
-
James Garbutt

Jonathan Delgado
+ +
Philipp A.
+
Pig Fang
+
Tadhg McDonald-Jensen
+
Thomas den Hollander
+
Yasar Siddiqui
+ + +
Yusuke Tanaka
+
Bence Dányi
+
Eric Wang
+
Soobin Bak
+ diff --git a/lerna.json b/lerna.json index 0a3d0f15d9fe..b478f846acf0 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "5.38.1", + "version": "5.39.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index 40c89b7d70aa..9a5fc2598bb1 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/ast-spec + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/ast-spec diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index b18621454eb9..a09416ecb357 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "5.38.1", + "version": "5.39.0", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index dbfc2f34a4a5..955f44300567 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index cb17e36a91a1..a8f20e7683a1 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": "5.38.1", + "version": "5.39.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,8 +14,8 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/scope-manager": "5.38.1", - "@typescript-eslint/utils": "5.38.1", + "@typescript-eslint/scope-manager": "5.39.0", + "@typescript-eslint/utils": "5.39.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index dc49f4f4e391..886cf7f02c94 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index eea133c05768..7dc807fdb1bf 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "5.38.1", + "version": "5.39.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.38.1", + "@typescript-eslint/utils": "5.39.0", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "5.38.1" + "@typescript-eslint/parser": "5.39.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 936f91f534ce..3fd0506e3893 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + + +### Features + +* **eslint-plugin:** allow using void as a default type for a generic argument if allowInGenericTypeArguments is specified ([#5671](https://github.com/typescript-eslint/typescript-eslint/issues/5671)) ([bb46ef0](https://github.com/typescript-eslint/typescript-eslint/commit/bb46ef0817fe03ef71f8e0f3df0cf96bc355e068)) + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/eslint-plugin diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 702e3db6dfab..514455e73136 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "5.38.1", + "version": "5.39.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,9 +44,9 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.38.1", - "@typescript-eslint/type-utils": "5.38.1", - "@typescript-eslint/utils": "5.38.1", + "@typescript-eslint/scope-manager": "5.39.0", + "@typescript-eslint/type-utils": "5.39.0", + "@typescript-eslint/utils": "5.39.0", "debug": "^4.3.4", "ignore": "^5.2.0", "regexpp": "^3.2.0", diff --git a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts index 6b9960e9d167..7cda184e4fdc 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts @@ -127,6 +127,21 @@ export default util.createRule<[Options], MessageIds>({ } } + /** + * @brief checks if the generic type parameter defaults to void + */ + function checkDefaultVoid( + node: TSESTree.TSVoidKeyword, + parentNode: TSESTree.TSTypeParameter, + ): void { + if (parentNode.default !== node) { + context.report({ + messageId: 'invalidVoidNotReturnOrGeneric', + node, + }); + } + } + /** * @brief checks that a union containing void is valid * @return true if every member of the union is specified as a valid type in @@ -162,6 +177,16 @@ export default util.createRule<[Options], MessageIds>({ return; } + // allow if allowInGenericTypeArguments is specified, and report if the generic type parameter extends void + if ( + allowInGenericTypeArguments && + node.parent.type === AST_NODE_TYPES.TSTypeParameter && + node.parent.default?.type === AST_NODE_TYPES.TSVoidKeyword + ) { + checkDefaultVoid(node, node.parent); + return; + } + // union w/ void must contain types from validUnionMembers, or a valid generic void type if ( node.parent.type === AST_NODE_TYPES.TSUnionType && diff --git a/packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts b/packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts index 0141da093b50..8164e85b2bd2 100644 --- a/packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts +++ b/packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts @@ -119,6 +119,8 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { 'type Generic = [T];', 'type voidPromiseUnion = void | Promise;', 'type promiseNeverUnion = Promise | never;', + 'const arrowGeneric1 = (arg: T) => {};', + 'declare function functionDeclaration1(arg: T): void;', ], invalid: [ { @@ -141,16 +143,6 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { }, ], }, - { - code: 'const arrowGeneric1 = (arg: T) => {};', - errors: [ - { - messageId: 'invalidVoidNotReturnOrGeneric', - line: 1, - column: 28, - }, - ], - }, { code: 'const arrowGeneric2 = (arg: T) => {};', errors: [ @@ -159,11 +151,6 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { line: 1, column: 34, }, - { - messageId: 'invalidVoidNotReturnOrGeneric', - line: 1, - column: 41, - }, ], }, { @@ -176,16 +163,6 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { }, ], }, - { - code: 'function functionGeneric1(arg: T) {}', - errors: [ - { - messageId: 'invalidVoidNotReturnOrGeneric', - line: 1, - column: 31, - }, - ], - }, { code: 'function functionGeneric2(arg: T) {}', errors: [ @@ -194,11 +171,6 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { line: 1, column: 37, }, - { - messageId: 'invalidVoidNotReturnOrGeneric', - line: 1, - column: 44, - }, ], }, { @@ -211,16 +183,6 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { }, ], }, - { - code: 'declare function functionDeclaration1(arg: T): void;', - errors: [ - { - messageId: 'invalidVoidNotReturnOrGeneric', - line: 1, - column: 43, - }, - ], - }, { code: 'declare function functionDeclaration2(arg: T): void;', errors: [ @@ -229,11 +191,6 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { line: 1, column: 49, }, - { - messageId: 'invalidVoidNotReturnOrGeneric', - line: 1, - column: 56, - }, ], }, { diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 641452f4aa00..d9ab5776de4a 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/experimental-utils diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 6dfea2e7ded1..20bf9271848c 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "5.38.1", + "version": "5.39.0", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.38.1" + "@typescript-eslint/utils": "5.39.0" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 0720ee165291..bf2bbe8aeae9 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/parser + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 25c0ae767c3c..1976d9efd6b3 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "5.38.1", + "version": "5.39.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -45,9 +45,9 @@ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.38.1", - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/typescript-estree": "5.38.1", + "@typescript-eslint/scope-manager": "5.39.0", + "@typescript-eslint/types": "5.39.0", + "@typescript-eslint/typescript-estree": "5.39.0", "debug": "^4.3.4" }, "devDependencies": { diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index 95bb6d6f2555..9ad9a8a12538 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/scope-manager + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/scope-manager diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index b0ee01c66ea1..f67265ca71b1 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "5.38.1", + "version": "5.39.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -38,12 +38,12 @@ "typecheck": "cd ../../ && nx typecheck @typescript-eslint/scope-manager" }, "dependencies": { - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/visitor-keys": "5.38.1" + "@typescript-eslint/types": "5.39.0", + "@typescript-eslint/visitor-keys": "5.39.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "5.38.1", + "@typescript-eslint/typescript-estree": "5.39.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index ca31a91c50fb..d15287d559d9 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index 2ca9620f4ab1..08055413546d 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "5.38.1", + "version": "5.39.0", "private": true } diff --git a/packages/type-utils/CHANGELOG.md b/packages/type-utils/CHANGELOG.md index 408b717ca454..ad834ddc3d7c 100644 --- a/packages/type-utils/CHANGELOG.md +++ b/packages/type-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/type-utils + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/type-utils diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index c184d37b5337..842c22887950 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/type-utils", - "version": "5.38.1", + "version": "5.39.0", "description": "Type utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -39,13 +39,13 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/typescript-estree": "5.38.1", - "@typescript-eslint/utils": "5.38.1", + "@typescript-eslint/typescript-estree": "5.39.0", + "@typescript-eslint/utils": "5.39.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, "devDependencies": { - "@typescript-eslint/parser": "5.38.1", + "@typescript-eslint/parser": "5.39.0", "typescript": "*" }, "peerDependencies": { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index f6025962fd72..517153ab6015 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/types + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index 4b5ac3ee5b17..22b83fe35ca6 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "5.38.1", + "version": "5.39.0", "description": "Types for the TypeScript-ESTree AST spec", "keywords": [ "eslint", diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 15e40d154250..1acad00016eb 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index d334869a153f..d6f16b776a58 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "5.38.1", + "version": "5.39.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -42,8 +42,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/visitor-keys": "5.38.1", + "@typescript-eslint/types": "5.39.0", + "@typescript-eslint/visitor-keys": "5.39.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -59,7 +59,7 @@ "@types/is-glob": "*", "@types/semver": "*", "@types/tmp": "*", - "@typescript-eslint/shared-fixtures": "5.38.1", + "@typescript-eslint/shared-fixtures": "5.39.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index cf2b23c4b1a2..6f6d1772f54e 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/utils + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/utils diff --git a/packages/utils/package.json b/packages/utils/package.json index 0a220c835067..15be0d287385 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/utils", - "version": "5.38.1", + "version": "5.39.0", "description": "Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -40,9 +40,9 @@ }, "dependencies": { "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.38.1", - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/typescript-estree": "5.38.1", + "@typescript-eslint/scope-manager": "5.39.0", + "@typescript-eslint/types": "5.39.0", + "@typescript-eslint/typescript-estree": "5.39.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index d9b1d277af89..cd78eccf8b04 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/visitor-keys diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index c722eb5773c8..9d4f90245511 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "5.38.1", + "version": "5.39.0", "description": "Visitor keys used to help traverse the TypeScript-ESTree AST", "keywords": [ "eslint", @@ -39,7 +39,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.38.1", + "@typescript-eslint/types": "5.39.0", "eslint-visitor-keys": "^3.3.0" }, "devDependencies": { diff --git a/packages/website-eslint/CHANGELOG.md b/packages/website-eslint/CHANGELOG.md index 27aeef269d26..c2d069e70a8c 100644 --- a/packages/website-eslint/CHANGELOG.md +++ b/packages/website-eslint/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package @typescript-eslint/website-eslint + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package @typescript-eslint/website-eslint diff --git a/packages/website-eslint/package.json b/packages/website-eslint/package.json index 45d851cf862e..7d4d0a520f39 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/website-eslint", - "version": "5.38.1", + "version": "5.39.0", "private": true, "description": "ESLint which works in browsers.", "engines": { @@ -16,19 +16,19 @@ "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore" }, "dependencies": { - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/utils": "5.38.1" + "@typescript-eslint/types": "5.39.0", + "@typescript-eslint/utils": "5.39.0" }, "devDependencies": { "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^14.1.0", "@rollup/pluginutils": "^4.2.1", - "@typescript-eslint/eslint-plugin": "5.38.1", - "@typescript-eslint/parser": "5.38.1", - "@typescript-eslint/scope-manager": "5.38.1", - "@typescript-eslint/typescript-estree": "5.38.1", - "@typescript-eslint/visitor-keys": "5.38.1", + "@typescript-eslint/eslint-plugin": "5.39.0", + "@typescript-eslint/parser": "5.39.0", + "@typescript-eslint/scope-manager": "5.39.0", + "@typescript-eslint/typescript-estree": "5.39.0", + "@typescript-eslint/visitor-keys": "5.39.0", "eslint": "*", "rollup": "^2.75.4", "rollup-plugin-terser": "^7.0.2", diff --git a/packages/website/.eslintrc.js b/packages/website/.eslintrc.js index 8b30fb624986..0b55f475b33c 100644 --- a/packages/website/.eslintrc.js +++ b/packages/website/.eslintrc.js @@ -22,7 +22,6 @@ module.exports = { 'react/jsx-no-target-blank': 'off', 'react/no-unescaped-entities': 'off', '@typescript-eslint/internal/prefer-ast-types-enum': 'off', - 'react-hooks/exhaustive-deps': 'off', // TODO: enable it later }, settings: { react: { diff --git a/packages/website/CHANGELOG.md b/packages/website/CHANGELOG.md index 74e30684826a..b46e5caeb195 100644 --- a/packages/website/CHANGELOG.md +++ b/packages/website/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.39.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.1...v5.39.0) (2022-10-03) + +**Note:** Version bump only for package website + + + + + ## [5.38.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.38.0...v5.38.1) (2022-09-26) **Note:** Version bump only for package website diff --git a/packages/website/data/sponsors.json b/packages/website/data/sponsors.json index 0de4c9ed2363..faef97d207fa 100644 --- a/packages/website/data/sponsors.json +++ b/packages/website/data/sponsors.json @@ -12,7 +12,7 @@ "image": "https://images.opencollective.com/nx/0efbe42/logo.png", "name": "Nx (by Nrwl)", "tier": "sponsor", - "totalDonations": 500000, + "totalDonations": 525000, "website": "https://nx.dev" }, { @@ -20,7 +20,7 @@ "image": "https://images.opencollective.com/eslint/96b09dc/logo.png", "name": "ESLint", "tier": "sponsor", - "totalDonations": 185000, + "totalDonations": 200000, "website": "https://eslint.org/" }, { @@ -28,7 +28,7 @@ "image": "https://images.opencollective.com/airbnb/d327d66/logo.png", "name": "Airbnb", "tier": "sponsor", - "totalDonations": 130800, + "totalDonations": 135800, "website": "https://www.airbnb.com/" }, { @@ -44,16 +44,24 @@ "image": "https://images.opencollective.com/n8n/dca2f0c/logo.png", "name": "n8n.io - n8n GmbH", "tier": "sponsor", - "totalDonations": 105000, + "totalDonations": 110000, "website": "https://n8n.io" }, { "id": "GitBook", "image": "https://images.opencollective.com/gitbook/d35a8e7/logo.png", "name": "GitBook", + "tier": "sponsor", + "totalDonations": 100000, + "website": "https://www.gitbook.com" + }, + { + "id": "Codecademy", + "image": "https://images.opencollective.com/codecademy/d56a48d/logo.png", + "name": "Codecademy", "tier": "supporter", "totalDonations": 90000, - "website": "https://www.gitbook.com" + "website": "https://codecademy.com" }, { "id": "EY Doberman", @@ -63,14 +71,6 @@ "totalDonations": 80400, "website": "https://doberman.co" }, - { - "id": "Codecademy", - "image": "https://images.opencollective.com/codecademy/d56a48d/logo.png", - "name": "Codecademy", - "tier": "supporter", - "totalDonations": 80000, - "website": "https://codecademy.com" - }, { "id": "Future Processing", "image": "https://images.opencollective.com/future-processing/1410d26/logo.png", @@ -95,6 +95,14 @@ "totalDonations": 40000, "website": "https://whitebox.com" }, + { + "id": "Sourcegraph", + "image": "https://images.opencollective.com/sourcegraph/67e40ff/logo.png", + "name": "Sourcegraph", + "tier": "contributor", + "totalDonations": 40000, + "website": "https://about.sourcegraph.com" + }, { "id": "Monito", "image": "https://images.opencollective.com/monito/50fc878/logo.png", @@ -103,20 +111,12 @@ "totalDonations": 30000, "website": "https://www.monito.com" }, - { - "id": "Sourcegraph", - "image": "https://images.opencollective.com/sourcegraph/67e40ff/logo.png", - "name": "Sourcegraph", - "tier": "contributor", - "totalDonations": 30000, - "website": "https://about.sourcegraph.com" - }, { "id": "STORIS", "image": "https://images.opencollective.com/storis/dfb0e13/logo.png", "name": "STORIS", "tier": "contributor", - "totalDonations": 24000, + "totalDonations": 25500, "website": "https://www.storis.com/" }, { @@ -136,21 +136,29 @@ "website": "https://twitter.com/nevir" }, { - "id": "Joe Alden", - "image": "https://images.opencollective.com/joealden/44a6738/avatar.png", - "name": "Joe Alden", + "id": "Codiga", + "image": "https://images.opencollective.com/codiga/1065f9f/logo.png", + "name": "Codiga", "tier": "contributor", - "totalDonations": 14000, - "website": "https://joealden.com" + "totalDonations": 20000, + "website": "https://www.codiga.io" }, { "id": "David Johnston", "image": "https://images.opencollective.com/blacksheepcode/976d69a/avatar.png", "name": "David Johnston", "tier": "contributor", - "totalDonations": 14000, + "totalDonations": 14500, "website": "https://blacksheepcode.com" }, + { + "id": "Joe Alden", + "image": "https://images.opencollective.com/joealden/44a6738/avatar.png", + "name": "Joe Alden", + "tier": "contributor", + "totalDonations": 14000, + "website": "https://joealden.com" + }, { "id": "Gianfranco Palumbo", "image": "https://images.opencollective.com/gianpaj/5d62d25/avatar.png", @@ -174,13 +182,5 @@ "tier": "contributor", "totalDonations": 10000, "website": "https://laserhub.com/" - }, - { - "id": "Codiga", - "image": "https://images.opencollective.com/codiga/1065f9f/logo.png", - "name": "Codiga", - "tier": "contributor", - "totalDonations": 10000, - "website": "https://www.codiga.io" } ] diff --git a/packages/website/package.json b/packages/website/package.json index ccc87860a0bb..d1b28be8e5b3 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "5.38.1", + "version": "5.39.0", "private": true, "scripts": { "build": "docusaurus build", @@ -20,8 +20,8 @@ "@docusaurus/remark-plugin-npm2yarn": "~2.0.1", "@docusaurus/theme-common": "~2.0.1", "@mdx-js/react": "1.6.22", - "@typescript-eslint/parser": "5.38.1", - "@typescript-eslint/website-eslint": "5.38.1", + "@typescript-eslint/parser": "5.39.0", + "@typescript-eslint/website-eslint": "5.39.0", "clsx": "^1.1.1", "eslint": "*", "json-schema": "^0.4.0", @@ -45,7 +45,7 @@ "@types/react": "^18.0.9", "@types/react-helmet": "^6.1.5", "@types/react-router-dom": "^5.3.3", - "@typescript-eslint/eslint-plugin": "5.38.1", + "@typescript-eslint/eslint-plugin": "5.39.0", "copy-webpack-plugin": "^11.0.0", "cypress": "8.3.0", "cypress-axe": "^0.14.0", diff --git a/packages/website/src/components/ASTViewerTS.tsx b/packages/website/src/components/ASTViewerTS.tsx index 1bbe5799a056..30dda954a43d 100644 --- a/packages/website/src/components/ASTViewerTS.tsx +++ b/packages/website/src/components/ASTViewerTS.tsx @@ -53,7 +53,17 @@ export default function ASTViewerTS({ ['TypeFlags', typeFlags], ); setModel(serialize(value, scopeSerializer)); - }, [value, syntaxKind]); + }, [ + value, + syntaxKind, + nodeFlags, + tokenFlags, + modifierFlags, + objectFlags, + symbolFlags, + flowFlags, + typeFlags, + ]); return ( diff --git a/packages/website/src/components/OptionsSelector.tsx b/packages/website/src/components/OptionsSelector.tsx index a39797d062b2..fe573ef86ab1 100644 --- a/packages/website/src/components/OptionsSelector.tsx +++ b/packages/website/src/components/OptionsSelector.tsx @@ -51,7 +51,7 @@ function OptionsSelectorContent({ .then(() => { setCopyLink(true); }); - }, []); + }, [setCopyLink]); const copyMarkdownToClipboard = useCallback(() => { if (isLoading) { @@ -60,7 +60,7 @@ function OptionsSelectorContent({ void navigator.clipboard.writeText(createMarkdown(state)).then(() => { setCopyMarkdown(true); }); - }, [state, isLoading]); + }, [isLoading, state, setCopyMarkdown]); const openIssue = useCallback(() => { if (isLoading) { diff --git a/packages/website/src/components/Playground.tsx b/packages/website/src/components/Playground.tsx index 3330e4998617..2a643a93976e 100644 --- a/packages/website/src/components/Playground.tsx +++ b/packages/website/src/components/Playground.tsx @@ -84,6 +84,15 @@ function Playground(): JSX.Element { [setState], ); + const onLoaded = useCallback( + (ruleNames: RuleDetails[], tsVersions: readonly string[]): void => { + setRuleNames(ruleNames); + setTSVersion(tsVersions); + setIsLoading(false); + }, + [], + ); + return (
{ruleNames.length > 0 && ( @@ -150,11 +159,7 @@ function Playground(): JSX.Element { onMarkersChange={setMarkers} decoration={selectedRange} onChange={setState} - onLoaded={(ruleNames, tsVersions): void => { - setRuleNames(ruleNames); - setTSVersion(tsVersions); - setIsLoading(false); - }} + onLoaded={onLoaded} onSelect={setPosition} />
diff --git a/packages/website/src/components/ast/Elements.tsx b/packages/website/src/components/ast/Elements.tsx index 985a5f01d814..b8a9d7c823c6 100644 --- a/packages/website/src/components/ast/Elements.tsx +++ b/packages/website/src/components/ast/Elements.tsx @@ -30,7 +30,7 @@ export function ComplexItem({ } } }, - [data], + [data.model.range, onSelectNode], ); useEffect(() => { @@ -44,10 +44,10 @@ export function ComplexItem({ level !== 'ast' && selected && !hasChildInRange(selection, data.model), ); - if (selected && !isExpanded) { + if (selected) { setIsExpanded(selected); } - }, [selection, data]); + }, [selection, data, level]); return ( ) => { e.preventDefault(); - props.onClick?.(e); + onClickProps?.(e); }, - [props.onClick], + [onClickProps], ); const onMouseEnter = useCallback(() => { - props.onHover?.(true); - }, [props.onHover]); + onHover?.(true); + }, [onHover]); const onMouseLeave = useCallback(() => { - props.onHover?.(false); - }, [props.onHover]); + onHover?.(false); + }, [onHover]); return props.onClick || props.onHover ? ( <> diff --git a/packages/website/src/components/ast/SimpleItem.tsx b/packages/website/src/components/ast/SimpleItem.tsx index 1bc3d368049f..23a25a8a57d0 100644 --- a/packages/website/src/components/ast/SimpleItem.tsx +++ b/packages/website/src/components/ast/SimpleItem.tsx @@ -20,7 +20,7 @@ export function SimpleItem({ onSelectNode(state ? data.model.range : null); } }, - [data], + [data.model.range, onSelectNode], ); return ( diff --git a/packages/website/src/components/config/ConfigEditor.tsx b/packages/website/src/components/config/ConfigEditor.tsx index 538ee85dd1b0..1d6e9346e0b1 100644 --- a/packages/website/src/components/config/ConfigEditor.tsx +++ b/packages/website/src/components/config/ConfigEditor.tsx @@ -89,26 +89,27 @@ function isDefault(value: unknown, defaults?: unknown[]): boolean { } function ConfigEditor(props: ConfigEditorProps): JSX.Element { + const { onClose: onCloseProps, isOpen, values } = props; const [filter, setFilter] = useState(''); const [config, setConfig] = useReducer(reducerObject, {}); const [filterInput, setFilterFocus] = useFocus(); const onClose = useCallback(() => { - props.onClose(config); - }, [props.onClose, config]); + onCloseProps(config); + }, [onCloseProps, config]); useEffect(() => { - setConfig({ type: 'init', config: props.values }); - }, [props.values]); + setConfig({ type: 'init', config: values }); + }, [values]); useEffect(() => { - if (props.isOpen) { + if (isOpen) { setFilterFocus(); } - }, [props.isOpen]); + }, [isOpen, setFilterFocus]); return ( - +
([]); const [configObject, updateConfigObject] = useState(); useEffect(() => { - if (props.isOpen) { - updateConfigObject(parseESLintRC(props.config)); + if (isOpen) { + updateConfigObject(parseESLintRC(config)); } - }, [props.isOpen, props.config]); + }, [isOpen, config]); useEffect(() => { updateOptions([ { heading: 'Rules', - fields: props.ruleOptions + fields: ruleOptions .filter(item => item.name.startsWith('@typescript')) .map(item => ({ key: item.name, @@ -52,7 +53,7 @@ function ConfigEslint(props: ConfigEslintProps): JSX.Element { }, { heading: 'Core rules', - fields: props.ruleOptions + fields: ruleOptions .filter(item => !item.name.startsWith('@typescript')) .map(item => ({ key: item.name, @@ -62,7 +63,7 @@ function ConfigEslint(props: ConfigEslintProps): JSX.Element { })), }, ]); - }, [props.ruleOptions]); + }, [ruleOptions]); const onClose = useCallback( (newConfig: Record) => { @@ -76,14 +77,14 @@ function ConfigEslint(props: ConfigEslintProps): JSX.Element { .filter(checkOptions), ); if (!shallowEqual(cfg, configObject?.rules)) { - props.onClose({ + onCloseProps({ eslintrc: toJson({ ...(configObject ?? {}), rules: cfg }), }); } else { - props.onClose(); + onCloseProps(); } }, - [props.onClose, configObject], + [onCloseProps, configObject], ); return ( @@ -91,7 +92,7 @@ function ConfigEslint(props: ConfigEslintProps): JSX.Element { header="Eslint Config" options={options} values={configObject?.rules ?? {}} - isOpen={props.isOpen} + isOpen={isOpen} onClose={onClose} /> ); diff --git a/packages/website/src/components/config/ConfigTypeScript.tsx b/packages/website/src/components/config/ConfigTypeScript.tsx index 78cccd9e9e69..40cd634ffb17 100644 --- a/packages/website/src/components/config/ConfigTypeScript.tsx +++ b/packages/website/src/components/config/ConfigTypeScript.tsx @@ -13,14 +13,15 @@ interface ConfigTypeScriptProps { } function ConfigTypeScript(props: ConfigTypeScriptProps): JSX.Element { + const { onClose: onCloseProps, isOpen, config } = props; const [tsConfigOptions, updateOptions] = useState([]); const [configObject, updateConfigObject] = useState(); useEffect(() => { - if (props.isOpen) { - updateConfigObject(parseTSConfig(props.config)); + if (isOpen) { + updateConfigObject(parseTSConfig(config)); } - }, [props.isOpen, props.config]); + }, [isOpen, config]); useEffect(() => { if (window.ts) { @@ -54,20 +55,20 @@ function ConfigTypeScript(props: ConfigTypeScriptProps): JSX.Element { ), ); } - }, [props.isOpen]); + }, [isOpen]); const onClose = useCallback( (newConfig: Record) => { const cfg = { ...newConfig }; if (!shallowEqual(cfg, configObject?.compilerOptions)) { - props.onClose({ + onCloseProps({ tsconfig: toJson({ ...(configObject ?? {}), compilerOptions: cfg }), }); } else { - props.onClose(); + onCloseProps(); } }, - [props.onClose, configObject], + [onCloseProps, configObject], ); return ( @@ -75,7 +76,7 @@ function ConfigTypeScript(props: ConfigTypeScriptProps): JSX.Element { header="TypeScript Config" options={tsConfigOptions} values={configObject?.compilerOptions ?? {}} - isOpen={props.isOpen} + isOpen={isOpen} onClose={onClose} /> ); diff --git a/packages/website/src/components/editor/LoadedEditor.tsx b/packages/website/src/components/editor/LoadedEditor.tsx index 3b959580193d..e641d77baa5a 100644 --- a/packages/website/src/components/editor/LoadedEditor.tsx +++ b/packages/website/src/components/editor/LoadedEditor.tsx @@ -47,7 +47,8 @@ export const LoadedEditor: React.FC = ({ webLinter, activeTab, }) => { - const [decorations, setDecorations] = useState([]); + const [_, setDecorations] = useState([]); + const codeActions = useRef(new Map()).current; const [tabs] = useState>(() => { const tabsDefault = { @@ -75,7 +76,12 @@ export const LoadedEditor: React.FC = ({ resource: model.uri, }); onMarkersChange(parseMarkers(markers, codeActions, sandboxInstance.editor)); - }, []); + }, [ + codeActions, + onMarkersChange, + sandboxInstance.editor, + sandboxInstance.monaco.editor, + ]); useEffect(() => { const newPath = jsx ? '/input.tsx' : '/input.ts'; @@ -92,7 +98,13 @@ export const LoadedEditor: React.FC = ({ tabs.code.dispose(); tabs.code = newModel; } - }, [jsx]); + }, [ + jsx, + sandboxInstance.editor, + sandboxInstance.monaco.Uri, + sandboxInstance.monaco.editor, + tabs, + ]); useEffect(() => { const config = createCompilerOptions( @@ -101,19 +113,19 @@ export const LoadedEditor: React.FC = ({ ); webLinter.updateCompilerOptions(config); sandboxInstance.setCompilerSettings(config); - }, [jsx, tsconfig]); + }, [jsx, sandboxInstance, tsconfig, webLinter]); useEffect(() => { webLinter.updateRules(parseESLintRC(eslintrc).rules); - }, [eslintrc]); + }, [eslintrc, webLinter]); useEffect(() => { sandboxInstance.editor.setModel(tabs[activeTab]); updateMarkers(); - }, [activeTab]); + }, [activeTab, sandboxInstance.editor, tabs, updateMarkers]); - useEffect( - debounce(() => { + useEffect(() => { + const lintEditor = debounce(() => { // eslint-disable-next-line no-console console.info('[Editor] linting triggered'); @@ -146,9 +158,28 @@ export const LoadedEditor: React.FC = ({ onTsASTChange(webLinter.storedTsAST); onScopeChange(webLinter.storedScope); onSelect(sandboxInstance.editor.getPosition()); - }, 500), - [code, jsx, tsconfig, eslintrc, sourceType, webLinter], - ); + }, 500); + + lintEditor(); + }, [ + code, + jsx, + tsconfig, + eslintrc, + sourceType, + webLinter, + onEsASTChange, + onTsASTChange, + onScopeChange, + onSelect, + sandboxInstance.editor, + sandboxInstance.monaco.editor, + sandboxInstance.monaco.Uri, + codeActions, + tabs.code, + updateMarkers, + onMarkersChange, + ]); useEffect(() => { // configure the JSON language support with schemas and schema associations @@ -222,7 +253,20 @@ export const LoadedEditor: React.FC = ({ } } }; - }, []); + }, [ + codeActions, + main.languages, + onChange, + onSelect, + sandboxInstance.editor, + sandboxInstance.monaco.editor, + sandboxInstance.monaco.languages.json.jsonDefaults, + tabs.code, + tabs.eslintrc, + tabs.tsconfig, + updateMarkers, + webLinter.ruleNames, + ]); const resize = useMemo(() => { return debounce(() => sandboxInstance.editor.layout(), 1); @@ -237,7 +281,7 @@ export const LoadedEditor: React.FC = ({ return new ResizeObserver(() => { resize(); }); - }, []); + }, [resize]); useEffect(() => { if (domNode) { @@ -246,7 +290,7 @@ export const LoadedEditor: React.FC = ({ return (): void => resizeObserver.unobserve(domNode); } return (): void => {}; - }, [domNode]); + }, [domNode, resizeObserver]); useEffect(() => { window.addEventListener('resize', resize); @@ -264,7 +308,7 @@ export const LoadedEditor: React.FC = ({ }, ]); } - }, [code]); + }, [code, tabs.code]); useEffect(() => { if (tsconfig !== tabs.tsconfig.getValue()) { @@ -275,7 +319,7 @@ export const LoadedEditor: React.FC = ({ }, ]); } - }, [tsconfig]); + }, [tabs.tsconfig, tsconfig]); useEffect(() => { if (eslintrc !== tabs.eslintrc.getValue()) { @@ -286,7 +330,7 @@ export const LoadedEditor: React.FC = ({ }, ]); } - }, [eslintrc]); + }, [eslintrc, tabs.eslintrc]); useEffect(() => { sandboxInstance.monaco.editor.setTheme(darkTheme ? 'vs-dark' : 'vs-light'); @@ -294,9 +338,9 @@ export const LoadedEditor: React.FC = ({ useEffect(() => { if (sandboxInstance.editor.getModel() === tabs.code) { - setDecorations( + setDecorations(prevDecorations => sandboxInstance.editor.deltaDecorations( - decorations, + prevDecorations, decoration && showAST ? [ { @@ -316,7 +360,7 @@ export const LoadedEditor: React.FC = ({ ), ); } - }, [decoration, sandboxInstance, showAST]); + }, [decoration, sandboxInstance, showAST, tabs.code]); return null; }; diff --git a/packages/website/src/components/editor/useSandboxServices.ts b/packages/website/src/components/editor/useSandboxServices.ts index d316f75acf97..73c336676b34 100644 --- a/packages/website/src/components/editor/useSandboxServices.ts +++ b/packages/website/src/components/editor/useSandboxServices.ts @@ -32,6 +32,7 @@ export interface SandboxServices { export const useSandboxServices = ( props: SandboxServicesProps, ): Error | SandboxServices | undefined => { + const { onLoaded } = props; const [services, setServices] = useState(); const [loadedTs, setLoadedTs] = useState(props.ts); const { colorMode } = useColorMode(); @@ -109,7 +110,7 @@ export const useSandboxServices = ( const webLinter = new WebLinter(system, compilerOptions, lintUtils); - props.onLoaded( + onLoaded( webLinter.ruleNames, Array.from( new Set([...sandboxInstance.supportedVersions, window.ts.version]), @@ -144,7 +145,7 @@ export const useSandboxServices = ( model.dispose(); } }; - }, [props.ts]); + }, [props.ts, colorMode, props.jsx, onLoaded]); return services; }; diff --git a/packages/website/src/components/hooks/useDebouncedToggle.ts b/packages/website/src/components/hooks/useDebouncedToggle.ts index b34bb889b0ac..d857f4aea2c0 100644 --- a/packages/website/src/components/hooks/useDebouncedToggle.ts +++ b/packages/website/src/components/hooks/useDebouncedToggle.ts @@ -19,7 +19,7 @@ export default function useDebouncedToggle( setState(value); }, timeout); }, - [timeoutIdRef], + [timeout, value], ); return [state, update]; diff --git a/packages/website/src/components/inputs/Checkbox.tsx b/packages/website/src/components/inputs/Checkbox.tsx index ed5a473b1578..0134bfa40012 100644 --- a/packages/website/src/components/inputs/Checkbox.tsx +++ b/packages/website/src/components/inputs/Checkbox.tsx @@ -1,4 +1,4 @@ -import React, { createRef, useEffect } from 'react'; +import React, { useCallback } from 'react'; export interface CheckboxProps { readonly name: string; @@ -10,17 +10,18 @@ export interface CheckboxProps { } function Checkbox(props: CheckboxProps): JSX.Element { - const checkboxRef = createRef(); + const { indeterminate } = props; - useEffect(() => { - if (!checkboxRef.current) { - return; - } + const checkboxRef = useCallback( + (node: HTMLInputElement | null) => { + if (!node) { + return; + } - if (props.indeterminate !== checkboxRef.current.indeterminate) { - checkboxRef.current.indeterminate = props.indeterminate ?? false; - } - }, [props.indeterminate]); + node.indeterminate = indeterminate ?? false; + }, + [indeterminate], + ); return ( { const closeOnEscapeKeyDown = (e: KeyboardEvent): void => { if ( @@ -21,7 +23,7 @@ function Modal(props: ModalProps): JSX.Element { // eslint-disable-next-line deprecation/deprecation -- intentional fallback for old browsers e.keyCode === 27 ) { - props.onClose(); + onClose(); } }; @@ -29,15 +31,15 @@ function Modal(props: ModalProps): JSX.Element { return (): void => { document.body.removeEventListener('keydown', closeOnEscapeKeyDown); }; - }, []); + }, [onClose]); const onClick = useCallback( (e: MouseEvent) => { if (e.currentTarget === e.target) { - props.onClose(); + onClose(); } }, - [props.onClose], + [onClose], ); return (