Repository navigation
Conversation
`lintedPath` normalizes the linted file to `/`, but a path the plugin resolves itself does not: `sourceImport` answers with `path.resolve`'s separators, and `startupEntries` took its root as given. `path.posix.relative` on a Windows path then names the whole absolute one (`../D:\...\src\index.ts`) instead of the relative path, so every rule that compares a resolved import with the repository root saw a path that matches nothing. On Windows that made 13 checks in `family-facts.test.ts` fail, and `npm run lint` reported the checkout's own facts modules as importing behaviour, because `startupsOf` could not see `tsup.config.ts` and threw. Normalize at the two points that produce a path, as `lintedPath` already did. Fixes the Windows half of the repository checks reported in Tencent#1889.
|
Companion to this one: #2009 fixes the same class of Windows path defect in the places this PR's normalization does not reach - the walk up stops at a drive, and specifiers resolve without consulting the cwd. With both applied |
XY-code1
left a comment
There was a problem hiding this comment.
This appears to overlap with #1927 around Windows path normalization in family-facts.js. The two PRs normalize paths at different layers (sourceImport/shared helpers versus local repoRelative handling).
Could a maintainer confirm which normalization boundary is preferred, and whether the regression cases from the other PR should be retained?
|
Fair question. Here is the overlap precisely, so a maintainer can decide with the diffs in front of them. #1927 (embrace897) changes one file: This PR changes three, and the normalisation sits one layer below the rule:
Measured with the repo's own family-facts suite on Windows: 13/35 passing before, 35/35 after, and the So: #1927 fixes the symptom in the one rule; this one puts the normalisation in the layer both rules read. If you would rather keep the focused fix, I can close this and carry only the |
Problem
lintedPathnormalizes the linted file to/, but a path the plugin resolves itself does not:sourceImportreturnspath.resolve's separators, so on Windows it isD:\...\src\index.ts;startupEntries(root)took its root as given, so a caller passing a native path (startupEntries(REPO)in the test,path.resolvein a caller) hands it a Windows path too.path.posix.relativeon two such strings does not answer with the relative path - it names the whole absolute one:Every rule that compares a resolved import with the repository root therefore sees a path that matches nothing.
What it breaks on Windows
npm run linton an unmodified checkout fails with 26teamai(family-facts)errors on the repository's own facts modules, andfamily-facts.test.tsfails 13 of its 35 cases - includingfinds the startup entries from the executables, the CLI and its hook and pull commands, which is the check that would catch it.startupsOfcannot seetsup.config.tsthrough the mixed path, throwsdeclares no hook-dispatch command, and oxlint reports the throw as an error on whichever file it was linting.Measured here (Windows 11, Node v24.18.0):
oxlint-plugin-teamaifamily-facts.test.tsmainThe remaining failures are other Windows-only assumptions in this suite, outside this change.
Change
toPosix()inutils.js, whichlintedPathnow uses (no behaviour change there);sourceImportanswers with/separators;startupsOfnormalizes the root it is given before using it.No rule's logic changes, and POSIX platforms are unaffected:
split('\').join('/')is the identity there.Verification
npx vitest run oxlint-plugin-teamai/rules/family-facts.test.ts-> 35 passed (13 of them failed before)npx vitest run oxlint-plugin-teamai-> 106 failed from 119, no new failure; the drop is exactly the 13 infamily-facts.test.tsnpm run lint-> nooxlint-plugin-teamai/*error (26 before, on the repository's ownpackages/tool-*/src/facts.ts)npx tsc --noEmitcleanoxlint-plugin-teamaiis lint tooling, not runtime code.Refs #1889 (the Windows half of the repository checks it reports; the docs and test-list halves there are separate).