Repository navigation
test: stop tests from reaching into other packages' folders - #144
Merged
Merged
Conversation
…dency The two tests passed core's optionsParser output to fetchindex, which repeated the two tests above them with the same options. They required core's optionsParser by relative path, and fetchindex listed luxon only so that file could load. knip.jsonc no longer needs its fetchindex exception.
…re's luxon luxon reads the time through Date.now, so stubbing it in the build's child process stops core's clock without resolving core's own copy of luxon. That drops static's luxon exception from knip.jsonc, and the root's @types/luxon, which knip then reported as unused. core still lists @types/luxon, so npm run types is unchanged.
core's index.json, schedule.json and now.json snapshots, the at() and beforeEachTemplate helpers, and the scripts that refresh the snapshots move into fixtures/, published nowhere (private: true). core, newest, oldest, parsefiles, ranges, static and translate list @nodevu/fixtures as a devDependency and require it by name, so no test reaches into another package's folder. ranges' at() was core's with a default date, so the two are now one at() with that default.
…kages tools/oxlint/nodevu/ is the repo's own oxlint JS plugin. Its no-cross-package-paths rule reports require(), require.resolve(), import and export paths, written out in full, that resolve into a different package's folder than the file's own. oxlint's no-restricted-imports only checks ESM imports, so it can't do this for CommonJS. npm run lint:rules tests the rule with oxlint's RuleTester and runs as part of npm run lint. The rule found translate/examples/default.js requiring ../../ranges, which now requires @nodevu/ranges.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Brings in #143. Its type-checked tests now load the shared snapshot and helpers from @nodevu/fixtures, and the fixtures workspace is added to everything #143 checks lists every workspace in: the TypeScript project references (with its own tsconfig and committed types), Dependabot's directories, release.yml's package lists (as !fixtures, which uppt skips), a LICENSE, and CI's path filters. The docs check in test/workspaces.test.mjs no longer asks private workspaces for a docs page. package-lock.json is regenerated with npm.
Draft
botandbang
added a commit
that referenced
this pull request
Nov 11, 2026
Brings in #143 and #144's squash. The merge keeps main's tree plus this branch's change: core requires @nodevu/fetchindex, and core/util/prod/versions.js, core/test/versions.js and its generated types stay deleted. #143's new assertion in core/test/versions.js, that the newest release lists npm, v8, uv, zlib, openssl and modules, is already in fetchindex's tests. CI's path filters for core and the packages built on it include fetchindex/**, and package-lock.json is updated with npm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four commits: one per part, then the lint rule.
fetchindex no longer loads core's optionsParser
fetchindex/test/test.js. They passed core'soptionsParseroutput to fetchindex, which repeated the two tests above them with the same options: the globalfetchor undici's, and the same index URL. Core doesn't use fetchindex, so nothing else covered them.luxondevDependency. It was only there becauseoptionsParserrequires luxon and CI installs just the workspace under test.knip.jsonc.static's build test stops the clock without core's luxon
static/test/test.build.jsstubsDate.nowin the build's child process instead of settingSettings.nowon core's copy of luxon, which it found withrequire.resolve('luxon', { paths: [core] }). luxon's default clock is() => Date.now(), so core sees the same time.knip.jsonc.@types/luxonfrom the root devDependencies. Once static stopped resolving luxon, knip reported it as unused. Core lists@types/luxonitself, so it's still installed andnpm run typesproduces the same output.A private fixtures workspace holds what the tests share
Adds
fixtures/as the workspace@nodevu/fixtures, with"private": trueso it's never published (release.yml lists the published packages by name, and this isn't one of them). It holds:data/index.json,data/schedule.jsonanddata/now.json, moved fromcore/test/data/static/.index.js, which exportsat(), moved fromcore/util/dev/fixtures.js.ranges/test/fixtures.jshad its own copy that differed only by defaulting the date to 2025-09-01, soat()now takes that default and the copy is gone.ranges/test/fixtures.jskeepsversionPatternand passesatthrough.beforeEachTemplate.js, moved fromcore/util/dev/, which core's network-mocking tests use.core/util/dev/tofixtures/util/along withwrite.js.npm run test:update -w fixturesreplacesnpm run test:update -w core, and the scripts write tofixtures/data/.core/test/dev-*.jstofixtures/test/, plus one for the new default date. Its coverage is 100%.core, newest, oldest, parsefiles, ranges, static and translate list
@nodevu/fixturesas a devDependency and require it by name (@nodevu/fixtures,@nodevu/fixtures/beforeEachTemplate,@nodevu/fixtures/data/*.json). No test requires a path in another package's folder now. That includes translate's tests, which used to loadranges/test/fixtures.js.CI's changed-package filter adds
fixtures/**to every package that uses it and gives fixtures its own entry, so its tests run in the coverage matrix. The README says where the shared snapshot lives and how to refresh it.A lint rule keeps it that way
Adds
tools/oxlint/nodevu/, the repo's own oxlint JS plugin, loaded from.oxlintrc.jsonnext to the vendored anti-slop one. Itsnodevu/no-cross-package-pathsrule reports arequire(),require.resolve(),import,export ... fromorimport()whose path is written out in full and resolves into a different package's folder than the file's own. A package is the nearest folder with apackage.json, so the repo root counts as one too. Paths built at runtime, likerequire(`../build/${name}`), aren't checked. oxlint's ownno-restricted-importsonly looks at ESMimport, so it can't do this for CommonJS. eslint-plugin-import-x'sno-relative-packageswould need eslint as a peer.npm run lint:rulestests the rule with oxlint'sRuleTester(22 cases, 100% of the plugin's lines and branches under c8) and runs as part ofnpm run lint. With the rule on, putting back fetchindex's oldrequire('../../core/util/prod/optionsParser')failsoxlint. The rule also foundtranslate/examples/default.jsrequiring../../ranges, which now requires@nodevu/ranges(already a translate devDependency). The README mentions the rule.Checked with
npm run lint(oxlint with the new rule, oxfmt, docov, harden, the rule's tests, knip),npm run types(committed types unchanged),npm run coverage(100% in all 10 packages with coverage) andnpm run docs. Each package's CI test job (npm ci -w <package>thennpm run coverage -w <package>) also passes on its own in a clean copy, fixtures included.