diff --git a/CHANGELOG.md b/CHANGELOG.md index 951e8468b548..833b81fbdda4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,9 +27,13 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom #### Bug fixes - Fix [#557](https://github.com/biomejs/biome/issues/557) which made [noUnusedImports](https://biomejs.dev/linter/rules/no-unused-imports) report imported types used in `typeof` expression. Contributed by @Conaclos + - Fix [#576](https://github.com/biomejs/biome/issues/576) by removing some erroneous logic in [noSelfAssign](https://biomejs.dev/linter/rules/no-self-assign/). Contributed by @ematipico + - Fix [#595](https://github.com/biomejs/biome/issues/595) by updating unsafe-apply logic to avoid unexpected errors in [noUselessFragments](https://biomejs.dev/linter/rules/no-useless-fragments/). Contributed by @nissy-dev +- Fix [#591](https://github.com/biomejs/biome/issues/591) which made [noRedeclare](https://biomejs.dev/linter/rules/no-redeclare) report type parameters with identical names but in different method signatures. Contributed by @Conaclos + ### Parser ### VSCode diff --git a/crates/biome_js_analyze/src/semantic_analyzers/correctness/use_exhaustive_dependencies.rs b/crates/biome_js_analyze/src/semantic_analyzers/correctness/use_exhaustive_dependencies.rs index caa3eb58eaf3..a06a1defecd6 100644 --- a/crates/biome_js_analyze/src/semantic_analyzers/correctness/use_exhaustive_dependencies.rs +++ b/crates/biome_js_analyze/src/semantic_analyzers/correctness/use_exhaustive_dependencies.rs @@ -692,7 +692,7 @@ impl Rule for UseExhaustiveDependencies { rule_category!(), use_effect_range, markup! { - "This hook do not specify all of its dependencies." + "This hook does not specify all of its dependencies." }, ); diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/checkHooksImportedFromReact.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/checkHooksImportedFromReact.js.snap index 3d0a97a5dff4..5f3d9667a7bb 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/checkHooksImportedFromReact.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/checkHooksImportedFromReact.js.snap @@ -31,7 +31,7 @@ function MyComponent2() { ``` checkHooksImportedFromReact.js:3:9 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 1 │ function MyComponent1() { 2 │ let a = 1; diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.js.snap index 1f082f589d57..cdfbefd31bf2 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/customHook.js.snap @@ -22,7 +22,7 @@ function MyComponent() { ``` customHook.js:5:5 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 3 │ function MyComponent() { 4 │ let a = 1; @@ -46,7 +46,7 @@ customHook.js:5:5 lint/correctness/useExhaustiveDependencies ━━━━━━ ``` customHook.js:8:5 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 6 │ console.log(a); 7 │ }); diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap index 336719c8002e..a97f3b502f6c 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/extraDependenciesInvalid.js.snap @@ -156,7 +156,7 @@ extraDependenciesInvalid.js:28:3 lint/correctness/useExhaustiveDependencies ━ ``` extraDependenciesInvalid.js:28:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 26 │ function MyComponent1() { 27 │ let someObj = getObj(); diff --git a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.js.snap b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.js.snap index 1bdd71a041b0..33e8521912bd 100644 --- a/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/correctness/useExhaustiveDependencies/missingDependenciesInvalid.js.snap @@ -136,7 +136,7 @@ function MyComponent13() { ``` missingDependenciesInvalid.js:7:5 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 5 │ let a = 1; 6 │ const b = a + 1; @@ -160,7 +160,7 @@ missingDependenciesInvalid.js:7:5 lint/correctness/useExhaustiveDependencies ━ ``` missingDependenciesInvalid.js:7:5 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 5 │ let a = 1; 6 │ const b = a + 1; @@ -184,7 +184,7 @@ missingDependenciesInvalid.js:7:5 lint/correctness/useExhaustiveDependencies ━ ``` missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 19 │ const deferredValue = useDeferredValue(value); 20 │ const [isPending, startTransition] = useTransition(); @@ -208,7 +208,7 @@ missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 19 │ const deferredValue = useDeferredValue(value); 20 │ const [isPending, startTransition] = useTransition(); @@ -232,7 +232,7 @@ missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 19 │ const deferredValue = useDeferredValue(value); 20 │ const [isPending, startTransition] = useTransition(); @@ -256,7 +256,7 @@ missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 19 │ const deferredValue = useDeferredValue(value); 20 │ const [isPending, startTransition] = useTransition(); @@ -280,7 +280,7 @@ missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 19 │ const deferredValue = useDeferredValue(value); 20 │ const [isPending, startTransition] = useTransition(); @@ -304,7 +304,7 @@ missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 19 │ const deferredValue = useDeferredValue(value); 20 │ const [isPending, startTransition] = useTransition(); @@ -327,7 +327,7 @@ missingDependenciesInvalid.js:21:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:41:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 39 │ function MyComponent3() { 40 │ let a = 1; @@ -351,7 +351,7 @@ missingDependenciesInvalid.js:41:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:42:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 40 │ let a = 1; 41 │ useEffect(() => console.log(a)); @@ -375,7 +375,7 @@ missingDependenciesInvalid.js:42:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:43:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 41 │ useEffect(() => console.log(a)); 42 │ useCallback(() => console.log(a)); @@ -399,7 +399,7 @@ missingDependenciesInvalid.js:43:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:44:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 42 │ useCallback(() => console.log(a)); 43 │ useMemo(() => console.log(a)); @@ -423,7 +423,7 @@ missingDependenciesInvalid.js:44:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:45:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 43 │ useMemo(() => console.log(a)); 44 │ useImperativeHandle(ref, () => console.log(a)); @@ -447,7 +447,7 @@ missingDependenciesInvalid.js:45:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:46:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 44 │ useImperativeHandle(ref, () => console.log(a)); 45 │ useLayoutEffect(() => console.log(a)); @@ -471,7 +471,7 @@ missingDependenciesInvalid.js:46:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:53:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 51 │ function MyComponent4() { 52 │ let a = 1; @@ -495,7 +495,7 @@ missingDependenciesInvalid.js:53:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:62:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 60 │ function MyComponent5() { 61 │ let a = 1; @@ -528,7 +528,7 @@ missingDependenciesInvalid.js:62:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:72:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 70 │ function MyComponent6() { 71 │ let someObj = getObj(); @@ -552,7 +552,7 @@ missingDependenciesInvalid.js:72:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:78:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 77 │ const MyComponent7 = React.memo(function ({ a }) { > 78 │ useEffect(() => { @@ -575,7 +575,7 @@ missingDependenciesInvalid.js:78:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:84:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 83 │ const MyComponent8 = React.memo(({ a }) => { > 84 │ useEffect(() => { @@ -598,7 +598,7 @@ missingDependenciesInvalid.js:84:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:92:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 90 │ export function MyComponent9() { 91 │ let a = 1; @@ -622,7 +622,7 @@ missingDependenciesInvalid.js:92:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:99:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 97 │ export default function MyComponent10() { 98 │ let a = 1; @@ -646,7 +646,7 @@ missingDependenciesInvalid.js:99:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:107:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 105 │ function MyComponent11() { 106 │ let a = 1; @@ -670,7 +670,7 @@ missingDependenciesInvalid.js:107:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:114:3 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 112 │ function MyComponent12() { 113 │ let a = 1; @@ -694,7 +694,7 @@ missingDependenciesInvalid.js:114:3 lint/correctness/useExhaustiveDependencies ``` missingDependenciesInvalid.js:122:9 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━ - ! This hook do not specify all of its dependencies. + ! This hook does not specify all of its dependencies. 120 │ function MyComponent13() { 121 │ let a = 1; diff --git a/crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/validMethodTypeParam.ts b/crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/validMethodTypeParam.ts new file mode 100644 index 000000000000..f3c0c94d9eec --- /dev/null +++ b/crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/validMethodTypeParam.ts @@ -0,0 +1,14 @@ +interface I { + get(f: T): T; + post(g: T): T; +} + +type A = { + get(f: T): T; + post(g: T): T; +} + +declare class C { + get(f: T): T; + post(g: T): T; +} diff --git a/crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/validMethodTypeParam.ts.snap b/crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/validMethodTypeParam.ts.snap new file mode 100644 index 000000000000..6fd793b47bd7 --- /dev/null +++ b/crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/validMethodTypeParam.ts.snap @@ -0,0 +1,24 @@ +--- +source: crates/biome_js_analyze/tests/spec_tests.rs +expression: validMethodTypeParam.ts +--- +# Input +```js +interface I { + get(f: T): T; + post(g: T): T; +} + +type A = { + get(f: T): T; + post(g: T): T; +} + +declare class C { + get(f: T): T; + post(g: T): T; +} + +``` + + diff --git a/crates/biome_js_semantic/src/events.rs b/crates/biome_js_semantic/src/events.rs index e8cf3984f449..b1d1b11efe01 100644 --- a/crates/biome_js_semantic/src/events.rs +++ b/crates/biome_js_semantic/src/events.rs @@ -324,7 +324,9 @@ impl SemanticEventExtractor { | TS_ENUM_DECLARATION | TS_TYPE_ALIAS_DECLARATION | TS_DECLARE_FUNCTION_DECLARATION - | TS_DECLARE_FUNCTION_EXPORT_DEFAULT_DECLARATION => { + | TS_DECLARE_FUNCTION_EXPORT_DEFAULT_DECLARATION + | TS_METHOD_SIGNATURE_CLASS_MEMBER + | TS_METHOD_SIGNATURE_TYPE_MEMBER => { self.push_scope( node.text_range(), ScopeHoisting::DontHoistDeclarationsToParent, @@ -602,6 +604,8 @@ impl SemanticEventExtractor { | JS_STATIC_INITIALIZATION_BLOCK_CLASS_MEMBER | TS_DECLARE_FUNCTION_DECLARATION | TS_DECLARE_FUNCTION_EXPORT_DEFAULT_DECLARATION + | TS_METHOD_SIGNATURE_CLASS_MEMBER + | TS_METHOD_SIGNATURE_TYPE_MEMBER | TS_INTERFACE_DECLARATION | TS_ENUM_DECLARATION | TS_TYPE_ALIAS_DECLARATION diff --git a/website/src/content/docs/internals/changelog.mdx b/website/src/content/docs/internals/changelog.mdx index 870067193c27..5e88d823f8ed 100644 --- a/website/src/content/docs/internals/changelog.mdx +++ b/website/src/content/docs/internals/changelog.mdx @@ -33,9 +33,13 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom #### Bug fixes - Fix [#557](https://github.com/biomejs/biome/issues/557) which made [noUnusedImports](https://biomejs.dev/linter/rules/no-unused-imports) report imported types used in `typeof` expression. Contributed by @Conaclos + - Fix [#576](https://github.com/biomejs/biome/issues/576) by removing some erroneous logic in [noSelfAssign](https://biomejs.dev/linter/rules/no-self-assign/). Contributed by @ematipico + - Fix [#595](https://github.com/biomejs/biome/issues/595) by updating unsafe-apply logic to avoid unexpected errors in [noUselessFragments](https://biomejs.dev/linter/rules/no-useless-fragments/). Contributed by @nissy-dev +- Fix [#591](https://github.com/biomejs/biome/issues/591) which made [noRedeclare](https://biomejs.dev/linter/rules/no-redeclare) report type parameters with identical names but in different method signatures. Contributed by @Conaclos + ### Parser ### VSCode diff --git a/website/src/content/docs/linter/rules/use-exhaustive-dependencies.md b/website/src/content/docs/linter/rules/use-exhaustive-dependencies.md index 2f856ea3c14a..0e30387ccba4 100644 --- a/website/src/content/docs/linter/rules/use-exhaustive-dependencies.md +++ b/website/src/content/docs/linter/rules/use-exhaustive-dependencies.md @@ -51,7 +51,7 @@ function component() {
correctness/useExhaustiveDependencies.js:5:5 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━
 
-   This hook do not specify all of its dependencies.
+   This hook does not specify all of its dependencies.
   
     3 │ function component() {
     4 │     let a = 1;
@@ -151,7 +151,7 @@ function component() {
 
 
correctness/useExhaustiveDependencies.js:6:5 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━
 
-   This hook do not specify all of its dependencies.
+   This hook does not specify all of its dependencies.
   
     4 │     let a = 1;
     5 │     const b = a + 1;