Skip to content

Conversation

@weswigham
Copy link
Contributor

@sebmarkbage on the React repo mentioned needing Recast to support a feature like this for them to support configurable quotemarks when compiling JSX transformations in the future. (mentioned originally on pull request 1709)

@abuiles
Copy link

abuiles commented Jan 13, 2015

@weswigham thanks! @benjamn it would be great to see this is in, we are using recast to generate code in https://github.com/ember-cli/ember-cli and people keep complaining that sometimes we generate with double quote even though single quote is our recommendation.

lib/options.js Outdated
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this so that options.quotemark is either null, '"' (rather than "double"), or "'" (rather than "single")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using "double" and "single" to be inline with the jshint/jslint options, but '"' and "'" are both doable.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could aim to some parity with escodegen? they use the key "quotes" instead of "quotemark" and "single", "double" or "auto" as options. see https://github.com/estools/escodegen/wiki/API#optionformatquotes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like mirroring that - though I think auto and null/undefined should be the same?

Edit: I read through what 'auto' does - that's cool, but who actually uses 'whichever literal is smaller'? Is that a use case worth supporting?

@weswigham
Copy link
Contributor Author

I removed the over-aggressive literal re-emissions from the patcher, and mirrored the escodegen quote transform api (since, on reflection, selecting the shortest literal makes sense for something like a minifier). Thoughts?

@abuiles
Copy link

abuiles commented Jan 15, 2015

👍

@kiwiupover
Copy link

👍 Thanks

lib/patcher.js Outdated
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be crazy, but I can't tell where options is used in this file. It seems like it's just being passed through the various find* functions but never examined. Am I missing something obvious?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! After I removed the overzealous reprinting it wasn't used anymore. Let me clean this up.

@benjamn
Copy link
Owner

benjamn commented Jan 29, 2015

Made some comments; sorry for the delay!

@weswigham
Copy link
Contributor Author

Removed all the stale changes and changed the whitespace of the switch to your preference.

benjamn added a commit that referenced this pull request Feb 2, 2015
Add tests and implementation for a "quotemark" printer option.
@benjamn benjamn merged commit 32da5b6 into benjamn:master Feb 2, 2015
@abuiles
Copy link

abuiles commented Feb 2, 2015

@weswigham @benjamn thanks! ember-cli/ember-cli#3182 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants