Skip to content

Commit 6a1d8c0

Browse files
committed
test: this is not experimental feature
1 parent 7402e18 commit 6a1d8c0

File tree

7 files changed

+30
-34
lines changed

7 files changed

+30
-34
lines changed

src/index.js

-6
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ const options = {
103103
category: "Global",
104104
default: false,
105105
description: "Output the Twig block name in the 'endblock' tag"
106-
},
107-
experimentalMethodChainIndentation: {
108-
type: "boolean",
109-
category: "Global",
110-
default: false,
111-
description: "Experimental: Fix indentation for chained method call"
112106
}
113107
};
114108

src/print/CallExpression.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88

99
const { group, softline, line, indent, join } = doc.builders;
1010

11-
const p = (node, path, print, options) => {
11+
const p = (node, path, print) => {
1212
node[EXPRESSION_NEEDED] = false;
1313
node[STRING_NEEDS_QUOTES] = true;
1414
const mappedArguments = path.map(print, "arguments");
@@ -22,8 +22,6 @@ const p = (node, path, print, options) => {
2222
// Optimization: No line break between "(" and "{" if
2323
// there is exactly one object parameter
2424
parts.push(mappedArguments[0], ")");
25-
} else if (options.experimentalMethodChainIndentation) {
26-
parts.push(indent([join([", "], mappedArguments)]), ")");
2725
} else {
2826
parts.push(
2927
indent([softline, join([",", line], mappedArguments)]),

src/print/MemberExpression.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@ import {
55
wrapExpressionIfNeeded
66
} from "../util/index.js";
77

8-
const { group, softline, indent } = doc.builders;
8+
const { group } = doc.builders;
99

10-
const p = (node, path, print, options) => {
10+
const p = (node, path, print) => {
1111
node[EXPRESSION_NEEDED] = false;
1212
node[STRING_NEEDS_QUOTES] = true;
1313
const parts = [path.call(print, "object")];
14-
if (node.computed) {
15-
parts.push("[");
16-
} else if (options.experimentalMethodChainIndentation) {
17-
parts.push(indent([softline, "."]));
18-
} else {
19-
parts.push(".");
20-
}
14+
parts.push(node.computed ? "[" : ".");
2115
parts.push(path.call(print, "property"));
2216
if (node.computed) {
2317
parts.push("]");

tests/Experimental/experimental.spec.js

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
<a class="task-edit"
1+
<a
2+
class="task-edit"
23
href="{{
34
ea_url()
45
.setDashboard('App\\Controller\\Dashboard\\DashboardController')
56
.setController('App\\Controller\\Dashboard\\CRUD\\TacheCrudController')
67
.setAction('edit')
78
.setEntityId(tache.id)
89
.set('sort', null)
9-
}}">
10+
}}"
11+
>
1012
<i class="fa-solid fa-edit"></i>
1113
</a>
14+
15+
{{
16+
craft
17+
.entries
18+
.section('news')
19+
.section('news')
20+
.orderBy('postDate DESC')
21+
.limit(10)
22+
.all(a.b)
23+
}}
24+
25+
{{ craft.entries.all() }}

tests/Expressions/jsfmt.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,14 @@ describe("Expressions", () => {
9191
});
9292
await expect(actual).toMatchFileSnapshot(snapshotFile);
9393
});
94+
95+
it("Properly indent chain method", async () => {
96+
const { actual, snapshotFile } = await run_spec(import.meta.url, {
97+
source: "chain_indentation.twig",
98+
formatOptions: {
99+
experimentalMethodChainIndentation: true
100+
}
101+
});
102+
await expect(actual).toMatchFileSnapshot(snapshotFile);
103+
});
94104
});

0 commit comments

Comments
 (0)