Skip to content

Commit

Permalink
feat: remove option twigPrintWidth
Browse files Browse the repository at this point in the history
Related GH-50.

BREAKING CHANGES: see CHANGELOG.md for more info.
  • Loading branch information
zackad committed Nov 20, 2024
1 parent 787d923 commit ee20eb4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

## unreleased

> [!IMPORTANT]
> Yet another breaking changes. See release notes or changelog before upgrading.
### BREAKING CHANGES
- Option `twigPrintWidth` has been removed

I don't see any reason why we should keep the option `twigPrintWidth`. Prettier provide mechanism to use different `printWidth` for different file types by using _override_ (see example below).

__What to do?__

Remove `twigPrintWidth` from your prettier config and use [override](https://prettier.io/docs/en/configuration.html#configuration-overrides) instead.

__Example__
```diff
# ./.prettierrc.yaml
- twigPrintWidth: 120
+ overrides:
+ - files: "*.twig"
+ options:
+ printWidth: 120
```

---
## 0.11.1 (2024-11-13)

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ This Prettier plugin comes with some options that you can add to your Prettier c

Values can be `true` or `false`. If `true`, single quotes will be used for string literals in Twig files.

### twigPrintWidth (default: `80`)

Because Twig files might have a lot of nesting, it can be useful to define a separate print width for Twig files. This can be done with this option. If it is not set, the standard `printWidth` option is used.

### twigAlwaysBreakObjects (default: `true`)

If set to `true`, objects will always be wrapped/broken, even if they would fit on one line:
Expand Down
6 changes: 0 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ const options = {
default: true,
description: "Should objects always break in Twig files?"
},
twigPrintWidth: {
type: "int",
category: "Global",
default: 80,
description: "Print width for Twig files"
},
twigFollowOfficialCodingStandards: {
type: "boolean",
category: "Global",
Expand Down
4 changes: 0 additions & 4 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ const print = (path, options, print) => {
originalSource = node[ORIGINAL_SOURCE];
}

if (options.twigPrintWidth) {
options.printWidth = options.twigPrintWidth;
}

checkForIgnoreEnd(node);
const useOriginalSource =
(shouldApplyIgnoreNext(node) && ignoreNext) || ignoreRegion;
Expand Down
2 changes: 1 addition & 1 deletion tests/Failing/jsfmt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";

/** @type {import('tests_config/run_spec').PrettierOptions} */
const formatOptions = {
twigPrintWidth: 120,
printWidth: 120,
twigAlwaysBreakObjects: true,
twigFollowOfficialCodingStandards: false
};
Expand Down
2 changes: 1 addition & 1 deletion tests/Options/jsfmt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("Options", () => {
const { actual, snapshotFile } = await run_spec(import.meta.url, {
source: "printWidth.twig",
formatOptions: {
twigPrintWidth: 120
printWidth: 120
}
});
await expect(actual).toMatchFileSnapshot(snapshotFile);
Expand Down

0 comments on commit ee20eb4

Please sign in to comment.