From dadd8c8c76e9bb7cd00d455ed3637ef712787be5 Mon Sep 17 00:00:00 2001 From: jycouet Date: Fri, 12 Sep 2025 21:56:23 +0200 Subject: [PATCH 1/4] internal prepare CI with prettier --- .changeset/config.json | 18 +++++++++--------- .github/workflows/ci.yml | 15 +++++++++++++-- .prettierignore | 6 ++++++ package.json | 4 +++- test/samples/jsx-basic/input.jsx | 14 ++++++++------ test/samples/ts-null-keyword/input.ts | 2 +- test/samples/ts-return-type/input.ts | 2 +- test/samples/ts-undefined-keyword/input.ts | 4 ++-- test/samples/with/input.json | 2 +- 9 files changed, 44 insertions(+), 23 deletions(-) diff --git a/.changeset/config.json b/.changeset/config.json index 6b37255..42efc1c 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,11 +1,11 @@ { - "$schema": "https://unpkg.com/@changesets/config@3.0.5/schema.json", - "changelog": "@changesets/cli/changelog", - "commit": false, - "fixed": [], - "linked": [], - "access": "restricted", - "baseBranch": "main", - "updateInternalDependencies": "patch", - "ignore": [] + "$schema": "https://unpkg.com/@changesets/config@3.0.5/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "main", + "updateInternalDependencies": "patch", + "ignore": [] } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 564bcf3..28c1a1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,17 @@ concurrency: cancel-in-progress: true jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm lint Tests: runs-on: ${{ matrix.os }} timeout-minutes: 15 @@ -30,7 +41,7 @@ jobs: os: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v3 with: @@ -46,7 +57,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v3 with: diff --git a/.prettierignore b/.prettierignore index ee43e2d..dc2af66 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,9 @@ +package.json +pnpm-lock.yaml + test/samples/*/*.js test/sandbox/_input.js test/sandbox/_output.js + +expected.ts +expected.jsx diff --git a/package.json b/package.json index 0fa59ac..aac4ae3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,9 @@ "prepublishOnly": "pnpm test && dts-buddy -m esrap:./src/public.d.ts -m esrap/languages/ts:./src/languages/ts/public.d.ts -m esrap/languages/tsx:./src/languages/tsx/public.d.ts", "sandbox": "node test/sandbox/index.js", "test": "vitest --run", - "test:ui": "vitest --ui" + "test:ui": "vitest --ui", + "format": "pnpm lint --write", + "lint": "prettier --check . --ignore-path .gitignore --ignore-path .prettierignore" }, "license": "MIT", "dependencies": { diff --git a/test/samples/jsx-basic/input.jsx b/test/samples/jsx-basic/input.jsx index 6ad284a..2d85f67 100644 --- a/test/samples/jsx-basic/input.jsx +++ b/test/samples/jsx-basic/input.jsx @@ -1,6 +1,8 @@ -console.log(<> -
- {"An - Time since last cat incident: {"5 days"} -
-) \ No newline at end of file +console.log( + <> +
+ {'An + Time since last cat incident: {'5 days'} +
+ +); diff --git a/test/samples/ts-null-keyword/input.ts b/test/samples/ts-null-keyword/input.ts index 5369a51..527fb62 100644 --- a/test/samples/ts-null-keyword/input.ts +++ b/test/samples/ts-null-keyword/input.ts @@ -1 +1 @@ -let a: string | null = null \ No newline at end of file +let a: string | null = null; diff --git a/test/samples/ts-return-type/input.ts b/test/samples/ts-return-type/input.ts index 6de8f37..bcabe9f 100644 --- a/test/samples/ts-return-type/input.ts +++ b/test/samples/ts-return-type/input.ts @@ -1,5 +1,5 @@ class Fields { static cuid(): string { - return 'random cuid...' + return 'random cuid...'; } } diff --git a/test/samples/ts-undefined-keyword/input.ts b/test/samples/ts-undefined-keyword/input.ts index 2756c56..b8c21c4 100644 --- a/test/samples/ts-undefined-keyword/input.ts +++ b/test/samples/ts-undefined-keyword/input.ts @@ -1,2 +1,2 @@ -let a: number | undefined -a = 2 \ No newline at end of file +let a: number | undefined; +a = 2; diff --git a/test/samples/with/input.json b/test/samples/with/input.json index fcb339c..326c95a 100644 --- a/test/samples/with/input.json +++ b/test/samples/with/input.json @@ -34,4 +34,4 @@ } ], "sourceType": "script" -} \ No newline at end of file +} From b795108e7b85b586e54773397fd6a7a914678e6b Mon Sep 17 00:00:00 2001 From: jycouet Date: Fri, 12 Sep 2025 21:59:40 +0200 Subject: [PATCH 2/4] update tests with now input format --- test/samples/jsx-basic/expected.jsx | 10 +++++----- test/samples/jsx-basic/expected.jsx.map | 4 ++-- test/samples/ts-null-keyword/expected.ts.map | 2 +- test/samples/ts-return-type/expected.ts.map | 2 +- test/samples/ts-undefined-keyword/expected.ts.map | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/samples/jsx-basic/expected.jsx b/test/samples/jsx-basic/expected.jsx index 8830fe7..8425af8 100644 --- a/test/samples/jsx-basic/expected.jsx +++ b/test/samples/jsx-basic/expected.jsx @@ -1,6 +1,6 @@ console.log(<> -
- {"An - Time since last cat incident: {"5 days"} -
-); +
+ {'An + Time since last cat incident: {'5 days'} +
+ ); \ No newline at end of file diff --git a/test/samples/jsx-basic/expected.jsx.map b/test/samples/jsx-basic/expected.jsx.map index 06a812c..12adb48 100644 --- a/test/samples/jsx-basic/expected.jsx.map +++ b/test/samples/jsx-basic/expected.jsx.map @@ -5,7 +5,7 @@ "input.js" ], "sourcesContent": [ - "console.log(<>\n
\n {\"An\n Time since last cat incident: {\"5 days\"}\n
\n)" + "console.log(\n\t<>\n\t\t
\n\t\t\t{'An\n\t\t\tTime since last cat incident: {'5 days'}\n\t\t
\n\t\n);\n" ], - "mappings": "AAAA,OAAO,CAAC,GAAG,GAAG;IACV,CAAC,GAAG,CAAC;QACD,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,0BAA0B,IAAI;sCACxB,CAAC,QAAQ,CAAC;IAC5C,EAAE,GAAG,CAAC;AACV" + "mappings": "AAAA,OAAO,CAAC,GAAG,GACR;EACD,CAAC,GAAG,CAAC;GACJ,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,0BAA0B,IAAI;iCACxB,CAAC,QAAQ,CAAC;EACzC,EAAE,GAAG,CAAC;CACP" } \ No newline at end of file diff --git a/test/samples/ts-null-keyword/expected.ts.map b/test/samples/ts-null-keyword/expected.ts.map index e61feb8..1783daa 100644 --- a/test/samples/ts-null-keyword/expected.ts.map +++ b/test/samples/ts-null-keyword/expected.ts.map @@ -5,7 +5,7 @@ "input.js" ], "sourcesContent": [ - "let a: string | null = null" + "let a: string | null = null;\n" ], "mappings": "IAAI,CAAgB,EAAb,MAAM,GAAG,IAAI,GAAG,IAAI" } \ No newline at end of file diff --git a/test/samples/ts-return-type/expected.ts.map b/test/samples/ts-return-type/expected.ts.map index 3f78c09..75e9df4 100644 --- a/test/samples/ts-return-type/expected.ts.map +++ b/test/samples/ts-return-type/expected.ts.map @@ -5,7 +5,7 @@ "input.js" ], "sourcesContent": [ - "class Fields {\n\tstatic cuid(): string {\n\t\treturn 'random cuid...'\n\t}\n}\n" + "class Fields {\n\tstatic cuid(): string {\n\t\treturn 'random cuid...';\n\t}\n}\n" ], "mappings": "MAAM,MAAM,CAAC,CAAC;QACN,IAAI,IAAI,MAAM,CAAC,CAAC;SACf,gBAAgB;CACxB,CAAC;AACF,CAAC" } \ No newline at end of file diff --git a/test/samples/ts-undefined-keyword/expected.ts.map b/test/samples/ts-undefined-keyword/expected.ts.map index f133c38..a2af5c9 100644 --- a/test/samples/ts-undefined-keyword/expected.ts.map +++ b/test/samples/ts-undefined-keyword/expected.ts.map @@ -5,7 +5,7 @@ "input.js" ], "sourcesContent": [ - "let a: number | undefined\na = 2" + "let a: number | undefined;\na = 2;\n" ], "mappings": "IAAI,CAAqB,EAAlB,MAAM,GAAG,SAAS;;AACzB,CAAC,GAAG,CAAC" } \ No newline at end of file From cf242d88959df22124009f80c54712192c9943e9 Mon Sep 17 00:00:00 2001 From: jycouet Date: Fri, 12 Sep 2025 22:04:41 +0200 Subject: [PATCH 3/4] tweak --- .prettierignore | 1 - package.json | 115 ++++++++++++++++++++++++------------------------ pnpm-lock.yaml | 7 ++- 3 files changed, 61 insertions(+), 62 deletions(-) diff --git a/.prettierignore b/.prettierignore index dc2af66..a73deb6 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,3 @@ -package.json pnpm-lock.yaml test/samples/*/*.js diff --git a/package.json b/package.json index aac4ae3..5112c7a 100644 --- a/package.json +++ b/package.json @@ -1,60 +1,61 @@ { - "name": "esrap", - "version": "2.1.0", - "description": "Parse in reverse", - "repository": { - "type": "git", - "url": "git+https://github.com/sveltejs/esrap.git" - }, - "type": "module", - "files": [ - "src", - "types" - ], - "exports": { - ".": { - "types": "./types/index.d.ts", - "default": "./src/index.js" - }, - "./languages/ts": { - "types": "./types/index.d.ts", - "default": "./src/languages/ts/index.js" - }, - "./languages/tsx": { - "types": "./types/index.d.ts", - "default": "./src/languages/tsx/index.js" - } - }, - "types": "./types/index.d.ts", - "devDependencies": { - "@changesets/cli": "^2.27.11", - "@sveltejs/acorn-typescript": "^1.0.5", - "@typescript-eslint/types": "^8.2.0", - "@vitest/ui": "^2.1.1", - "acorn": "^8.15.0", - "dts-buddy": "^0.6.2", - "prettier": "^3.0.3", - "typescript": "^5.7.2", - "vitest": "^2.1.1", - "zimmerframe": "^1.0.0" - }, - "scripts": { - "changeset:version": "changeset version", - "changeset:publish": "changeset publish", - "check": "tsc", - "prepublishOnly": "pnpm test && dts-buddy -m esrap:./src/public.d.ts -m esrap/languages/ts:./src/languages/ts/public.d.ts -m esrap/languages/tsx:./src/languages/tsx/public.d.ts", - "sandbox": "node test/sandbox/index.js", - "test": "vitest --run", - "test:ui": "vitest --ui", - "format": "pnpm lint --write", + "name": "esrap", + "version": "2.1.0", + "description": "Parse in reverse", + "repository": { + "type": "git", + "url": "git+https://github.com/sveltejs/esrap.git" + }, + "type": "module", + "files": [ + "src", + "types" + ], + "exports": { + ".": { + "types": "./types/index.d.ts", + "default": "./src/index.js" + }, + "./languages/ts": { + "types": "./types/index.d.ts", + "default": "./src/languages/ts/index.js" + }, + "./languages/tsx": { + "types": "./types/index.d.ts", + "default": "./src/languages/tsx/index.js" + } + }, + "types": "./types/index.d.ts", + "devDependencies": { + "@changesets/cli": "^2.27.11", + "@jridgewell/sourcemap-codec": "^1.5.0", + "@sveltejs/acorn-typescript": "^1.0.5", + "@typescript-eslint/types": "^8.2.0", + "@vitest/ui": "^2.1.1", + "acorn": "^8.15.0", + "dts-buddy": "^0.6.2", + "prettier": "^3.0.3", + "typescript": "^5.7.2", + "vitest": "^2.1.1", + "zimmerframe": "^1.0.0" + }, + "scripts": { + "changeset:version": "changeset version", + "changeset:publish": "changeset publish", + "check": "tsc", + "prepublishOnly": "pnpm test && dts-buddy -m esrap:./src/public.d.ts -m esrap/languages/ts:./src/languages/ts/public.d.ts -m esrap/languages/tsx:./src/languages/tsx/public.d.ts", + "sandbox": "node test/sandbox/index.js", + "test": "vitest --run", + "test:ui": "vitest --ui", + "format": "pnpm lint --write", "lint": "prettier --check . --ignore-path .gitignore --ignore-path .prettierignore" - }, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.15" - }, - "packageManager": "pnpm@9.8.0", - "publishConfig": { - "access": "public" - } + }, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "packageManager": "pnpm@9.8.0", + "publishConfig": { + "access": "public" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 53807dd..62ed5aa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,14 +7,13 @@ settings: importers: .: - dependencies: - '@jridgewell/sourcemap-codec': - specifier: ^1.4.15 - version: 1.5.0 devDependencies: '@changesets/cli': specifier: ^2.27.11 version: 2.27.11 + '@jridgewell/sourcemap-codec': + specifier: ^1.5.0 + version: 1.5.0 '@sveltejs/acorn-typescript': specifier: ^1.0.5 version: 1.0.5(acorn@8.15.0) From bf06151e52e1c0be9c059415a303afde7e01de0d Mon Sep 17 00:00:00 2001 From: jycouet Date: Fri, 12 Sep 2025 22:07:00 +0200 Subject: [PATCH 4/4] back to dev --- pnpm-lock.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 62ed5aa..53807dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,13 +7,14 @@ settings: importers: .: + dependencies: + '@jridgewell/sourcemap-codec': + specifier: ^1.4.15 + version: 1.5.0 devDependencies: '@changesets/cli': specifier: ^2.27.11 version: 2.27.11 - '@jridgewell/sourcemap-codec': - specifier: ^1.5.0 - version: 1.5.0 '@sveltejs/acorn-typescript': specifier: ^1.0.5 version: 1.0.5(acorn@8.15.0)