Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --align-object-properties option #7

Merged
merged 9 commits into from
May 19, 2017

Conversation

josephfrazier
Copy link

As discussed in prettier#1622 (comment)

Since this is based off of upstream prettier's master branch, that should be merged first to eliminate conflicts. The meaningful changes in this PR are in only the last handful of commits (the ones not in upstream master).

test code

    o = {
      2:3,
      "k-2":2,
    keyasdf:3
    }

TODO make Identifier case more robust,
     note how it puts the padding inside the concat, not outside,
     need to account for type annotation
It's possible to detect simple computed names like `[someVariable]` and
handle those, but don't bother for now.
Since nodeStr can change the length of the string, we should use it
instead of just using n.value
This will likely break down if the name computation spans multiple
lines, but it's probably best not to do that anyway.
@rhengles
Copy link
Member

Thank you! I will do that 👍

@rhengles
Copy link
Member

I've updated the master branch, can you please rebase? Thanks! 😊

@josephfrazier
Copy link
Author

I just fixed the conflicts. Not sure why a test failed, but it seems unrelated to this change: https://travis-ci.org/arijs/prettier-miscellaneous/jobs/234104749#L1027-L1032

@rhengles
Copy link
Member

Alright, I'll just merge it and try on master. 👍

@nmaxcom
Copy link

nmaxcom commented Jun 25, 2017

This is not on the website yet though, is it?

@langdonx
Copy link

@nmaxcom No, and it won't be. That's the main version of prettier. See #16

brody4hire pushed a commit to bangkokjs/prettierx-0.4.x-fork that referenced this pull request Jan 1, 2019
ported from prettier-miscellaneous
(arijs#7 & arijs#8)

with some adaptations by @brodybits
(Christopher J. Brody <[email protected]>), including:
* adapt const shouldBreak = hasNewlineInRange(...)
  for newer version of prettier
* extra comment & spacing
* add object to test to ensure that it does not get unwanted padding
* adapt tests/align-object-properties/__snapshots__/jsfmt.spec.js.snap
  for newer version of prettier

XXX TODO ITEMS including:
* export & check alignObjectProperties option
* resolve issue with object partially but not completely defined
  on the first line

Co-authored-by: Joseph Frazier <[email protected]>
Co-authored-by: Christopher J. Brody <[email protected]>
brody4hire pushed a commit to bangkokjs/prettierx-0.4.x-fork that referenced this pull request Jan 14, 2019
feature ported from prettier-miscellaneous
(arijs#7 & arijs#8)

with adaptations by @brodybits
(Christopher J. Brody <[email protected]>), including:
* JavaScript tests in es test subdirectory
* not applied with any of the JSON parsers, as verified by json test
  (not applied in case parser matches /json/ pattern)
* --align-object-properties option config & docs adapted
  (copy-pasted) into newer prettier/prettierx project structure
* const shouldBreak hack updated (and reformatted), can now deal
  with an object that is partially but not completely defined
  on the first line, as verified by an additional test object
* extra comment(s) & spacing
* additional testing to ensure that it does not get unwanted padding
  in case an object is on a single line
* hack with fix for object partially but not completely defined
  on the first line, with additional test to verify
* test coverage on babel, flow, and typescript parsers
* test with shorthand object member
* tests_integration updates
* some other added tests
* lint fixes

Co-authored-by: Christopher J. Brody <[email protected]>
Co-authored-by: Joseph Frazier <[email protected]>
Co-authored-by: Rafael Hengles <[email protected]>
Co-authored-by: Ika <[email protected]>
Co-authored-by: Lucas Azzola <[email protected]>
brody4hire pushed a commit to bangkokjs/prettierx-0.4.x-fork that referenced this pull request Jan 14, 2019
feature ported from prettier-miscellaneous
(arijs#7 & arijs#8)

with adaptations by @brodybits
(Christopher J. Brody <[email protected]>), including:
* JavaScript tests in es test subdirectory
* not applied with any of the JSON parsers, as verified by json test
  (not applied in case parser matches /json/ pattern)
* --align-object-properties option config & docs adapted
  (copy-pasted) into newer prettier/prettierx project structure
* const shouldBreak hack updated (and reformatted), can now deal
  with an object that is partially but not completely defined
  on the first line, as verified by an additional test object
* extra comment(s) & spacing
* additional testing to ensure that it does not get unwanted padding
  in case an object is on a single line
* hack with fix for object partially but not completely defined
  on the first line, with additional test to verify
* test coverage on babel, flow, and typescript parsers
* test with shorthand object member
* tests_integration updates
* some other added tests
* lint fixes

Co-authored-by: Christopher J. Brody <[email protected]>
Co-authored-by: Joseph Frazier <[email protected]>
Co-authored-by: Rafael Hengles <[email protected]>
Co-authored-by: Ika <[email protected]>
Co-authored-by: Lucas Azzola <[email protected]>
brody4hire pushed a commit to bangkokjs/prettierx-0.4.x-fork that referenced this pull request Jan 14, 2019
feature ported from prettier-miscellaneous
(arijs#7 & arijs#8)

with adaptations by @brodybits
(Christopher J. Brody <[email protected]>), including:
* JavaScript tests in es test subdirectory
* not applied with any of the JSON parsers, as verified by json test
  (not applied in case parser matches /json/ pattern)
* --align-object-properties option config & docs adapted
  (copy-pasted) into newer prettier/prettierx project structure
* const shouldBreak hack updated (and reformatted), can now deal
  with an object that is partially but not completely defined
  on the first line, as verified by an additional test object
* extra comment(s) & spacing
* additional testing to ensure that it does not get unwanted padding
  in case an object is on a single line
* hack with fix for object partially but not completely defined
  on the first line, with additional test to verify
* test coverage on babel, flow, and typescript parsers
* test with shorthand object member
* tests_integration updates
* some other added tests
* lint fixes

Co-authored-by: Christopher J. Brody <[email protected]>
Co-authored-by: Joseph Frazier <[email protected]>
Co-authored-by: Rafael Hengles <[email protected]>
Co-authored-by: Ika <[email protected]>
Co-authored-by: Lucas Azzola <[email protected]>
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