Skip to content

Commit

Permalink
All tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
bterlson committed Aug 7, 2024
1 parent 0b1eb97 commit 50fd032
Show file tree
Hide file tree
Showing 23 changed files with 471 additions and 415 deletions.
187 changes: 0 additions & 187 deletions packages/babel-plugin-alloy/src/transform copy.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/babel-plugin-alloy/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function transformElement(

children.forEach((child) => child.remove());
newChildren.forEach((newChild) => {
const newItem = path.pushContainer("children", newChild)[0];
path.pushContainer("children", newChild)[0];
});

path.get("children").forEach((child) => {
Expand Down Expand Up @@ -133,6 +133,7 @@ function registerIndent(path: NodePath, opts: Options) {
nameHint: `$Indent`,
}
);
imports.set(`${moduleName}:Indent`, id);
return t.jsxIdentifier(id.name);
} else {
let id = imports.get(`${moduleName}:Indent`);
Expand Down
87 changes: 14 additions & 73 deletions packages/babel-plugin-alloy/test/fixtures/blank-lines/code.js
Original file line number Diff line number Diff line change
@@ -1,84 +1,25 @@
/*
After normal transform:
* Group sequences of lines which are conditional
* If literal text comes after the group, consume group plus trailing linebreak.
Join by line break. Render trailing linebreak if anything in group is present.
* If group is before end of component/fragment, consume leading linebreak plus
group. Join by line break. Render leading linebreak if anything in group is
present.
*/
function blankLines() {
return <Hi>

/*
function Foo() {
return <A>
{a}
{b}
c
</A>
}
function Foo() {
return <A>{maybeLine(a)}{maybeLine(b)}c</A>
}
function Bar() {
return <A>
{a}x
{b}
c
</A>
}
function Bar() {
return <A>{a}x{maybeLine(() => b)}c</A>
}
hello

function Baz() {
return <A>
{a}x
{b}
</A>
}
function Baz() {
return <A>{a}x
{b}</A>
}
function Baz() {
return <A>{a}x{maybeLastLine(() => b)}</A>
}
how

maybeLines -> lines.join("\n");
maybeLastLines -> "\n" + lines.join("\n");

function Baz2() {
return <A>
{a}
{b}
{c}
</A>
are you
</Hi>;
}

function Baz2() {
return <A>{maybeLine(a)}{maybeLine(b)}{maybeLastLine(c)}</A>
}
function blankLinesWithIndent() {
return <Hi>

maybeLine -> x + "\n";
maybeLastLine -> x;
hello

const maybeLines = <>{a}
{b}
{c}</>
how

const maybeLastLines = <>start
{a}
{b}
{c}</>

const bothLines = <>{a}
start
{a}
middle
{a}</>
are you

const bothLines = <>{maybeStart(a)}start
{maybeStart(a)}middle{maybeEnd(a)}</>
*/
there
</Hi>;
}
Loading

0 comments on commit 50fd032

Please sign in to comment.