From 8ed81e27c02e8e9d5cda8e11b0c71afcb22586bc Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 3 Sep 2026 19:08:18 +0800 Subject: [PATCH] chore: migrate to Rstack CLI --- .github/workflows/release.yml | 4 +- .github/workflows/test.yml | 13 +- .husky/pre-commit | 2 - .rstack/hooks/pre-commit | 1 + .vscode/extensions.json | 2 +- .vscode/settings.json | 2 +- AGENTS.md | 16 +- README.md | 34 +- dprint.jsonc | 38 - package.json | 30 +- pnpm-lock.yaml | 931 ++++++++---------- pnpm-workspace.yaml | 19 +- rslib.config.ts | 11 - rslint.config.ts | 3 - rstack.config.ts | 37 + rstest.config.ts | 21 - src/createTarball.ts | 34 +- src/getExitCode.ts | 53 +- src/index.ts | 31 +- src/problemUtils.ts | 66 +- src/render/index.ts | 8 +- src/render/typed.ts | 133 ++- src/render/untyped.ts | 2 +- test/basic/index.test.ts | 92 +- test/build-tools/index.test.ts | 92 +- test/cjs-only-exports-default/index.test.ts | 95 +- test/cjs-only-exports-default/package.json | 6 +- test/cjs-only-exports-default/src/index.js | 4 +- test/cjs-resolves-to-esm/index.test.ts | 70 +- test/cjs-resolves-to-esm/package.json | 6 +- test/cjs-resolves-to-esm/src/index.js | 4 +- test/exports/index.test.ts | 92 +- test/exports/package.json | 2 +- test/fallback-condition/index.test.ts | 90 +- test/fallback-condition/package.json | 6 +- test/fallback-condition/src/index.js | 2 +- test/false-cjs/index.test.ts | 86 +- test/false-cjs/package.json | 6 +- test/false-cjs/src/index.js | 2 +- test/false-cjs/src/index.mjs | 2 +- test/false-esm/index.test.ts | 86 +- test/false-esm/package.json | 6 +- test/false-export-default/index.test.ts | 64 +- test/false-export-default/package.json | 6 +- test/false-export-default/src/index.js | 4 +- test/internal-resolution-error/index.test.ts | 107 +- test/internal-resolution-error/package.json | 6 +- .../internal-resolution-error/src/index.d.cts | 2 +- test/internal-resolution-error/src/index.d.ts | 4 +- test/missing-export-equals/index.test.ts | 98 +- test/missing-export-equals/package.json | 6 +- test/missing-export-equals/src/index.d.ts | 2 +- test/named-exports/index.test.ts | 86 +- test/named-exports/package.json | 6 +- test/named-exports/src/index.js | 4 +- test/no-resolution/index.test.ts | 91 +- test/npm/index.test.ts | 92 +- test/pnpm-workspace/index.test.ts | 98 +- test/pnpm/index.test.ts | 92 +- test/unexpected-module-syntax/index.test.ts | 95 +- test/unexpected-module-syntax/package.json | 6 +- test/unexpected-module-syntax/src/index.js | 2 +- test/untyped-resolution/index.test.ts | 139 ++- test/untyped-resolution/package.json | 6 +- test/untyped/index.test.ts | 42 +- test/untyped/package.json | 2 +- test/wildcard/index.test.ts | 92 +- test/wildcard/package.json | 2 +- test/with-scope/index.test.ts | 92 +- test/yarn-berry/index.test.ts | 92 +- test/yarn/index.test.ts | 92 +- tsconfig.json | 4 +- 72 files changed, 2053 insertions(+), 1621 deletions(-) delete mode 100755 .husky/pre-commit create mode 100644 .rstack/hooks/pre-commit delete mode 100644 dprint.jsonc delete mode 100644 rslib.config.ts delete mode 100644 rslint.config.ts create mode 100644 rstack.config.ts delete mode 100644 rstest.config.ts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53d28ff..63d2793 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ on: # Run `npm run bump` to bump the version and create a git tag. push: tags: - - "v*" + - 'v*' workflow_dispatch: @@ -32,7 +32,7 @@ jobs: run_install: true - name: Build Packages - run: pnpm build + run: node --run build - name: Publish run: pnpm stage publish --no-git-checks diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b4c5c35..59dbe30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,13 +35,10 @@ jobs: run_install: true - name: Build - run: pnpm build + run: node --run build - - name: Format check - uses: dprint/check@9cb3a2b17a8e606d37aae341e49df3654933fc23 # v2.3 - - - name: Run Lint - run: pnpm run lint + - name: Run Check + run: node --run check test: runs-on: ${{ matrix.os }} @@ -68,7 +65,7 @@ jobs: run_install: true - name: Build - run: pnpm build + run: node --run build - name: Run Test - run: pnpm run test --test-timeout=30000 + run: node --run test -- --test-timeout=30000 diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index c2bc3a5..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,2 +0,0 @@ -nano-staged - diff --git a/.rstack/hooks/pre-commit b/.rstack/hooks/pre-commit new file mode 100644 index 0000000..8890b96 --- /dev/null +++ b/.rstack/hooks/pre-commit @@ -0,0 +1 @@ +rs staged diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 0af0fbf..72d54ca 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["dprint.dprint"] + "recommendations": ["rstack.rstack"] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 71c843d..8455616 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { "search.useIgnoreFiles": true, - "editor.defaultFormatter": "dprint.dprint", + "editor.defaultFormatter": "rstack.rstack" } diff --git a/AGENTS.md b/AGENTS.md index 50c284f..a7b1781 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,30 +7,30 @@ This repository contains `rsbuild-plugin-arethetypeswrong`, a plugin for checkin This project uses `pnpm` (version 10+) as its package manager. Always use `pnpm` instead of `npm` or `yarn`. - **Install Dependencies:** `pnpm install` -- **Build the Plugin:** `pnpm build` (Runs `rslib build` under the hood) +- **Build the Plugin:** `pnpm build` (Runs `rs lib` under the hood) The plugin is built as an ESM package. Pay attention to `.js` vs `.ts` extensions in internal imports. Since the project has `"type": "module"` and `moduleResolution: node16` in `tsconfig.json`, local imports in source files must include the `.js` extension (e.g., `import "./createTarball.js"`). ## 🧪 Testing -We use **rstest** (`@rstest/core`) for testing. Tests are located in the `test/` directory. +We use **Rstest** through Rstack CLI for testing. Tests are located in the `test/` directory. - **Run All Tests:** `pnpm test` (runs with coverage) -- **Run a Single Test:** `pnpm exec rstest test/path-to-test/index.test.ts` -- **Update Snapshots:** `pnpm exec rstest -u` +- **Run a Single Test:** `pnpm exec rs test test/path-to-test/index.test.ts` +- **Update Snapshots:** `pnpm exec rs test -u` **Testing Guidelines:** - Most tests are integration tests that create an Rsbuild instance with the plugin and check the output. - Assertions typically involve spying on `logger.success` or `logger.error`, filtering the messages for `[arethetypeswrong]`, stripping VT control characters, and running snapshot tests (`toMatchSnapshot()`). -- Use `rs.spyOn(logger, "...")` from `@rstest/core` to capture console outputs. Ensure to clean up mocks using `rs.restoreAllMocks()` in `beforeEach()`. +- Use `rs.spyOn(logger, "...")` from `rstack/test` to capture console outputs. Ensure to clean up mocks using `rs.restoreAllMocks()` in `beforeEach()`. ## 🧹 Linting & Formatting -- **Linting:** We use `rslint` (powered by `@typescript-eslint` via `rslint.jsonc`). +- **Linting:** We use Rslint through Rstack CLI. - Command: `pnpm lint` -- **Formatting:** We use `dprint` for highly-performant code formatting. - - Command: `npx dprint fmt` (or let `nano-staged` handle it on commit) +- **Formatting:** We use Rstack CLI's formatter. + - Command: `pnpm format` (or let `rs staged` handle it on commit) - **Code standards:** Never leave unused variables, imports, or dead code. `rslint` enforces these rules strictly. ## 🎨 Code Style & Conventions diff --git a/README.md b/README.md index 6a0e8ed..2464a3f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ npm add rsbuild-plugin-arethetypeswrong -D Add plugin to your `rslib.config.ts` or `rsbuild.config.ts`: ```ts -import { pluginAreTheTypesWrong } from "rsbuild-plugin-arethetypeswrong"; +import { pluginAreTheTypesWrong } from 'rsbuild-plugin-arethetypeswrong'; export default { plugins: [pluginAreTheTypesWrong()], @@ -64,20 +64,20 @@ interface areTheTypesWrongOptions { } type ProblemFlag = - | "no-resolution" - | "untyped-resolution" - | "false-cjs" - | "false-esm" - | "cjs-resolves-to-esm" - | "fallback-condition" - | "cjs-only-exports-default" - | "named-exports" - | "false-export-default" - | "missing-export-equals" - | "unexpected-module-syntax" - | "internal-resolution-error"; - -type ResolutionKind = "node10" | "node16-cjs" | "node16-esm" | "bundler"; + | 'no-resolution' + | 'untyped-resolution' + | 'false-cjs' + | 'false-esm' + | 'cjs-resolves-to-esm' + | 'fallback-condition' + | 'cjs-only-exports-default' + | 'named-exports' + | 'false-export-default' + | 'missing-export-equals' + | 'unexpected-module-syntax' + | 'internal-resolution-error'; + +type ResolutionKind = 'node10' | 'node16-cjs' | 'node16-esm' | 'bundler'; ``` - Default: @@ -96,8 +96,8 @@ const defaultOptions = { ```js pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: ["false-cjs"], - ignoreResolutions: ["node16-cjs"], + ignoreRules: ['false-cjs'], + ignoreResolutions: ['node16-cjs'], }, }); ``` diff --git a/dprint.jsonc b/dprint.jsonc deleted file mode 100644 index 7e2238d..0000000 --- a/dprint.jsonc +++ /dev/null @@ -1,38 +0,0 @@ -{ - "typescript": { - "module.sortImportDeclarations": "caseInsensitive", - "module.sortExportDeclarations": "caseInsensitive", - }, - "json": { - "jsonTrailingCommaFiles": [ - "dprint.jsonc", - "tsconfig.json", - ".vscode/settings.json", - ], - }, - "markdown": { - }, - "toml": { - }, - "malva": { - }, - "markup": { - }, - "yaml": { - }, - "excludes": [ - "**/node_modules", - "**/*-lock.json", - "pnpm-lock.yaml", - "dist/**", - ], - "plugins": [ - "https://plugins.dprint.dev/typescript-0.95.9.wasm", - "https://plugins.dprint.dev/json-0.20.0.wasm", - "https://plugins.dprint.dev/markdown-0.19.0.wasm", - "https://plugins.dprint.dev/toml-0.7.0.wasm", - "https://plugins.dprint.dev/g-plane/malva-v0.14.1.wasm", - "https://plugins.dprint.dev/g-plane/markup_fmt-v0.23.1.wasm", - "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm", - ], -} diff --git a/package.json b/package.json index 9fced2c..f53c78c 100644 --- a/package.json +++ b/package.json @@ -19,35 +19,25 @@ "dist" ], "scripts": { - "build": "rslib", - "lint": "rslint", - "prepare": "husky", - "test": "rstest --coverage" - }, - "nano-staged": { - "*.{js,jsx,ts,tsx,mjs,cjs,md,json,jsonc,yml,yaml}": [ - "dprint fmt --allow-no-files --" - ], - "*.{js,jsx,ts,tsx,mjs,cjs}": [ - "rslint" - ] + "build": "rs lib", + "bump": "pnpx bumpp", + "check": "rs check", + "dev": "rs lib -w", + "format": "rs fmt", + "lint": "rs lint", + "prepare": "rs hooks", + "test": "rs test --coverage" }, "devDependencies": { "@arethetypeswrong/core": "^0.18.5", "@microsoft/api-extractor": "^7.59.0", - "@rsbuild/core": "2.2.1", - "@rslib/core": "^0.23.2", - "@rslint/core": "^0.9.0", - "@rstest/adapter-rslib": "^0.11.11", - "@rstest/core": "^0.11.11", + "@rsbuild/core": "^2.2.2", "@rstest/coverage-istanbul": "^0.11.11", "@types/node": "^24.13.3", "cli-table3": "^0.6.5", - "dprint": "^0.56.1", - "husky": "^9.1.7", - "nano-staged": "^1.0.2", "package-manager-detector": "^1.8.0", "rsbuild-plugin-publint": "^1.0.0", + "rstack": "^0.7.2", "tinyexec": "^1.3.0", "typescript": "^7.0.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b7d24b3..bc9e4b5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,20 +15,8 @@ importers: specifier: ^7.59.0 version: 7.59.0(@types/node@24.13.3) '@rsbuild/core': - specifier: 2.2.1 - version: 2.2.1 - '@rslib/core': - specifier: ^0.23.2 - version: 0.23.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2) - '@rslint/core': - specifier: ^0.9.0 - version: 0.9.0 - '@rstest/adapter-rslib': - specifier: ^0.11.11 - version: 0.11.11(@rslib/core@0.23.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2))(@rstest/core@0.11.11)(typescript@7.0.2) - '@rstest/core': - specifier: ^0.11.11 - version: 0.11.11 + specifier: ^2.2.2 + version: 2.2.3 '@rstest/coverage-istanbul': specifier: ^0.11.11 version: 0.11.11(@rstest/core@0.11.11)(supports-color@8.1.1) @@ -38,21 +26,15 @@ importers: cli-table3: specifier: ^0.6.5 version: 0.6.5 - dprint: - specifier: ^0.56.1 - version: 0.56.1 - husky: - specifier: ^9.1.7 - version: 9.1.7 - nano-staged: - specifier: ^1.0.2 - version: 1.0.2 package-manager-detector: specifier: ^1.8.0 version: 1.8.0 rsbuild-plugin-publint: specifier: ^1.0.0 - version: 1.0.0(@rsbuild/core@2.2.1) + version: 1.0.0(@rsbuild/core@2.2.3) + rstack: + specifier: ^0.7.2 + version: 0.7.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2) tinyexec: specifier: ^1.3.0 version: 1.3.0 @@ -69,66 +51,66 @@ packages: resolution: {integrity: sha512-9ytjzGwxjm9Uz7I9avfbt5vlQt6uk9uRRESzJjqrznl6WKvI6dwYTo+vJ3U02Wrq/mR3iql/PzhvHhKdJIAjDQ==} engines: {node: '>=20'} - '@ast-grep/napi-darwin-arm64@0.37.0': - resolution: {integrity: sha512-QAiIiaAbLvMEg/yBbyKn+p1gX2/FuaC0SMf7D7capm/oG4xGMzdeaQIcSosF4TCxxV+hIH4Bz9e4/u7w6Bnk3Q==} + '@ast-grep/napi-darwin-arm64@0.45.2': + resolution: {integrity: sha512-29+sfXTJ7xxqgTuWAHA89gDAQIiJyAZ1ZiHoupjKIqyn0mhXrktO1WOghlDzyYs++hITEPOeXftxy48Y0tDGDQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@ast-grep/napi-darwin-x64@0.37.0': - resolution: {integrity: sha512-zvcvdgekd4ySV3zUbUp8HF5nk5zqwiMXTuVzTUdl/w08O7JjM6XPOIVT+d2o/MqwM9rsXdzdergY5oY2RdhSPA==} + '@ast-grep/napi-darwin-x64@0.45.2': + resolution: {integrity: sha512-PUjh7Zf4dKNzYLOYhX5wU6O4BgRPdJnD9zkS1n+/5SeK0U1L5YL486RjNgFt9Xyff0PGtP/wDeoHMF5PhKEwsw==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@ast-grep/napi-linux-arm64-gnu@0.37.0': - resolution: {integrity: sha512-L7Sj0lXy8X+BqSMgr1LB8cCoWk0rericdeu+dC8/c8zpsav5Oo2IQKY1PmiZ7H8IHoFBbURLf8iklY9wsD+cyA==} + '@ast-grep/napi-linux-arm64-gnu@0.45.2': + resolution: {integrity: sha512-bnGKLLHWO13pjPChOFq7Ifqj3HJdOAxMQAGDCUC2JSJhO2YL8/xBZrpN0cHIWNuoUNSAXjCtr5AsCnPz/3jlFg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [glibc] - '@ast-grep/napi-linux-arm64-musl@0.37.0': - resolution: {integrity: sha512-LF9sAvYy6es/OdyJDO3RwkX3I82Vkfsng1sqUBcoWC1jVb1wX5YVzHtpQox9JrEhGl+bNp7FYxB4Qba9OdA5GA==} + '@ast-grep/napi-linux-arm64-musl@0.45.2': + resolution: {integrity: sha512-FXVb4/V55THjhKxi5zWVrAO8JQj+/DiYP7JLsqenkm5V3UNuC8p2opGOyQpUvNpvcqJiZA9Hl+Onj/yfwSVr/A==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [musl] - '@ast-grep/napi-linux-x64-gnu@0.37.0': - resolution: {integrity: sha512-TViz5/klqre6aSmJzswEIjApnGjJzstG/SE8VDWsrftMBMYt2PTu3MeluZVwzSqDao8doT/P+6U11dU05UOgxw==} + '@ast-grep/napi-linux-x64-gnu@0.45.2': + resolution: {integrity: sha512-mtEIPLV9MW2PBswFcp3ydM4T5Ub73s89SRd0QMT2+DfA9XBLCLhnC+r/Yt4eRgnf8FyNx49bFTPxXvFKscr9hw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [glibc] - '@ast-grep/napi-linux-x64-musl@0.37.0': - resolution: {integrity: sha512-/BcCH33S9E3ovOAEoxYngUNXgb+JLg991sdyiNP2bSoYd30a9RHrG7CYwW6fMgua3ijQ474eV6cq9yZO1bCpXg==} + '@ast-grep/napi-linux-x64-musl@0.45.2': + resolution: {integrity: sha512-WLLHxDmuXkb/e3mz/xDCrB2dZPzv1ntsepuRTtpaIGczxnQTgFSzX/CXPD0e1MfsU/QL1AiXxxni8w+NGy/ZpQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [musl] - '@ast-grep/napi-win32-arm64-msvc@0.37.0': - resolution: {integrity: sha512-TjQA4cFoIEW2bgjLkaL9yqT4XWuuLa5MCNd0VCDhGRDMNQ9+rhwi9eLOWRaap3xzT7g+nlbcEHL3AkVCD2+b3A==} + '@ast-grep/napi-win32-arm64-msvc@0.45.2': + resolution: {integrity: sha512-04iOFaMzD2nf8CKw3nURWN42900wqPtUTQaMo1I2KRk3qbgtHSJjJoVJGAWUXkCq4LhPg3Xlk1s+ssWf4rNm2A==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@ast-grep/napi-win32-ia32-msvc@0.37.0': - resolution: {integrity: sha512-uNmVka8fJCdYsyOlF9aZqQMLTatEYBynjChVTzUfFMDfmZ0bihs/YTqJVbkSm8TZM7CUX82apvn50z/dX5iWRA==} + '@ast-grep/napi-win32-ia32-msvc@0.45.2': + resolution: {integrity: sha512-tE3y0RQcajocKwpYLbgHKd4lzGGAx1wGMA0bGPsWdoFK8VSob6ZDuYdSlSdnaRs8jAc4F3axToNRKn15p+0/Dg==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@ast-grep/napi-win32-x64-msvc@0.37.0': - resolution: {integrity: sha512-vCiFOT3hSCQuHHfZ933GAwnPzmL0G04JxQEsBRfqONywyT8bSdDc/ECpAfr3S9VcS4JZ9/F6tkePKW/Om2Dq2g==} + '@ast-grep/napi-win32-x64-msvc@0.45.2': + resolution: {integrity: sha512-o8Z5Z42TAJe0fPnb11rrjtte58wlw/MuR4KpVMHl8IhJLBBR7gHR0E8wfMz88TxzsQz0U2KYev0k0a2fV4i0sQ==} engines: {node: '>= 10'} cpu: [x64] os: [win32] - '@ast-grep/napi@0.37.0': - resolution: {integrity: sha512-Hb4o6h1Pf6yRUAX07DR4JVY7dmQw+RVQMW5/m55GoiAT/VRoKCWBtIUPPOnqDVhbx1Cjfil9b6EDrgJsUAujEQ==} + '@ast-grep/napi@0.45.2': + resolution: {integrity: sha512-hBA5c7JV6OM7zFWoLjUNZhsDpxEIEIeew5S3z1giwK5tPQqobuFfM2OhS45bN3E0+yQtgCX/o8/AEHKbGD3ykg==} engines: {node: '>= 10'} '@braidai/lang@1.1.2': @@ -138,105 +120,12 @@ packages: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} - '@dprint/android-arm64@0.56.1': - resolution: {integrity: sha512-+tvgCtqraz5ws3et615SZThgrLtH0KV5c9beC/FK/5WW0HxvFad8vl1EyiC6Emo4/J6FFbh6c9H8DLK41QNKFg==} - cpu: [arm64] - os: [android] - - '@dprint/android-x64@0.56.1': - resolution: {integrity: sha512-zw3qY+8z1eaPDog6XgpBJOJAfsJXapbtysxXf/VBPEk1FEYG/alrYpP0McjtlURys6lRrea8aQrIH+noatR/wg==} - cpu: [x64] - os: [android] - - '@dprint/darwin-arm64@0.56.1': - resolution: {integrity: sha512-1U2qE8i0Np5bY7aB+Mq6DqIwI/DQgR4haQFR0ixxsQ9gXQSVe8YQTzM33Kw65V5FVwTn5sNcaqjlm0mYTLt56w==} - cpu: [arm64] - os: [darwin] - - '@dprint/darwin-x64@0.56.1': - resolution: {integrity: sha512-88tW6kuSoJ1VjoEI/1PSLuCsed5+84YyARzz8Kyata4chP8HgEwTT7A61gWgTdLNJEj9v+MmhbiqsnK/yJn/2A==} - cpu: [x64] - os: [darwin] - - '@dprint/linux-arm64-glibc@0.56.1': - resolution: {integrity: sha512-XJHlFlZpcZTjs2442W01GzE63GqiMFvXnFAiW/6ewjSl7U/NupxvqlyJDVhUxgfEgApEfETkn8WxBBUlErQh4A==} - cpu: [arm64] - os: [linux] - libc: [glibc] - - '@dprint/linux-arm64-musl@0.56.1': - resolution: {integrity: sha512-HlX5HRc4Ht3BCejbs78QacfWZuDbqVEilqEQSQzQXsFiKa4HntdhvuL37rLDVi8FPziSmUm2mniBpxqPC1WfuA==} - cpu: [arm64] - os: [linux] - libc: [musl] - - '@dprint/linux-loong64-glibc@0.56.1': - resolution: {integrity: sha512-/g9PFXhODtN8zb6Ta4ILmYykF/TXNN7M5ihVfZ/KWgyhLYAyCBS3klohrVLoDhD0bRo6RgYvm3cTRXtxSiQ6Eg==} - cpu: [loong64] - os: [linux] - libc: [glibc] - - '@dprint/linux-loong64-musl@0.56.1': - resolution: {integrity: sha512-jI/RSNdJ096YsP0IfAB5qIOnuNbFZqP4SI+y8iPcaQBsMe1YngkB0jT9eA5XMJgEyWjpeDq9YNoV7SQZWYbIaA==} - cpu: [loong64] - os: [linux] - libc: [musl] - - '@dprint/linux-ppc64-glibc@0.56.1': - resolution: {integrity: sha512-/76IxLsbtGtwtENc0cPIFi7LwG9p5uJdMzVzxxZ69FTCRaobMkaepYfpwv9mxuaLLFp1dubRBoVLT0jt16+wNA==} - cpu: [ppc64] - os: [linux] - libc: [glibc] - - '@dprint/linux-ppc64-musl@0.56.1': - resolution: {integrity: sha512-JcixMtCTunVocQvai5zmn8Nm7O/HRihWsmGF6zPrte/BaMaiuTM/j6ATamuYS3FqesTnF1kNfv21C4nrya88tw==} - cpu: [ppc64] - os: [linux] - libc: [musl] - - '@dprint/linux-riscv64-glibc@0.56.1': - resolution: {integrity: sha512-hgapHq0oRtowyarRi5vtA7/rCWxTMQHK6ZORxSUKxiF4ypiCy+aetLKFERooB6axv1mUPOtEFFmuhA96di2kEg==} - cpu: [riscv64] - os: [linux] - libc: [glibc] - - '@dprint/linux-x64-glibc@0.56.1': - resolution: {integrity: sha512-hsNt9WCD8rt28Fz/kP15CQzmeiSFbr3n0XeyJ5JyfsTXxazpMBY0eAGpMn3o8x+WF74gTF8FOkz3vACPt23xvg==} - cpu: [x64] - os: [linux] - libc: [glibc] - - '@dprint/linux-x64-musl@0.56.1': - resolution: {integrity: sha512-yvRcYtrQ0gJ0UyQjX9nbon3NTi+sN1pZ6o0QcB0l1QfqiIJZXXTAXrmnUXqjR43fXEjxARjWBE+M6NyYFYxjmw==} - cpu: [x64] - os: [linux] - libc: [musl] - - '@dprint/win32-arm64@0.56.1': - resolution: {integrity: sha512-yItk0aKrANS3Y7CWEcOt4zAD0c0zdLckqFte6tB2MtijV32wpS56gbUn3cQhcjoD4zuy+YvCuBuxopr5yK43Ew==} - cpu: [arm64] - os: [win32] - - '@dprint/win32-x64@0.56.1': - resolution: {integrity: sha512-40xoYm0lar2naQ7uxTyziHt4o6GuRsFKzwxgKWvkmFW9RLh+htxsnISn89gDG9HJFDxxa2bVfQQ35oJbAAWWpA==} - cpu: [x64] - os: [win32] - - '@emnapi/core@1.11.2': - resolution: {integrity: sha512-TC8MkTuZUtcTSiFeuC0ksCh9QIJ5+F21MvZ4Wn4ORfYaFJ/0dsiudv5tVkejgwZlwQ39jL9WWDe2lz8x0WglOA==} - '@emnapi/core@1.11.3': resolution: {integrity: sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==} - '@emnapi/runtime@1.11.2': - resolution: {integrity: sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA==} - '@emnapi/runtime@1.11.3': resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==} - '@emnapi/wasi-threads@1.2.2': - resolution: {integrity: sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==} - '@emnapi/wasi-threads@1.2.3': resolution: {integrity: sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==} @@ -278,18 +167,8 @@ packages: resolution: {integrity: sha512-HDVTWq3H0uTXiU0eeSQntcVUTPP3GamzeXI41+x7uU9J65JgWQh3qWZHblR1i0npXfFtF+mxBiU2nJH8znxWnQ==} engines: {node: '>=18'} - '@rsbuild/core@2.1.9': - resolution: {integrity: sha512-yqf1hFZ3wbMYI431LqsxLH3r0VZkfyarVKTf7kMeIiGe0YLwsrgsfp+sKpIyVkQkq60J0qyp6l/CoqqsQZqEwQ==} - engines: {node: ^20.19.0 || >=22.12.0} - hasBin: true - peerDependencies: - core-js: '>= 3.0.0' - peerDependenciesMeta: - core-js: - optional: true - - '@rsbuild/core@2.2.1': - resolution: {integrity: sha512-JcGtG4bo7PBihj6fBL6gaxaJihqLf7nGWW/t4zEmXpMJkV6XNdr1jAo9B0xI4mLAOmtFeva8cUbn9SE2ZEmAIw==} + '@rsbuild/core@2.2.3': + resolution: {integrity: sha512-oJrYtYDhb7AMwY8HIda2hgMuuxHkYPYar4svdS5uTq0fXY0M1wLfllkTQz0d729pNJ4S//6GUM1WX5LsW2mFLw==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: @@ -298,13 +177,13 @@ packages: core-js: optional: true - '@rslib/core@0.23.2': - resolution: {integrity: sha512-KxSp+/y0BJ1O4oKwxX4ydBY7/ZVeJCUpWAmQniCIct8mTxIQFPGO/ibKbKq2IxZYqRuRpM8g+Dtyq0VbEQf9HQ==} + '@rslib/core@1.0.0': + resolution: {integrity: sha512-eZNXCWU1v5oti4+DKCunc76DkNnYqMgRtks9UyZRRFlmaK4pKAxhejeCUS+XkbMurGIAa+aDyVynQD7DXEgK1w==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: '@microsoft/api-extractor': ^7 - typescript: ^5 || ^6 || ^7.0.1-0 + typescript: ^5 || ^6 || ^7 peerDependenciesMeta: '@microsoft/api-extractor': optional: true @@ -364,156 +243,88 @@ packages: cpu: [x64] os: [win32] - '@rspack/binding-darwin-arm64@2.1.7': - resolution: {integrity: sha512-DwxzrXRctueP/3Pyom9JHcIsRShuEAlHb+mrE5OPT+4cdHI1UnJpbzEvEDLTo4IKJhDb3vjXdHLtjqtL0SYbeA==} + '@rspack/binding-darwin-arm64@2.2.2': + resolution: {integrity: sha512-/le/AvV4HSinXTPs2Lqpujxt189Z5T10Ggt96QzckLRPvIchzqoavVDDjltzC7XcaZ87XCH/X06jNKgzkcBBNA==} cpu: [arm64] os: [darwin] - '@rspack/binding-darwin-arm64@2.2.1': - resolution: {integrity: sha512-Y/Naw/7V76QiUYdYRuBzBZtzRjt/3fjDUuF8GK0+/BO7BP1RrpY4tk1ln+iiqegRUD8u9uGn08fi8No1rwfyUg==} - cpu: [arm64] - os: [darwin] - - '@rspack/binding-darwin-x64@2.1.7': - resolution: {integrity: sha512-kPbrYvR/XUHfAMgRVq3QnC71DW/qjwsPj+3hEUuEnRmlploPNy9u8Szf1IHKSVUSrVZBTgDyMoZQdxYLfhResw==} - cpu: [x64] - os: [darwin] - - '@rspack/binding-darwin-x64@2.2.1': - resolution: {integrity: sha512-rTIG/xZIW7RbEEuMR9hnNn5dv3fDBpX0N4FAQUwfhUYy3tN2+3vibTTq/Nj1Sd9Vn4yWydbWIEwBX6m/aGejig==} + '@rspack/binding-darwin-x64@2.2.2': + resolution: {integrity: sha512-uFIcUPUXiPxM6ljenLafp5TemT8eLZm1riRn8fJYmpqNCK+aCcTaud18XHZpI5SjzzcY+xUHfVShgvNzKXuf2g==} cpu: [x64] os: [darwin] - '@rspack/binding-linux-arm64-gnu@2.1.7': - resolution: {integrity: sha512-VFB+YXM3kZ6IIuLV64H3vgnwqvQIIaqfR/aeGwuxYvwcZsrgblSBmXMeDULdgDjqP8Yr0VaFMBBiD9OtG5KdFw==} + '@rspack/binding-linux-arm64-gnu@2.2.2': + resolution: {integrity: sha512-Pjby4pDSMNJQK2VBzpgCj6lb+DGuenS1fEDb6xi5/apbJb9v5WE+e43Mz7i+XqgXS8e846pjaONV3KM5WKB1LQ==} cpu: [arm64] os: [linux] libc: [glibc] - '@rspack/binding-linux-arm64-gnu@2.2.1': - resolution: {integrity: sha512-53rAMU6Hqiat21IMU1hTt4Si2F33h+ZbXOt+Y18W39AFjcwmleIBId2u7beqJeGXLJuBgIAm31jcbJj/PN7mWQ==} - cpu: [arm64] - os: [linux] - libc: [glibc] - - '@rspack/binding-linux-arm64-musl@2.1.7': - resolution: {integrity: sha512-Mzbxyg0aJ+ITj526Iuz0enEDYY6WxhFIwEKXqwjQh+Vpd5v/+aPzPo83sSQVX/3puBV1sbmviTURbh6N9e1fvA==} - cpu: [arm64] - os: [linux] - libc: [musl] - - '@rspack/binding-linux-arm64-musl@2.2.1': - resolution: {integrity: sha512-o7zFiWkt4MqSfSdTbxUdF27fcrWKpRizcuVB8H3yd2G6xW9V2OfYbhVGQnOlbKi+GK74RkCmoJtANB+QboIqKQ==} + '@rspack/binding-linux-arm64-musl@2.2.2': + resolution: {integrity: sha512-0u9O7tTVT2z+F6o/eEY6f6+My8Jn9U56QiBwkfy90ZaoAfZyQSSTxqaK/zA7W43oFxQefeCpiPas27VUzrSakw==} cpu: [arm64] os: [linux] libc: [musl] - '@rspack/binding-linux-ppc64-gnu@2.2.1': - resolution: {integrity: sha512-pvx1oeg1z7cr8OcNt7PAt1SJTHzdsN/pvu7HkGnfks2fWE7GDs9DLL2KvN7tUkzQvJm6bGgUwqSCOrqV4uSwAg==} + '@rspack/binding-linux-ppc64-gnu@2.2.2': + resolution: {integrity: sha512-N3lVnhq5qOvpmP5n386JzR1GcE8HzAqq4/r440Z6yle9m7PhVFJ6oXVWxgaDTYV0mtv9YLJmaG+YrjYfUa1vuA==} cpu: [ppc64] os: [linux] libc: [glibc] - '@rspack/binding-linux-riscv64-gnu@2.1.7': - resolution: {integrity: sha512-mpazwgT/Pse1720mvEJsoXfPkJ+enj0xUqpbe/wL6aedwjGT+9jJNB8HTJXE4XBX0UO7umGqcJMeKA6YsD2CDA==} + '@rspack/binding-linux-riscv64-gnu@2.2.2': + resolution: {integrity: sha512-ReClZyp32/rJkUDV/oGDU0X6BCFyEkTR6r4stFwm/qOOaG6mUMRzZe4gur8Yh979p4Hiz9EdkmfEHY02GBXcaQ==} cpu: [riscv64] os: [linux] libc: [glibc] - '@rspack/binding-linux-riscv64-gnu@2.2.1': - resolution: {integrity: sha512-WQ6P94Wz2tgwOsgifTWP2/bV63iZH5+rkxngQwF22FC8KmIXXy/Yug7lyMH1ld8Hzg4p1qXjBBr4i1cCyJTR+w==} - cpu: [riscv64] - os: [linux] - libc: [glibc] - - '@rspack/binding-linux-riscv64-musl@2.1.7': - resolution: {integrity: sha512-oU/l3soPRsDEWn7KZic+npyTMM2N1kRdHjoJ+L5IUBXs8bjdTXPLoyTbTdIOza5ZSoT4+UeEiEryj4BB0tQE5w==} - cpu: [riscv64] - os: [linux] - libc: [musl] - - '@rspack/binding-linux-riscv64-musl@2.2.1': - resolution: {integrity: sha512-GEFUFHQkjKU7OYyHXnrIo8wWcUHM7jeKov5z6Lxd3i+3hKo11yBOgb7b+uD94Rx2tPuWF4jyFdWmcNu46Njb/A==} + '@rspack/binding-linux-riscv64-musl@2.2.2': + resolution: {integrity: sha512-mqsorvTNerr3r8zI35NFTPYATPDlhepdiUhZjKT6ylqpHlP7vLU9fp4aEMK/CuTv2f+IVsa0+iZqtMxHs2tSjw==} cpu: [riscv64] os: [linux] libc: [musl] - '@rspack/binding-linux-s390x-gnu@2.2.1': - resolution: {integrity: sha512-Cqw2UjSmFGZaw1EjQXClKDud86ThynGEEIazy2PZfPzZG4WjICK1WjdeFCJd7xWsSbUQ3jGyzb7/EHiDVa+sKA==} + '@rspack/binding-linux-s390x-gnu@2.2.2': + resolution: {integrity: sha512-ql2Jub8QYWSugBppmj2u0SjcIj6fOQuAaLCYQOqU7zbvz/uuWTfoqmdWKExwrxeCU9Tzt7emVM0ETuVEpoca+A==} cpu: [s390x] os: [linux] libc: [glibc] - '@rspack/binding-linux-x64-gnu@2.1.7': - resolution: {integrity: sha512-7Gtpl3h3jtnOpk1mYQE8mRndXAO2ibI8mnAbs7klevdKey+ZHneWMoMi2yOMQhhI/ifWEFxDzyGJ8bdxo0XTsA==} + '@rspack/binding-linux-x64-gnu@2.2.2': + resolution: {integrity: sha512-MNYKYEHrtIVEno2q5rgpou/JVffRwn109xPK3kxct95EojHsniNa8jwy6eEHeOazP4EN60Si7NElE3aQ6JssHw==} cpu: [x64] os: [linux] libc: [glibc] - '@rspack/binding-linux-x64-gnu@2.2.1': - resolution: {integrity: sha512-QX+gRxg2CS9ri2fUG5eNurdsrOCWoJ56SsD2O7kcVGiRm+S2+muNb/QhkdkAdt/u/m++7Ve5TMIpHTnaKYCpCw==} - cpu: [x64] - os: [linux] - libc: [glibc] - - '@rspack/binding-linux-x64-musl@2.1.7': - resolution: {integrity: sha512-w+whI2Uy+DYkGN+MVkzMFWweL7B/s1gMqX+nvTE1vhOy3hGV0VyA9H6lqWjSD3I+eGkpYhN9Pr244cYnLpZOUQ==} + '@rspack/binding-linux-x64-musl@2.2.2': + resolution: {integrity: sha512-y9/9CmE8lrECaF17GAhacibTL+SvlEPEotQnUuBFC/WFtXh8hU2E7a7bAkpYGSLH6kM0nrJZHO3hTvM1wdWOJw==} cpu: [x64] os: [linux] libc: [musl] - '@rspack/binding-linux-x64-musl@2.2.1': - resolution: {integrity: sha512-mBZQl1NdGbEB3y5M9d0tkuF7RL1GLz3Hb3gqFa3QRZBymP9PCV83Jiji8s2PJimNUJIVcdZRIw8+VGYs/35c2A==} - cpu: [x64] - os: [linux] - libc: [musl] - - '@rspack/binding-wasm32-wasi@2.1.7': - resolution: {integrity: sha512-cDVgvzRdTgxaeM+a5Lx0+7/VAvunvwO0wNtQ3ATQGOtFCW5b7cUzhNPcytH5ZSJTnFWuxinlGwtar5yfcnkdZQ==} + '@rspack/binding-wasm32-wasi@2.2.2': + resolution: {integrity: sha512-VbDIjjeFwZvMSKAOGY5IbU6lLzt6AHHHncTdMMkZ94Xk7O2BOHe9BXDV32Ln29TIW2C8m1fdxfPZWDiecVghUQ==} cpu: [wasm32] - '@rspack/binding-wasm32-wasi@2.2.1': - resolution: {integrity: sha512-/d2ImKDS+lT+FJ07MxKBeUkTat84tr2Nm2+nIRt8HmZK7/N8odkQml9vb4MHr8E7oYOp4B+jm6W5frdRzKrkJQ==} - cpu: [wasm32] - - '@rspack/binding-win32-arm64-msvc@2.1.7': - resolution: {integrity: sha512-JDd85+iYwUvaG9Zrt5X7oIxRZRiTW+76FwkRakoXNy/5VAWQW32Jq4ESjSVz6l6mh0KnZxPq3TLMugacCPnLjw==} - cpu: [arm64] - os: [win32] - - '@rspack/binding-win32-arm64-msvc@2.2.1': - resolution: {integrity: sha512-TfmaKPF3KC7uoZb6A+8ZUbLS8g8P5EdeXFGLCaJ+UgdkJ20TsapcfJXZXWNnKzFEkV8dUO/t5oNxNLYy2URusw==} + '@rspack/binding-win32-arm64-msvc@2.2.2': + resolution: {integrity: sha512-rfcNg0W3ZPZvXma1gTyEt9/Z8FxASIaQr+sMWTSaTPPaeU3xY1+0hYcrD0kUFNs3/5L4u63myI4R8qRXiuW3pA==} cpu: [arm64] os: [win32] - '@rspack/binding-win32-ia32-msvc@2.1.7': - resolution: {integrity: sha512-y9PKEs6v9BLHV0i/4eaIRtxpATvSgcf/VYQkMT8mp+qWlPjUwDQNwU2ueWVGpff6INO+YAa7zobzziNFRgO7Lg==} - cpu: [ia32] - os: [win32] - - '@rspack/binding-win32-ia32-msvc@2.2.1': - resolution: {integrity: sha512-rdBXayngvpQFMSUIC4b71FDZrSBJszSHNEkln/Nis3a17DMAE7IkgJcqe7SqLWbk2OPF/N920AOWmBEDQQCaMg==} + '@rspack/binding-win32-ia32-msvc@2.2.2': + resolution: {integrity: sha512-TFPvr9RZw9oHIhooDhXHzWjKcHpGPTxkznSeM2poIWU0CdEuua2rVUfsrriTF1Dmx+9kMly61DQmyOHCbb+b2g==} cpu: [ia32] os: [win32] - '@rspack/binding-win32-x64-msvc@2.1.7': - resolution: {integrity: sha512-BjkOzcPY/K8YlRRvyywz0mDWk89MMxqAMhDmgBXCWorh1IjgKTsWDJ2lCGIM8M9CZXUG3khom8AfrOGwRT2I+g==} + '@rspack/binding-win32-x64-msvc@2.2.2': + resolution: {integrity: sha512-GvEGyL594dtWN9SoVnKWh0exrM8WLInaUjwcuA2JKbCi1ak/9iHxip/U1dY3DuVqBYBhmvYq96JPbl91xnzFjg==} cpu: [x64] os: [win32] - '@rspack/binding-win32-x64-msvc@2.2.1': - resolution: {integrity: sha512-l3K4s7nrQJc+3LacPFjZGjX8Jk1sf8Q4TK6IXAsdSucOjTqYSpD8PMl2NUXCBDXOl8T2V4v323z1LfxwW8BPmA==} - cpu: [x64] - os: [win32] - - '@rspack/binding@2.1.7': - resolution: {integrity: sha512-wYqi8TY30hsIzLry503o/Uqu7y9Ec7pEwN5TVmB7Pb3xHrR2eHsQPzdpF/GkCLUjQSgD2Es3CDVV1mr6zO/78g==} - - '@rspack/binding@2.2.1': - resolution: {integrity: sha512-56TqztuEMd+aHGv1jDXnkJQGSLTb4NoO146flFxJqPG8931UdXPO2pNR9M0Q2Pz+GvmO0fLHGPLYBHoRVrRlHw==} + '@rspack/binding@2.2.2': + resolution: {integrity: sha512-gWjKDQfVQJSBh/I+y9WTlyERsiShSJ7eI6Yl0SJs/6gjx8t4ixuwWCsaEFFjwSL4nSn6ML5hNQ7UFY3gj72BWA==} - '@rspack/core@2.1.7': - resolution: {integrity: sha512-d5Ju3zXzGgbqQWvlMlLUtek2eFPIzsFe2QOF4nwTAknxo/4OZ64t+kPT9nM6fr3aZX93VK0R3v02/kZYIRrV9Q==} + '@rspack/core@2.2.2': + resolution: {integrity: sha512-/yztfDZR5syIPBrUpzBpL+6fhhl0IHBPcXlNr4tOMBULbocFIz7Z4/cqvf1ix0DBbKpIGx99v6N1IDbk2gi8hw==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: '@module-federation/runtime-tools': ^0.24.1 || ^2.0.0 @@ -524,27 +335,91 @@ packages: '@swc/helpers': optional: true - '@rspack/core@2.2.1': - resolution: {integrity: sha512-EHFX2oWCY1HkHJkG/Ev8HXCcl4gQzgETyairdIlBkKaypuW8i7kowBxUFzpHHg/ObF70vB3focToel9Wwg4MRA==} - engines: {node: ^20.19.0 || >=22.12.0} - peerDependencies: - '@module-federation/runtime-tools': ^0.24.1 || ^2.0.0 - '@swc/helpers': ^0.5.23 - peerDependenciesMeta: - '@module-federation/runtime-tools': - optional: true - '@swc/helpers': - optional: true + '@rstackjs/cli-darwin-arm64@0.7.2': + resolution: {integrity: sha512-po/JUgHx7DZ+Kmrbyy3L0/xr3rlZfVEk0Oy4D2xsjmAa3bHhP63B5XCOCyArLAZeMOqYPze9VaOcgWmGN5qWwQ==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [arm64] + os: [darwin] - '@rstest/adapter-rslib@0.11.11': - resolution: {integrity: sha512-tdApcpVuV29RPOzKftw7SLaMZr7yzlkcut+m56LsIW9WagQF2wjdhM4sdvMogVDT2ltPtKi+COMCATpNhq4Raw==} - peerDependencies: - '@rslib/core': '>=0.18.6 || ^1.0.0-0' - '@rstest/core': ^0.11.0 - typescript: ^5.0.0 || ^6.0.0 || ^7.0.0 - peerDependenciesMeta: - typescript: - optional: true + '@rstackjs/cli-darwin-x64@0.7.2': + resolution: {integrity: sha512-RFgUgUUXC3ZLF2iKJplsK2Ty49VkVw+rR8y5Hgf+3BAUn9ffRCUAqscWQGPCrJZENVbTEUWDyEVCMNnUpM6+Ww==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [x64] + os: [darwin] + + '@rstackjs/cli-linux-arm64-gnu@0.7.2': + resolution: {integrity: sha512-pNUbP/Bd962FznXLiJHnCcxpP/l1L9wmLsdIh43T8MQkY4m0Rv/s5tpA1rRcoqYHymhnVqWFcBAWxAPTSnOFFQ==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rstackjs/cli-linux-arm64-musl@0.7.2': + resolution: {integrity: sha512-cOC1WNNAZEeUxA0Lvbkk0ZBGMQIhKcjlZZinwGkg6zHJ7jxW42/SvwjNdnXv1xEpQd59OGJ1aSR1/Gt7PpItzw==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rstackjs/cli-linux-ppc64-gnu@0.7.2': + resolution: {integrity: sha512-jOk/KA3gpNapZO8y0Pc99XG7kjtgz6ndOGqKczgYD7VWBZcnMvD2KKI1GmeLxLf+9v0NiLtefj1CCtFEbqwXKg==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rstackjs/cli-linux-riscv64-gnu@0.7.2': + resolution: {integrity: sha512-8fukS3qf1nrvYDQ4886gWphHsg9gyktSkUUudSEFkamKKKOCmdZn+tDUvEebxYiqQCUEC/mqkUc/jg7EQKvP7Q==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@rstackjs/cli-linux-riscv64-musl@0.7.2': + resolution: {integrity: sha512-AciMUbdFgC/bDP05iuC13x4uPDISkyx2S9KiWDnjhs7bCjHv19bhPeOGLnpUWjAL86LxbHNuk+rM8wdt1da4gg==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@rstackjs/cli-linux-s390x-gnu@0.7.2': + resolution: {integrity: sha512-pj5V7Thbdc0FfK7Ngl3wLish7S0Yyy/ZmlH0Qd9UEMrNwMyMoyR+ZAJaWRjv7LFJQegPZNKBEgXfDc6Yeg7KjA==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rstackjs/cli-linux-x64-gnu@0.7.2': + resolution: {integrity: sha512-25Xzm2SXyDA1WkXrcHQym1ZI71ZK4n9AD32+0UT8IhVF+FGDBw0WG2UeOIr5XcaCCxgjGw1qec4aZ4GEd0/6vg==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rstackjs/cli-linux-x64-musl@0.7.2': + resolution: {integrity: sha512-77E3zZ5nrIP86nh40mMOvAu547a8qPDfTcKUQU/4fVjcE7g7zX17gQGGOHubzoqWRxv5abTABkG/ovhxqZ8bwQ==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rstackjs/cli-win32-arm64-msvc@0.7.2': + resolution: {integrity: sha512-fg8vRphmnXZQIC0lo757rwbFJS1s7Ft9RT9BzaJrqEcMWinxHx9HtKCddJ1scEpgu5Al8Vws74KYu2XNcUFUbA==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [arm64] + os: [win32] + + '@rstackjs/cli-win32-ia32-msvc@0.7.2': + resolution: {integrity: sha512-veUcxZ+ZqGzkkRYfkKj0GHlIKxR3NKm/Va4taifZLFXcqDFrSAmoueXTfhIzsLrNII+g85gizyaMdjytWhw8Lw==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [ia32] + os: [win32] + + '@rstackjs/cli-win32-x64-msvc@0.7.2': + resolution: {integrity: sha512-E/+K2W+GtezTLaOZ87erMyWOEbivKZiN/m/Iqeg8UJrfp9Zkqm7yIhQnYwG+KxN0gp3qjB/zxlcYdN5fnnhOWQ==} + engines: {node: ^22.18.0 || >=24.3.0} + cpu: [x64] + os: [win32] '@rstest/core@0.11.11': resolution: {integrity: sha512-7Ii2/2/ex1Oa0Kg5Qk5RKx2+e0I83BHLwH0/gn1B7IDwXCh5msFCF7yTyVGFuMltlm3E8Cf4QD7jadOEaBfXfw==} @@ -735,6 +610,75 @@ packages: cpu: [x64] os: [win32] + '@yuku-parser/binding-android-arm64@0.9.3': + resolution: {integrity: sha512-z3tDGTaUXD5Q4IuebFOY/QHxhR/SqujMhkMv9C5bh25upyFEXdafp0MsXQIIheWhVZzn5VMOniyxFni/7s9LgQ==} + cpu: [arm64] + os: [android] + + '@yuku-parser/binding-darwin-arm64@0.9.3': + resolution: {integrity: sha512-hzKvKSKS7z3ufnu1VkQYEoxmS6A5uNnkwukKnc2atxpWdq648nLVOqut4h1jUXjbM2WcoTfuZLF6AHAGFf8cmg==} + cpu: [arm64] + os: [darwin] + + '@yuku-parser/binding-darwin-x64@0.9.3': + resolution: {integrity: sha512-OM2PiVlPATvzlj/KGHNlu+t8FC3YzM5joVNjhsz/EaigQ8x2UUQ1Q0agQLiv5GZ2L8TSzrLUwBCZ7YOvP8q+tw==} + cpu: [x64] + os: [darwin] + + '@yuku-parser/binding-freebsd-x64@0.9.3': + resolution: {integrity: sha512-WMn9M4LHNVysGNwsAJ9gpRPqQIW2lcPrDNGcyk0agx3IYqCJq1MQugh6Be8Otc5U08eGdE39o8Kx9YWJmXz7GA==} + cpu: [x64] + os: [freebsd] + + '@yuku-parser/binding-linux-arm-gnu@0.9.3': + resolution: {integrity: sha512-vqKjwiyW1FWvbykYMEQIcAJwA17WxK3rxxqDuyCvQwcNVaLEUxI4BXiUdlF3kHucc7MnoFQhoRPkySgOzlLM+Q==} + cpu: [arm] + os: [linux] + libc: [glibc] + + '@yuku-parser/binding-linux-arm-musl@0.9.3': + resolution: {integrity: sha512-qohilhYOT+zkt2gYzym4F1T6BzRdvPqS9/sFB03pmnVV8LrvjOXVsGwEBAa3CEvzJKhAZjdTmVz7zsVdjyHWLg==} + cpu: [arm] + os: [linux] + libc: [musl] + + '@yuku-parser/binding-linux-arm64-gnu@0.9.3': + resolution: {integrity: sha512-tvTIyUvTGkeee68i4JIo9o27As+Ug6LXOZvElGgFbTs6+KBdb5LGhvugaIQljdfIsm2XnIbOLG6OnQSXHMLB9w==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@yuku-parser/binding-linux-arm64-musl@0.9.3': + resolution: {integrity: sha512-OWZBHW1wuChBpFlrF+On1yiBcFPMRrj2g0VKsM/PCBGffu1OM0ORkS+vLS3Snu6wYwndM5Dd9Ctvux6eUlrQjA==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@yuku-parser/binding-linux-x64-gnu@0.9.3': + resolution: {integrity: sha512-/tbk1h0dlADOCngbiQO9V3SHwBIJkoGBq8BDEraSw2CC3nGxPEPTCCYUDp5738Ij2FxVwy1FWVuhFkHvpMrPbQ==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@yuku-parser/binding-linux-x64-musl@0.9.3': + resolution: {integrity: sha512-u3+0sCso/mcjDvtc3866D2giV7l34PDyDVBkMesAWa3DWbIWPlybehi2SSnmScgArV22ctqSSgUzdBBVJ6zYAg==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@yuku-parser/binding-win32-arm64@0.9.3': + resolution: {integrity: sha512-xnGEvdhyjRkXozHtpXVpEEkyGZWAxJ3RoILv7XRV5SvTEztaTCk5GQyfcOzI9An/EJtcL4ERCI8QmS0TpDPJiA==} + cpu: [arm64] + os: [win32] + + '@yuku-parser/binding-win32-x64@0.9.3': + resolution: {integrity: sha512-N5eShGcuwnrXEprePFmEjtng6acZmtnC4zgazK9xxkavcx1q1uX8Nz8lU5RS973EMlNr902cIc6Cd2D4tqZDBg==} + cpu: [x64] + os: [win32] + + '@yuku-toolchain/types@0.9.3': + resolution: {integrity: sha512-rFE+5P4g2wxko5C85MugJOlVjBHEQq87dIkhLkniLXLp63PEtgaFjD954i5HXlfnyzLxPcZHsSOVDVgmo1HToA==} + ajv-draft-04@1.0.0: resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==} peerDependencies: @@ -796,10 +740,6 @@ packages: resolution: {integrity: sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==} engines: {node: '>=0.3.1'} - dprint@0.56.1: - resolution: {integrity: sha512-1r+e9cnecxoxIfac4+gyYvEftPgkFrNZOHMBmOYutLolph1u0yeQcBdhmLAo9RDuBD6FupKy0kZlcoyhgPVGOQ==} - hasBin: true - emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -833,11 +773,6 @@ packages: html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} - husky@9.1.7: - resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} - engines: {node: '>=18'} - hasBin: true - import-lazy@4.0.0: resolution: {integrity: sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==} engines: {node: '>=8'} @@ -894,11 +829,6 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - nano-staged@1.0.2: - resolution: {integrity: sha512-Fytar3zHLY99nlMfqPPbraxZodqQAHPpdPRyYaplL+lB9DCR6pUrafxbG+Btz4+7fO5Rm/+DO4ZeDO/nLSUMhw==} - engines: {node: ^22 || >= 24} - hasBin: true - package-manager-detector@1.8.0: resolution: {integrity: sha512-yQA4H19AmPEoMUeavPMDIe1higySl/gH/yaQrkT/s07Qp+7pp2hYz30N3z2l5BkjVkF9Ow6o0wjJamm2y7Sn0A==} @@ -912,6 +842,11 @@ packages: resolution: {integrity: sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==} engines: {node: '>=12'} + prettier@3.9.6: + resolution: {integrity: sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==} + engines: {node: '>=14'} + hasBin: true + publint@0.3.21: resolution: {integrity: sha512-OqejcnMV6E9zel2oCrUOJEiiFkGiAAni0A6ibfQNh1k9Gu5z4F+Yso8lllam7AzmV6Do0vp7u3UpZNRBwuXaHQ==} engines: {node: '>=18'} @@ -926,19 +861,16 @@ packages: engines: {node: '>= 0.4'} hasBin: true - rsbuild-plugin-dts@0.23.2: - resolution: {integrity: sha512-Ve8WOSPyTBjxH40O/6fChJtflL7yqcUtt5zbF0eHDM4hIt35jqLocRlSdCxFJdQm0blTjl6+hkmPa/vNI06ArA==} + rsbuild-plugin-dts@1.0.0: + resolution: {integrity: sha512-FVoTsiTfSc0LPeSjrVhpvFOBRig0YXJq3Hp+bVxzh9/bzFvODzLRWOEux8q1Phe1oVCIIVSc2+Nb7kDcxIhosw==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: '@microsoft/api-extractor': ^7 - '@rsbuild/core': ^1.0.0 || ^2.0.0-0 - '@typescript/native-preview': ^7.0.0-0 - typescript: ^5 || ^6 || ^7.0.1-0 + '@rsbuild/core': ^2.0.0 + typescript: ^5 || ^6 || ^7 peerDependenciesMeta: '@microsoft/api-extractor': optional: true - '@typescript/native-preview': - optional: true typescript: optional: true @@ -951,6 +883,16 @@ packages: '@rsbuild/core': optional: true + rstack@0.7.2: + resolution: {integrity: sha512-A0nL89XfrcA1tqhX7WmA+6p7ogMr4oWSYaPH1h+Kybl/e4+mEQAO/GCVA2BPsoUsSx8KltC3wUkmuhkKtoQojQ==} + engines: {node: ^22.18.0 || >=24.3.0} + hasBin: true + peerDependencies: + '@rspress/core': ^2.0.17 + peerDependenciesMeta: + '@rspress/core': + optional: true + sade@1.8.1: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} @@ -998,6 +940,10 @@ packages: resolution: {integrity: sha512-QKAl9m8gWWGHV8jZcPeym6j+XULi6tOf1mT83WYJ4Lk2ytW/uwAWkrP0uFsdoYMdueVJ0qs26wZ+23xeB4ibNQ==} engines: {node: '>=18'} + tinypool@2.1.2: + resolution: {integrity: sha512-9YodfrxS9g9IbFr/KOjE5bAeJ0p61n3bW6mqvy0jtoeKd1kTW1Cxm0oulm6KX2lyM9Gl6WIe8nEbY7LWv5ZJww==} + engines: {node: ^20.0.0 || >=22.0.0} + tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} @@ -1027,6 +973,12 @@ packages: resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + yuku-ast@0.9.3: + resolution: {integrity: sha512-Kt0PXlPCXdKF1fWFTl7N3DaxsVk6DHF8VAXHJMkwPtJnWYgbx20pYgGSweuC/86mIM7k1NUITQ4JffgOLUWTCw==} + + yuku-parser@0.9.3: + resolution: {integrity: sha512-96wPoHnwaXfkZv7UIOUkDb+s7ZH8lv8Qtg+MxdvHUV1LFa5jV9iKOaams1942YQt+krFQrWiD6lSg2ermv5kHA==} + snapshots: '@andrewbranch/untar.js@1.0.3': {} @@ -1042,122 +994,61 @@ snapshots: typescript: 5.6.1-rc validate-npm-package-name: 5.0.1 - '@ast-grep/napi-darwin-arm64@0.37.0': + '@ast-grep/napi-darwin-arm64@0.45.2': optional: true - '@ast-grep/napi-darwin-x64@0.37.0': + '@ast-grep/napi-darwin-x64@0.45.2': optional: true - '@ast-grep/napi-linux-arm64-gnu@0.37.0': + '@ast-grep/napi-linux-arm64-gnu@0.45.2': optional: true - '@ast-grep/napi-linux-arm64-musl@0.37.0': + '@ast-grep/napi-linux-arm64-musl@0.45.2': optional: true - '@ast-grep/napi-linux-x64-gnu@0.37.0': + '@ast-grep/napi-linux-x64-gnu@0.45.2': optional: true - '@ast-grep/napi-linux-x64-musl@0.37.0': + '@ast-grep/napi-linux-x64-musl@0.45.2': optional: true - '@ast-grep/napi-win32-arm64-msvc@0.37.0': + '@ast-grep/napi-win32-arm64-msvc@0.45.2': optional: true - '@ast-grep/napi-win32-ia32-msvc@0.37.0': + '@ast-grep/napi-win32-ia32-msvc@0.45.2': optional: true - '@ast-grep/napi-win32-x64-msvc@0.37.0': + '@ast-grep/napi-win32-x64-msvc@0.45.2': optional: true - '@ast-grep/napi@0.37.0': + '@ast-grep/napi@0.45.2': optionalDependencies: - '@ast-grep/napi-darwin-arm64': 0.37.0 - '@ast-grep/napi-darwin-x64': 0.37.0 - '@ast-grep/napi-linux-arm64-gnu': 0.37.0 - '@ast-grep/napi-linux-arm64-musl': 0.37.0 - '@ast-grep/napi-linux-x64-gnu': 0.37.0 - '@ast-grep/napi-linux-x64-musl': 0.37.0 - '@ast-grep/napi-win32-arm64-msvc': 0.37.0 - '@ast-grep/napi-win32-ia32-msvc': 0.37.0 - '@ast-grep/napi-win32-x64-msvc': 0.37.0 + '@ast-grep/napi-darwin-arm64': 0.45.2 + '@ast-grep/napi-darwin-x64': 0.45.2 + '@ast-grep/napi-linux-arm64-gnu': 0.45.2 + '@ast-grep/napi-linux-arm64-musl': 0.45.2 + '@ast-grep/napi-linux-x64-gnu': 0.45.2 + '@ast-grep/napi-linux-x64-musl': 0.45.2 + '@ast-grep/napi-win32-arm64-msvc': 0.45.2 + '@ast-grep/napi-win32-ia32-msvc': 0.45.2 + '@ast-grep/napi-win32-x64-msvc': 0.45.2 '@braidai/lang@1.1.2': {} '@colors/colors@1.5.0': optional: true - '@dprint/android-arm64@0.56.1': - optional: true - - '@dprint/android-x64@0.56.1': - optional: true - - '@dprint/darwin-arm64@0.56.1': - optional: true - - '@dprint/darwin-x64@0.56.1': - optional: true - - '@dprint/linux-arm64-glibc@0.56.1': - optional: true - - '@dprint/linux-arm64-musl@0.56.1': - optional: true - - '@dprint/linux-loong64-glibc@0.56.1': - optional: true - - '@dprint/linux-loong64-musl@0.56.1': - optional: true - - '@dprint/linux-ppc64-glibc@0.56.1': - optional: true - - '@dprint/linux-ppc64-musl@0.56.1': - optional: true - - '@dprint/linux-riscv64-glibc@0.56.1': - optional: true - - '@dprint/linux-x64-glibc@0.56.1': - optional: true - - '@dprint/linux-x64-musl@0.56.1': - optional: true - - '@dprint/win32-arm64@0.56.1': - optional: true - - '@dprint/win32-x64@0.56.1': - optional: true - - '@emnapi/core@1.11.2': - dependencies: - '@emnapi/wasi-threads': 1.2.2 - tslib: 2.8.1 - optional: true - '@emnapi/core@1.11.3': dependencies: '@emnapi/wasi-threads': 1.2.3 tslib: 2.8.1 optional: true - '@emnapi/runtime@1.11.2': - dependencies: - tslib: 2.8.1 - optional: true - '@emnapi/runtime@1.11.3': dependencies: tslib: 2.8.1 optional: true - '@emnapi/wasi-threads@1.2.2': - dependencies: - tslib: 2.8.1 - optional: true - '@emnapi/wasi-threads@1.2.3': dependencies: tslib: 2.8.1 @@ -1211,13 +1102,6 @@ snapshots: '@microsoft/tsdoc@0.16.0': {} - '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.2)(@emnapi/runtime@1.11.2)': - dependencies: - '@emnapi/core': 1.11.2 - '@emnapi/runtime': 1.11.2 - '@tybys/wasm-util': 0.10.3 - optional: true - '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)': dependencies: '@emnapi/core': 1.11.3 @@ -1227,30 +1111,22 @@ snapshots: '@publint/pack@0.1.4': {} - '@rsbuild/core@2.1.9': + '@rsbuild/core@2.2.3': dependencies: - '@rspack/core': 2.1.7(@swc/helpers@0.5.23) + '@rspack/core': 2.2.2(@swc/helpers@0.5.23) '@swc/helpers': 0.5.23 transitivePeerDependencies: - '@module-federation/runtime-tools' - '@rsbuild/core@2.2.1': + '@rslib/core@1.0.0(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2)': dependencies: - '@rspack/core': 2.2.1(@swc/helpers@0.5.23) - '@swc/helpers': 0.5.23 - transitivePeerDependencies: - - '@module-federation/runtime-tools' - - '@rslib/core@0.23.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2)': - dependencies: - '@rsbuild/core': 2.1.9 - rsbuild-plugin-dts: 0.23.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(@rsbuild/core@2.1.9)(typescript@7.0.2) + '@rsbuild/core': 2.2.3 + rsbuild-plugin-dts: 1.0.0(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(@rsbuild/core@2.2.3)(typescript@7.0.2) optionalDependencies: '@microsoft/api-extractor': 7.59.0(@types/node@24.13.3) typescript: 7.0.2 transitivePeerDependencies: - '@module-federation/runtime-tools' - - '@typescript/native-preview' - core-js '@rslint/core@0.9.0': @@ -1290,146 +1166,117 @@ snapshots: '@rslint/native-win32-x64-msvc@0.9.0': optional: true - '@rspack/binding-darwin-arm64@2.1.7': + '@rspack/binding-darwin-arm64@2.2.2': optional: true - '@rspack/binding-darwin-arm64@2.2.1': + '@rspack/binding-darwin-x64@2.2.2': optional: true - '@rspack/binding-darwin-x64@2.1.7': + '@rspack/binding-linux-arm64-gnu@2.2.2': optional: true - '@rspack/binding-darwin-x64@2.2.1': + '@rspack/binding-linux-arm64-musl@2.2.2': optional: true - '@rspack/binding-linux-arm64-gnu@2.1.7': + '@rspack/binding-linux-ppc64-gnu@2.2.2': optional: true - '@rspack/binding-linux-arm64-gnu@2.2.1': + '@rspack/binding-linux-riscv64-gnu@2.2.2': optional: true - '@rspack/binding-linux-arm64-musl@2.1.7': + '@rspack/binding-linux-riscv64-musl@2.2.2': optional: true - '@rspack/binding-linux-arm64-musl@2.2.1': + '@rspack/binding-linux-s390x-gnu@2.2.2': optional: true - '@rspack/binding-linux-ppc64-gnu@2.2.1': + '@rspack/binding-linux-x64-gnu@2.2.2': optional: true - '@rspack/binding-linux-riscv64-gnu@2.1.7': + '@rspack/binding-linux-x64-musl@2.2.2': optional: true - '@rspack/binding-linux-riscv64-gnu@2.2.1': + '@rspack/binding-wasm32-wasi@2.2.2': + dependencies: + '@emnapi/core': 1.11.3 + '@emnapi/runtime': 1.11.3 + '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) optional: true - '@rspack/binding-linux-riscv64-musl@2.1.7': + '@rspack/binding-win32-arm64-msvc@2.2.2': optional: true - '@rspack/binding-linux-riscv64-musl@2.2.1': + '@rspack/binding-win32-ia32-msvc@2.2.2': optional: true - '@rspack/binding-linux-s390x-gnu@2.2.1': + '@rspack/binding-win32-x64-msvc@2.2.2': optional: true - '@rspack/binding-linux-x64-gnu@2.1.7': - optional: true + '@rspack/binding@2.2.2': + optionalDependencies: + '@rspack/binding-darwin-arm64': 2.2.2 + '@rspack/binding-darwin-x64': 2.2.2 + '@rspack/binding-linux-arm64-gnu': 2.2.2 + '@rspack/binding-linux-arm64-musl': 2.2.2 + '@rspack/binding-linux-ppc64-gnu': 2.2.2 + '@rspack/binding-linux-riscv64-gnu': 2.2.2 + '@rspack/binding-linux-riscv64-musl': 2.2.2 + '@rspack/binding-linux-s390x-gnu': 2.2.2 + '@rspack/binding-linux-x64-gnu': 2.2.2 + '@rspack/binding-linux-x64-musl': 2.2.2 + '@rspack/binding-wasm32-wasi': 2.2.2 + '@rspack/binding-win32-arm64-msvc': 2.2.2 + '@rspack/binding-win32-ia32-msvc': 2.2.2 + '@rspack/binding-win32-x64-msvc': 2.2.2 + + '@rspack/core@2.2.2(@swc/helpers@0.5.23)': + dependencies: + '@rspack/binding': 2.2.2 + optionalDependencies: + '@swc/helpers': 0.5.23 - '@rspack/binding-linux-x64-gnu@2.2.1': + '@rstackjs/cli-darwin-arm64@0.7.2': optional: true - '@rspack/binding-linux-x64-musl@2.1.7': + '@rstackjs/cli-darwin-x64@0.7.2': optional: true - '@rspack/binding-linux-x64-musl@2.2.1': + '@rstackjs/cli-linux-arm64-gnu@0.7.2': optional: true - '@rspack/binding-wasm32-wasi@2.1.7': - dependencies: - '@emnapi/core': 1.11.2 - '@emnapi/runtime': 1.11.2 - '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.2)(@emnapi/runtime@1.11.2) + '@rstackjs/cli-linux-arm64-musl@0.7.2': optional: true - '@rspack/binding-wasm32-wasi@2.2.1': - dependencies: - '@emnapi/core': 1.11.3 - '@emnapi/runtime': 1.11.3 - '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) + '@rstackjs/cli-linux-ppc64-gnu@0.7.2': optional: true - '@rspack/binding-win32-arm64-msvc@2.1.7': + '@rstackjs/cli-linux-riscv64-gnu@0.7.2': optional: true - '@rspack/binding-win32-arm64-msvc@2.2.1': + '@rstackjs/cli-linux-riscv64-musl@0.7.2': optional: true - '@rspack/binding-win32-ia32-msvc@2.1.7': + '@rstackjs/cli-linux-s390x-gnu@0.7.2': optional: true - '@rspack/binding-win32-ia32-msvc@2.2.1': + '@rstackjs/cli-linux-x64-gnu@0.7.2': optional: true - '@rspack/binding-win32-x64-msvc@2.1.7': + '@rstackjs/cli-linux-x64-musl@0.7.2': optional: true - '@rspack/binding-win32-x64-msvc@2.2.1': + '@rstackjs/cli-win32-arm64-msvc@0.7.2': optional: true - '@rspack/binding@2.1.7': - optionalDependencies: - '@rspack/binding-darwin-arm64': 2.1.7 - '@rspack/binding-darwin-x64': 2.1.7 - '@rspack/binding-linux-arm64-gnu': 2.1.7 - '@rspack/binding-linux-arm64-musl': 2.1.7 - '@rspack/binding-linux-riscv64-gnu': 2.1.7 - '@rspack/binding-linux-riscv64-musl': 2.1.7 - '@rspack/binding-linux-x64-gnu': 2.1.7 - '@rspack/binding-linux-x64-musl': 2.1.7 - '@rspack/binding-wasm32-wasi': 2.1.7 - '@rspack/binding-win32-arm64-msvc': 2.1.7 - '@rspack/binding-win32-ia32-msvc': 2.1.7 - '@rspack/binding-win32-x64-msvc': 2.1.7 - - '@rspack/binding@2.2.1': - optionalDependencies: - '@rspack/binding-darwin-arm64': 2.2.1 - '@rspack/binding-darwin-x64': 2.2.1 - '@rspack/binding-linux-arm64-gnu': 2.2.1 - '@rspack/binding-linux-arm64-musl': 2.2.1 - '@rspack/binding-linux-ppc64-gnu': 2.2.1 - '@rspack/binding-linux-riscv64-gnu': 2.2.1 - '@rspack/binding-linux-riscv64-musl': 2.2.1 - '@rspack/binding-linux-s390x-gnu': 2.2.1 - '@rspack/binding-linux-x64-gnu': 2.2.1 - '@rspack/binding-linux-x64-musl': 2.2.1 - '@rspack/binding-wasm32-wasi': 2.2.1 - '@rspack/binding-win32-arm64-msvc': 2.2.1 - '@rspack/binding-win32-ia32-msvc': 2.2.1 - '@rspack/binding-win32-x64-msvc': 2.2.1 - - '@rspack/core@2.1.7(@swc/helpers@0.5.23)': - dependencies: - '@rspack/binding': 2.1.7 - optionalDependencies: - '@swc/helpers': 0.5.23 - - '@rspack/core@2.2.1(@swc/helpers@0.5.23)': - dependencies: - '@rspack/binding': 2.2.1 - optionalDependencies: - '@swc/helpers': 0.5.23 + '@rstackjs/cli-win32-ia32-msvc@0.7.2': + optional: true - '@rstest/adapter-rslib@0.11.11(@rslib/core@0.23.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2))(@rstest/core@0.11.11)(typescript@7.0.2)': - dependencies: - '@rslib/core': 0.23.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2) - '@rstest/core': 0.11.11 - optionalDependencies: - typescript: 7.0.2 + '@rstackjs/cli-win32-x64-msvc@0.7.2': + optional: true '@rstest/core@0.11.11': dependencies: - '@rsbuild/core': 2.2.1 + '@rsbuild/core': 2.2.3 '@types/chai': 5.2.3 transitivePeerDependencies: - '@module-federation/runtime-tools' @@ -1567,6 +1414,44 @@ snapshots: '@typescript/typescript-win32-x64@7.0.2': optional: true + '@yuku-parser/binding-android-arm64@0.9.3': + optional: true + + '@yuku-parser/binding-darwin-arm64@0.9.3': + optional: true + + '@yuku-parser/binding-darwin-x64@0.9.3': + optional: true + + '@yuku-parser/binding-freebsd-x64@0.9.3': + optional: true + + '@yuku-parser/binding-linux-arm-gnu@0.9.3': + optional: true + + '@yuku-parser/binding-linux-arm-musl@0.9.3': + optional: true + + '@yuku-parser/binding-linux-arm64-gnu@0.9.3': + optional: true + + '@yuku-parser/binding-linux-arm64-musl@0.9.3': + optional: true + + '@yuku-parser/binding-linux-x64-gnu@0.9.3': + optional: true + + '@yuku-parser/binding-linux-x64-musl@0.9.3': + optional: true + + '@yuku-parser/binding-win32-arm64@0.9.3': + optional: true + + '@yuku-parser/binding-win32-x64@0.9.3': + optional: true + + '@yuku-toolchain/types@0.9.3': {} + ajv-draft-04@1.0.0(ajv@8.20.0): optionalDependencies: ajv: 8.20.0 @@ -1619,24 +1504,6 @@ snapshots: diff@8.0.3: {} - dprint@0.56.1: - optionalDependencies: - '@dprint/android-arm64': 0.56.1 - '@dprint/android-x64': 0.56.1 - '@dprint/darwin-arm64': 0.56.1 - '@dprint/darwin-x64': 0.56.1 - '@dprint/linux-arm64-glibc': 0.56.1 - '@dprint/linux-arm64-musl': 0.56.1 - '@dprint/linux-loong64-glibc': 0.56.1 - '@dprint/linux-loong64-musl': 0.56.1 - '@dprint/linux-ppc64-glibc': 0.56.1 - '@dprint/linux-ppc64-musl': 0.56.1 - '@dprint/linux-riscv64-glibc': 0.56.1 - '@dprint/linux-x64-glibc': 0.56.1 - '@dprint/linux-x64-musl': 0.56.1 - '@dprint/win32-arm64': 0.56.1 - '@dprint/win32-x64': 0.56.1 - emoji-regex@8.0.0: {} fast-deep-equal@3.1.3: {} @@ -1663,8 +1530,6 @@ snapshots: html-escaper@2.0.2: {} - husky@9.1.7: {} - import-lazy@4.0.0: {} is-core-module@2.16.1: @@ -1718,8 +1583,6 @@ snapshots: ms@2.1.3: {} - nano-staged@1.0.2: {} - package-manager-detector@1.8.0: {} path-parse@1.0.7: {} @@ -1728,6 +1591,8 @@ snapshots: picomatch@4.0.5: {} + prettier@3.9.6: {} + publint@0.3.21: dependencies: '@publint/pack': 0.1.4 @@ -1743,19 +1608,51 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - rsbuild-plugin-dts@0.23.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(@rsbuild/core@2.1.9)(typescript@7.0.2): + rsbuild-plugin-dts@1.0.0(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(@rsbuild/core@2.2.3)(typescript@7.0.2): dependencies: - '@ast-grep/napi': 0.37.0 - '@rsbuild/core': 2.1.9 + '@ast-grep/napi': 0.45.2 + '@rsbuild/core': 2.2.3 optionalDependencies: '@microsoft/api-extractor': 7.59.0(@types/node@24.13.3) typescript: 7.0.2 - rsbuild-plugin-publint@1.0.0(@rsbuild/core@2.2.1): + rsbuild-plugin-publint@1.0.0(@rsbuild/core@2.2.3): dependencies: publint: 0.3.21 optionalDependencies: - '@rsbuild/core': 2.2.1 + '@rsbuild/core': 2.2.3 + + rstack@0.7.2(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2): + dependencies: + '@rsbuild/core': 2.2.3 + '@rslib/core': 1.0.0(@microsoft/api-extractor@7.59.0(@types/node@24.13.3))(typescript@7.0.2) + '@rslint/core': 0.9.0 + '@rstest/core': 0.11.11 + prettier: 3.9.6 + tinypool: 2.1.2 + yuku-parser: 0.9.3 + optionalDependencies: + '@rstackjs/cli-darwin-arm64': 0.7.2 + '@rstackjs/cli-darwin-x64': 0.7.2 + '@rstackjs/cli-linux-arm64-gnu': 0.7.2 + '@rstackjs/cli-linux-arm64-musl': 0.7.2 + '@rstackjs/cli-linux-ppc64-gnu': 0.7.2 + '@rstackjs/cli-linux-riscv64-gnu': 0.7.2 + '@rstackjs/cli-linux-riscv64-musl': 0.7.2 + '@rstackjs/cli-linux-s390x-gnu': 0.7.2 + '@rstackjs/cli-linux-x64-gnu': 0.7.2 + '@rstackjs/cli-linux-x64-musl': 0.7.2 + '@rstackjs/cli-win32-arm64-msvc': 0.7.2 + '@rstackjs/cli-win32-ia32-msvc': 0.7.2 + '@rstackjs/cli-win32-x64-msvc': 0.7.2 + transitivePeerDependencies: + - '@microsoft/api-extractor' + - '@module-federation/runtime-tools' + - core-js + - happy-dom + - jiti + - jsdom + - typescript sade@1.8.1: dependencies: @@ -1793,6 +1690,8 @@ snapshots: tinyexec@1.3.0: {} + tinypool@2.1.2: {} + tslib@2.8.1: {} typescript@5.6.1-rc: {} @@ -1827,3 +1726,25 @@ snapshots: universalify@2.0.1: {} validate-npm-package-name@5.0.1: {} + + yuku-ast@0.9.3: + dependencies: + '@yuku-toolchain/types': 0.9.3 + + yuku-parser@0.9.3: + dependencies: + '@yuku-toolchain/types': 0.9.3 + yuku-ast: 0.9.3 + optionalDependencies: + '@yuku-parser/binding-android-arm64': 0.9.3 + '@yuku-parser/binding-darwin-arm64': 0.9.3 + '@yuku-parser/binding-darwin-x64': 0.9.3 + '@yuku-parser/binding-freebsd-x64': 0.9.3 + '@yuku-parser/binding-linux-arm-gnu': 0.9.3 + '@yuku-parser/binding-linux-arm-musl': 0.9.3 + '@yuku-parser/binding-linux-arm64-gnu': 0.9.3 + '@yuku-parser/binding-linux-arm64-musl': 0.9.3 + '@yuku-parser/binding-linux-x64-gnu': 0.9.3 + '@yuku-parser/binding-linux-x64-musl': 0.9.3 + '@yuku-parser/binding-win32-arm64': 0.9.3 + '@yuku-parser/binding-win32-x64': 0.9.3 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index c613d24..98da541 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -5,18 +5,17 @@ optimisticRepeatInstall: true strictDepBuilds: true minimumReleaseAgeExclude: - - "@rsbuild/*" - - "@rslib/*" - - "@rslint/*" - - "@rspack/*" - - "@rspress/*" - - "@rstackjs/*" - - "@rstest/*" - - "@typescript/*" - - "rsbuild-plugin-*" + - '@rsbuild/*' + - '@rslib/*' + - '@rslint/*' + - '@rspack/*' + - '@rspress/*' + - '@rstackjs/*' + - '@rstest/*' + - '@typescript/*' + - 'rsbuild-plugin-*' - rstack - typescript allowBuilds: core-js: false - dprint: true diff --git a/rslib.config.ts b/rslib.config.ts deleted file mode 100644 index a6b1f08..0000000 --- a/rslib.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from "@rslib/core"; -import { pluginPublint } from "rsbuild-plugin-publint"; - -export default defineConfig({ - lib: [ - { format: "esm", syntax: "es2022", dts: { bundle: true } }, - ], - plugins: [ - pluginPublint(), - ], -}); diff --git a/rslint.config.ts b/rslint.config.ts deleted file mode 100644 index 2195e70..0000000 --- a/rslint.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineConfig, js, ts } from "@rslint/core"; - -export default defineConfig([js.configs.recommended, ts.configs.recommended]); diff --git a/rstack.config.ts b/rstack.config.ts new file mode 100644 index 0000000..d65a52c --- /dev/null +++ b/rstack.config.ts @@ -0,0 +1,37 @@ +// Configuration guide: https://rstack.rs/config +import { define } from 'rstack'; + +define.lib(async () => { + const { pluginPublint } = await import('rsbuild-plugin-publint'); + + return { + dts: { bundle: true }, + format: 'esm', + plugins: [pluginPublint()], + syntax: 'es2022', + }; +}); + +define.test({ + coverage: { + exclude: ['.rslib/**', './dist/**', './test/**', './rstack.config.ts'], + thresholds: { + statements: 100, + functions: 100, + branches: 98, + lines: 100, + }, + }, +}); + +define.fmt({ + singleQuote: true, + sortPackageJson: true, +}); + +define.staged({ + '*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}': ['rs lint', 'rs fmt'], + '*.{json,jsonc,md,mdx,css,scss,less,html,yml,yaml}': 'rs fmt', +}); + +define.lint(({ js, ts }) => [js.configs.recommended, ts.configs.recommended]); diff --git a/rstest.config.ts b/rstest.config.ts deleted file mode 100644 index aaeb688..0000000 --- a/rstest.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { withRslibConfig } from "@rstest/adapter-rslib"; -import { defineConfig } from "@rstest/core"; - -export default defineConfig({ - extends: withRslibConfig(), - coverage: { - exclude: [ - ".rslib/**", - "./dist/**", - "./test/**", - "./rslib.config.ts", - "./rstest.config.ts", - ], - thresholds: { - statements: 100, - functions: 100, - branches: 98, - lines: 100, - }, - }, -}); diff --git a/src/createTarball.ts b/src/createTarball.ts index b0a085c..76dfa15 100644 --- a/src/createTarball.ts +++ b/src/createTarball.ts @@ -1,8 +1,8 @@ -import fs from "node:fs/promises"; -import path from "node:path"; +import fs from 'node:fs/promises'; +import path from 'node:path'; -import { detect } from "package-manager-detector"; -import { x } from "tinyexec"; +import { detect } from 'package-manager-detector'; +import { x } from 'tinyexec'; interface Result extends AsyncDisposable { path: string; @@ -19,23 +19,23 @@ export async function createTarball( const detectResult = await detect({ cwd: root }); - const [command, args] = (function(): [string, string[]] { + const [command, args] = (function (): [string, string[]] { switch (detectResult?.agent) { - case "yarn": + case 'yarn': // https://classic.yarnpkg.com/lang/en/docs/cli/pack/ - return ["yarn", ["pack", "--filename", tarballPath]]; - case "yarn@berry": + return ['yarn', ['pack', '--filename', tarballPath]]; + case 'yarn@berry': // https://yarnpkg.com/cli/pack - return ["corepack", ["yarn", "pack", "--out", tarballPath]]; - case "pnpm": - case "pnpm@6": - return ["pnpm", ["pack"]]; - case "npm": - case "bun": - case "deno": + return ['corepack', ['yarn', 'pack', '--out', tarballPath]]; + case 'pnpm': + case 'pnpm@6': + return ['pnpm', ['pack']]; + case 'npm': + case 'bun': + case 'deno': case undefined: default: - return ["npm", ["pack"]]; + return ['npm', ['pack']]; } })(); @@ -59,5 +59,5 @@ export async function createTarball( } function normalizeNpmPackageName(name: string): string { - return name.replaceAll("@", "").replaceAll("/", "-"); + return name.replaceAll('@', '').replaceAll('/', '-'); } diff --git a/src/getExitCode.ts b/src/getExitCode.ts index 54bebc7..df79ebe 100644 --- a/src/getExitCode.ts +++ b/src/getExitCode.ts @@ -9,35 +9,42 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import type { CheckResult } from "@arethetypeswrong/core"; -import { problemAffectsResolutionKind } from "@arethetypeswrong/core/problems"; -import { allResolutionKinds } from "@arethetypeswrong/core/utils"; -import { problemFlags } from "./problemUtils.js"; -import type { RenderOptions } from "./render/index.js"; - -export function getExitCode(analysis: CheckResult, opts?: RenderOptions): 0 | 1 { +import type { CheckResult } from '@arethetypeswrong/core'; +import { problemAffectsResolutionKind } from '@arethetypeswrong/core/problems'; +import { allResolutionKinds } from '@arethetypeswrong/core/utils'; +import { problemFlags } from './problemUtils.js'; +import type { RenderOptions } from './render/index.js'; + +export function getExitCode( + analysis: CheckResult, + opts?: RenderOptions, +): 0 | 1 { if (!analysis.types) { return 1; } const ignoreRules = opts?.ignoreRules ?? []; const ignoreResolutions = opts?.ignoreResolutions ?? []; return analysis.problems.some((problem) => { - const notRuleIgnored = !ignoreRules.includes(problemFlags[problem.kind]); - if (!notRuleIgnored) { - return false; - } - - const affectedKinds = allResolutionKinds.filter(rk => problemAffectsResolutionKind(problem, rk, analysis)); - - /* v8 ignore next */ - /* istanbul ignore next */ - if (affectedKinds.length === 0) { - return true; - } - - const notResolutionIgnored = affectedKinds.some(rk => !ignoreResolutions.includes(rk)); - return notResolutionIgnored; - }) + const notRuleIgnored = !ignoreRules.includes(problemFlags[problem.kind]); + if (!notRuleIgnored) { + return false; + } + + const affectedKinds = allResolutionKinds.filter((rk) => + problemAffectsResolutionKind(problem, rk, analysis), + ); + + /* v8 ignore next */ + /* istanbul ignore next */ + if (affectedKinds.length === 0) { + return true; + } + + const notResolutionIgnored = affectedKinds.some( + (rk) => !ignoreResolutions.includes(rk), + ); + return notResolutionIgnored; + }) ? 1 : 0; } diff --git a/src/index.ts b/src/index.ts index 5491757..533c4b1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ -import fs from "node:fs"; -import path from "node:path"; +import fs from 'node:fs'; +import path from 'node:path'; -import { logger, type RsbuildPlugin } from "@rsbuild/core"; +import { logger, type RsbuildPlugin } from '@rsbuild/core'; -import type { RenderOptions } from "./render/index.js"; +import type { RenderOptions } from './render/index.js'; export interface PluginAreTheTypesWrongOptions { /** @@ -18,7 +18,7 @@ export interface PluginAreTheTypesWrongOptions { export const pluginAreTheTypesWrong = ( options: PluginAreTheTypesWrongOptions = {}, ): RsbuildPlugin => ({ - name: "plugin-arethetypeswrong", + name: 'plugin-arethetypeswrong', setup(api) { if (options.enable === false) { @@ -38,28 +38,31 @@ export const pluginAreTheTypesWrong = ( // Read package.json to get package name and version const packageJson = JSON.parse( - fs.readFileSync(path.join(rootPath, "package.json"), "utf-8"), + fs.readFileSync(path.join(rootPath, 'package.json'), 'utf-8'), ) as { name: string; version: string }; const packageName = packageJson.name; const packageVersion = packageJson.version; - logger.start(`[arethetypeswrong] Checking ${packageName}@${packageVersion}...`); - logger.info(""); + logger.start( + `[arethetypeswrong] Checking ${packageName}@${packageVersion}...`, + ); + logger.info(''); logger.debug(`[arethetypeswrong] Running npm pack from ${rootPath}`); - const { createTarball } = await import("./createTarball.js"); + const { createTarball } = await import('./createTarball.js'); await using tarball = await createTarball(rootPath, packageJson); logger.debug(`[arethetypeswrong] npm pack success`); - const { checkPackage, createPackageFromTarballData } = await import("@arethetypeswrong/core"); + const { checkPackage, createPackageFromTarballData } = + await import('@arethetypeswrong/core'); const pkg = createPackageFromTarballData(fs.readFileSync(tarball.path)); const result = await checkPackage(pkg); - const { render } = await import("./render/index.js"); + const { render } = await import('./render/index.js'); const message = render(result, options.areTheTypesWrongOptions ?? {}); - const { getExitCode } = await import("./getExitCode.js"); + const { getExitCode } = await import('./getExitCode.js'); const exitCode = getExitCode(result, options.areTheTypesWrongOptions); const hasErrors = exitCode !== 0; @@ -68,7 +71,7 @@ export const pluginAreTheTypesWrong = ( /* v8 ignore next */ /* istanbul ignore next */ if (!isWatch) { - throw new Error("arethetypeswrong failed!"); + throw new Error('arethetypeswrong failed!'); } /* v8 ignore next */ /* istanbul ignore next */ @@ -76,7 +79,7 @@ export const pluginAreTheTypesWrong = ( } logger.success(message); }, - order: "post", + order: 'post', }); }, }); diff --git a/src/problemUtils.ts b/src/problemUtils.ts index 6676e46..cf7e7a1 100644 --- a/src/problemUtils.ts +++ b/src/problemUtils.ts @@ -1,44 +1,44 @@ -import type * as core from "@arethetypeswrong/core"; -import type { ProblemKind } from "@arethetypeswrong/core"; +import type * as core from '@arethetypeswrong/core'; +import type { ProblemKind } from '@arethetypeswrong/core'; export type ProblemFlag = - | "no-resolution" - | "untyped-resolution" - | "false-cjs" - | "false-esm" - | "cjs-resolves-to-esm" - | "fallback-condition" - | "cjs-only-exports-default" - | "named-exports" - | "false-export-default" - | "missing-export-equals" - | "unexpected-module-syntax" - | "internal-resolution-error"; + | 'no-resolution' + | 'untyped-resolution' + | 'false-cjs' + | 'false-esm' + | 'cjs-resolves-to-esm' + | 'fallback-condition' + | 'cjs-only-exports-default' + | 'named-exports' + | 'false-export-default' + | 'missing-export-equals' + | 'unexpected-module-syntax' + | 'internal-resolution-error'; export const problemFlags: Record = { - NoResolution: "no-resolution", - UntypedResolution: "untyped-resolution", - FalseCJS: "false-cjs", - FalseESM: "false-esm", - CJSResolvesToESM: "cjs-resolves-to-esm", - FallbackCondition: "fallback-condition", - CJSOnlyExportsDefault: "cjs-only-exports-default", - NamedExports: "named-exports", - FalseExportDefault: "false-export-default", - MissingExportEquals: "missing-export-equals", - UnexpectedModuleSyntax: "unexpected-module-syntax", - InternalResolutionError: "internal-resolution-error", + NoResolution: 'no-resolution', + UntypedResolution: 'untyped-resolution', + FalseCJS: 'false-cjs', + FalseESM: 'false-esm', + CJSResolvesToESM: 'cjs-resolves-to-esm', + FallbackCondition: 'fallback-condition', + CJSOnlyExportsDefault: 'cjs-only-exports-default', + NamedExports: 'named-exports', + FalseExportDefault: 'false-export-default', + MissingExportEquals: 'missing-export-equals', + UnexpectedModuleSyntax: 'unexpected-module-syntax', + InternalResolutionError: 'internal-resolution-error', }; export const resolutionKinds: Record = { - node10: "node10", - "node16-cjs": "node16 (from CJS)", - "node16-esm": "node16 (from ESM)", - bundler: "bundler", + node10: 'node10', + 'node16-cjs': 'node16 (from CJS)', + 'node16-esm': 'node16 (from ESM)', + bundler: 'bundler', }; export const moduleKinds = { - 1: "(CJS)", - 99: "(ESM)", - "": "", + 1: '(CJS)', + 99: '(ESM)', + '': '', }; diff --git a/src/render/index.ts b/src/render/index.ts index a2c33f7..da83800 100644 --- a/src/render/index.ts +++ b/src/render/index.ts @@ -1,8 +1,8 @@ -import type { CheckResult, ResolutionKind } from "@arethetypeswrong/core"; +import type { CheckResult, ResolutionKind } from '@arethetypeswrong/core'; -import type { ProblemFlag } from "../problemUtils.js"; -import { renderTyped } from "./typed.js"; -import { renderUntyped } from "./untyped.js"; +import type { ProblemFlag } from '../problemUtils.js'; +import { renderTyped } from './typed.js'; +import { renderUntyped } from './untyped.js'; export function render(analysis: CheckResult, options: RenderOptions): string { if (analysis.types) { diff --git a/src/render/typed.ts b/src/render/typed.ts index 943efd2..a1cc1fb 100644 --- a/src/render/typed.ts +++ b/src/render/typed.ts @@ -9,141 +9,186 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import type * as core from "@arethetypeswrong/core"; +import type * as core from '@arethetypeswrong/core'; import { filterProblems, problemAffectsEntrypoint, problemAffectsResolutionKind, problemKindInfo, -} from "@arethetypeswrong/core/problems"; -import { allResolutionKinds, getResolutionOption, groupProblemsByKind } from "@arethetypeswrong/core/utils"; -import Table from "cli-table3"; -import { styleText } from "node:util"; +} from '@arethetypeswrong/core/problems'; +import { + allResolutionKinds, + getResolutionOption, + groupProblemsByKind, +} from '@arethetypeswrong/core/utils'; +import Table from 'cli-table3'; +import { styleText } from 'node:util'; -import { moduleKinds, problemFlags, resolutionKinds } from "../problemUtils.js"; -import type { RenderOptions } from "./index.js"; +import { moduleKinds, problemFlags, resolutionKinds } from '../problemUtils.js'; +import type { RenderOptions } from './index.js'; export function renderTyped( analysis: core.Analysis, - { emoji = true, summary = true, ignoreRules = [], ignoreResolutions = [] }: RenderOptions, + { + emoji = true, + summary = true, + ignoreRules = [], + ignoreResolutions = [], + }: RenderOptions, ): string { - let output = ""; + let output = ''; const problems = analysis.problems.filter( - (problem) => !ignoreRules || !ignoreRules.includes(problemFlags[problem.kind]), + (problem) => + !ignoreRules || !ignoreRules.includes(problemFlags[problem.kind]), ); // sort resolutions with required (impacts result) first and ignored after - const requiredResolutions = allResolutionKinds.filter((kind) => !ignoreResolutions.includes(kind)); - const ignoredResolutions = allResolutionKinds.filter((kind) => ignoreResolutions.includes(kind)); + const requiredResolutions = allResolutionKinds.filter( + (kind) => !ignoreResolutions.includes(kind), + ); + const ignoredResolutions = allResolutionKinds.filter((kind) => + ignoreResolutions.includes(kind), + ); const resolutions = requiredResolutions.concat(ignoredResolutions); const entrypoints = Object.keys(analysis.entrypoints); out(`[arethetypeswrong] ${analysis.packageName} v${analysis.packageVersion}`); out(); if (Object.keys(analysis.buildTools).length) { - out("Build tools:"); + out('Build tools:'); out( Object.entries(analysis.buildTools) .map(([tool, version]) => { return `- ${tool}@${version}`; }) - .join("\n"), + .join('\n'), ); out(); } if (ignoreRules && ignoreRules.length) { - out(styleText("gray", ` (ignoring rules: ${ignoreRules.map((rule) => `'${rule}'`).join(", ")})\n`)); + out( + styleText( + 'gray', + ` (ignoring rules: ${ignoreRules.map((rule) => `'${rule}'`).join(', ')})\n`, + ), + ); } if (ignoreResolutions && ignoreResolutions.length) { out( styleText( - "gray", - ` (ignoring resolutions: ${ignoreResolutions.map((resolution) => `'${resolution}'`).join(", ")})\n`, + 'gray', + ` (ignoring resolutions: ${ignoreResolutions.map((resolution) => `'${resolution}'`).join(', ')})\n`, ), ); } if (summary) { - const defaultSummary = !emoji ? " No problems found" : " No problems found 🌟"; + const defaultSummary = !emoji + ? ' No problems found' + : ' No problems found 🌟'; const grouped = groupProblemsByKind(problems); const summaryTexts = Object.entries(grouped).map(([kind, kindProblems]) => { const info = problemKindInfo[kind as core.ProblemKind]; const affectsRequiredResolution = kindProblems.some((p) => - requiredResolutions.some((r) => problemAffectsResolutionKind(p, r, analysis)) + requiredResolutions.some((r) => + problemAffectsResolutionKind(p, r, analysis), + ), ); let description = `${info.description}${ - info.details ? ` Use \`-f json\` to see ${info.details}.` : "" + info.details ? ` Use \`-f json\` to see ${info.details}.` : '' } ${info.docsUrl}`; // Simple markdown replacement for terminal readability description = description // Inline code blocks (e.g., `code`) -> highlighted code - .replace(/`([^`]+)`/g, (_: string, code: string) => styleText("cyan", code)) + .replace(/`([^`]+)`/g, (_: string, code: string) => + styleText('cyan', code), + ) // Links (e.g., [text](url)) -> text (url) // Using negative lookbehind to avoid matching ANSI escape sequences like \x1b[36m .replace( // rslint-disable-next-line no-control-regex /(? - `${styleText("bold", text)} (${styleText("blue", styleText("underline", url))})`, + `${styleText('bold', text)} (${styleText('blue', styleText('underline', url))})`, ); - return `${affectsRequiredResolution ? "" : "(ignored per resolution) "}${ - emoji ? `${info.emoji} ` : "" + return `${affectsRequiredResolution ? '' : '(ignored per resolution) '}${ + emoji ? `${info.emoji} ` : '' }${description}\n\n`; }); - out(summaryTexts.join("") || defaultSummary); + out(summaryTexts.join('') || defaultSummary); } const entrypointNames = entrypoints.map( - (s) => `"${s === "." ? analysis.packageName : `${analysis.packageName}/${s.substring(2)}`}"`, + (s) => + `"${s === '.' ? analysis.packageName : `${analysis.packageName}/${s.substring(2)}`}"`, ); const entrypointHeaders = entrypoints.map((s, i) => { - const hasProblems = problems.some((p) => problemAffectsEntrypoint(p, s, analysis)); - return styleText("bold", styleText(hasProblems ? "redBright" : "greenBright", entrypointNames[i])); + const hasProblems = problems.some((p) => + problemAffectsEntrypoint(p, s, analysis), + ); + return styleText( + 'bold', + styleText(hasProblems ? 'redBright' : 'greenBright', entrypointNames[i]), + ); }); - const getCellContents = (subpath: string, resolutionKind: core.ResolutionKind) => { - const ignoredPrefix = ignoreResolutions.includes(resolutionKind) ? "(ignored) " : ""; + const getCellContents = ( + subpath: string, + resolutionKind: core.ResolutionKind, + ) => { + const ignoredPrefix = ignoreResolutions.includes(resolutionKind) + ? '(ignored) ' + : ''; const problemsForCell = groupProblemsByKind( - filterProblems(problems, analysis, { entrypoint: subpath, resolutionKind }), + filterProblems(problems, analysis, { + entrypoint: subpath, + resolutionKind, + }), ); - const entrypoint = analysis.entrypoints[subpath].resolutions[resolutionKind]; + const entrypoint = + analysis.entrypoints[subpath].resolutions[resolutionKind]; const resolution = entrypoint.resolution; const kinds = Object.keys(problemsForCell) as core.ProblemKind[]; if (kinds.length) { return kinds .map( (kind) => - ignoredPrefix + (emoji ? `${problemKindInfo[kind].emoji} ` : "") + problemKindInfo[kind].shortDescription, + ignoredPrefix + + (emoji ? `${problemKindInfo[kind].emoji} ` : '') + + problemKindInfo[kind].shortDescription, ) - .join("\n"); + .join('\n'); } - const jsonResult = !emoji ? "OK (JSON)" : "🟢 (JSON)"; + const jsonResult = !emoji ? 'OK (JSON)' : '🟢 (JSON)'; const moduleResult = entrypoint.isWildcard - ? "(wildcard)" - : (!emoji ? "OK " : "🟢 ") - + moduleKinds[ - analysis.programInfo[getResolutionOption(resolutionKind)].moduleKinds?.[resolution?.fileName ?? ""] - ?.detectedKind || "" + ? '(wildcard)' + : (!emoji ? 'OK ' : '🟢 ') + + moduleKinds[ + analysis.programInfo[getResolutionOption(resolutionKind)] + .moduleKinds?.[resolution?.fileName ?? '']?.detectedKind || '' ]; return ignoredPrefix + (resolution?.isJson ? jsonResult : moduleResult); }; const table = new Table({ - head: ["", ...entrypointHeaders], + head: ['', ...entrypointHeaders], }); resolutions.forEach((kind) => { - table.push([resolutionKinds[kind], ...entrypoints.map((entrypoint) => getCellContents(entrypoint, kind))]); + table.push([ + resolutionKinds[kind], + ...entrypoints.map((entrypoint) => getCellContents(entrypoint, kind)), + ]); }); out(table.toString()); return output.trimEnd(); - function out(s = "") { - output += s + "\n"; + function out(s = '') { + output += s + '\n'; } } diff --git a/src/render/untyped.ts b/src/render/untyped.ts index 18b96b6..9f0ddaf 100644 --- a/src/render/untyped.ts +++ b/src/render/untyped.ts @@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import type { UntypedResult } from "@arethetypeswrong/core"; +import type { UntypedResult } from '@arethetypeswrong/core'; export function renderUntyped(analysis: UntypedResult): string { return `[arethetypeswrong] Package ${analysis.packageName}@${analysis.packageVersion} does not contain types.`; diff --git a/test/basic/index.test.ts b/test/basic/index.test.ts index 0f7b8e2..4a84ac9 100644 --- a/test/basic/index.test.ts +++ b/test/basic/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-basic-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-basic-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-basic-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-basic-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-basic-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-basic-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/build-tools/index.test.ts b/test/build-tools/index.test.ts index 853207f..6eb29a4 100644 --- a/test/build-tools/index.test.ts +++ b/test/build-tools/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-build-tools-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-build-tools-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-build-tools-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-build-tools-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-build-tools-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-build-tools-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/cjs-only-exports-default/index.test.ts b/test/cjs-only-exports-default/index.test.ts index 0461c11..3143287 100644 --- a/test/cjs-only-exports-default/index.test.ts +++ b/test/cjs-only-exports-default/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should pass when no issues found", async () => { +test('should pass when no issues found', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,89 +19,110 @@ test("should pass when no issues found", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-cjs-only-exports-default-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-cjs-only-exports-default-0.0.0.tgz'), + ), + ).toBeFalsy(); }); -test("should be able to ignore resolution node16-esm and bundler", async () => { +test('should be able to ignore resolution node16-esm and bundler', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "bundler", - "node16-esm", - ], + ignoreResolutions: ['bundler', 'node16-esm'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-cjs-only-exports-default-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-cjs-only-exports-default-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should be able to ignore rule cjs-only-exports-default", async () => { +test('should be able to ignore rule cjs-only-exports-default', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "cjs-only-exports-default", - ], + ignoreRules: ['cjs-only-exports-default'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-cjs-only-exports-default-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-cjs-only-exports-default-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -113,13 +134,17 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-cjs-only-exports-default-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-cjs-only-exports-default-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); diff --git a/test/cjs-only-exports-default/package.json b/test/cjs-only-exports-default/package.json index aef3182..0443322 100644 --- a/test/cjs-only-exports-default/package.json +++ b/test/cjs-only-exports-default/package.json @@ -3,12 +3,12 @@ "version": "0.0.0", "private": true, "type": "commonjs", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { ".": { "types": "./src/index.d.ts", "default": "./src/index.js" } - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/cjs-only-exports-default/src/index.js b/test/cjs-only-exports-default/src/index.js index 25811bc..49d2361 100644 --- a/test/cjs-only-exports-default/src/index.js +++ b/test/cjs-only-exports-default/src/index.js @@ -1,4 +1,4 @@ -Object.defineProperty(exports, "__esModule", { value: true }); +Object.defineProperty(exports, '__esModule', { value: true }); exports.default = function main() { - return "hello from CommonJS"; + return 'hello from CommonJS'; }; diff --git a/test/cjs-resolves-to-esm/index.test.ts b/test/cjs-resolves-to-esm/index.test.ts index 14ec288..19012b1 100644 --- a/test/cjs-resolves-to-esm/index.test.ts +++ b/test/cjs-resolves-to-esm/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when CJS resolves to ESM", async () => { +test('should throw when CJS resolves to ESM', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -25,55 +25,71 @@ test("should throw when CJS resolves to ESM", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-cjs-resolves-to-esm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-cjs-resolves-to-esm-0.0.0.tgz'), + ), + ).toBeFalsy(); }); -test("should be able to ignore rule cjs-resolves-to-esm", async () => { +test('should be able to ignore rule cjs-resolves-to-esm', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "cjs-resolves-to-esm", - ], + ignoreRules: ['cjs-resolves-to-esm'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-cjs-resolves-to-esm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-cjs-resolves-to-esm-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -85,11 +101,15 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-cjs-resolves-to-esm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-cjs-resolves-to-esm-0.0.0.tgz'), + ), + ).toBeFalsy(); }); diff --git a/test/cjs-resolves-to-esm/package.json b/test/cjs-resolves-to-esm/package.json index b453797..61eb17e 100644 --- a/test/cjs-resolves-to-esm/package.json +++ b/test/cjs-resolves-to-esm/package.json @@ -3,12 +3,12 @@ "version": "0.0.0", "private": true, "type": "module", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { ".": { "import": "./src/index.js", "types": "./src/index.d.ts" } - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/cjs-resolves-to-esm/src/index.js b/test/cjs-resolves-to-esm/src/index.js index 35cfd74..1825726 100644 --- a/test/cjs-resolves-to-esm/src/index.js +++ b/test/cjs-resolves-to-esm/src/index.js @@ -1,5 +1,5 @@ // This is an ESM-only package -export const hello = "world"; +export const hello = 'world'; export default function main() { - return "hello from ESM"; + return 'hello from ESM'; } diff --git a/test/exports/index.test.ts b/test/exports/index.test.ts index 5c4714a..d642d8e 100644 --- a/test/exports/index.test.ts +++ b/test/exports/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-exports-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-exports-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-exports-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-exports-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-exports-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-exports-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/exports/package.json b/test/exports/package.json index 195a7dd..dc698b1 100644 --- a/test/exports/package.json +++ b/test/exports/package.json @@ -1,8 +1,8 @@ { "name": "test-exports", "version": "0.0.0", - "type": "module", "private": true, + "type": "module", "exports": { "./foo": { "types": { diff --git a/test/fallback-condition/index.test.ts b/test/fallback-condition/index.test.ts index 20209d4..64ce5d4 100644 --- a/test/fallback-condition/index.test.ts +++ b/test/fallback-condition/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should failed on fallback-condition", async () => { +test('should failed on fallback-condition', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,88 +19,104 @@ test("should failed on fallback-condition", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); }); -test("should be able to ignore resolution node16-* and bundler", async () => { +test('should be able to ignore resolution node16-* and bundler', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "node16-cjs", - "node16-esm", - "bundler", - ], + ignoreResolutions: ['node16-cjs', 'node16-esm', 'bundler'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-fallback-condition-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-fallback-condition-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should be able to ignore rule fallback-condition", async () => { +test('should be able to ignore rule fallback-condition', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "fallback-condition", - ], + ignoreRules: ['fallback-condition'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-fallback-condition-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-fallback-condition-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -112,13 +128,17 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-fallback-condition-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-fallback-condition-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); diff --git a/test/fallback-condition/package.json b/test/fallback-condition/package.json index 0605bab..d9edb6b 100644 --- a/test/fallback-condition/package.json +++ b/test/fallback-condition/package.json @@ -3,10 +3,10 @@ "version": "0.0.0", "private": true, "type": "commonjs", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { "import": "./src/index.mjs", "default": "./src/index.js" - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/fallback-condition/src/index.js b/test/fallback-condition/src/index.js index 1cbb2ff..3a8adcf 100644 --- a/test/fallback-condition/src/index.js +++ b/test/fallback-condition/src/index.js @@ -1,6 +1,6 @@ // CommonJS module that only exports default module.exports = function main() { - return "hello from CommonJS"; + return 'hello from CommonJS'; }; // No named exports provided diff --git a/test/false-cjs/index.test.ts b/test/false-cjs/index.test.ts index 3cf0973..25906d8 100644 --- a/test/false-cjs/index.test.ts +++ b/test/false-cjs/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when has false CJS", async () => { +test('should throw when has false CJS', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,87 +19,103 @@ test("should throw when has false CJS", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-false-cjs-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-false-cjs-0.0.0.tgz')), + ).toBeFalsy(); }); -test("should be able to ignore resolutions node16-esm", async () => { +test('should be able to ignore resolutions node16-esm', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "node16-esm", - ], + ignoreResolutions: ['node16-esm'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-false-cjs-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-false-cjs-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should be able to ignore rule false-cjs", async () => { +test('should be able to ignore rule false-cjs', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "false-cjs", - ], + ignoreRules: ['false-cjs'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-false-cjs-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-false-cjs-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -111,13 +127,15 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-false-cjs-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-false-cjs-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/false-cjs/package.json b/test/false-cjs/package.json index 0f225ad..497688d 100644 --- a/test/false-cjs/package.json +++ b/test/false-cjs/package.json @@ -3,13 +3,13 @@ "version": "0.0.0", "private": true, "type": "commonjs", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { ".": { "types": "./src/index.d.ts", "import": "./src/index.mjs", "require": "./src/index.js" } - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/false-cjs/src/index.js b/test/false-cjs/src/index.js index 2fbec58..a9ff975 100644 --- a/test/false-cjs/src/index.js +++ b/test/false-cjs/src/index.js @@ -1,3 +1,3 @@ module.exports = function main() { - return "hello"; + return 'hello'; }; diff --git a/test/false-cjs/src/index.mjs b/test/false-cjs/src/index.mjs index 9b8dcd4..b1d2be3 100644 --- a/test/false-cjs/src/index.mjs +++ b/test/false-cjs/src/index.mjs @@ -1,3 +1,3 @@ export default function main() { - return "hello"; + return 'hello'; } diff --git a/test/false-esm/index.test.ts b/test/false-esm/index.test.ts index 16cfb11..cb6ee1a 100644 --- a/test/false-esm/index.test.ts +++ b/test/false-esm/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when has false ESM", async () => { +test('should throw when has false ESM', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,89 +19,105 @@ test("should throw when has false ESM", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-false-esm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-false-esm-0.0.0.tgz')), + ).toBeFalsy(); }); // TODO: fix this -test("should pass when all thrown resolution is disabled", async () => { +test('should pass when all thrown resolution is disabled', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "node16-cjs", - ], + ignoreResolutions: ['node16-cjs'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-false-esm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-false-esm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should be able to ignore rule false-esm", async () => { +test('should be able to ignore rule false-esm', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "false-esm", - ], + ignoreRules: ['false-esm'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-false-esm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-false-esm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -113,13 +129,15 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-false-esm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-false-esm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/false-esm/package.json b/test/false-esm/package.json index 6967d40..6408e1a 100644 --- a/test/false-esm/package.json +++ b/test/false-esm/package.json @@ -1,15 +1,15 @@ { "name": "test-false-esm", - "type": "module", "version": "0.0.0", "private": true, - "main": "./src/index.cjs", - "types": "./src/index.d.ts", + "type": "module", "exports": { "types": "./src/index.d.ts", "import": "./src/index.mjs", "require": "./src/index.cjs" }, + "main": "./src/index.cjs", + "types": "./src/index.d.ts", "files": [ "src/*" ] diff --git a/test/false-export-default/index.test.ts b/test/false-export-default/index.test.ts index 6160687..7d9aece 100644 --- a/test/false-export-default/index.test.ts +++ b/test/false-export-default/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when false export default", async () => { +test('should throw when false export default', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,58 +19,72 @@ test("should throw when false export default", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-false-export-default-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-false-export-default-0.0.0.tgz'), + ), + ).toBeFalsy(); }); -test("should be able to ignore rule false-export-default", async () => { +test('should be able to ignore rule false-export-default', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "false-export-default", - ], + ignoreRules: ['false-export-default'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).toBeCalled(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); expect( - existsSync(path.join(import.meta.dirname, "test-false-export-default-0.0.0.tgz")), + existsSync( + path.join(import.meta.dirname, 'test-false-export-default-0.0.0.tgz'), + ), ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -82,7 +96,7 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); @@ -90,7 +104,7 @@ test("should not throw when enable: false", async () => { expect( existsSync( - path.join(import.meta.dirname, "test-false-export-default-0.0.0.tgz"), + path.join(import.meta.dirname, 'test-false-export-default-0.0.0.tgz'), ), ).toBeFalsy(); diff --git a/test/false-export-default/package.json b/test/false-export-default/package.json index 2cea221..74fb256 100644 --- a/test/false-export-default/package.json +++ b/test/false-export-default/package.json @@ -3,12 +3,12 @@ "version": "0.0.0", "private": true, "type": "commonjs", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { ".": { "types": "./src/index.d.ts", "default": "./src/index.js" } - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/false-export-default/src/index.js b/test/false-export-default/src/index.js index c638c7c..e43d9b5 100644 --- a/test/false-export-default/src/index.js +++ b/test/false-export-default/src/index.js @@ -1,7 +1,7 @@ // CommonJS module that uses module.exports module.exports = { - hello: "world", - greet: function(name) { + hello: 'world', + greet: function (name) { return `Hello, ${name}!`; }, }; diff --git a/test/internal-resolution-error/index.test.ts b/test/internal-resolution-error/index.test.ts index d3c659d..0919d7f 100644 --- a/test/internal-resolution-error/index.test.ts +++ b/test/internal-resolution-error/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when have internal resolution error", async () => { +test('should throw when have internal resolution error', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,89 +19,119 @@ test("should throw when have internal resolution error", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-internal-resolution-error-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join( + import.meta.dirname, + 'test-internal-resolution-error-0.0.0.tgz', + ), + ), + ).toBeFalsy(); }); -test("should be able to ignore resolution node16-*", async () => { +test('should be able to ignore resolution node16-*', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "node16-cjs", - "node16-esm", - ], + ignoreResolutions: ['node16-cjs', 'node16-esm'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-internal-resolution-error-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join( + import.meta.dirname, + 'test-internal-resolution-error-0.0.0.tgz', + ), + ), + ).toBeFalsy(); await close(); }); -test("should be able to ignore rule internal-resolution-error", async () => { +test('should be able to ignore rule internal-resolution-error', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "internal-resolution-error", - ], + ignoreRules: ['internal-resolution-error'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-internal-resolution-error-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join( + import.meta.dirname, + 'test-internal-resolution-error-0.0.0.tgz', + ), + ), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -113,13 +143,20 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-internal-resolution-error-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join( + import.meta.dirname, + 'test-internal-resolution-error-0.0.0.tgz', + ), + ), + ).toBeFalsy(); await close(); }); diff --git a/test/internal-resolution-error/package.json b/test/internal-resolution-error/package.json index 81a55ae..ff7f49b 100644 --- a/test/internal-resolution-error/package.json +++ b/test/internal-resolution-error/package.json @@ -3,8 +3,6 @@ "version": "0.0.0", "private": true, "type": "module", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { ".": { "types": { @@ -13,5 +11,7 @@ }, "import": "./src/index.js" } - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/internal-resolution-error/src/index.d.cts b/test/internal-resolution-error/src/index.d.cts index 01bba92..5c1e8e2 100644 --- a/test/internal-resolution-error/src/index.d.cts +++ b/test/internal-resolution-error/src/index.d.cts @@ -1 +1 @@ -import {} from "./types"; +import {} from './types'; diff --git a/test/internal-resolution-error/src/index.d.ts b/test/internal-resolution-error/src/index.d.ts index 2f5a6e2..447e853 100644 --- a/test/internal-resolution-error/src/index.d.ts +++ b/test/internal-resolution-error/src/index.d.ts @@ -1,3 +1,3 @@ -import {} from "./types"; +import {} from './types'; -export default function(): number; +export default function (): number; diff --git a/test/missing-export-equals/index.test.ts b/test/missing-export-equals/index.test.ts index 8376427..82ec22f 100644 --- a/test/missing-export-equals/index.test.ts +++ b/test/missing-export-equals/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when missing export =", async () => { +test('should throw when missing export =', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,22 +19,32 @@ test("should throw when missing export =", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-missing-export-equals-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-missing-export-equals-0.0.0.tgz'), + ), + ).toBeFalsy(); }); -test("should be able to ignore resolution node16-*, node10, bundler", async () => { +test('should be able to ignore resolution node16-*, node10, bundler', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -42,10 +52,10 @@ test("should be able to ignore resolution node16-*, node10, bundler", async () = pluginAreTheTypesWrong({ areTheTypesWrongOptions: { ignoreResolutions: [ - "node16-cjs", - "node16-esm", - "node10", - "bundler", + 'node16-cjs', + 'node16-esm', + 'node10', + 'bundler', ], }, }), @@ -53,57 +63,71 @@ test("should be able to ignore resolution node16-*, node10, bundler", async () = }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-missing-export-equals-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-missing-export-equals-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should be able to ignore rule missing-export-equals", async () => { +test('should be able to ignore rule missing-export-equals', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "missing-export-equals", - ], + ignoreRules: ['missing-export-equals'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-missing-export-equals-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-missing-export-equals-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -115,13 +139,17 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-missing-export-equals-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-missing-export-equals-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); diff --git a/test/missing-export-equals/package.json b/test/missing-export-equals/package.json index 0c86ad9..ca2a84c 100644 --- a/test/missing-export-equals/package.json +++ b/test/missing-export-equals/package.json @@ -3,12 +3,12 @@ "version": "0.0.0", "private": true, "type": "commonjs", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { ".": { "types": "./src/index.d.ts", "default": "./src/index.js" } - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/missing-export-equals/src/index.d.ts b/test/missing-export-equals/src/index.d.ts index c8cbd45..db74d32 100644 --- a/test/missing-export-equals/src/index.d.ts +++ b/test/missing-export-equals/src/index.d.ts @@ -1 +1 @@ -export default function(): number; +export default function (): number; diff --git a/test/named-exports/index.test.ts b/test/named-exports/index.test.ts index 82449ed..7e85bf2 100644 --- a/test/named-exports/index.test.ts +++ b/test/named-exports/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should detect fallback condition usage", async () => { +test('should detect fallback condition usage', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,88 +19,104 @@ test("should detect fallback condition usage", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-named-exports-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-named-exports-0.0.0.tgz')), + ).toBeFalsy(); }); -test("should be able to ignore resolution node16-esm", async () => { +test('should be able to ignore resolution node16-esm', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "node16-esm", - ], + ignoreResolutions: ['node16-esm'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-named-exports-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-named-exports-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should be able to ignore rule named-exports", async () => { +test('should be able to ignore rule named-exports', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "named-exports", - ], + ignoreRules: ['named-exports'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-named-exports-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-named-exports-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -112,13 +128,15 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-named-exports-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-named-exports-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/named-exports/package.json b/test/named-exports/package.json index fc30cc9..e3d7f51 100644 --- a/test/named-exports/package.json +++ b/test/named-exports/package.json @@ -3,12 +3,12 @@ "version": "0.0.0", "private": true, "type": "commonjs", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { ".": { "types": "./src/index.d.ts", "default": "./src/index.js" } - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/named-exports/src/index.js b/test/named-exports/src/index.js index 3249112..30f8cbc 100644 --- a/test/named-exports/src/index.js +++ b/test/named-exports/src/index.js @@ -1,5 +1,5 @@ // CommonJS module module.exports = { - hello: "world", - version: "1.0.0", + hello: 'world', + version: '1.0.0', }; diff --git a/test/no-resolution/index.test.ts b/test/no-resolution/index.test.ts index 8a7cd3f..2e5d898 100644 --- a/test/no-resolution/index.test.ts +++ b/test/no-resolution/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when cannot resolve types", async () => { +test('should throw when cannot resolve types', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,87 +19,104 @@ test("should throw when cannot resolve types", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-no-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-no-resolution-0.0.0.tgz')), + ).toBeFalsy(); }); -test("should be able to ignore resolution", async () => { +test('should be able to ignore resolution', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "node16-cjs", - "node16-esm", - ], + ignoreResolutions: ['node16-cjs', 'node16-esm'], }, }), ], }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-no-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-no-resolution-0.0.0.tgz')), + ).toBeFalsy(); }); -test("should not throw when no-resolution is ignored", async () => { +test('should not throw when no-resolution is ignored', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "no-resolution", - ], + ignoreRules: ['no-resolution'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-no-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-no-resolution-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -111,13 +128,15 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-no-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-no-resolution-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/npm/index.test.ts b/test/npm/index.test.ts index 95a6924..a380cc7 100644 --- a/test/npm/index.test.ts +++ b/test/npm/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-npm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-npm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-npm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-npm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-npm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-npm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/pnpm-workspace/index.test.ts b/test/pnpm-workspace/index.test.ts index de90ac4..3745974 100644 --- a/test/pnpm-workspace/index.test.ts +++ b/test/pnpm-workspace/index.test.ts @@ -1,96 +1,118 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ - cwd: path.join(import.meta.dirname, "foo"), + cwd: path.join(import.meta.dirname, 'foo'), rsbuildConfig: { plugins: [pluginAreTheTypesWrong()], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-pnpm-foo-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-pnpm-foo-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ - cwd: path.join(import.meta.dirname, "foo"), + cwd: path.join(import.meta.dirname, 'foo'), rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-pnpm-foo-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-pnpm-foo-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ - cwd: path.join(import.meta.dirname, "foo"), + cwd: path.join(import.meta.dirname, 'foo'), rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-pnpm-foo-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-pnpm-foo-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/pnpm/index.test.ts b/test/pnpm/index.test.ts index 981569f..4edb951 100644 --- a/test/pnpm/index.test.ts +++ b/test/pnpm/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-pnpm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-pnpm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-pnpm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-pnpm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-pnpm-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-pnpm-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/unexpected-module-syntax/index.test.ts b/test/unexpected-module-syntax/index.test.ts index e21d5a2..8d3ce01 100644 --- a/test/unexpected-module-syntax/index.test.ts +++ b/test/unexpected-module-syntax/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when have unexpected module syntax", async () => { +test('should throw when have unexpected module syntax', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,89 +19,110 @@ test("should throw when have unexpected module syntax", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-unexpected-module-syntax-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-unexpected-module-syntax-0.0.0.tgz'), + ), + ).toBeFalsy(); }); -test("should be able to ignore resolution node16-*", async () => { +test('should be able to ignore resolution node16-*', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "node16-cjs", - "node16-esm", - ], + ignoreResolutions: ['node16-cjs', 'node16-esm'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-unexpected-module-syntax-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-unexpected-module-syntax-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should be able to ignore rule unexpected-module-syntax", async () => { +test('should be able to ignore rule unexpected-module-syntax', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "unexpected-module-syntax", - ], + ignoreRules: ['unexpected-module-syntax'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-unexpected-module-syntax-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-unexpected-module-syntax-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -113,13 +134,17 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-unexpected-module-syntax-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-unexpected-module-syntax-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); diff --git a/test/unexpected-module-syntax/package.json b/test/unexpected-module-syntax/package.json index 7867b0b..4449a60 100644 --- a/test/unexpected-module-syntax/package.json +++ b/test/unexpected-module-syntax/package.json @@ -3,12 +3,12 @@ "version": "0.0.0", "private": true, "type": "commonjs", - "main": "./src/index.js", - "types": "./src/index.d.ts", "exports": { ".": { "types": "./src/index.d.ts", "default": "./src/index.js" } - } + }, + "main": "./src/index.js", + "types": "./src/index.d.ts" } diff --git a/test/unexpected-module-syntax/src/index.js b/test/unexpected-module-syntax/src/index.js index 1e29c45..35f468b 100644 --- a/test/unexpected-module-syntax/src/index.js +++ b/test/unexpected-module-syntax/src/index.js @@ -1 +1 @@ -export const hello = "world"; +export const hello = 'world'; diff --git a/test/untyped-resolution/index.test.ts b/test/untyped-resolution/index.test.ts index 1dc94cc..2821740 100644 --- a/test/untyped-resolution/index.test.ts +++ b/test/untyped-resolution/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when does resolve to types", async () => { +test('should throw when does resolve to types', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,122 +19,153 @@ test("should throw when does resolve to types", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-untyped-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-untyped-resolution-0.0.0.tgz'), + ), + ).toBeFalsy(); }); -test("should pass when all thrown resolution is disabled", async () => { +test('should pass when all thrown resolution is disabled', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - ignoreResolutions: [ - "bundler", - "node16-cjs", - "node16-esm", - ], - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + ignoreResolutions: ['bundler', 'node16-cjs', 'node16-esm'], + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-untyped-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-untyped-resolution-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); -test("should be able to ignore resolution", async () => { +test('should be able to ignore resolution', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreResolutions: [ - "node16-cjs", - "node16-esm", - ], + ignoreResolutions: ['node16-cjs', 'node16-esm'], }, }), ], }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-untyped-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-untyped-resolution-0.0.0.tgz'), + ), + ).toBeFalsy(); }); -test("should be able to ignore rule untyped-resolution", async () => { +test('should be able to ignore rule untyped-resolution', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { plugins: [ pluginAreTheTypesWrong({ areTheTypesWrongOptions: { - ignoreRules: [ - "untyped-resolution", - ], + ignoreRules: ['untyped-resolution'], }, }), ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-untyped-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-untyped-resolution-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); - expect(existsSync(path.join(import.meta.dirname, "test-no-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-no-resolution-0.0.0.tgz')), + ).toBeFalsy(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -146,13 +177,17 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-untyped-resolution-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync( + path.join(import.meta.dirname, 'test-untyped-resolution-0.0.0.tgz'), + ), + ).toBeFalsy(); await close(); }); diff --git a/test/untyped-resolution/package.json b/test/untyped-resolution/package.json index 945b68d..6d4614f 100644 --- a/test/untyped-resolution/package.json +++ b/test/untyped-resolution/package.json @@ -1,14 +1,14 @@ { "name": "test-untyped-resolution", - "type": "module", "version": "0.0.0", "private": true, - "main": "./src/index.cjs", - "types": "./src/index.d.ts", + "type": "module", "exports": { "import": "./src/index.mjs", "require": "./src/index.cjs" }, + "main": "./src/index.cjs", + "types": "./src/index.d.ts", "files": [ "src/*" ] diff --git a/test/untyped/index.test.ts b/test/untyped/index.test.ts index 3f4a906..0088896 100644 --- a/test/untyped/index.test.ts +++ b/test/untyped/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should throw when does not contain types", async () => { +test('should throw when does not contain types', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,22 +19,30 @@ test("should throw when does not contain types", async () => { }, }); - const error = rs.spyOn(logger, "error"); + const error = rs.spyOn(logger, 'error'); - await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: arethetypeswrong failed!]`); + await expect(rsbuild.build()).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: arethetypeswrong failed!]`, + ); expect( - error.mock.calls.flatMap(call => + error.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-untyped-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-untyped-0.0.0.tgz')), + ).toBeFalsy(); }); -test("should not throw when enable: false", async () => { +test('should not throw when enable: false', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -46,13 +54,15 @@ test("should not throw when enable: false", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect(success).not.toBeCalled(); - expect(existsSync(path.join(import.meta.dirname, "test-untyped-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-untyped-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/untyped/package.json b/test/untyped/package.json index ec435f5..4c9b6b0 100644 --- a/test/untyped/package.json +++ b/test/untyped/package.json @@ -1,8 +1,8 @@ { "name": "test-untyped", - "type": "module", "version": "0.0.0", "private": true, + "type": "module", "files": [ "src/*" ] diff --git a/test/wildcard/index.test.ts b/test/wildcard/index.test.ts index 15fae27..943cbba 100644 --- a/test/wildcard/index.test.ts +++ b/test/wildcard/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-wildcard-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-wildcard-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-wildcard-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-wildcard-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-wildcard-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-wildcard-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/wildcard/package.json b/test/wildcard/package.json index 6c6d1c4..d163a1f 100644 --- a/test/wildcard/package.json +++ b/test/wildcard/package.json @@ -1,8 +1,8 @@ { "name": "test-wildcard", "version": "0.0.0", - "type": "module", "private": true, + "type": "module", "exports": { "./*": { "types": { diff --git a/test/with-scope/index.test.ts b/test/with-scope/index.test.ts index 86da6af..63030a6 100644 --- a/test/with-scope/index.test.ts +++ b/test/with-scope/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "foo-test-bar-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'foo-test-bar-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "foo-test-bar-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'foo-test-bar-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "@foo/test-bar-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, '@foo/test-bar-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/yarn-berry/index.test.ts b/test/yarn-berry/index.test.ts index eaec049..385bdfa 100644 --- a/test/yarn-berry/index.test.ts +++ b/test/yarn-berry/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-yarn-berry-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-yarn-berry-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-yarn-berry-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-yarn-berry-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-yarn-berry-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-yarn-berry-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/test/yarn/index.test.ts b/test/yarn/index.test.ts index a2bfbb7..0622825 100644 --- a/test/yarn/index.test.ts +++ b/test/yarn/index.test.ts @@ -1,17 +1,17 @@ -import { existsSync } from "node:fs"; -import path from "node:path"; -import { stripVTControlCharacters } from "node:util"; +import { existsSync } from 'node:fs'; +import path from 'node:path'; +import { stripVTControlCharacters } from 'node:util'; -import { createRsbuild, logger } from "@rsbuild/core"; -import { beforeEach, expect, rs, test } from "@rstest/core"; +import { createRsbuild, logger } from '@rsbuild/core'; +import { beforeEach, expect, rs, test } from 'rstack/test'; -import { pluginAreTheTypesWrong } from "../../src"; +import { pluginAreTheTypesWrong } from '../../src'; beforeEach(() => { rs.restoreAllMocks(); }); -test("should run arethetypeswrong as expected", async () => { +test('should run arethetypeswrong as expected', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { @@ -19,78 +19,100 @@ test("should run arethetypeswrong as expected", async () => { }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-yarn-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-yarn-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without emoji", async () => { +test('should run arethetypeswrong without emoji', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-yarn-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-yarn-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); -test("should run arethetypeswrong without summary", async () => { +test('should run arethetypeswrong without summary', async () => { const rsbuild = await createRsbuild({ cwd: import.meta.dirname, rsbuildConfig: { - plugins: [pluginAreTheTypesWrong({ - areTheTypesWrongOptions: { - emoji: false, - summary: false, - }, - })], + plugins: [ + pluginAreTheTypesWrong({ + areTheTypesWrongOptions: { + emoji: false, + summary: false, + }, + }), + ], }, }); - const success = rs.spyOn(logger, "success"); + const success = rs.spyOn(logger, 'success'); const { close } = await rsbuild.build(); expect( - success.mock.calls.flatMap(call => + success.mock.calls.flatMap((call) => call - .filter(message => typeof message === "string" && message.includes("[arethetypeswrong]")) - .map(stripVTControlCharacters) + .filter( + (message) => + typeof message === 'string' && + message.includes('[arethetypeswrong]'), + ) + .map(stripVTControlCharacters), ), ).toMatchSnapshot(); - expect(existsSync(path.join(import.meta.dirname, "test-yarn-0.0.0.tgz"))).toBeFalsy(); + expect( + existsSync(path.join(import.meta.dirname, 'test-yarn-0.0.0.tgz')), + ).toBeFalsy(); await close(); }); diff --git a/tsconfig.json b/tsconfig.json index e2733ae..ce86842 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "skipLibCheck": true, "resolveJsonModule": true, "erasableSyntaxOnly": true, - "verbatimModuleSyntax": true, + "verbatimModuleSyntax": true }, - "include": ["src"], + "include": ["src"] }