From 5435411d57284b2fc2bc3d0754a1ec185645d03f Mon Sep 17 00:00:00 2001 From: alethes Date: Fri, 24 Mar 2017 22:02:00 +0100 Subject: [PATCH] Fix lint issues --- package.json | 5 +++-- src/babel.js | 25 ++++--------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index f48bfa7..8d74191 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "ava": "^0.17.0", "babel-cli": "^6.18.0", "babel-core": "^6.21.0", + "babel-generator": "^6.24.0", "babel-plugin-transform-async-to-generator": "^6.16.0", "babel-plugin-transform-es2015-destructuring": "^6.19.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0", @@ -45,10 +46,10 @@ "dependencies": { "babel-traverse": "^6.21.0", "babylon": "^6.14.1", + "deasync": "^0.1.9", "postcss": "^5.2.8", "postcss-load-plugins": "^2.2.0", - "styled-jsx": "^0.4.0", - "deasync": "^0.1.9" + "styled-jsx": "^0.4.0" }, "ava": { "require": [ diff --git a/src/babel.js b/src/babel.js index 21cd88f..d7c9a15 100644 --- a/src/babel.js +++ b/src/babel.js @@ -25,16 +25,16 @@ export default function ({types: t}) { } } - let source = "" + let source = '' const replacements = [] node.expressions.forEach((e, i) => { - let r = `___styledjsxexpression${i}___` + const r = `___styledjsxexpression${i}___` source += node.quasis[i].value.cooked + r replacements.push({ replacement: r, initial: `$\{${generate(e).code}}` - }); - }); + }) + }) source += node.quasis[node.quasis.length - 1].value.cooked return { @@ -134,23 +134,6 @@ export default function ({types: t}) { } } -function getPlaceholders(expressions) { - return expressions.map((e, id) => ({ - replacement: `___styledjsxexpression${id}___`, - initial: `$\{${e.getSource()}}` - })).sort((a, b) => a.initial.length < b.initial.length) -} - -function addPlaceholders(replacements, src) { - return replacements.reduce((src, currentReplacement) => { - src = src.replace( - currentReplacement.initial, - currentReplacement.replacement - ) - return src - }, src) -} - function replacePlaceholders(replacements, src) { return replacements.reduce((src, currentReplacement) => { src = src.replace(