Commit Graph

33 Commits (90cb3c268d4fbb6456975473f3ba7e9b5b3f8798)

Author SHA1 Message Date
fisker Cheung 56a2cd8a1b Refactor createLanguage to use function transform (#6676) 2019-10-29 20:49:44 +02:00
Chad Carbert a7cae47cdf Glimmer: Improve whitespace handling (#6354)
* Improve curly and whitespace handling

* Refactoring and clean up

* Collapse elements with non-whitespace children

* Clean selfClosing check in AST compare

selfClosing tags can't be considered when using AST_COMPARE=1.
The new AST may have a Glimmer component that has been collapsed,
ie: <HelloWorld></HelloWorld> -> <HelloWorld />

These result in different ASTs and thereofre we need to clean the
check that compares self-closing in the before and after ASTs

Co-authored-by: Jamie White <jamie@jgwhite.co.uk>

* Add istanbul ignore for ternaries in utilities

* Improve handling around whitespace near elements and block statements

* Update tests after rebasing

* Fix CHANGELOG.unreleased.md after rebase

* Tweak regex around leading and trialing line beraks and update test

Co-authored-by: FabHof <35104465+FabHof@users.noreply.github.com>

* Extract attribute value from concat node
2019-10-21 23:51:41 +02:00
Cyrille David 7cb0c23774 fix(handlebars): Use quotes from config in AttrNode (#6377) 2019-09-30 17:08:58 +03:00
fisker Cheung 5ce16eaa02 Update linguist-languages to v7 (#6367)
* Update linguist-languages to v7

* Trigger build

* Update

* replace `includes` with `indexOf`

* fix `exclude`

* add `nodejs` back
2019-09-14 00:57:16 +03:00
Joffrey JAFFEUX b557dc3603 [Glimmer/Handlebars] Forces multilines print when almost at max length (#6249) 2019-07-22 10:39:18 -03:00
Gavin Joyce 12b8176d5d [Glimmer] preserve html entities (#6234) 2019-07-08 11:07:41 +02:00
Gavin Joyce e8037ff250 [Glimmer] improve text/mustache formatting (#6206) 2019-06-19 09:53:27 -03:00
Chris Brody cacaa92a3f @glimmer/syntax 0.39.3 update (#5983) 2019-06-18 08:50:51 -03:00
Gavin Joyce ff7bc1c008 [Glimmer] improve text/mustache formatting (#6186) 2019-06-14 12:11:47 -03:00
Lucas Duailibe 4cc99242a8 Bump Prettier dependency to 1.18.0 2019-06-06 18:48:11 -03:00
Gavin Joyce 90308ebe76 fix: avoid unwanted whitespace in glimmer components (#6178) 2019-06-05 11:15:11 -03:00
Cyrille David 84cc273c7d fix(glimmer): {{else}}{{#if}} into {{else if}} merging (#6080) 2019-05-02 16:26:26 +03:00
Mahir Shah 30ec30daa9 Escape Quotes in Glimmer String Literals (#5143) 2018-10-05 22:19:33 +02:00
Simon Lydell f87c82cc4e
Improve glimmer parse errors (#5161)
Instead of showing 80 carets, point out just which line the error was
on, and rely on the original message to point out the "column".

I thought about matching the `----^` in the original message with a
regex and use the length of it as the column number, but unfortunately
the original message does not show the original code (in this example
some whitespace is missing), so it wouldn't work.

Before:

```
$ ./bin/prettier.js test.hbs --parser glimmer
[error] test.hbs: SyntaxError: Parse error on line 2:
[error] {{one}}{{
[error] ---------^
[error] Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF' (2:0)
[error]   1 | {{one}}
[error] > 2 | {{
[error]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]   3 |
```

After:

```
$ ./bin/prettier.js test.hbs --parser glimmer
[error] test.hbs: SyntaxError: Parse error on line 2:
[error] {{one}}{{
[error] ---------^
[error] Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF' (2:0)
[error]   1 | {{one}}
[error] > 2 | {{
[error]   3 |
```
2018-09-30 00:25:45 +02:00
Ika 58d34bb844
refactor: language extend (#4994) 2018-08-22 10:12:57 +08:00
Paul Chavard 783923a81b fix(glimmer): preserve empty text attributes (#4897) 2018-08-01 12:45:36 -03:00
Paul Chavard 0571b2b884 fix(glimmer): treat glimmer components as self closing tags (#4900) 2018-07-27 06:49:13 -04:00
Paul Chavard 65d65a5c13 fix(glimmer): better formatting of boolean attributes (and also ...attributes) (#4891) 2018-07-26 09:50:45 -03:00
Paul Chavard 505e08292c fix(glimmer): add softline in nested block statements (#4896) 2018-07-26 09:49:50 -03:00
Paul Chavard ca8e049126 fix(glimmer): remove extra space from sub-expressions without params (#4890) 2018-07-24 19:50:30 -03:00
Paul Chavard 5d254ce310 fix(glimmer): do not strip block params on <Component> (#4889) 2018-07-24 19:07:49 -03:00
Prashant Andani cdcb7b11c9 Use destructures and refactor code for readability (#4844)
* Use destructuring for readability and optimzations at for loop length property

* Destructure variables for easy maintainability of code

* PR review fix

* refactor: fix linting

* Use destructures and refactor code for better readability

* Remove merge conflict line

* lint before commit
2018-07-17 18:01:44 -03:00
Ika 0b659b898d
feat: update linguist languages (#4741)
Context: https://github.com/prettier/prettier/pull/4734#issue-196702272

Languages should be easy to maintain now.
2018-06-28 08:24:02 +08:00
Lucas Azzola b0cb63a7bb
Use destructuring for imports (#4554)
* Use destructuring for imports

* Clean up integration tests

* Use moduleNameMapper for require_prettier
2018-05-27 21:36:12 +10:00
Lucas Duailibe 52a2a46b3c
New build system (#4449) 2018-05-24 15:30:45 -03:00
Dray Lacy bb6d130b5b Fix printing of `{{{raw}}}` handlebars expressions (#4535)
Previously, `{{{raw}}}` would be output as `{{raw}}`.
2018-05-24 11:16:50 -07:00
Ika d0f6aac001
refactor(massageAst): move stripLocation to corresponding plugins (#4477) 2018-05-14 20:52:27 +08:00
Nate Pendleton 91c701886d fix(glimmer): preserve leading/trailing spaces in text nodes undernea… (#4288)
* fix(glimmer): preserve leading/trailing spaces in text nodes underneath attribute nodes when next to mustache statements.

* fix(glimmer): format printer-glimmer.js

* fix(glimmer): lint fix

* fix(glimmer): removed decomposition assignments to be compatible with Node 4

* fix(glimmer): Array.includes() -> indexOf() for Node 4
2018-04-27 14:20:10 -06:00
Nate Pendleton 28e4b07b17 fix(issue-3982): Glimmer printer now properly handles else-if blocks without else block … (#4256)
* fix(glimmer): Now properly handles else-if blocks without else block and block statements as root of else.

* run prettier on printer-glimmer.js
2018-04-08 11:36:37 -06:00
Lucas Azzola a0668129da
Do not require plugins to set 'since' field (#4038)
* Do not require plugins to set 'since' field

* Refactor
2018-02-24 19:00:51 +11:00
Christian Zosel fac08034e7 Split out location extraction into plugin config (#3777)
* Split out location extraction into plugin config

* Reduce set of exported function, rebase to current master

* Pass custom locStart/locEnd fn's directly to affected methods

* (wip) always use locStart/locEnd from plugin

* Convert graphql implementation

* Convert HTML implementation

* (wip) convert JS implementation

* Remove unused variables

* Continue conversion of JS implementation

* Replace "util.locStart" with direct call to "options.locStart"

* Remove util closure

* Add unit test for structure of shared util

* Fix linting error, simplify locStart/End implementations
2018-02-09 23:17:48 +11:00
Lucas Azzola a041914551
Extract cleanAST to language-specific files (#3610)
* Extract cleanAST to language-specific files

* Fix lint

* Fix clean-ast for vue and glimmer
2017-12-30 21:30:09 +11:00
Robert Webb 833666a394 Support handlebars (#3534)
* feat(glimmer): initial HTML/Handlebars/Glimmer support

* feat(glimmer): support un-escaped mustache expressions

* fix(glimmer): add 'as |foo|' syntax

* fix(glimmer): support {{foo bar}} syntax

* feat(glimmer): implement all AST types

* feat(glimmer): implement if/else if/else

* test(glimmer): ignore leading/trailing whitespace from AST_COMPARE

* fix(glimmer): do not use trailing slash for void self-closing elements

* chore(build): disable html tests until we can sort out the glimmer dependency

* feat(html): complete rebase on parse5 addition

* Prettier Support For Glimmer VM/Handlebars

Polished Support for Sub Expressions
Added test cases for glimmer primitives
Added support for concat statements
Attempted to make element nodes work
Attempted block statements
Element Nodes are OK
Added support for block elements that are not else-if related
Added support for Else/If
Cleaning up
Rebase
Switch node 4 syntax
Update build

* Removed dead code/partials

* Added new lines to end of test files.

* Rebase after plugin change

* Added ignores to code coverage
2017-12-29 18:14:31 +01:00