Skip to content

Commit 517f078

Browse files
committed
Remove natural order comparison utility and simplify duplicate exports/imports handling
1 parent 8e87baf commit 517f078

File tree

5 files changed

+4
-17
lines changed

5 files changed

+4
-17
lines changed

packages/tsl-module/src/rules/no-duplicate-exports.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { type AST, defineRule } from "tsl";
22
import ts from "typescript";
33

4-
import { naturalCompare } from "../utils";
5-
64
export const messages = {
75
noDuplicateExports: (p: { source: string }) => `Duplicate export from module ${p.source}.`,
86
} as const;
@@ -77,7 +75,7 @@ function buildSuggestions(a: ReExportDeclaration, b: ReExportDeclaration) {
7775
&& ts.isNamedExports(b.exportClause): {
7876
const aElements = a.exportClause.elements.map((el) => el.getText());
7977
const bElements = b.exportClause.elements.map((el) => el.getText());
80-
const parts = Array.from(new Set([...aElements, ...bElements])).toSorted(naturalCompare);
78+
const parts = Array.from(new Set([...aElements, ...bElements]));
8179
return [
8280
{
8381
message: "Merge duplicate exports",

packages/tsl-module/src/rules/no-duplicate-imports.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ test("no-duplicate-import", () => {
8181
{
8282
message: "Merge duplicate imports",
8383
output: tsx`
84-
import foo, { baz, quux, type bar, type qux } from 'module';\n
84+
import foo, { type bar, baz, type qux, quux } from 'module';\n
8585
import foo3, { corge } from 'module';
8686
`,
8787
},
@@ -94,7 +94,7 @@ test("no-duplicate-import", () => {
9494
{
9595
message: "Merge duplicate imports",
9696
output: tsx`
97-
import foo, { baz, corge, type bar } from 'module';
97+
import foo, { type bar, baz, corge } from 'module';
9898
import foo2, { type qux, quux } from 'module';\n
9999
`,
100100
},

packages/tsl-module/src/rules/no-duplicate-imports.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { unit } from "@let/eff";
22
import { P, match } from "ts-pattern";
33
import { type AST, defineRule } from "tsl";
44
import ts from "typescript";
5-
import { naturalCompare } from "../utils";
65

76
export const messages = {
87
noDuplicateImports: (p: { source: string }) => `Duplicate import from module ${p.source}.`,
@@ -136,7 +135,7 @@ function buildMergedImport(a: ImportInfo, b: ImportInfo): string {
136135
parts.push(`* as ${b.namespaceImport}`);
137136
}
138137
// Named imports
139-
const namedImports = Array.from(new Set([...a.namedImports, ...b.namedImports])).toSorted(naturalCompare);
138+
const namedImports = Array.from(new Set([...a.namedImports, ...b.namedImports]));
140139
// Construct named imports part
141140
if (namedImports.length > 0) {
142141
parts.push(`{ ${namedImports.join(", ")} }`);

packages/tsl-module/src/utils/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/tsl-module/src/utils/string.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)