Skip to content

A snippet that doesn't compile down to pretty jsx #239

@chenglou

Description

@chenglou

Currently jsx transforms this (with the indentation):

            if (this.props.completedCount > 0) {
                clearButton = (
                    <button
                        id="clear-completed"
                        onClick={this.props.onClearCompleted}>
                        Clear completed ({this.props.completedCount})
                    </button>
                );
            }

into this:

            if (this.props.completedCount > 0) {
                clearButton = (
                    React.DOM.button(
                        {id:"clear-completed",
                        onClick:this.props.onClearCompleted}, [
" Clear completed (",this.props.completedCount,") "                 ])
                );
            }

Which fails to pass jshint because of the indentation (the temporary solution is to put {''} before and after the bad line). It gets worse if you prefer the style of putting the > on a new line, it becomes:

            if (this.props.completedCount > 0) {
                clearButton = (
                    React.DOM.button(
                        {id:"clear-completed",
                        onClick:this.props.onClearCompleted}
                    , [
" Clear completed (",this.props.completedCount,") "                 ])
                );
            }

Which fails two additional tests, the comma style (that can be disabled with laxcomma and bad line breaking (not sure if it can be disabled).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions