From b3d4a53396696eb6bce024a7625331cda787d89d Mon Sep 17 00:00:00 2001 From: Boshen Date: Tue, 11 Jun 2024 16:43:11 +0800 Subject: [PATCH] chore(linter): fix merge conflict --- .../src/rules/eslint/sort_imports.rs | 38 +++++++++---------- .../src/snapshots/sort_imports.snap | 6 +-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/sort_imports.rs b/crates/oxc_linter/src/rules/eslint/sort_imports.rs index fea6c86bc..9e5a3a856 100644 --- a/crates/oxc_linter/src/rules/eslint/sort_imports.rs +++ b/crates/oxc_linter/src/rules/eslint/sort_imports.rs @@ -307,7 +307,7 @@ impl SortImports { let specifiers_span = specifiers[0].span.merge(&specifiers[specifiers.len() - 1].span); ctx.diagnostic_with_fix( sort_members_alphabetically_diagnostic(unsorted_name, unsorted_span), - || { + |fixer| { // import { a, b, c, d } from 'foo.js' // ^ ^^^^^^ ^ let mut paddings: Vec<&str> = specifiers @@ -344,7 +344,7 @@ impl SortImports { }, ); - Fix::new(sorted_text, specifiers_span) + fixer.replace(specifiers_span, sorted_text) }, ); } else { @@ -555,7 +555,7 @@ fn test() { ("import a, * as b from 'foo.js';", None), ( "import * as a from 'foo.js'; - + import b from 'bar.js';", None, ), @@ -572,20 +572,20 @@ fn test() { ("import React, {Component} from 'react';", None), ( "import b from 'b'; - + import a from 'a';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), ( "import a from 'a'; - + import 'b';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), ( "import { b } from 'b'; - - + + import { a } from 'a';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), @@ -603,30 +603,30 @@ fn test() { ), ( "import { b } from 'b';/* - comment + comment */import { a } from 'a';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), ( "import b from 'b'; - + import a from 'a';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), ( "import c from 'c'; - + import a from 'a'; import b from 'b';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), ( "import c from 'c'; - + import b from 'b'; - + import a from 'a';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), @@ -733,7 +733,7 @@ fn test() { Some(serde_json::json!([{ "allowSeparatedGroups": false }])), ), ( - "import { b } from 'b'; /* comment line 1 + "import { b } from 'b'; /* comment line 1 comment line 2 */ import { a } from 'a';", Some(serde_json::json!([{ "allowSeparatedGroups": false }])), ), @@ -744,13 +744,13 @@ fn test() { Some(serde_json::json!([{ "allowSeparatedGroups": false }])), ), ( - "import { b } from + "import { b } from 'b'; /* comment */ import { a } from 'a';", Some(serde_json::json!([{ "allowSeparatedGroups": false }])), ), ( - "import { b } from + "import { b } from 'b'; import { a } from 'a';", @@ -758,14 +758,14 @@ fn test() { ), ( "import c from 'c'; - + import b from 'b'; import a from 'a';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), ( "import b from 'b'; - + import { c, a } from 'c';", Some(serde_json::json!([{ "allowSeparatedGroups": true }])), ), @@ -796,11 +796,11 @@ fn test() { ( " import b from 'b'; - + import { c, a } from 'c';", " import b from 'b'; - + import { a, c } from 'c';", None, ), diff --git a/crates/oxc_linter/src/snapshots/sort_imports.snap b/crates/oxc_linter/src/snapshots/sort_imports.snap index 370423c12..8fde88243 100644 --- a/crates/oxc_linter/src/snapshots/sort_imports.snap +++ b/crates/oxc_linter/src/snapshots/sort_imports.snap @@ -158,7 +158,7 @@ expression: sort_imports ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:35] - 1 │ import { b } from 'b'; /* comment line 1 + 1 │ import { b } from 'b'; /* comment line 1 2 │ comment line 2 */ import { a } from 'a'; · ────────────────────── ╰──── @@ -172,7 +172,7 @@ expression: sort_imports ⚠ eslint(sort-imports): Imports should be sorted alphabetically. ╭─[sort_imports.tsx:2:32] - 1 │ import { b } from + 1 │ import { b } from 2 │ ╭─▶ 'b'; /* comment */ import 3 │ ╰─▶ { a } from 'a'; ╰──── @@ -193,7 +193,7 @@ expression: sort_imports ⚠ eslint(sort-imports): Member 'a' of the import declaration should be sorted alphabetically. ╭─[sort_imports.tsx:3:25] - 2 │ + 2 │ 3 │ import { c, a } from 'c'; · ─ ╰────