Uh oh!
There was an error while loading. Please reload this page.
feat!: error on unknown configs, flags, and abbreviations - #9276
Conversation
a386ace to
fd9faf7CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
fd9faf7 to
7c21cdfCompare| 'Run `npm help config` for supported options.', | ||
| ].join('\n') | ||
| throw Object.assign(new Error(msg), { | ||
| code: 'EUNKNOWNCONFIG', |
There was a problem hiding this comment.
If a user has both bad cli flags and bad keys in .npmrc, they will only see the cli set, fix those, re-run, then see the file set. Worth combining both lists into a single error so it is one trip?
| } | ||
| // Returns unknown-config entries for a given source ('cli', 'builtin', 'project', 'user', 'global') or all non-env entries when omitted. | ||
| getUnknownConfigs (where) { |
There was a problem hiding this comment.
nit — comment says "all non-env entries when omitted" but the filter also drops publishConfig. Maybe "all entries except env and publishConfig"?
| } | ||
| const command = new TestCommand(npm) | ||
| t.doesNotThrow(() => command.validateCli(), 'skipConfigValidation bypasses unknown-file-config check') |
There was a problem hiding this comment.
nit — worth adding a test here that runs a command with NPM_CONFIG_<unknown>=1 set and asserts validateCli does not throw? The carve-out lives in getUnknownConfigs() — a regression test at the base-cmd level would lock it in so the env→warn behavior cannot silently flip if that filter changes.
BREAKING CHANGE: unknown configs in .npmrc, unknown CLI flags, abbreviated flags, and single-hyphen multi-char shorthands now throw instead of warning.
7c21cdf to
8d584bcCompareUh oh!
There was an error while loading. Please reload this page.
Unknown configuration keys in .npmrc files now emit a warning by default, restoring pre-npm-12 behavior, instead of throwing. This reverts the breaking change from 979518d (#9276) for file-based configs. The new `strict-npmrc` config (default false) opts back into treating them as a hard error. Unknown CLI flags and abbreviations continue to error regardless of this setting. The warning flows through the normal display pipeline, so it respects loglevel suppression (e.g. --loglevel=error, --silent). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Unknown configuration keys in .npmrc files now emit a warning by default, restoring pre-npm-12 behavior, instead of throwing. This reverts the breaking change from 979518d (#9276) for file-based configs. The new `strict-npmrc` config (default false) opts back into treating them as a hard error. Unknown CLI flags and abbreviations continue to error regardless of this setting.
## What / Why #9729 reverts the `.npmrc` file-config half of the breaking change from `979518d` (#9276): unknown `.npmrc` configs warn by default again, and the new `strict-npmrc` config opts back into erroring. Unknown CLI flags and abbreviations still throw. The `12.0.0-pre.1` changelog entry still carried the original wording, which claimed unknown `.npmrc` configs now throw. Since release-please aggregates every prerelease `BREAKING CHANGE` note into the eventual stable `v12.0.0` release notes, that stale line would surface (inaccurately) in the 12.0.0 notes. This corrects the wording in place. ## Change Edits the single breaking-changes bullet in the `## [12.0.0-pre.1]` section: > unknown CLI flags, abbreviated flags, and single-hyphen multi-char shorthands now throw instead of warning. (Unknown `.npmrc` configs still warn by default; opt into erroring with the new `strict-npmrc` config.) ## Notes - Manual, targeted edit to an already-released, release-please-generated section — this does not disturb release-please, which derives versions from git tags + commit history and only prepends new sections. Precedent: #8298 (`chore: add contributor to changelog entry`). - Best merged alongside / after #9729 so the corrected note reflects shipped behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tibility (#35) The first real automated publish attempt (0.1.1-beta.2, all 9 packages) failed identically for every package: EUNKNOWNCONFIG "Unknown cli flag: --git-checks". Root cause confirmed via pnpm/pnpm#9646 and npm/cli#9276: changeset publish always runs pnpm publish --no-git-checks for a pnpm workspace, and pnpm has an open bug that mangles --no-git-checks into a bare --git-checks before forwarding it to the underlying npm call. npm <12 only warned about this; npm 12's breaking change (npm/cli#9276) made unknown CLI flags a hard error, and the later walkback (npm/cli#9729) explicitly excludes CLI flags from the softened behavior - so npm 12 will always hard-fail here regardless of patch version. `npm install -g npm@latest` was pulling in 12.0.1. Pinned to 11.18.0 instead - the newest 11.x release, well past the >=11.5.1 OIDC requirement, but before the breaking change. Nothing was actually published by the failed attempt (confirmed: all 9 packages failed identically before any registry write), so this is a clean retry, not a partial-state cleanup.
BREAKING CHANGE: unknown configs in .npmrc, unknown CLI flags, abbreviated flags, and single-hyphen multi-char shorthands now throw instead of warning.
Closesnpm/statusboard#1084.
Unknown configs are now hard errors instead of warnings:
.npmrc(project/user/global/builtin), aggregated across files--bogus)--dryfor--dry-run)-longflag)Env (
npm_config_*) andpublishConfigunknowns still warn.config,help,doctor,completion, andversionopt out viastatic skipConfigValidation = truesonpm config fixand friends keep working when.npmrcis broken.Notable breaks
email,_authToken,_password,username,certfile,keyfile) must be in scoped/nerfdart form. Runnpm config fixto migrate.-jno longer expands to--json. Use--json.