Repository navigation
Conversation
…the cwd Two Windows defects kept most of this plugin's rules from firing at all, so `npm run lint` passed violations it reports on every other platform. `workspaceRoot` and `packageRoot` walk up with `path.posix.dirname`, which answers `.` above a drive: `C:` -> `.`. The walk treated that `.` as an ancestor, read the checkout's own package.json - the one declaring `workspaces` - and returned `"."`, so `repositoryPath()` made every file's relative path the whole absolute one and each rule's scope test failed. On Windows, 12 of the rules silently checked nothing. `path.posix.resolve(dir, specifier)` consults the process directory unless its first argument starts with `/`, and a Windows path this plugin builds (`C:/checkout/src`) does not: `mock-source` resolving `../utils/log` against it produced `/cwd/C:/checkout/src/utils/log`, so the specifier it looked up never existed. `resolveFrom()` joins and normalizes instead, and the four call sites use it. The test harness spawned the `.bin` shim with `shell: true`, which is what a `.cmd` needs on Windows: cmd.exe caps the command line, so a rule with many fixtures got back output that was not JSON and its whole suite failed. It now runs the package's own entry with this Node, no shell. With Tencent#1967 in, the suite is 1277/1277 on Windows; on this branch alone 119 failures drop to the 13 that Tencent#1967 fixes.
XY-code1
left a comment
There was a problem hiding this comment.
This PR appears to overlap substantially with #1935, #1944, and #1947:
- #1935 addresses
mock-sourcepath resolution on Windows. - #1944 runs oxlint without the Windows shell.
- #1947 stops workspace discovery at the drive root.
This PR appears to combine all three areas under one path-handling approach. Could a maintainer confirm which implementation should be kept, and whether the focused regression tests from the older PRs should be carried into this one?
|
You are right that this overlaps #1935, #1944 and #1947, and it does cover all three. The reason it is one diff rather than three is that they share a root cause the focused fixes do not reach:
Evidence, on Windows: the plugin's own suite goes from 119 failing to 13 failing on its own, and to 1277 passing with #1967 applied. That is the number that shows the rules actually run now; #1947's focused test only covers the stop at the root. If you would rather land the three focused diffs first, say so and I will close this and re-open only the |
The description documents Windows lint and plugin-test runs sufficiently for this lint-rule-only change; no real-CLI verification record is required. I did not run, build, or install PR code. |
Problem
Two defects kept most of this plugin's rules from firing at all on Windows, so
npm run lintthere passed violations it reports everywhere else.1. The walk up does not stop at a drive
workspaceRootandpackageRootclimb withpath.posix.dirname, which answers.above a drive (C:->.). The climb treated that.as an ancestor, read the checkout's ownpackage.json- the one that declaresworkspaces- and returned".".repositoryPath()then made every file's relative path the whole absolute one:so each rule's scope test (
src/**,packages/*/src/**) failed and the rule checked nothing. Measured with a fixture that must be flagged: oxlint returned{"diagnostics": []}.2.
path.posix.resolveconsults the process directorypath.posix.resolve(dir, specifier)uses the process directory unless its first argument starts with/, and a Windows path this plugin builds (C:/checkout/src) does not:mock-sourceandpackage-boundaries/tool-registrylooked up specifiers that never existed.3. The harness's
.binshim needs a shellspawnSync(OXLINT, …, { shell: process.platform === 'win32' })is what a.cmdneeds on Windows, and cmd.exe caps the command line:package-boundaries(80 fixtures) got back output that was not JSON, so its whole suite failed before any case ran.Change
isWalkEnd()stops the climb at a POSIX root or a drive..is deliberately not an end: it is the right root for a filename oxlint reports relative to its own directory, and that behaviour is unchanged.resolveFrom()joins and normalizes instead of resolving against the cwd;mock-source(2 call sites),package-boundariesandtool-registryuse it.node_modules/oxlint/bin/oxlintwithprocess.execPath, no shell, on every platform.Verification
Windows 11 / Node v24.18.0,
npx vitest run oxlint-plugin-teamai:mainThe 13 left on this branch alone are exactly the
family-factscases #1967 fixes; with it applied the suite is fully green on Windows.npm run lint: 26 errors before and after - the pre-existingteamai(family-facts)ones this checkout reports onmain, none new. The rules that now fire flagged tworequire-readable-spacingviolations in my own first draft of this patch, which I fixed rather than suppressed - a small proof that they run.npx tsc --noEmitclean.resolveFromis used by four call sites; nopath.posix.resolveis left in the plugin.isWalkEndshould also treat a UNC share (//server/share) as an end. It cannot occur here, and the walk stops at.for such a path the way it does for a relative one.Refs #1967 (the same class, in the rules' own import resolution) and #1889.