Skip to content

Commit b96f336

Browse files
committed
Merge branch 'GH-36/rename-ast' into master
Close GH-36 BREAKING CHANGE: parser name has been renamed from 'melody' to 'twig'. This changes is to clearly communicate the intention of this project is to focus on twig template formatting. Not to continue supporting melody project.
2 parents 79cf386 + 2f406e2 commit b96f336

File tree

30 files changed

+83
-90
lines changed

30 files changed

+83
-90
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"scripts": {
1717
"lint": "DEBUG=eslint:cli-engine eslint .",
18-
"prettier": "prettier --plugin=./src/index.js --parser=melody",
18+
"prettier": "prettier --plugin=./src/index.js --parser=twig",
1919
"test": "vitest --run"
2020
},
2121
"dependencies": {

src/index.js

+6-13
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ import * as publicFunctions from "./util/publicFunctions.js";
1010
*/
1111
const languages = [
1212
{
13-
name: "melody",
14-
parsers: ["melody"],
15-
group: "Melody",
16-
tmScope: "melody.twig",
17-
aceMode: "html",
18-
codemirrorMode: "clike",
19-
codemirrorMimeType: "text/melody-twig",
20-
extensions: [".melody.twig", ".html.twig", ".twig"],
21-
linguistLanguageId: 0,
22-
vscodeLanguageIds: ["twig"]
13+
name: "twig",
14+
parsers: ["twig"],
15+
extensions: [".html.twig", ".twig"]
2316
}
2417
];
2518

@@ -29,9 +22,9 @@ const languages = [
2922
* @type Record<string, Parser>
3023
*/
3124
const parsers = {
32-
melody: {
25+
twig: {
3326
parse,
34-
astFormat: "melody",
27+
astFormat: "twig",
3528
hasPragma() {
3629
return false;
3730
},
@@ -50,7 +43,7 @@ const parsers = {
5043
* @type Record<string, Printer>
5144
*/
5245
const printers = {
53-
melody: {
46+
twig: {
5447
print,
5548
printComment(commentPath) {
5649
const comment = commentPath.getValue();

tests/Comments/__snapshots__/jsfmt.spec.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`htmlComments.melody.twig - melody-verify > htmlComments.melody.twig 1`] = `
3+
exports[`htmlComments.melody.twig - twig-verify > htmlComments.melody.twig 1`] = `
44
<!-- I am a comment -->
55
This is a paragraph
66
@@ -34,7 +34,7 @@ A third paragraph
3434
3535
`;
3636

37-
exports[`twigComments.melody.twig - melody-verify > twigComments.melody.twig 1`] = `
37+
exports[`twigComments.melody.twig - twig-verify > twigComments.melody.twig 1`] = `
3838
{# One #}
3939
4040
{# Two #}

tests/Comments/jsfmt.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
run_spec(__dirname, ["melody"]);
1+
run_spec(__dirname, ["twig"]);

tests/ConstantValue/__snapshots__/jsfmt.spec.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`constant-value-int.melody.twig - melody-verify > constant-value-int.melody.twig 1`] = `
3+
exports[`constant-value-int.melody.twig - twig-verify > constant-value-int.melody.twig 1`] = `
44
123
55
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66
123
77
88
`;
99

10-
exports[`constant-value-string.melody.twig - melody-verify > constant-value-string.melody.twig 1`] = `
10+
exports[`constant-value-string.melody.twig - twig-verify > constant-value-string.melody.twig 1`] = `
1111
Test string
1212
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1313
Test string
1414
1515
`;
1616

17-
exports[`special-cases.melody.twig - melody-verify > special-cases.melody.twig 1`] = `
17+
exports[`special-cases.melody.twig - twig-verify > special-cases.melody.twig 1`] = `
1818
{% if isRTL %}&#8206;{% endif %}
1919
2020
{% if searchResultFailing %}

tests/ConstantValue/jsfmt.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
run_spec(__dirname, ["melody"]);
1+
run_spec(__dirname, ["twig"]);

tests/ControlStructures/__snapshots__/jsfmt.spec.js.snap

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`for.melody.twig - melody-verify > for.melody.twig 1`] = `
3+
exports[`for.melody.twig - twig-verify > for.melody.twig 1`] = `
44
<ul>
55
{% for item in items %}
66
<li class="{{ loop.last ? 'last' : '' }}">
@@ -35,7 +35,7 @@ exports[`for.melody.twig - melody-verify > for.melody.twig 1`] = `
3535
3636
`;
3737
38-
exports[`forIfElse.melody.twig - melody-verify > forIfElse.melody.twig 1`] = `
38+
exports[`forIfElse.melody.twig - twig-verify > forIfElse.melody.twig 1`] = `
3939
<ul>
4040
{% for a,b in c | slice(3, c.length) if b is even -%}
4141
<li>{{ a }} - {{ b }}</li>
@@ -75,7 +75,7 @@ exports[`forIfElse.melody.twig - melody-verify > forIfElse.melody.twig 1`] = `
7575
7676
`;
7777
78-
exports[`forInclude.melody.twig - melody-verify > forInclude.melody.twig 1`] = `
78+
exports[`forInclude.melody.twig - twig-verify > forInclude.melody.twig 1`] = `
7979
{% for foo in range(1, category) %}
8080
<span key="{{ foo }}" class="qtp-item__star icon-ic icon-icn_star--white {{ foo }}">
8181
{% include './Star.twig' only %}
@@ -91,7 +91,7 @@ exports[`forInclude.melody.twig - melody-verify > forInclude.melody.twig 1`] = `
9191
9292
`;
9393
94-
exports[`forWithBlock.melody.twig - melody-verify > forWithBlock.melody.twig 1`] = `
94+
exports[`forWithBlock.melody.twig - twig-verify > forWithBlock.melody.twig 1`] = `
9595
<h1>{{ title | title }}</h1>
9696
<ul>
9797
{% for item in items %}
@@ -118,7 +118,7 @@ exports[`forWithBlock.melody.twig - melody-verify > forWithBlock.melody.twig 1`]
118118
119119
`;
120120
121-
exports[`if.melody.twig - melody-verify > if.melody.twig 1`] = `
121+
exports[`if.melody.twig - twig-verify > if.melody.twig 1`] = `
122122
<div>
123123
{%- if foo %}
124124
<div class="foo"></div>

tests/ControlStructures/jsfmt.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
run_spec(__dirname, ["melody"]);
1+
run_spec(__dirname, ["twig"]);

tests/Declaration/__snapshots__/jsfmt.spec.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`doctype.melody.twig - melody-verify > doctype.melody.twig 1`] = `
3+
exports[`doctype.melody.twig - twig-verify > doctype.melody.twig 1`] = `
44
<!DOCTYPE html>
55
66
<! DOCTYPE html>

tests/Declaration/jsfmt.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
run_spec(__dirname, ["melody"]);
1+
run_spec(__dirname, ["twig"]);

tests/Element/__snapshots__/jsfmt.spec.js.snap

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`attributes.melody.twig - melody-verify > attributes.melody.twig 1`] = `
3+
exports[`attributes.melody.twig - twig-verify > attributes.melody.twig 1`] = `
44
<a href="#abcd" target="_blank" lang="en" >Link</a>
55
66
<fantasy {{ {
@@ -35,7 +35,7 @@ exports[`attributes.melody.twig - melody-verify > attributes.melody.twig 1`] = `
3535
3636
`;
3737
38-
exports[`breakingSiblings.melody.twig - melody-verify > breakingSiblings.melody.twig 1`] = `
38+
exports[`breakingSiblings.melody.twig - twig-verify > breakingSiblings.melody.twig 1`] = `
3939
<span>One</span><b>Two</b><i>Three</i><span>Four</span><b>Five</b><i>Six</i><span>Seven</span>
4040
4141
<span>One</span>
@@ -60,7 +60,7 @@ exports[`breakingSiblings.melody.twig - melody-verify > breakingSiblings.melody.
6060
6161
`;
6262
63-
exports[`children.melody.twig - melody-verify > children.melody.twig 1`] = `
63+
exports[`children.melody.twig - twig-verify > children.melody.twig 1`] = `
6464
<div class="{{ css.loader }}">
6565
<div class="{{ css.barWrapper }}">
6666
<span class="{{ css.bar }}"></span>
@@ -77,7 +77,7 @@ exports[`children.melody.twig - melody-verify > children.melody.twig 1`] = `
7777
7878
`;
7979
80-
exports[`emptyLines.melody.twig - melody-verify > emptyLines.melody.twig 1`] = `
80+
exports[`emptyLines.melody.twig - twig-verify > emptyLines.melody.twig 1`] = `
8181
<div>
8282
<img src="/img/posts/08/07/dns-resolution-expl.png" alt="DNS explained">
8383
@@ -105,14 +105,14 @@ exports[`emptyLines.melody.twig - melody-verify > emptyLines.melody.twig 1`] = `
105105
106106
`;
107107
108-
exports[`extraSpaces.melody.twig - melody-verify > extraSpaces.melody.twig 1`] = `
108+
exports[`extraSpaces.melody.twig - twig-verify > extraSpaces.melody.twig 1`] = `
109109
<span >Text</span >
110110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111111
<span>Text</span>
112112
113113
`;
114114
115-
exports[`manyAttributes.melody.twig - melody-verify > manyAttributes.melody.twig 1`] = `
115+
exports[`manyAttributes.melody.twig - twig-verify > manyAttributes.melody.twig 1`] = `
116116
<span attr1="one" attr2="two" attr3="three" attr4="four" attr5="five" attr6="six" attr7="seven" attr8="eight">Text</span>
117117
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118118
<span attr1="one"
@@ -128,7 +128,7 @@ exports[`manyAttributes.melody.twig - melody-verify > manyAttributes.melody.twig
128128
129129
`;
130130
131-
exports[`oneLine.melody.twig - melody-verify > oneLine.melody.twig 1`] = `
131+
exports[`oneLine.melody.twig - twig-verify > oneLine.melody.twig 1`] = `
132132
<a href="{{ url }}">
133133
Next
134134
</a>
@@ -137,7 +137,7 @@ exports[`oneLine.melody.twig - melody-verify > oneLine.melody.twig 1`] = `
137137
138138
`;
139139
140-
exports[`selfClosing.melody.twig - melody-verify > selfClosing.melody.twig 1`] = `
140+
exports[`selfClosing.melody.twig - twig-verify > selfClosing.melody.twig 1`] = `
141141
<input type="text" name="user" />
142142
143143
<input attr1="one" attr2="two" attr3="three" attr4="four" attr5="five" attr6="six" attr7="seven" attr8="eight" />
@@ -161,14 +161,14 @@ exports[`selfClosing.melody.twig - melody-verify > selfClosing.melody.twig 1`] =
161161
162162
`;
163163
164-
exports[`siblings.melody.twig - melody-verify > siblings.melody.twig 1`] = `
164+
exports[`siblings.melody.twig - twig-verify > siblings.melody.twig 1`] = `
165165
<span>One</span><b>Two</b><i>Three</i>
166166
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167167
<span>One</span><b>Two</b><i>Three</i>
168168
169169
`;
170170
171-
exports[`whitespace.melody.twig - melody-verify > whitespace.melody.twig 1`] = `
171+
exports[`whitespace.melody.twig - twig-verify > whitespace.melody.twig 1`] = `
172172
<span class="price">{{ price }} {{ currencySymbol }}</span>
173173
174174
<span class="price">Price: {{ price }} {{ currencySymbol }} per night</span>

tests/Element/jsfmt.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
run_spec(__dirname, ["melody"]);
1+
run_spec(__dirname, ["twig"]);

tests/Expressions/__snapshots__/jsfmt.spec.js.snap

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`arrayExpression.melody.twig - melody-verify > arrayExpression.melody.twig 1`] = `
3+
exports[`arrayExpression.melody.twig - twig-verify > arrayExpression.melody.twig 1`] = `
44
{{ [2, 3, "cat"] }}
55
66
{{ [ 2, 3, "cat","dog", "mouse"] }}
@@ -42,7 +42,7 @@ exports[`arrayExpression.melody.twig - melody-verify > arrayExpression.melody.tw
4242
4343
`;
4444

45-
exports[`binaryExpressions.melody.twig - melody-verify > binaryExpressions.melody.twig 1`] = `
45+
exports[`binaryExpressions.melody.twig - twig-verify > binaryExpressions.melody.twig 1`] = `
4646
{% set highlightValueForMoney = isFeatureEnabled('vFMV5') or isCTestActive('WEB-48935') or isCTestActive('WEB-48956') or isCTestActive('WEB-48955')%}
4747
4848
{% set name = condition1 or condition2 and condition3 or condition4 or condition5 and condition6 %}
@@ -95,7 +95,7 @@ exports[`binaryExpressions.melody.twig - melody-verify > binaryExpressions.melod
9595
9696
`;
9797

98-
exports[`callExpression.melody.twig - melody-verify > callExpression.melody.twig 1`] = `
98+
exports[`callExpression.melody.twig - twig-verify > callExpression.melody.twig 1`] = `
9999
{{ range(3) }}
100100
101101
{{ date('d/m/Y H:i', timezone="Europe/Paris") }}
@@ -155,7 +155,7 @@ exports[`callExpression.melody.twig - melody-verify > callExpression.melody.twig
155155
156156
`;
157157
158-
exports[`conditionalExpression.melody.twig - melody-verify > conditionalExpression.melody.twig 1`] = `
158+
exports[`conditionalExpression.melody.twig - twig-verify > conditionalExpression.melody.twig 1`] = `
159159
{{ test ? "One" : "Two" }}
160160
161161
{{ test ? "This is a slightly longer string to overflow the line" : "and here is its counterpart" }}
@@ -172,7 +172,7 @@ exports[`conditionalExpression.melody.twig - melody-verify > conditionalExpressi
172172
173173
`;
174174
175-
exports[`filterExpression.melody.twig - melody-verify > filterExpression.melody.twig 1`] = `
175+
exports[`filterExpression.melody.twig - twig-verify > filterExpression.melody.twig 1`] = `
176176
{{ 'test.foo' | split('.') }}
177177
{{ range(3) | sort | join(',') }}
178178
{{ 'SHOUTING' | lower|escape('html') | upper | escape('markdown') | lower | upper | escape('markdown') }}
@@ -224,14 +224,14 @@ exports[`filterExpression.melody.twig - melody-verify > filterExpression.melody.
224224
225225
`;
226226
227-
exports[`memberExpression.melody.twig - melody-verify > memberExpression.melody.twig 1`] = `
227+
exports[`memberExpression.melody.twig - twig-verify > memberExpression.melody.twig 1`] = `
228228
{{ alternativeMarriottRewardRates[deal.dealId].short }}
229229
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
230230
{{ alternativeMarriottRewardRates[deal.dealId].short }}
231231
232232
`;
233233
234-
exports[`objectExpression.melody.twig - melody-verify > objectExpression.melody.twig 1`] = `
234+
exports[`objectExpression.melody.twig - twig-verify > objectExpression.melody.twig 1`] = `
235235
{{ {
236236
a: "foo",
237237
"b#{ar}": "bar",
@@ -260,7 +260,7 @@ exports[`objectExpression.melody.twig - melody-verify > objectExpression.melody.
260260
261261
`;
262262
263-
exports[`operators.melody.twig - melody-verify > operators.melody.twig 1`] = `
263+
exports[`operators.melody.twig - twig-verify > operators.melody.twig 1`] = `
264264
{{ a b-and b }}
265265
{{ a b-or b }}
266266
{{ a b-xor b }}
@@ -392,7 +392,7 @@ exports[`operators.melody.twig - melody-verify > operators.melody.twig 1`] = `
392392
393393
`;
394394
395-
exports[`stringConcat.melody.twig - melody-verify > stringConcat.melody.twig 1`] = `
395+
exports[`stringConcat.melody.twig - twig-verify > stringConcat.melody.twig 1`] = `
396396
<div>
397397
{{ first ~ second }}
398398
</div>
@@ -423,7 +423,7 @@ exports[`stringConcat.melody.twig - melody-verify > stringConcat.melody.twig 1`]
423423
424424
`;
425425
426-
exports[`stringLiteral.melody.twig - melody-verify > stringLiteral.melody.twig 1`] = `
426+
exports[`stringLiteral.melody.twig - twig-verify > stringLiteral.melody.twig 1`] = `
427427
{{ 'zzz\\\\bar\\\\baz' }}
428428
429429
{{ "College - Women's" }}
@@ -446,7 +446,7 @@ exports[`stringLiteral.melody.twig - melody-verify > stringLiteral.melody.twig 1
446446
447447
`;
448448
449-
exports[`unaryNot.melody.twig - melody-verify > unaryNot.melody.twig 1`] = `
449+
exports[`unaryNot.melody.twig - twig-verify > unaryNot.melody.twig 1`] = `
450450
{% if not invalid %}
451451
<p>All's well.</p>
452452
{% endif %}

tests/Expressions/jsfmt.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
run_spec(__dirname, ["melody"]);
1+
run_spec(__dirname, ["twig"]);

tests/Failing/__snapshots__/jsfmt.spec.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`controversial.melody.twig - melody-verify > controversial.melody.twig 1`] = `
3+
exports[`controversial.melody.twig - twig-verify > controversial.melody.twig 1`] = `
44
{% set isRewardRate = isMarriottRewardRate or (rewardRateAltIds and deal.dealId in rewardRateAltIds[accommodation.id.id]) %}
55
66
<!-- Alternatively, introduce another variable -->
@@ -89,7 +89,7 @@ exports[`controversial.melody.twig - melody-verify > controversial.melody.twig 1
8989
9090
`;
9191
92-
exports[`failing.melody.twig - melody-verify > failing.melody.twig 1`] = `
92+
exports[`failing.melody.twig - twig-verify > failing.melody.twig 1`] = `
9393
{# IF tag in element not allowed
9494
<option {% if not purchasable.isAvailable %}disabled{% endif %}>
9595
{{ purchasable.description }}

tests/Failing/jsfmt.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
run_spec(__dirname, ["melody"], {
1+
run_spec(__dirname, ["twig"], {
22
twigPrintWidth: 120,
33
twigAlwaysBreakObjects: true,
44
twigFollowOfficialCodingStandards: false

0 commit comments

Comments
 (0)