@effect/language-service 0.23.4 → 0.23.5
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/index.js +21 -4
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +21 -4
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -2687,6 +2687,8 @@ var importFromBarrel = createDiagnostic({
|
|
|
2687
2687
|
if (!moduleSymbol.exports) return;
|
|
2688
2688
|
const sourceFile2 = importDeclaration.getSourceFile();
|
|
2689
2689
|
const nodeForSymbol = element.propertyName || element.name;
|
|
2690
|
+
const aliasSymbol = element.name || element.propertyName;
|
|
2691
|
+
const aliasedName = aliasSymbol.text;
|
|
2690
2692
|
if (!ts.isIdentifier(nodeForSymbol)) return;
|
|
2691
2693
|
const importedName = nodeForSymbol.text;
|
|
2692
2694
|
const reexportedSymbol = moduleSymbol.exports.get(ts.escapeLeadingUnderscores(importedName));
|
|
@@ -2709,7 +2711,15 @@ var importFromBarrel = createDiagnostic({
|
|
|
2709
2711
|
program
|
|
2710
2712
|
);
|
|
2711
2713
|
if (unbarrelledFileName.toLowerCase().indexOf(barrelModuleName.toLowerCase() + "/") === -1) return;
|
|
2712
|
-
return {
|
|
2714
|
+
return {
|
|
2715
|
+
unbarrelledFileName,
|
|
2716
|
+
importedName,
|
|
2717
|
+
barrelModuleName,
|
|
2718
|
+
importClause,
|
|
2719
|
+
namedBindings,
|
|
2720
|
+
importDeclaration,
|
|
2721
|
+
aliasedName
|
|
2722
|
+
};
|
|
2713
2723
|
};
|
|
2714
2724
|
const nodeToVisit = [];
|
|
2715
2725
|
const appendNodeToVisit = (node) => {
|
|
@@ -2726,14 +2736,21 @@ var importFromBarrel = createDiagnostic({
|
|
|
2726
2736
|
}
|
|
2727
2737
|
const result = isImportedFromBarrelExport(node);
|
|
2728
2738
|
if (!result) continue;
|
|
2729
|
-
const {
|
|
2739
|
+
const {
|
|
2740
|
+
aliasedName,
|
|
2741
|
+
barrelModuleName,
|
|
2742
|
+
importClause,
|
|
2743
|
+
importDeclaration,
|
|
2744
|
+
namedBindings,
|
|
2745
|
+
unbarrelledFileName
|
|
2746
|
+
} = result;
|
|
2730
2747
|
report({
|
|
2731
2748
|
node,
|
|
2732
2749
|
messageText: `Importing from barrel module ${barrelModuleName} is not allowed.`,
|
|
2733
2750
|
fixes: [
|
|
2734
2751
|
{
|
|
2735
2752
|
fixName: "replaceWithUnbarrelledImport",
|
|
2736
|
-
description: `Import * as ${
|
|
2753
|
+
description: `Import * as ${aliasedName} from ${unbarrelledFileName}`,
|
|
2737
2754
|
apply: gen(function* () {
|
|
2738
2755
|
const changeTracker = yield* service(ChangeTracker);
|
|
2739
2756
|
const newImport = ts.factory.createImportDeclaration(
|
|
@@ -2741,7 +2758,7 @@ var importFromBarrel = createDiagnostic({
|
|
|
2741
2758
|
ts.factory.createImportClause(
|
|
2742
2759
|
importClause.isTypeOnly || node.isTypeOnly,
|
|
2743
2760
|
void 0,
|
|
2744
|
-
ts.factory.createNamespaceImport(ts.factory.createIdentifier(
|
|
2761
|
+
ts.factory.createNamespaceImport(ts.factory.createIdentifier(aliasedName))
|
|
2745
2762
|
),
|
|
2746
2763
|
ts.factory.createStringLiteral(unbarrelledFileName)
|
|
2747
2764
|
);
|