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..a73deb6 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,8 @@ +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..5112c7a 100644 --- a/package.json +++ b/package.json @@ -1,58 +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" - }, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.15" - }, - "packageManager": "pnpm@9.8.0", - "publishConfig": { - "access": "public" - } + "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" + } } 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/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/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-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/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-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/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 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 +}