Skip to content

Commit 0c1b3c4

Browse files
Sec-antCopilot
andauthored
fix: refactor embedded options and embedder logic (#157)
* fix: refactor embedded options and embedder logic * Update biome.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: apply suggestions * chore(ci): fix workflows * fix: remove unused imports * chore(tests): add test cases for various languages with formatting issues * chore: nitpick * fix: add Ruby setup to CI test workflow * chore: add installation step for Ruby gems in CI workflow * fix(ruby): update ruby test snapshots * fix(prisma, xml): formatting behavior for embedded `prisma` and `xml` --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 488a112 commit 0c1b3c4

File tree

104 files changed

+3696
-4495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+3696
-4495
lines changed

.changeset/cuddly-webs-chew.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"prettier-plugin-embed": patch
3+
---
4+
5+
Fix indentation issues in sql, css and markdown embedded languages.

.changeset/icy-impalas-laugh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"prettier-plugin-embed": patch
3+
---
4+
5+
Fix embedded xml and prisma formatting behavior.

.github/actions/setup/action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ runs:
55
using: composite
66
steps:
77
- name: Setup PNPM
8-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
8+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
99

1010
- name: Setup Node.js
11-
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
11+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
1212
with:
1313
node-version-file: .node-version
1414
cache: pnpm
15+
registry-url: https://registry.npmjs.org
16+
17+
- name: Upgrade npm for trusted publishing
18+
shell: bash
19+
run: npm install -g npm@latest
1520

1621
- name: Install Dependencies
1722
shell: bash

.github/workflows/preview-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout Repo
14-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
14+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1515

1616
- name: Setup
1717
uses: ./.github/actions/setup

.github/workflows/release.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Release
22

33
on:
4-
workflow_dispatch:
54
push:
65
branches:
76
- main
@@ -17,32 +16,32 @@ permissions:
1716
env:
1817
NPM_CONFIG_PROVENANCE: true
1918

20-
concurrency: ${{ github.workflow }}-${{ github.ref }}
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
2122

2223
jobs:
2324
release:
24-
if: ${{ github.repository != 'Sec-ant/vanilla-ts' }}
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: Checkout Repo
28-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2929

3030
- name: Setup
3131
uses: ./.github/actions/setup
3232

3333
- name: Test
34-
run: pnpm -s test
34+
run: pnpm -s test:ci
3535

3636
- name: Get Next Package Version
3737
id: package-version
3838
run: echo "version=$(pnpm -s changeset status --output=release.json && jq -r '.releases[0].newVersion // '$(npm pkg get version)'' release.json && rm release.json)" >> $GITHUB_OUTPUT
3939

4040
- name: Create Release Pull Request or Publish to NPM
4141
id: changesets
42-
uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 # v1.4.9
42+
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
4343
with:
4444
publish: pnpm -s changeset publish
4545
commit: "chore(release): v${{ steps.package-version.outputs.version }}"
4646
env:
47-
GITHUB_TOKEN: ${{ secrets.CHANGESET_TOKEN }}
48-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout Repo
14-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
14+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1515

1616
- name: Setup
1717
uses: ./.github/actions/setup
1818

19+
# This is required for @prettier/plugin-ruby to work correctly
20+
- name: Setup Ruby
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: "3.4" # Not needed with a .ruby-version, .tool-versions or mise.toml
24+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25+
26+
- name: Install Ruby gems for plugin-ruby
27+
run: |
28+
gem install syntax_tree --no-document
29+
1930
- name: Test
20-
run: pnpm -s test
31+
run: pnpm -s test:ci

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010
*.tsx
1111
*.json
1212
*.jsonc
13+
pnpm-lock.yaml
14+
tests/**/fixtures/**/*
1315
.all-contributorsrc

CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
### Patch Changes
1212

1313
- fbb5cae: Fix wrong options fallback behaviors:
14-
1514
- Empty list of tags and comments shouldn't fallback to identifiers in options.
1615

1716
- 5cadbfa: Fix unstable embedded markdown indentation when using the `useTabs` option: https://github.com/Sec-ant/prettier-plugin-embed/pull/91#issuecomment-1963760555.
@@ -36,7 +35,6 @@
3635
### Patch Changes
3736

3837
- 67d0726: Fix a regression of formatting template literals with only whitespaces:
39-
4038
- Template literals with only whitespaces should be formatted to ` `` `.
4139

4240
## 0.4.11
@@ -45,7 +43,6 @@
4543

4644
- 3639712: Set up changesets
4745
- f4a41e7: Deprecate `identifier`-named options.
48-
4946
- Change options `embedded<Language>Identifiers` to `embedded<Language>Comments` and `embedded<Language>Tags`.
5047
- Remove option ~~`noEmbeddedIdentificationByComment`~~ because it is not needed anymore.
5148
- Remove option ~~`noEmbeddedIdentificationByTag`~~ because it is not needded anymore.

biome.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
33
"files": {
4-
"ignore": ["./tests/**/fixtures/**/*"],
4+
"includes": ["**", "!tests/**/fixtures/**/*"],
55
"ignoreUnknown": true
66
},
7-
"organizeImports": {
8-
"enabled": true
9-
},
7+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
108
"formatter": {
119
"enabled": true,
1210
"indentStyle": "space"
@@ -32,15 +30,15 @@
3230
},
3331
"overrides": [
3432
{
35-
"include": ["*.json"],
33+
"includes": ["**/*.json"],
3634
"json": {
3735
"parser": {
3836
"allowTrailingCommas": true
3937
}
4038
}
4139
},
4240
{
43-
"include": ["package.json", ".all-contributorsrc"],
41+
"includes": ["**/package.json", "**/.all-contributorsrc"],
4442
"json": {
4543
"formatter": {
4644
"lineWidth": 1

package.json

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"nocheck-chevrotain-types": "tsx ./scripts/nocheck-chevrotain-types.ts",
7272
"copy": "copy-files-from-to",
7373
"postbuild": "tsc --project ./tsconfig.production.json && conc \"pnpm:add-glob-import-types\" \"pnpm:nocheck-chevrotain-types\" \"pnpm:copy\"",
74+
"test:ci": "vitest --run",
7475
"test": "vitest",
7576
"test:ui": "vitest --ui",
7677
"process-readme": "tsx ./scripts/process-readme",
@@ -81,54 +82,54 @@
8182
"bump-biome:nightly": "pnpm add -DE @biomejs/biome@nightly"
8283
},
8384
"devDependencies": {
84-
"@biomejs/biome": "1.9.4",
85-
"@changesets/cli": "^2.28.1",
86-
"@commitlint/cli": "^19.7.1",
87-
"@commitlint/config-conventional": "^19.7.1",
88-
"@prettier/plugin-php": "^0.22.4",
89-
"@prettier/plugin-pug": "^3.2.1",
85+
"@biomejs/biome": "2.3.10",
86+
"@changesets/cli": "^2.29.8",
87+
"@commitlint/cli": "^20.2.0",
88+
"@commitlint/config-conventional": "^20.2.0",
89+
"@prettier/plugin-php": "^0.24.0",
90+
"@prettier/plugin-pug": "^3.4.2",
9091
"@prettier/plugin-ruby": "^4.0.4",
91-
"@prettier/plugin-xml": "^3.4.1",
92-
"@stedi/prettier-plugin-jsonata": "^2.1.3",
93-
"@types/node": "^22.13.5",
94-
"@vitest/coverage-istanbul": "^3.0.6",
95-
"@vitest/ui": "^3.0.6",
92+
"@prettier/plugin-xml": "^3.4.2",
93+
"@stedi/prettier-plugin-jsonata": "^2.1.8",
94+
"@types/node": "^25.0.3",
95+
"@vitest/coverage-istanbul": "^4.0.16",
96+
"@vitest/ui": "^4.0.16",
9697
"@xml-tools/parser": "^1.0.11",
9798
"chevrotain": "7.1.1",
98-
"concurrently": "^9.1.2",
99-
"copy-files-from-to": "^3.12.1",
100-
"esbuild": "^0.25.0",
101-
"lint-staged": "^15.4.3",
102-
"npm-check-updates": "^17.1.14",
103-
"prettier": "^3.5.2",
104-
"prettier-plugin-glsl": "^0.2.0",
99+
"concurrently": "^9.2.1",
100+
"copy-files-from-to": "^3.13.0",
101+
"esbuild": "^0.27.1",
102+
"lint-staged": "^16.2.7",
103+
"npm-check-updates": "^19.2.0",
104+
"prettier": "^3.7.4",
105+
"prettier-plugin-glsl": "^0.2.2",
105106
"prettier-plugin-ini": "^1.3.0",
106-
"prettier-plugin-java": "^2.6.7",
107+
"prettier-plugin-java": "^2.7.7",
107108
"prettier-plugin-latex": "^2.0.1",
108109
"prettier-plugin-nginx": "^1.0.3",
109110
"prettier-plugin-pegjs": "^2.0.2",
110111
"prettier-plugin-prisma": "^5.0.0",
111112
"prettier-plugin-properties": "^0.3.0",
112-
"prettier-plugin-sh": "^0.15.0",
113-
"prettier-plugin-sql": "^0.18.1",
114-
"prettier-plugin-sql-cst": "^0.12.2",
115-
"prettier-plugin-toml": "^2.0.2",
116-
"simple-git-hooks": "^2.11.1",
117-
"tinyglobby": "^0.2.12",
118-
"tsx": "^4.19.3",
119-
"typescript": "^5.7.3",
120-
"vite": "^6.1.1",
121-
"vitest": "^3.0.6"
113+
"prettier-plugin-sh": "^0.18.0",
114+
"prettier-plugin-sql": "^0.19.2",
115+
"prettier-plugin-sql-cst": "^0.17.2",
116+
"prettier-plugin-toml": "^2.0.6",
117+
"simple-git-hooks": "^2.13.1",
118+
"tinyglobby": "^0.2.15",
119+
"tsx": "^4.21.0",
120+
"typescript": "^5.9.3",
121+
"vite": "^7.3.0",
122+
"vitest": "^4.0.16"
122123
},
123124
"dependencies": {
124-
"@types/estree": "^1.0.6",
125-
"dedent": "^1.5.3",
126-
"micro-memoize": "^4.1.3",
125+
"@types/estree": "^1.0.8",
126+
"dedent": "^1.7.1",
127+
"micro-memoize": "^5.1.1",
127128
"package-up": "^5.0.0",
128129
"tiny-jsonc": "^1.0.2",
129-
"type-fest": "^4.35.0"
130+
"type-fest": "^5.3.1"
130131
},
131-
"packageManager": "pnpm@10.4.1+sha512.c753b6c3ad7afa13af388fa6d808035a008e30ea9993f58c6663e2bc5ff21679aa834db094987129aa4d488b86df57f7b634981b2f827cdcacc698cc0cfb88af",
132+
"packageManager": "pnpm@10.26.0+sha512.3b3f6c725ebe712506c0ab1ad4133cf86b1f4b687effce62a9b38b4d72e3954242e643190fc51fa1642949c735f403debd44f5cb0edd657abe63a8b6a7e1e402",
132133
"pnpm": {
133134
"onlyBuiltDependencies": [
134135
"@biomejs/biome",

0 commit comments

Comments
 (0)