Skip to content

Commit

Permalink
test: this is not experimental feature
Browse files Browse the repository at this point in the history
  • Loading branch information
zackad committed Dec 18, 2024
1 parent 1aa277a commit e48f91d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 32 deletions.
6 changes: 0 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ const options = {
category: "Global",
default: false,
description: "Output the Twig block name in the 'endblock' tag"
},
experimentalMethodChainIndentation: {
type: "boolean",
category: "Global",
default: false,
description: "Experimental: Fix indentation for chained method call"
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/print/CallExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const printCallExpression = (node, path, print) => {
// Optimization: No line break between "(" and "{" if
// there is exactly one object parameter
parts.push(mappedArguments[0], ")");
} else if (options.experimentalMethodChainIndentation) {
parts.push(indent([join([", "], mappedArguments)]), ")");
} else {
parts.push(
indent([softline, join([",", line], mappedArguments)]),
Expand Down
10 changes: 2 additions & 8 deletions src/print/MemberExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ import {
wrapExpressionIfNeeded
} from "../util/index.js";

const { group, softline, indent } = doc.builders;
const { group } = doc.builders;

const printMemberExpression = (node, path, print) => {
node[EXPRESSION_NEEDED] = false;
node[STRING_NEEDS_QUOTES] = true;
const parts = [path.call(print, "object")];
if (node.computed) {
parts.push("[");
} else if (options.experimentalMethodChainIndentation) {
parts.push(indent([softline, "."]));
} else {
parts.push(".");
}
parts.push(node.computed ? "[" : ".");
parts.push(path.call(print, "property"));
if (node.computed) {
parts.push("]");
Expand Down
14 changes: 0 additions & 14 deletions tests/Experimental/experimental.spec.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
<a class="task-edit"
<a
class="task-edit"
href="{{
ea_url()
.setDashboard('App\\Controller\\Dashboard\\DashboardController')
.setController('App\\Controller\\Dashboard\\CRUD\\TacheCrudController')
.setAction('edit')
.setEntityId(tache.id)
.set('sort', null)
}}">
}}"
>
<i class="fa-solid fa-edit"></i>
</a>

{{
craft
.entries
.section('news')
.section('news')
.orderBy('postDate DESC')
.limit(10)
.all(a.b)
}}

{{ craft.entries.all() }}
File renamed without changes.
10 changes: 10 additions & 0 deletions tests/Expressions/jsfmt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,14 @@ describe("Expressions", () => {
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
});

it("Properly indent chain method", async () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "chain_indentation.twig",
formatOptions: {
experimentalMethodChainIndentation: true
}
});
await expect(actual).toMatchFileSnapshot(snapshotFile);

Check failure on line 102 in tests/Expressions/jsfmt.spec.js

View workflow job for this annotation

GitHub Actions / Test (18)

tests/Expressions/jsfmt.spec.js > Expressions > Properly indent chain method

Error: Snapshot `Expressions > Properly indent chain method 1` mismatched - Expected + Received <a class="task-edit" href="{{ - ea_url() - .setDashboard('App\\Controller\\Dashboard\\DashboardController') - .setController('App\\Controller\\Dashboard\\CRUD\\TacheCrudController') - .setAction('edit') - .setEntityId(tache.id) - .set('sort', null) + ea_url().setDashboard( + 'App\\Controller\\Dashboard\\DashboardController' + ).setController( + 'App\\Controller\\Dashboard\\CRUD\\TacheCrudController' + ).setAction( + 'edit' + ).setEntityId( + tache.id + ).set( + 'sort', + null + ) }}" > <i class="fa-solid fa-edit"></i> </a> {{ - craft - .entries - .section('news') - .section('news') - .orderBy('postDate DESC') - .limit(10) - .all(a.b) + craft.entries.section('news').section('news').orderBy( + 'postDate DESC' + ).limit( + 10 + ).all( + a.b + ) }} {{ craft.entries.all() }} ❯ tests/Expressions/jsfmt.spec.js:102:9

Check failure on line 102 in tests/Expressions/jsfmt.spec.js

View workflow job for this annotation

GitHub Actions / Test (20)

tests/Expressions/jsfmt.spec.js > Expressions > Properly indent chain method

Error: Snapshot `Expressions > Properly indent chain method 1` mismatched - Expected + Received <a class="task-edit" href="{{ - ea_url() - .setDashboard('App\\Controller\\Dashboard\\DashboardController') - .setController('App\\Controller\\Dashboard\\CRUD\\TacheCrudController') - .setAction('edit') - .setEntityId(tache.id) - .set('sort', null) + ea_url().setDashboard( + 'App\\Controller\\Dashboard\\DashboardController' + ).setController( + 'App\\Controller\\Dashboard\\CRUD\\TacheCrudController' + ).setAction( + 'edit' + ).setEntityId( + tache.id + ).set( + 'sort', + null + ) }}" > <i class="fa-solid fa-edit"></i> </a> {{ - craft - .entries - .section('news') - .section('news') - .orderBy('postDate DESC') - .limit(10) - .all(a.b) + craft.entries.section('news').section('news').orderBy( + 'postDate DESC' + ).limit( + 10 + ).all( + a.b + ) }} {{ craft.entries.all() }} ❯ tests/Expressions/jsfmt.spec.js:102:9

Check failure on line 102 in tests/Expressions/jsfmt.spec.js

View workflow job for this annotation

GitHub Actions / Test (22)

tests/Expressions/jsfmt.spec.js > Expressions > Properly indent chain method

Error: Snapshot `Expressions > Properly indent chain method 1` mismatched - Expected + Received <a class="task-edit" href="{{ - ea_url() - .setDashboard('App\\Controller\\Dashboard\\DashboardController') - .setController('App\\Controller\\Dashboard\\CRUD\\TacheCrudController') - .setAction('edit') - .setEntityId(tache.id) - .set('sort', null) + ea_url().setDashboard( + 'App\\Controller\\Dashboard\\DashboardController' + ).setController( + 'App\\Controller\\Dashboard\\CRUD\\TacheCrudController' + ).setAction( + 'edit' + ).setEntityId( + tache.id + ).set( + 'sort', + null + ) }}" > <i class="fa-solid fa-edit"></i> </a> {{ - craft - .entries - .section('news') - .section('news') - .orderBy('postDate DESC') - .limit(10) - .all(a.b) + craft.entries.section('news').section('news').orderBy( + 'postDate DESC' + ).limit( + 10 + ).all( + a.b + ) }} {{ craft.entries.all() }} ❯ tests/Expressions/jsfmt.spec.js:102:9
});
});

0 comments on commit e48f91d

Please sign in to comment.