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

Wrong formatting if "or" condition is used in hash object definition #164

Open
eugenet8k opened this issue Jan 23, 2020 · 2 comments
Open

Comments

@eugenet8k
Copy link

This original code

b = null

obj =
  c: 1
  d: b or b: 1
  e: 100

prettier turns to

b = null

obj =
  c: 1
  d: b or
    b: 1

  e: 100

Having a line break breaks CoffeeScript compiler as it is not the same definition anymore

@helixbass
Copy link
Owner

Ok this one is also a Coffeescript parser bug (opened jashkenas/coffeescript#5292)

This one would be trickier to guard against in the Prettier plugin (at least in a robust way)

I might be able to implement at least a "stopgap" in the Prettier plugin that avoids this specific case

But I'll also take a look at fixing the parsing issue on the Coffeescript side

Thanks for reporting all of these, it's great to see the Prettier and ESLint plugins being exercised against an actual production hybrid JS/Coffeescript React app 👍

@eugenet8k
Copy link
Author

@helixbass thank you for looking and spending time. I came with a workaround, of course, something like

b or= b:1

obj =
  c: 1
  d: b
  e: 100

But generally, we did successfully migrate our fairly big project to prettier, after fixing around 3000 lint errors now it seems it's working well. We do have a 50/50 mix of JS and CS and the usage of React in both codebases. I really like having one eslintrc for both JS and CS, moreover, it seems when I override rules for CS some of the general JS rules are inherited (can't say for sure, but it seems so).

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

No branches or pull requests

2 participants