Loading
feat(npm): S11 package-name & scope validation (Step 7a)
What
Split 1/3 of !427 (closed) (S11 Step 7 validation helpers), kept under the
500-LOC review line. Pure, dependency-free package-name and scope
validators per docs/specs/S11-npm-local.md (Validation rules), backing
the publish/dist-tag/download handlers (wired in later steps).
ValidatePackageName— npm name rules: 1-214 bytes, lowercase, leading char, surrounding whitespace, URL-safe /encodeURIComponent, forbidden~'!()*, reserved set; per-segment for scoped names.ParseScope— decompose into scope (@sigil retained) and plain name; validates viaValidatePackageNamefirst.PackageNameError+PackageNameInvalidReasoncarry the rejection cause for thepackage_name_invalidenvelope detail.
Spec / acceptance
Covers AC 39 (package_name_invalid) unit half. Table-driven units with
=1 positive + negative case per rule, plus multi-rule rejection cases and
FuzzValidatePackageName(no-panic over arbitrary input + aParseScope/ValidatePackageNamevalidity-agreement invariant).
Notes
- Stacking: base of the 3-MR stack; targets
main. !427 (closed) superseded. validate.gouses a detached file comment (the package doc now lives inbuffered.go, merged via npm Step 24 since !427 (closed) opened) to avoid a second package godoc — clears thegodoclintfailure !427 (closed) hit after main advanced.- Review follow-ups:
//nolint:gochecknoglobalsonreservedNames(otherwise blocks the merged-resultsgolangci-lint); addedFuzzValidatePackageName+ a positive test; documented that reserved names are a full-name (top-level-only) check matching npm'svalidate-npm-package-name. The reserved-set scoping and theisURLSafeSegmentuppercase arm are discussed in-thread. - CI: the red
conformance:ociandlint:linksjobs are bothallow_failureand pre-existing/base-wide —lint:linksis gitlab.com 429 rate-limiting;conformance:ocifails identically on unrelated MRs (e.g. !437 (merged)) and does not run onmain. Neither is touched by this npm-only change.
Edited by Dzmitry (Dima) Meshcharakou