From 039e7fec2022fd2808978846ce4b506b71788434 Mon Sep 17 00:00:00 2001 From: Mahesh Date: Sun, 17 Sep 2023 03:23:56 +0530 Subject: [PATCH 1/2] fix: void error on type of a function declaration --- .../src/analyzers/nursery/no_confusing_void_type.rs | 1 + .../tests/specs/nursery/noConfusingVoidType/valid.ts | 2 ++ .../tests/specs/nursery/noConfusingVoidType/valid.ts.snap | 2 +- website/src/content/docs/internals/changelog.mdx | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/biome_js_analyze/src/analyzers/nursery/no_confusing_void_type.rs b/crates/biome_js_analyze/src/analyzers/nursery/no_confusing_void_type.rs index f2df6e6fae91..c8445ea5d414 100644 --- a/crates/biome_js_analyze/src/analyzers/nursery/no_confusing_void_type.rs +++ b/crates/biome_js_analyze/src/analyzers/nursery/no_confusing_void_type.rs @@ -114,6 +114,7 @@ fn node_in(node: &SyntaxNode) -> Option { JsSyntaxKind::TS_THIS_PARAMETER | JsSyntaxKind::TS_RETURN_TYPE_ANNOTATION | JsSyntaxKind::TS_TYPE_PARAMETER + | JsSyntaxKind::TS_FUNCTION_TYPE | JsSyntaxKind::TS_TYPE_ARGUMENT_LIST => { return None; } diff --git a/crates/biome_js_analyze/tests/specs/nursery/noConfusingVoidType/valid.ts b/crates/biome_js_analyze/tests/specs/nursery/noConfusingVoidType/valid.ts index 0e590a71f24b..a35ed7e33554 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noConfusingVoidType/valid.ts +++ b/crates/biome_js_analyze/tests/specs/nursery/noConfusingVoidType/valid.ts @@ -5,3 +5,5 @@ logAndReturn(undefined); let voidPromise: Promise = new Promise(() => { }); let voidMap: Map = new Map(); + +type FallbackHandler = (error?: Error) => void; \ No newline at end of file diff --git a/crates/biome_js_analyze/tests/specs/nursery/noConfusingVoidType/valid.ts.snap b/crates/biome_js_analyze/tests/specs/nursery/noConfusingVoidType/valid.ts.snap index e3e20055d86d..4239668bf62e 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noConfusingVoidType/valid.ts.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/noConfusingVoidType/valid.ts.snap @@ -1,6 +1,5 @@ --- source: crates/biome_js_analyze/tests/spec_tests.rs -assertion_line: 80 expression: valid.ts --- # Input @@ -13,6 +12,7 @@ logAndReturn(undefined); let voidPromise: Promise = new Promise(() => { }); let voidMap: Map = new Map(); +type FallbackHandler = (error?: Error) => void; ``` diff --git a/website/src/content/docs/internals/changelog.mdx b/website/src/content/docs/internals/changelog.mdx index e364abd59152..dae32e986ded 100644 --- a/website/src/content/docs/internals/changelog.mdx +++ b/website/src/content/docs/internals/changelog.mdx @@ -15,7 +15,7 @@ New entries must be placed in a section entitled `Unreleased`. Read our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog). ## Unreleased - +- Fix [#294](https://github.com/biomejs/biome/issues/294) - `useConfusingVoidType` raising error on Function Type ### Analyzer ### CLI ### Configuration From 3c596f8428cff87a0d2b7118cae8028934eec48a Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Sun, 17 Sep 2023 14:50:32 +0200 Subject: [PATCH 2/2] docs: update changelog and website --- CHANGELOG.md | 4 ++++ website/src/content/docs/internals/changelog.mdx | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b01f536066..1d08ffcaa375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom - Add [noMisleadingInstantiator](https://biomejs.dev/linter/rules/no-mileading-instantiator) rule. The rule reports the misleading use of the `new` and `constructor` methods. Contributed by @unvalley +#### Bug fixes + +- Fix [#294](https://github.com/biomejs/biome/issues/294). [noConfusingVoidType](https://biomejs.dev/linter/rules/no-confusing-void-type/) no longer reports false positives for return types. Contributed by @b4s36t4 + ### Parser ### VSCode diff --git a/website/src/content/docs/internals/changelog.mdx b/website/src/content/docs/internals/changelog.mdx index dae32e986ded..4bf3716e8d85 100644 --- a/website/src/content/docs/internals/changelog.mdx +++ b/website/src/content/docs/internals/changelog.mdx @@ -15,7 +15,7 @@ New entries must be placed in a section entitled `Unreleased`. Read our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog). ## Unreleased -- Fix [#294](https://github.com/biomejs/biome/issues/294) - `useConfusingVoidType` raising error on Function Type + ### Analyzer ### CLI ### Configuration @@ -28,6 +28,10 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom - Add [noMisleadingInstantiator](https://biomejs.dev/linter/rules/no-mileading-instantiator) rule. The rule reports the misleading use of the `new` and `constructor` methods. Contributed by @unvalley +#### Bug fixes + +- Fix [#294](https://github.com/biomejs/biome/issues/294). [noConfusingVoidType](https://biomejs.dev/linter/rules/no-confusing-void-type/) no longer reports false positives for return types. Contributed by @b4s36t4 + ### Parser ### VSCode