Shopify / javascript

The home for all things JavaScript at Shopify.
MIT License
253 stars 38 forks source link

`hosted_fields.coffee` should be parseable #182

Closed GoodForOneFare closed 8 years ago

GoodForOneFare commented 8 years ago

app/assets/javascripts/checkout_next/v2/hosted_fields.coffee trips up decaf with an interpolated key in the final line of fetchFonts:

  fetchFonts: =>
    type = @fetchBodyFontType()
    return {} if type == 'system'

    {"#{type}": [@fetchBodyFontFamily()]}
SyntaxError: Unexpected token (77:6)
    at Parser.pp.raise (jscodeshift/node_modules/babylon/lib/parser/location.js:24:13)
    at Parser.pp.unexpected (jscodeshift/node_modules/babylon/lib/parser/util.js:82:8)
    at Parser.pp.parseIdent (jscodeshift/node_modules/babylon/lib/parser/expression.js:818:10)
    at Parser.pp.parsePropertyName (jscodeshift/node_modules/babylon/lib/parser/expression.js:694:135)
    at Parser.pp.parseObj (jscodeshift/node_modules/babylon/lib/parser/expression.js:638:12)
    at Parser.pp.parseExprAtom (jscodeshift/node_modules/babylon/lib/parser/expression.js:392:19)
    at Parser.parseExprAtom (jscodeshift/node_modules/babylon/lib/plugins/jsx/index.js:412:22)
    at Parser.pp.parseExprSubscripts (jscodeshift/node_modules/babylon/lib/parser/expression.js:236:19)
    at Parser.pp.parseMaybeUnary (jscodeshift/node_modules/babylon/lib/parser/expression.js:217:19)
    at Parser.pp.parseExprOps (jscodeshift/node_modules/babylon/lib/parser/expression.js:163:19)
    at Parser.pp.parseMaybeConditional (jscodeshift/node_modules/babylon/lib/parser/expression.js:145:19)
    at Parser.pp.parseMaybeAssign (jscodeshift/node_modules/babylon/lib/parser/expression.js:112:19)
    at Parser.pp.parseExpression (jscodeshift/node_modules/babylon/lib/parser/expression.js:79:19)
    at Parser.pp.parseReturnStatement (jscodeshift/node_modules/babylon/lib/parser/statement.js:287:26)
    at Parser.pp.parseStatement (jscodeshift/node_modules/babylon/lib/parser/statement.js:89:19)
    at Parser.parseStatement (jscodeshift/node_modules/babylon/lib/plugins/flow.js:655:22)
    at Parser.pp.parseBlock (jscodeshift/node_modules/babylon/lib/parser/statement.js:442:21)
    at Parser.pp.parseFunctionBody (jscodeshift/node_modules/babylon/lib/parser/expression.js:747:22)
    at Parser.parseFunctionBody (jscodeshift/node_modules/babylon/lib/plugins/flow.js:643:20)
    at Parser.pp.parseMethod (jscodeshift/node_modules/babylon/lib/parser/expression.js:717:8)
    at Parser.parseClassMethod (jscodeshift/node_modules/babylon/lib/plugins/flow.js:852:27)
    at Parser.pp.parseClass (jscodeshift/node_modules/babylon/lib/parser/statement.js:596:10)
    at Parser.pp.parseExprAtom (jscodeshift/node_modules/babylon/lib/parser/expression.js:405:19)
    at Parser.parseExprAtom (jscodeshift/node_modules/babylon/lib/plugins/jsx/index.js:412:22)
    at Parser.pp.parseExprSubscripts (jscodeshift/node_modules/babylon/lib/parser/expression.js:236:19)
    at Parser.pp.parseMaybeUnary (jscodeshift/node_modules/babylon/lib/parser/expression.js:217:19)
    at Parser.pp.parseExprOps (jscodeshift/node_modules/babylon/lib/parser/expression.js:163:19)
    at Parser.pp.parseMaybeConditional (jscodeshift/node_modules/babylon/lib/parser/expression.js:145:19)
    at Parser.pp.parseMaybeAssign (jscodeshift/node_modules/babylon/lib/parser/expression.js:112:19)
    at Parser.pp.parseMaybeAssign (jscodeshift/node_modules/babylon/lib/parser/expression.js:132:23)
    at Parser.pp.parseExpression (jscodeshift/node_modules/babylon/lib/parser/expression.js:79:19)
    at Parser.pp.parseStatement (jscodeshift/node_modules/babylon/lib/parser/statement.js:137:23)
    at Parser.parseStatement (jscodeshift/node_modules/babylon/lib/plugins/flow.js:655:22)
    at Parser.pp.parseTopLevel (jscodeshift/node_modules/babylon/lib/parser/statement.js:30:21)
    at Parser.parse (jscodeshift/node_modules/babylon/lib/parser/index.js:70:17)
    at Object.parse (jscodeshift/node_modules/babylon/lib/index.js:45:50)
    at Object.parse (jscodeshift/node_modules/babel-core/lib/api/node.js:160:21)
    at Object.parse (recast/lib/parser.js:26:34)
    at fromSource (jscodeshift/dist/core.js:72:25)
    at core (jscodeshift/dist/core.js:44:39)
    at coffeescriptSoakToCondition (coffeescript-soak-to-condition.js:312:10)
    at runTransform (esify/lib/codemod.js:68:17)
GoodForOneFare commented 8 years ago

This is a one-off; probably easier to just alter this in core.