- Notifications
You must be signed in to change notification settings - Fork30.1k
[backport] [CNA] use linter preference (#83194)#84087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ijjk commentedSep 22, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Tests Passed |
| initial: | ||
| linterIndexMap[ | ||
| getPrefOrDefault('linter')askeyoftypeoflinterIndexMap | ||
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| ], | |
| ]??0, |
The code could fail if the user's linter preference contains an unexpected value, causingundefined to be passed as the initial prompt selection.
View Details
Analysis
Undefined initial value passed to prompts when linter preference is invalid
What fails: ThelinterIndexMap lookup inpackages/create-next-app/index.ts:321-324 returnsundefined whengetPrefOrDefault('linter') returns a value not in the map ('eslint', 'biome', 'none'), causing the prompts library to receiveinitial: undefined.
How to trigger:
- Create or modify the create-next-app config with an invalid linter preference:
# Edit ~/.config/create-next-app/config.json to contain:{"preferences": {"linter":"invalid-value"}}
- Run create-next-app without CLI linter flags to trigger the interactive prompt
Result: The prompts library receivesinitial: undefined instead of a valid array index, leading to unpredictable default selection behavior.
Expected: Should default to a valid index (0 = ESLint) when the preference value is not recognized, ensuring consistent user experience.
Fix applied: Added nullish coalescing operator?? 0 to provide fallback to first option (ESLint) when lookup returns undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We will get at least a default value so wouldn't be undefined
b6a32bb intonext-15-5Uh oh!
There was an error while loading.Please reload this page.
backports#83194