Skip to content

Commit

Permalink
fix(qs): always replace with namespaced import
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzyma authored Dec 12, 2024
1 parent e6f23a3 commit c22dbb1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions codemods/qs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`));
Expand Down

0 comments on commit c22dbb1

Please sign in to comment.