Skip to content

Commit 4aa31a8

Browse files
blikblumjviide
authored andcommitted
Convert indentation from space to tab
1 parent f6bfe88 commit 4aa31a8

File tree

1 file changed

+83
-83
lines changed
  • packages/babel-plugin-transform-jsx-to-htm

1 file changed

+83
-83
lines changed

packages/babel-plugin-transform-jsx-to-htm/index.mjs

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,24 @@ export default function jsxToHtmBabelPlugin({ types: t }, options = {}) {
8686
cooked: buffer
8787
}));
8888
buffer = '';
89-
}
90-
91-
function getName(node) {
92-
switch (node.type) {
93-
case 'JSXMemberExpression':
94-
return `${node.object.name}.${node.property.name}`
95-
96-
default:
97-
return node.name;
98-
}
99-
}
100-
101-
function processChildren(node, name, isFragment) {
102-
const children = t.react.buildChildren(node);
89+
}
90+
91+
function getName(node) {
92+
switch (node.type) {
93+
case 'JSXMemberExpression':
94+
return `${node.object.name}.${node.property.name}`
95+
96+
default:
97+
return node.name;
98+
}
99+
}
100+
101+
function processChildren(node, name, isFragment) {
102+
const children = t.react.buildChildren(node);
103103
if (children && children.length !== 0) {
104-
if (!isFragment) {
105-
raw('>');
106-
}
104+
if (!isFragment) {
105+
raw('>');
106+
}
107107
for (let i = 0; i < children.length; i++) {
108108
let child = children[i];
109109
if (t.isStringLiteral(child)) {
@@ -118,67 +118,67 @@ export default function jsxToHtmBabelPlugin({ types: t }, options = {}) {
118118
}
119119
}
120120

121-
if (!isFragment) {
122-
if (name.match(/^[A-Z]/)) {
123-
raw('</');
124-
expr(t.identifier(name));
125-
raw('>');
126-
}
127-
else {
128-
raw('</');
129-
raw(name);
130-
raw('>');
131-
}
132-
}
121+
if (!isFragment) {
122+
if (name.match(/^[A-Z]/)) {
123+
raw('</');
124+
expr(t.identifier(name));
125+
raw('>');
126+
}
127+
else {
128+
raw('</');
129+
raw(name);
130+
raw('>');
131+
}
132+
}
133133
}
134134
else if (!isFragment) {
135135
raw('/>');
136-
}
137-
}
136+
}
137+
}
138138

139139
function processNode(node, path, isRoot) {
140140
const open = node.openingElement;
141-
const name = getName(open.name);
142-
const isFragment = name === 'React.Fragment';
143-
144-
if (!isFragment) {
145-
if (name.match(/^[A-Z]/)) {
146-
raw('<');
147-
expr(t.identifier(name));
148-
}
149-
else {
150-
raw('<');
151-
raw(name);
152-
}
153-
154-
if (open.attributes) {
155-
for (let i = 0; i < open.attributes.length; i++) {
156-
const attr = open.attributes[i];
157-
raw(' ');
158-
if (t.isJSXSpreadAttribute(attr)) {
159-
raw('...');
160-
expr(attr.argument);
161-
continue;
162-
}
163-
const { name, value } = attr;
164-
raw(name.name);
165-
if (value) {
166-
raw('=');
167-
if (value.expression) {
168-
expr(value.expression);
169-
}
170-
else if (t.isStringLiteral(value)) {
171-
escapePropValue(value);
172-
}
173-
else {
174-
expr(value);
175-
}
176-
}
177-
}
178-
}
179-
}
180-
181-
processChildren(node, name, isFragment);
141+
const name = getName(open.name);
142+
const isFragment = name === 'React.Fragment';
143+
144+
if (!isFragment) {
145+
if (name.match(/^[A-Z]/)) {
146+
raw('<');
147+
expr(t.identifier(name));
148+
}
149+
else {
150+
raw('<');
151+
raw(name);
152+
}
153+
154+
if (open.attributes) {
155+
for (let i = 0; i < open.attributes.length; i++) {
156+
const attr = open.attributes[i];
157+
raw(' ');
158+
if (t.isJSXSpreadAttribute(attr)) {
159+
raw('...');
160+
expr(attr.argument);
161+
continue;
162+
}
163+
const { name, value } = attr;
164+
raw(name.name);
165+
if (value) {
166+
raw('=');
167+
if (value.expression) {
168+
expr(value.expression);
169+
}
170+
else if (t.isStringLiteral(value)) {
171+
escapePropValue(value);
172+
}
173+
else {
174+
expr(value);
175+
}
176+
}
177+
}
178+
}
179+
}
180+
181+
processChildren(node, name, isFragment);
182182

183183
if (isRoot) {
184184
commit(true);
@@ -216,9 +216,9 @@ export default function jsxToHtmBabelPlugin({ types: t }, options = {}) {
216216
buffer = bufferBefore;
217217

218218
state.set('jsxElement', true);
219-
},
220-
221-
JSXFragment(path, state) {
219+
},
220+
221+
JSXFragment(path, state) {
222222
let quasisBefore = quasis.slice();
223223
let expressionsBefore = expressions.slice();
224224
let bufferBefore = buffer;
@@ -229,17 +229,17 @@ export default function jsxToHtmBabelPlugin({ types: t }, options = {}) {
229229

230230
processChildren(path.node, '', true);
231231

232-
commit();
233-
const template = t.templateLiteral(quasis, expressions);
234-
const replacement = t.taggedTemplateExpression(tag, template);
235-
path.replaceWith(replacement);
232+
commit();
233+
const template = t.templateLiteral(quasis, expressions);
234+
const replacement = t.taggedTemplateExpression(tag, template);
235+
path.replaceWith(replacement);
236236

237237
quasis = quasisBefore;
238238
expressions = expressionsBefore;
239-
buffer = bufferBefore;
240-
241-
state.set('jsxElement', true);
242-
}
239+
buffer = bufferBefore;
240+
241+
state.set('jsxElement', true);
242+
}
243243
}
244244
};
245245
}

0 commit comments

Comments
 (0)