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

Template or backtick strings keep being indented #72

Closed
ckknight opened this issue May 20, 2016 · 4 comments
Closed

Template or backtick strings keep being indented #72

ckknight opened this issue May 20, 2016 · 4 comments
Labels

Comments

@ckknight
Copy link
Contributor

This is likely related to #53, but occurs regardless if formatJSXExpressions is true or false

Using esformatter 0.9.3 and esformatter-jsx 5.0.4

.esformatter:

{
    "preset": "default",
    "plugins": [
        "esformatter-jsx"
    ]
}

Initial input:

function render(count) {
    return (
        <FormattedMessage
            id="some.id"
            defaultMessage={`You have {count, plural,
                =0 {no Items}
                one {one Item}
                other {{count} Items}
            }`}
            description="Description goes here"
            values={{ count }}
        />
    );
}

First output:

function render(count) {
  return (
    <FormattedMessage id="some.id" defaultMessage={ `You have {count, plural,
                                                                =0 {no Items}
                                                                one {one Item}
                                                                other {{count} Items}
                                                            }` } description="Description goes here" values={ { count } } />
    );
}

Second output:

function render(count) {
  return (
    <FormattedMessage id="some.id" defaultMessage={ `You have {count, plural,
                                                                                                                =0 {no Items}
                                                                                                                one {one Item}
                                                                                                                other {{count} Items}
                                                                                                            }` } description="Description goes here" values={ { count } } />
    );
}

Third output:

function render(count) {
  return (
    <FormattedMessage id="some.id" defaultMessage={ `You have {count, plural,
                                                                                                                                                                =0 {no Items}
                                                                                                                                                                one {one Item}
                                                                                                                                                                other {{count} Items}
                                                                                                                                                            }` } description="Description goes here" values={ { count } } />
    );
}

Also see #70 for a PR to verify reformatting

@royriojas royriojas added the bug label May 22, 2016
@royriojas
Copy link
Owner

definitively an ugly bug. :(

Will try to take a look at it now

@royriojas
Copy link
Owner

I just published a new version with this fixed. Let me know if there is any instance where it fails...

demo

@ckknight
Copy link
Contributor Author

ckknight commented Jun 20, 2016

@royriojas Your demo duplicates the backtick string in the inner backtick string.

Also, the indentation bug is present if you do something akin to

<Comp prop={fn`
  hello
`}/>

@royriojas
Copy link
Owner

@ckknight I have to update the demo to use the latest. That shouldn't be happening with the latest.

For the other one I will investigate. Would you matter to create a new issue for the tags in backtips? please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants