@1adybug/prettier-plugin-sort-imports 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -558,6 +558,13 @@ function mergeImports(imports) {
|
|
|
558
558
|
const src_require = createRequire(import.meta.url);
|
|
559
559
|
function preprocessImports(text, options, config = {}) {
|
|
560
560
|
try {
|
|
561
|
+
const parser = options.parser;
|
|
562
|
+
const supportedParsers = [
|
|
563
|
+
"babel",
|
|
564
|
+
"typescript",
|
|
565
|
+
"babel-ts"
|
|
566
|
+
];
|
|
567
|
+
if (!parser || !supportedParsers.includes(parser)) return text;
|
|
561
568
|
const imports = parseImports(text);
|
|
562
569
|
if (0 === imports.length) return text;
|
|
563
570
|
const optionsConfig = options;
|
|
@@ -594,7 +601,6 @@ function preprocessImports(text, options, config = {}) {
|
|
|
594
601
|
const separator = needsExtraNewline ? "\n\n" : "\n";
|
|
595
602
|
return beforeImports + formattedImports + separator + afterImports;
|
|
596
603
|
} catch (error) {
|
|
597
|
-
console.error("Failed to sort imports:", error);
|
|
598
604
|
return text;
|
|
599
605
|
}
|
|
600
606
|
}
|