From c22dbb1f6070d51840171b79b54967e2e48cd791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich-Matthias=20Sch=C3=A4fer?= Date: Thu, 12 Dec 2024 21:09:39 +0100 Subject: [PATCH 1/3] fix(qs): always replace with namespaced import --- codemods/qs/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/codemods/qs/index.js b/codemods/qs/index.js index 6cf8ebc..a9d3556 100644 --- a/codemods/qs/index.js +++ b/codemods/qs/index.js @@ -165,8 +165,20 @@ export default function (options) { const nameMatch = imp.getMatch('NAME'); if (nameMatch) { - importName = nameMatch.text(); - edits.push(nameMatch.replace('pq')); + const namespaceImport = nameMatch.find({ + rule: { + kind: 'identifier', + inside: { + kind: 'namespace_import', + }, + }, + }); + if (namespaceImport) { + importName = namespaceImport.text(); + } else { + importName = nameMatch.text(); + } + edits.push(nameMatch.replace('* as pq')); } edits.push(source.replace(`${quoteType}picoquery${quoteType}`)); From 42d2b347451399872d7c9b0e181c457eab8a1ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich-Matthias=20Sch=C3=A4fer?= Date: Thu, 12 Dec 2024 21:16:50 +0100 Subject: [PATCH 2/3] fix: test result --- test/fixtures/qs/basic/result.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/qs/basic/result.js b/test/fixtures/qs/basic/result.js index 8832aff..e2b88d4 100644 --- a/test/fixtures/qs/basic/result.js +++ b/test/fixtures/qs/basic/result.js @@ -1,4 +1,4 @@ -import pq from 'picoquery'; +import * as pq from 'picoquery'; const obj = {foo: 'bar'}; const query = 'foo=bar'; From 5f5e319c92e17d396c45e060681530f07bc308d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich-Matthias=20Sch=C3=A4fer?= Date: Thu, 12 Dec 2024 21:17:14 +0100 Subject: [PATCH 3/3] fix: test after.js --- test/fixtures/qs/basic/after.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/qs/basic/after.js b/test/fixtures/qs/basic/after.js index 8832aff..e2b88d4 100644 --- a/test/fixtures/qs/basic/after.js +++ b/test/fixtures/qs/basic/after.js @@ -1,4 +1,4 @@ -import pq from 'picoquery'; +import * as pq from 'picoquery'; const obj = {foo: 'bar'}; const query = 'foo=bar';