Conversation
showHidden(false) only skipped registering the --show-hidden flag, it never
stopped it from working. options.showHiddenOpt kept the default 'show-hidden'
name, and filterHiddenOptions() reveals a hidden key whenever
argv[showHiddenOpt] is set, so passing --show-hidden still listed every hidden
option even though the flag itself was absent from the help output.
Clear showHiddenOpt when the option is disabled so there is no name left to
look up. Documented behaviour in docs/api.md ("hidden keys will be permanently
hidden if first argument is false") already matches this.
Fixes yargs#2449
gyanu2507
force-pushed
the
fix/show-hidden-false-permanently-hides
branch
from
August 31, 2026 10:48
da0c662 to
4844ce4
Compare
Member
|
Well that looks simple enough! (It is likely to be weeks before I am able to review.) |
Member
|
A side-comment. The original post had a comment at the bottom, "Made with Cursor". I guess that was probably promotional and added by Cursor itself, but I do appreciate people acknowledging when there are high levels of AI use in PRs. |
Author
|
That footer was injected by the editor. I strip those when I catch them. The change itself is just |
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.
Fixes #2449.
.showHidden(false)currently only skips registering the--show-hiddenflag — it never stops it from working.addShowHiddenOpt()returns early, sooptions.showHiddenOptkeeps its default'show-hidden'value, andfilterHiddenOptions()reveals a hidden key wheneverargv[showHiddenOpt]is set:The result is what @shadowspawn described in the issue:
--show-hiddenis absent from the help output, but passing it alongside--helpstill lists every hidden option.This clears
showHiddenOptwhen the option is disabled, so there is no name left forfilterHiddenOptions()to look up.On the "bug or documentation problem?" question from the issue —
docs/api.mdis already unambiguous about the intent, so I treated it as a code bug and left the docs alone:Unchanged: the default behaviour (
--show-hiddenworks without calling.showHidden()),.showHidden(), and.showHidden('custom-name').Two tests added, both failing before the change — a help-output test next to the existing
--show-hiddencases intest/usage.mjs, and an option-state test in theshowHiddenblock oftest/yargs.mjs.npm run checkis clean.npm testgoes from 821 to 823 passing; the 18 failures I see locally are thecommandDirESM andintegrationsuites, and they fail identically on an unmodifiedmainin my environment.