Commit Graph

8 Commits (master)

Author SHA1 Message Date
Lucas Duailibe 2c5a792d9a fix(jsx): Break opening elements with single text attribute if there's a comment (#3154)
* fix(jsx): Break opening elements with single text attribute if there's a comment

* Single text attribute with a comment on the JSXElement name

* Consolidate rules of comments in JSX
2017-11-07 08:05:59 +11:00
Lucas Azzola c0aaa0fa52 Don't print JSX bracket on same line when it has trailing comments (#3088) 2017-10-23 17:13:12 +11:00
Marshall Bowers 445f51709e Fix indentation for JSDoc comments (#2470)
* Fix TypeScript comment snapshot

* Add failing test for TypeScript method comments

* Remove trailing space in comment

* Add snapshot for comment with many lines

* Add TODO marking potential location for comment re-indentation

* Update snapshot

* Indent comments based on the parent node

* Only adjust indentation if the comment looks like a JSDoc comment

* Only strip leading spaces when adjusting comment indentation

* Update snapshot

* Add test to show incorrect indentation based on parent node

* Update snapshot

* Update snapshot

* Update comment indentation to not rely on the parent node

* Extract code for getting the indent size

* Add test where the parent indentation changes as well

* Fix lint warning regarding lexical declarations within case block

* Update lockfile

* Update snapshot

* Add test case for block comment inside of a method

* Replace spread operator with `concat`

* Use `align` instead of `addAlignmentToDoc`

* Add test for mismatched indentation within JSDoc comment

* Always add a leading space to subsequent lines in a JSDoc comment

* Refactor JSDoc comment printing into a separate function

* Remove unneeded `align`

* Replace `forEach` with `map` for better style

* Only `trimLeft` when the end comment token is on the last line of the comment

* Remove unneeded `docBuilders`

* Add tests for JSDoc comments in JSX

* Update snapshots
2017-10-08 20:34:24 +11:00
Christopher Chedeau f7bd74ed98 Fix fatal with empty jsx (#2663) 2017-08-24 18:02:44 -07:00
David Hong 411f0fb6e7 Print line/mixed comments on new lines inside JSXEmptyExpression (#985) 2017-03-10 18:23:11 -08:00
Christopher Chedeau 4b237d331e Fix jsx expression comment that break (#852)
In #596, I fixed a bunch of jsx expression comment edge cases and happened to add a softline there. But it turns out that it's not needed and is actually harmful :)

Fixes #712
2017-03-02 22:27:08 -05:00
Christopher Chedeau 7abd6f5f9b Fix single indented JSX comment (#596)
This one was pretty annoying to figure out but now it's working. All the crazy comments I could throw at jsx seems to be working fine now :)

Fixes #543
2017-02-04 21:37:18 -05:00
Christopher Chedeau 3b66af3d60 Remove the concept of globalPrecedingNode (#561)
The original motivation for this change is trying to fix #560 where the comment was attached to the JSXText node instead of the JSXExpressionContainer because it used the globalPrecedingNode. In general, I don't think that it is very safe to attach a comment to a random node just because it happened to be before.

I tried to delete the globalPrecedingNode codepath and I think that it actually improves the results. I'll add inline comments in the pull request to explain the various changes.

Fixes #560
2017-02-03 13:56:06 -08:00