diff --git a/CHANGELOG.md b/CHANGELOG.md index ac88c2e7ce63..63d59129e43d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,9 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom - Fix [#639](https://github.com/biomejs/biome/issues/639) by ignoring unused TypeScript's mapped key. Contributed by @Conaclos -- Fix [#565](https://github.com/biomejs/biome/issues/565) by handling several `infer` with the same name in extends clauses of TypeScript's conditional types. +- Fix [#565](https://github.com/biomejs/biome/issues/565) by handling several `infer` with the same name in extends clauses of TypeScript's conditional types. Contributed by @Conaclos + +- Fix [#653](https://github.com/biomejs/biome/issues/653). [noUnusedImports](https://biomejs.dev/linter/rules/no-unused-imports) now correctly removes the entire line where the unused `import` is. Contributed by @Conaclos ### Parser diff --git a/crates/biome_js_analyze/src/utils/batch.rs b/crates/biome_js_analyze/src/utils/batch.rs index de05b917a811..d0633ab7a4e4 100644 --- a/crates/biome_js_analyze/src/utils/batch.rs +++ b/crates/biome_js_analyze/src/utils/batch.rs @@ -6,7 +6,7 @@ use biome_js_syntax::{ JsSyntaxNode, JsVariableDeclaration, JsVariableDeclarator, JsVariableDeclaratorList, JsVariableStatement, JsxChildList, T, }; -use biome_rowan::{AstNode, AstSeparatedList, BatchMutation}; +use biome_rowan::{chain_trivia_pieces, AstNode, AstSeparatedList, BatchMutation}; pub trait JsBatchMutation { /// Removes the declarator, and: @@ -312,20 +312,22 @@ impl JsBatchMutation for BatchMutation { let Some(pieces) = node.first_leading_trivia().map(|trivia| trivia.pieces()) else { return; }; - let (sibling, new_sibling) = - if let Some(next_sibling) = node.last_token().and_then(|x| x.next_token()) { - ( - next_sibling.clone(), - next_sibling.prepend_trivia_pieces(pieces), - ) - } else if let Some(prev_sibling) = node.first_token().and_then(|x| x.prev_token()) { - ( - prev_sibling.clone(), - prev_sibling.append_trivia_pieces(pieces), - ) - } else { - return; - }; + let (sibling, new_sibling) = if let Some(next_sibling) = + node.last_token().and_then(|x| x.next_token()) + { + let mut next_sibling_leading_trivia = next_sibling.leading_trivia().pieces().peekable(); + // Remove next newline + next_sibling_leading_trivia.next_if(|piece| piece.is_newline()); + ( + next_sibling.clone(), + next_sibling.with_leading_trivia_pieces(chain_trivia_pieces( + pieces, + next_sibling_leading_trivia, + )), + ) + } else { + return; + }; self.replace_token_discard_trivia(sibling, new_sibling); } } diff --git a/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.js b/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.js index 78abe58a88c6..13986e70352e 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.js +++ b/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.js @@ -22,3 +22,9 @@ import {/*a*/J/*b*/, /*c*/K/*d*/} from "mod"; // Header comment import { L as M, } from "mod"; // Import comment + +// See https://github.com/biomejs/biome/issues/653 +import {a} from 'a' +import {d} from 'd' +import {b} from 'b' +export const bb = a + b \ No newline at end of file diff --git a/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.js.snap b/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.js.snap index 19577ef53f86..002aa380276f 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.js.snap @@ -29,6 +29,11 @@ import {/*a*/J/*b*/, /*c*/K/*d*/} from "mod"; // Header comment import { L as M, } from "mod"; // Import comment +// See https://github.com/biomejs/biome/issues/653 +import {a} from 'a' +import {d} from 'd' +import {b} from 'b' +export const bb = a + b ``` # Diagnostics @@ -47,8 +52,11 @@ invalid.js:2:8 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 2 │ import·A·from·"mod"; - │ -------------------- + 1 1 │ // Header comment + 2 │ - import·A·from·"mod"; + 3 2 │ + 4 3 │ // Header comment + ``` @@ -67,8 +75,12 @@ invalid.js:5:13 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 5 │ import·*·as·B·from·"mod";·//·Import·comment - │ ------------------------------------------- + 3 3 │ + 4 4 │ // Header comment + 5 │ - import·*·as·B·from·"mod";·//·Import·comment + 6 5 │ + 7 6 │ // Header comment + ``` @@ -87,8 +99,12 @@ invalid.js:8:10 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 8 │ import·{·C·}·from·"mod";·//·Import·comment - │ ------------------------------------------ + 6 6 │ + 7 7 │ // Header comment + 8 │ - import·{·C·}·from·"mod";·//·Import·comment + 9 8 │ + 10 9 │ // Header comment + ``` @@ -278,13 +294,44 @@ invalid.js:24:15 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ > 24 │ import { L as M, } from "mod"; // Import comment │ ^ 25 │ + 26 │ // See https://github.com/biomejs/biome/issues/653 i Unused imports might be the result of an incomplete refactoring. i Safe fix: Remove the unused import. - 24 │ import·{·L·as·M,·}·from·"mod";·//·Import·comment - │ ------------------------------------------------ + 22 22 │ + 23 23 │ // Header comment + 24 │ - import·{·L·as·M,·}·from·"mod";·//·Import·comment + 25 24 │ + 26 25 │ // See https://github.com/biomejs/biome/issues/653 + + +``` + +``` +invalid.js:28:9 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This import is unused. + + 26 │ // See https://github.com/biomejs/biome/issues/653 + 27 │ import {a} from 'a' + > 28 │ import {d} from 'd' + │ ^ + 29 │ import {b} from 'b' + 30 │ export const bb = a + b + + i Unused imports might be the result of an incomplete refactoring. + + i Safe fix: Remove the unused import. + + 26 26 │ // See https://github.com/biomejs/biome/issues/653 + 27 27 │ import {a} from 'a' + 28 │ - import·{d}·from·'d' + 29 │ - import·{b}·from·'b' + 28 │ + import·{b}·from·'b' + 30 29 │ export const bb = a + b + ``` diff --git a/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.jsx.snap b/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.jsx.snap index f37aaf6e82b4..c5473b8dc1de 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.jsx.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.jsx.snap @@ -40,8 +40,12 @@ invalid.jsx:1:8 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 1 │ import·X·from·"react" - │ --------------------- + 1 │ - import·X·from·"react" + 2 │ - import·*·as·X·from·"react" + 1 │ + import·*·as·X·from·"react" + 3 2 │ import { default as X } from "react" + 4 3 │ + ``` @@ -60,8 +64,13 @@ invalid.jsx:2:13 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 2 │ import·*·as·X·from·"react" - │ -------------------------- + 1 1 │ import X from "react" + 2 │ - import·*·as·X·from·"react" + 3 │ - import·{·default·as·X·}·from·"react" + 2 │ + import·{·default·as·X·}·from·"react" + 4 3 │ + 5 4 │ import React from "x" + ``` @@ -81,8 +90,12 @@ invalid.jsx:3:21 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 3 │ import·{·default·as·X·}·from·"react" - │ ------------------------------------ + 1 1 │ import X from "react" + 2 2 │ import * as X from "react" + 3 │ - import·{·default·as·X·}·from·"react" + 4 3 │ + 5 4 │ import React from "x" + ``` @@ -102,8 +115,14 @@ invalid.jsx:5:8 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 5 │ import·React·from·"x" - │ --------------------- + 3 3 │ import { default as X } from "react" + 4 4 │ + 5 │ - import·React·from·"x" + 6 │ - import·*·as·React·from·"x" + 5 │ + import·*·as·React·from·"x" + 7 6 │ import { default as React } from "x" + 8 7 │ import React, { useEffect } from "x" + ``` @@ -122,8 +141,14 @@ invalid.jsx:6:13 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 6 │ import·*·as·React·from·"x" - │ -------------------------- + 4 4 │ + 5 5 │ import React from "x" + 6 │ - import·*·as·React·from·"x" + 7 │ - import·{·default·as·React·}·from·"x" + 6 │ + import·{·default·as·React·}·from·"x" + 8 7 │ import React, { useEffect } from "x" + 9 8 │ + ``` @@ -143,8 +168,14 @@ invalid.jsx:7:21 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 7 │ import·{·default·as·React·}·from·"x" - │ ------------------------------------ + 5 5 │ import React from "x" + 6 6 │ import * as React from "x" + 7 │ - import·{·default·as·React·}·from·"x" + 8 │ - import·React,·{·useEffect·}·from·"x" + 7 │ + import·React,·{·useEffect·}·from·"x" + 9 8 │ + 10 9 │ // unsupported patterns + ``` @@ -287,8 +318,14 @@ invalid.jsx:15:8 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 15 │ import·React·from·"react" - │ ------------------------- + 13 13 │ + 14 14 │ // React import (no exception) + 15 │ - import·React·from·"react" + 16 │ - import·*·as·React·from·"react" + 15 │ + import·*·as·React·from·"react" + 17 16 │ import { default as React } from "react" + 18 17 │ import React, { useEffect } from "react" + ``` @@ -308,8 +345,14 @@ invalid.jsx:16:13 lint/nursery/noUnusedImports FIXABLE ━━━━━━━ i Safe fix: Remove the unused import. - 16 │ import·*·as·React·from·"react" - │ ------------------------------ + 14 14 │ // React import (no exception) + 15 15 │ import React from "react" + 16 │ - import·*·as·React·from·"react" + 17 │ - import·{·default·as·React·}·from·"react" + 16 │ + import·{·default·as·React·}·from·"react" + 18 17 │ import React, { useEffect } from "react" + 19 18 │ + ``` @@ -329,8 +372,13 @@ invalid.jsx:17:21 lint/nursery/noUnusedImports FIXABLE ━━━━━━━ i Safe fix: Remove the unused import. - 17 │ import·{·default·as·React·}·from·"react" - │ ---------------------------------------- + 15 15 │ import React from "react" + 16 16 │ import * as React from "react" + 17 │ - import·{·default·as·React·}·from·"react" + 18 │ - import·React,·{·useEffect·}·from·"react" + 17 │ + import·React,·{·useEffect·}·from·"react" + 19 18 │ + ``` diff --git a/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.ts.snap b/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.ts.snap index 337f2922155b..afa91eec4abf 100644 --- a/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.ts.snap +++ b/crates/biome_js_analyze/tests/specs/nursery/noUnusedImports/invalid.ts.snap @@ -47,8 +47,11 @@ invalid.ts:2:13 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 2 │ import·type·A·from·"mod"; - │ ------------------------- + 1 1 │ // Header comment + 2 │ - import·type·A·from·"mod"; + 3 2 │ + 4 3 │ // Header comment + ``` @@ -67,8 +70,12 @@ invalid.ts:5:18 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 5 │ import·type·*·as·B·from·"mod";·//·Import·comment - │ ------------------------------------------------ + 3 3 │ + 4 4 │ // Header comment + 5 │ - import·type·*·as·B·from·"mod";·//·Import·comment + 6 5 │ + 7 6 │ // Header comment + ``` @@ -87,8 +94,12 @@ invalid.ts:8:15 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 8 │ import·type·{·C·}·from·"mod";·//·Import·comment - │ ----------------------------------------------- + 6 6 │ + 7 7 │ // Header comment + 8 │ - import·type·{·C·}·from·"mod";·//·Import·comment + 9 8 │ + 10 9 │ // Header comment + ``` @@ -283,8 +294,11 @@ invalid.ts:24:20 lint/nursery/noUnusedImports FIXABLE ━━━━━━━━ i Safe fix: Remove the unused import. - 24 │ import·type·{·L·as·M,·}·from·"mod";·//·Import·comment - │ ----------------------------------------------------- + 22 22 │ + 23 23 │ // Header comment + 24 │ - import·type·{·L·as·M,·}·from·"mod";·//·Import·comment + 25 24 │ + ``` diff --git a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.cjs.snap b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.cjs.snap index 27a37c4f9c1e..edf4c635e5c3 100644 --- a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.cjs.snap +++ b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.cjs.snap @@ -42,8 +42,11 @@ invalid.cjs:2:1 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━ i Safe fix: Remove the redundant use strict directive. - 2 │ "use·strict"; - │ ------------- + 1 1 │ "use strict"; + 2 │ - "use·strict"; + 3 2 │ + 4 3 │ function test() { + ``` @@ -67,8 +70,14 @@ invalid.cjs:5:2 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━ i Safe fix: Remove the redundant use strict directive. - 5 │ → "use·strict"; - │ ------------- + 3 3 │ + 4 4 │ function test() { + 5 │ - → "use·strict"; + 6 │ - → function·inner_a()·{ + 5 │ + → → function·inner_a()·{ + 7 6 │ "use strict"; // redundant directive + 8 7 │ } + ``` @@ -93,8 +102,14 @@ invalid.cjs:7:3 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━ i Safe fix: Remove the redundant use strict directive. - 7 │ → → "use·strict";·//·redundant·directive - │ ------------------------------------ + 5 5 │ "use strict"; + 6 6 │ function inner_a() { + 7 │ - → → "use·strict";·//·redundant·directive + 8 │ - → } + 7 │ + → → → } + 9 8 │ function inner_b() { + 10 9 │ function inner_inner() { + ``` @@ -119,8 +134,14 @@ invalid.cjs:11:4 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━ i Safe fix: Remove the redundant use strict directive. - 11 │ → → → "use·strict";·//·additional·redundant·directive - │ ----------------------------------------------- + 9 9 │ function inner_b() { + 10 10 │ function inner_inner() { + 11 │ - → → → "use·strict";·//·additional·redundant·directive + 12 │ - → → } + 11 │ + → → → → → } + 13 12 │ } + 14 13 │ } + ``` diff --git a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.js.snap b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.js.snap index 08c7212da466..ee4f39cae49e 100644 --- a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.js.snap +++ b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.js.snap @@ -43,8 +43,11 @@ invalid.js:2:1 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━━ i Safe fix: Remove the redundant use strict directive. - 2 │ "use·strict";·//·Associated·comment - │ ----------------------------------- + 1 1 │ // js module + 2 │ - "use·strict";·//·Associated·comment + 3 2 │ + 4 3 │ function foo() { + ``` @@ -63,8 +66,14 @@ invalid.js:5:2 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━━ i Safe fix: Remove the redundant use strict directive. - 5 │ → "use·strict"; - │ ------------- + 3 3 │ + 4 4 │ function foo() { + 5 │ - → "use·strict"; + 6 │ - } + 5 │ + → } + 7 6 │ + 8 7 │ class C1 { + ``` @@ -84,8 +93,14 @@ invalid.js:11:3 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━ i Safe fix: Remove the redundant use strict directive. - 11 │ → → "use·strict"; - │ ------------- + 9 9 │ // All code here is evaluated in strict mode + 10 10 │ test() { + 11 │ - → → "use·strict"; + 12 │ - → } + 11 │ + → → → } + 13 12 │ } + 14 13 │ + ``` @@ -105,8 +120,14 @@ invalid.js:18:3 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━ i Safe fix: Remove the redundant use strict directive. - 18 │ → → "use·strict"; - │ ------------- + 16 16 │ // All code here is evaluated in strict mode + 17 17 │ test() { + 18 │ - → → "use·strict"; + 19 │ - → } + 18 │ + → → → } + 20 19 │ }; + 21 20 │ + ``` diff --git a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.ts.snap b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.ts.snap index 165e58240466..204d262d3050 100644 --- a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.ts.snap +++ b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalid.ts.snap @@ -26,8 +26,12 @@ invalid.ts:2:2 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━━━ i Safe fix: Remove the redundant use strict directive. - 2 │ → "use·strict"; - │ ------------- + 1 1 │ function test(): void { + 2 │ - → "use·strict"; + 3 │ - } + 2 │ + → } + 4 3 │ + ``` diff --git a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidClass.cjs.snap b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidClass.cjs.snap index 0fe9a4b1ae29..e7879179e7b8 100644 --- a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidClass.cjs.snap +++ b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidClass.cjs.snap @@ -45,8 +45,14 @@ invalidClass.cjs:3:3 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━ i Safe fix: Remove the redundant use strict directive. - 3 │ → → "use·strict"; - │ ------------- + 1 1 │ class C1 { + 2 2 │ test() { + 3 │ - → → "use·strict"; + 4 │ - → } + 3 │ + → → → } + 5 4 │ } + 6 5 │ + ``` @@ -77,8 +83,14 @@ invalidClass.cjs:9:3 lint/suspicious/noRedundantUseStrict FIXABLE ━━━━ i Safe fix: Remove the redundant use strict directive. - 9 │ → → "use·strict"; - │ ------------- + 7 7 │ const C2 = class { + 8 8 │ test() { + 9 │ - → → "use·strict"; + 10 │ - → } + 9 │ + → → → } + 11 10 │ }; + 12 11 │ + ``` diff --git a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidFunction.cjs.snap b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidFunction.cjs.snap index 138076aed150..7f82d2dad8f7 100644 --- a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidFunction.cjs.snap +++ b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidFunction.cjs.snap @@ -34,8 +34,13 @@ invalidFunction.cjs:3:2 lint/suspicious/noRedundantUseStrict FIXABLE ━━━ i Safe fix: Remove the redundant use strict directive. - 3 │ → "use·strict"; - │ ------------- + 1 1 │ function test() { + 2 2 │ "use strict"; + 3 │ - → "use·strict"; + 4 │ - } + 3 │ + → } + 5 4 │ + ``` diff --git a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidFunction.js.snap b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidFunction.js.snap index ed7bdaa0af46..cc9973e229b4 100644 --- a/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidFunction.js.snap +++ b/crates/biome_js_analyze/tests/specs/suspicious/noRedundantUseStrict/invalidFunction.js.snap @@ -27,8 +27,13 @@ invalidFunction.js:2:2 lint/suspicious/noRedundantUseStrict FIXABLE ━━━ i Safe fix: Remove the redundant use strict directive. - 2 │ → "use·strict"; - │ ------------- + 1 1 │ function test() { + 2 │ - → "use·strict"; + 3 │ - → "use·strict"; + 2 │ + → → "use·strict"; + 4 3 │ } + 5 4 │ + ``` @@ -48,8 +53,13 @@ invalidFunction.js:3:2 lint/suspicious/noRedundantUseStrict FIXABLE ━━━ i Safe fix: Remove the redundant use strict directive. - 3 │ → "use·strict"; - │ ------------- + 1 1 │ function test() { + 2 2 │ "use strict"; + 3 │ - → "use·strict"; + 4 │ - } + 3 │ + → } + 5 4 │ + ``` diff --git a/website/src/content/docs/internals/changelog.mdx b/website/src/content/docs/internals/changelog.mdx index 3a9affc2d07d..5d6508ff0207 100644 --- a/website/src/content/docs/internals/changelog.mdx +++ b/website/src/content/docs/internals/changelog.mdx @@ -38,7 +38,9 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom - Fix [#639](https://github.com/biomejs/biome/issues/639) by ignoring unused TypeScript's mapped key. Contributed by @Conaclos -- Fix [#565](https://github.com/biomejs/biome/issues/565) by handling several `infer` with the same name in extends clauses of TypeScript's conditional types. +- Fix [#565](https://github.com/biomejs/biome/issues/565) by handling several `infer` with the same name in extends clauses of TypeScript's conditional types. Contributed by @Conaclos + +- Fix [#653](https://github.com/biomejs/biome/issues/653). [noUnusedImports](https://biomejs.dev/linter/rules/no-unused-imports) now correctly removes the entire line where the unused `import` is. Contributed by @Conaclos ### Parser diff --git a/website/src/content/docs/linter/rules/no-redundant-use-strict.md b/website/src/content/docs/linter/rules/no-redundant-use-strict.md index 8c08cc8c67b1..0f442a3155b3 100644 --- a/website/src/content/docs/linter/rules/no-redundant-use-strict.md +++ b/website/src/content/docs/linter/rules/no-redundant-use-strict.md @@ -41,8 +41,13 @@ function foo() { Safe fix: Remove the redundant use strict directive. - 3 │ ·"use·strict"; - ------------- + 1 1 "use strict"; + 2 2 function foo() { + 3 - ·"use·strict"; + 4 - } + 3+ ·} + 5 4 + ```js @@ -73,8 +78,11 @@ function foo() { Safe fix: Remove the redundant use strict directive. - 2 │ "use·strict"; - ------------- + 1 1 "use strict"; + 2 - "use·strict"; + 3 2 + 4 3 function foo() { + ```js @@ -105,8 +113,12 @@ function foo() { Safe fix: Remove the redundant use strict directive. - 3 │ "use·strict"; - ------------- + 1 1 function foo() { + 2 2 "use strict"; + 3 - "use·strict"; + 4 3 } + 5 4 + ```js @@ -141,8 +153,14 @@ class C1 { Safe fix: Remove the redundant use strict directive. - 3 │ "use·strict"; - ------------- + 1 1 class C1 { + 2 2 test() { + 3 - "use·strict"; + 4 - } + 3+ } + 5 4 } + 6 5 + ```js @@ -178,8 +196,14 @@ const C2 = class { Safe fix: Remove the redundant use strict directive. - 3 │ "use·strict"; - ------------- + 1 1 const C2 = class { + 2 2 test() { + 3 - "use·strict"; + 4 - } + 3+ } + 5 4 }; + 6 5 + ### Valid diff --git a/website/src/content/docs/linter/rules/no-unused-imports.md b/website/src/content/docs/linter/rules/no-unused-imports.md index 642d26e4e6c7..b848dfb6b4aa 100644 --- a/website/src/content/docs/linter/rules/no-unused-imports.md +++ b/website/src/content/docs/linter/rules/no-unused-imports.md @@ -34,8 +34,9 @@ import A from 'mod'; Safe fix: Remove the unused import. - 1 │ import·A·from·'mod'; - -------------------- + 1 - import·A·from·'mod'; + 2 - + ```jsx @@ -54,8 +55,9 @@ import * as A from 'mod'; Safe fix: Remove the unused import. - 1 │ import·*·as·A·from·'mod'; - ------------------------- + 1 - import·*·as·A·from·'mod'; + 2 - + ```ts