Next.js Codebase Analysis <> create-next-app <> index.ts explained — Part 1.15
In the previous article, you will find code explanation about how — typecript or — javascript arguments via CLI are handled.
In this article, you will see how the “— es-lint” or “? Would you like to use ESLint? › No / Yes” is configured
You will find the code below in next.js/create-next-app/index.ts
if (
// Check if there is an argument --es-lint passed
!process.argv.includes('--eslint') &&
!process.argv.includes('--no-eslint')
) {
// If not, check the user preferences
// cached/stored using Conf npm package
// Skip the prompt, if this package runs in CI
// ciInfo is from https://www.npmjs.com/package/ci-info
if (ciInfo.isCI) {
program.eslint = getPrefOrDefault('eslint')
} else {
// styledEslint, you could just directly use blue from picocolors
// in the message below
const styledEslint = blue('ESLint')
// This is the prompt configuration that shows you the EsList prompt
// in the CLI
const { eslint } = await prompts({
onState: onPromptState,
type: 'toggle',
name: 'eslint',
message: `Would you like to use ${styledEslint}?`,
initial: getPrefOrDefault('eslint'),
active: 'Yes',
inactive: 'No',
})
// set the program and preferneces keys
program.eslint = Boolean(eslint)
preferences.eslint = Boolean(eslint)
}
}
Conclusion
To summarise the code snippet used in this article, check if there is an argument passed via the CLI for ESLint, if not, show a prompt and take user’s input. There’s a side effect that makes the prompt skip if ciInfo.isCI is true. https://www.npmjs.com/package/ci-info can be used to detect if your node program is executed on CI server
If you have any questions, feel free to reach out to me at ramu.narasinga@gmail.com

Get free courses inspired by the best practices used in open source.
About me:
Hey, my name is Ramu Narasinga. Email: ramu.narasinga@gmail.com
Tired of AI-generated code that works but nobody understands?
I spent 3+ years studying OSS codebases and wrote 350+ articles on what makes them production-grade. I built an open source tool that reviews your PR against your existing codebase patterns.
Your codebase. Your patterns. Enforced.
