From 4ac9da965e06404f4922feb8e1d9bd748ee3ac82 Mon Sep 17 00:00:00 2001 From: Aleksei Potsetsuev Date: Fri, 11 Oct 2024 00:58:56 +0800 Subject: [PATCH 1/3] fix: yarn pnpm resolving --- src/binary-finder.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/binary-finder.ts b/src/binary-finder.ts index 08a09c08..9ff0f613 100644 --- a/src/binary-finder.ts +++ b/src/binary-finder.ts @@ -176,7 +176,7 @@ const yarnPnpStrategy: LocatorStrategy = { name: "Yarn Plug'n'Play", find: async (path: Uri): Promise => { for (const extension of ["cjs", "js"]) { - const yarnPnpFile = Uri.file(`${path}/.pnp.${extension}`); + const yarnPnpFile = Uri.joinPath(path, `.pnp.${extension}`); if (!(await fileExists(yarnPnpFile))) { continue; @@ -194,9 +194,11 @@ const yarnPnpStrategy: LocatorStrategy = { continue; } - return yarnPnpApi.resolveRequest( - `${platformSpecificNodePackageName}/${platformSpecificBinaryName}`, - biomePackage, + return Uri.file( + yarnPnpApi.resolveRequest( + `${platformSpecificNodePackageName}/${platformSpecificBinaryName}`, + biomePackage, + ) as string, ); } catch { return undefined; From a84eaa4160ea004f1e6a6e3024c611f05dcef8fd Mon Sep 17 00:00:00 2001 From: Aleksei Potsetsuev Date: Fri, 11 Oct 2024 00:59:43 +0800 Subject: [PATCH 2/3] fix: use local biome command for pre-commit --- lefthook.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lefthook.yaml b/lefthook.yaml index cb23b3ec..3526145d 100644 --- a/lefthook.yaml +++ b/lefthook.yaml @@ -2,4 +2,4 @@ pre-commit: commands: check: glob: "*.{js,ts,json}" - run: biome check --apply {staged_files} && git add {staged_files} + run: pnpm biome check --apply {staged_files} && git add {staged_files} From e52b631459ae61b46bf6d3235c850d1af4424d69 Mon Sep 17 00:00:00 2001 From: Aleksei Potsetsuev Date: Fri, 11 Oct 2024 01:21:54 +0800 Subject: [PATCH 3/3] chore: add yarn pnp workspace launch configuration --- .vscode/launch.json | 14 ++++++++++++++ test/fixtures/yarn-pnp/.gitignore | 13 +++++++++++++ test/fixtures/yarn-pnp/README.md | 17 +++++++++++++++++ test/fixtures/yarn-pnp/biome.json | 1 + test/fixtures/yarn-pnp/index.js | 1 + test/fixtures/yarn-pnp/package.json | 8 ++++++++ test/fixtures/yarn-pnp/yarn.lock | 0 7 files changed, 54 insertions(+) create mode 100644 test/fixtures/yarn-pnp/.gitignore create mode 100644 test/fixtures/yarn-pnp/README.md create mode 100644 test/fixtures/yarn-pnp/biome.json create mode 100644 test/fixtures/yarn-pnp/index.js create mode 100644 test/fixtures/yarn-pnp/package.json create mode 100644 test/fixtures/yarn-pnp/yarn.lock diff --git a/.vscode/launch.json b/.vscode/launch.json index fd47c7c6..3c3e65a5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -83,6 +83,20 @@ "outFiles": ["${workspaceFolder}/out/**/*.js"], "preLaunchTask": "npm: dev", "sourceMapRenames": true + }, + { + "name": "🧩 Debug Extension (yarn pnp)", + "type": "extensionHost", + "request": "launch", + "args": [ + "--disable-extensions", + "--extensionDevelopmentKind=node", + "--extensionDevelopmentPath=${workspaceFolder}", + "${workspaceFolder}/test/fixtures/yarn-pnp" + ], + "outFiles": ["${workspaceFolder}/out/**/*.js"], + "preLaunchTask": "npm: dev", + "sourceMapRenames": true } ] } diff --git a/test/fixtures/yarn-pnp/.gitignore b/test/fixtures/yarn-pnp/.gitignore new file mode 100644 index 00000000..870eb6a5 --- /dev/null +++ b/test/fixtures/yarn-pnp/.gitignore @@ -0,0 +1,13 @@ +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +# Swap the comments on the following lines if you wish to use zero-installs +# In that case, don't forget to run `yarn config set enableGlobalCache false`! +# Documentation here: https://yarnpkg.com/features/caching#zero-installs + +#!.yarn/cache +.pnp.* diff --git a/test/fixtures/yarn-pnp/README.md b/test/fixtures/yarn-pnp/README.md new file mode 100644 index 00000000..d4f332de --- /dev/null +++ b/test/fixtures/yarn-pnp/README.md @@ -0,0 +1,17 @@ +# Yarn PnP + +This folder contains an example single-root workspace used as a test fixture for +the Biome extension. The workspace folder is setup as a yarn pnp project. + +## Expectations + +When the workspace folder is opened in VS Code, the Biome extension should be active +and used the `biome.json` configuration file at the root of the workspace folder. + +## Test protocol + +1. Open the workspace in VS Code. +2. Run command `yarn` +3. Open the `index.js` file. +4. Run the `Format Document with...` command, and select the Biome extension. +5. Verify that the document gets formatted with `indentWidth` set to `2`. and `indentStyle` set to `space`. \ No newline at end of file diff --git a/test/fixtures/yarn-pnp/biome.json b/test/fixtures/yarn-pnp/biome.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/test/fixtures/yarn-pnp/biome.json @@ -0,0 +1 @@ +{} diff --git a/test/fixtures/yarn-pnp/index.js b/test/fixtures/yarn-pnp/index.js new file mode 100644 index 00000000..54b82a09 --- /dev/null +++ b/test/fixtures/yarn-pnp/index.js @@ -0,0 +1 @@ +const a = 1; diff --git a/test/fixtures/yarn-pnp/package.json b/test/fixtures/yarn-pnp/package.json new file mode 100644 index 00000000..a2b4d8f5 --- /dev/null +++ b/test/fixtures/yarn-pnp/package.json @@ -0,0 +1,8 @@ +{ + "name": "foo", + "version": "0.0.0", + "packageManager": "yarn@4.5.0", + "devDependencies": { + "@biomejs/biome": "1.8.3" + } +} diff --git a/test/fixtures/yarn-pnp/yarn.lock b/test/fixtures/yarn-pnp/yarn.lock new file mode 100644 index 00000000..e69de29b