Skip to content

Conversation

hyperz111
Copy link
Contributor

@hyperz111 hyperz111 commented Aug 15, 2025

Prerequisites checklist

What is the purpose of this pull request?

In this PR, i make the prompt is handle ctrl + c gracefully.

What changes did you make? (Give an overview)

When we do ctrl + c:

@eslint/create-config: v1.9.0

✖ What do you want to lint? · No items were selected
node:internal/readline/interface:568
      throw new ERR_USE_AFTER_CLOSE('readline');
            ^

Error [ERR_USE_AFTER_CLOSE]: readline was closed
    at Interface.pause (node:internal/readline/interface:568:13)
    at MultiSelect.off [as stop] (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/lib/keypress.js:217:8)
    at Object.onceWrapper (node:events:622:28)
    at MultiSelect.emit (node:events:520:35)
    at prompt.emit (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/index.js:128:14)
    at MultiSelect.close (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/lib/prompt.js:182:10)
    at MultiSelect.cancel (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/lib/prompt.js:161:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async MultiSelect.keypress (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/lib/prompt.js:46:14) {
  code: 'ERR_USE_AFTER_CLOSE'
}

Node.js v24.6.0

In this change, this would be:

@eslint/create-config: v1.10.0

✖ What do you want to lint? · No items were selected

Related Issues

N/A

Is there anything you'd like reviewers to focus on?

N/A

@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Aug 15, 2025
@eslintbot eslintbot added this to Triage Aug 15, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Aug 15, 2025
@hyperz111 hyperz111 changed the title fix: exit gracefully & change prompt styles fix, chore: exit gracefully & change prompt styles Aug 15, 2025
@eslint-github-bot
Copy link

Hi @hyperz111!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

@hyperz111 hyperz111 changed the title fix, chore: exit gracefully & change prompt styles fix: exit gracefully & change prompt styles Aug 15, 2025
@lumirlumir lumirlumir requested review from aladdin-add, Copilot and a team August 18, 2025 05:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the user experience of ESLint's configuration generator by implementing graceful exit handling for Ctrl+C interruptions and updating the visual styling of prompts and logging.

  • Adds colored symbols and improved visual feedback for different types of log messages
  • Updates prompt styling with consistent colors and symbols for better visual hierarchy
  • Modifies logging utility functions to include colored symbols and consistent formatting

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
package.json Adds ansi-colors dependency for terminal color support
lib/utils/logging.js Refactors logging functions to include colored symbols and adds new log/success functions
lib/questions.js Implements prompt styling with colors and symbols via setQuestionsPromptStyle function
lib/config-generator.js Updates log function calls to use new success function for positive outcomes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nzakas
Copy link
Member

nzakas commented Aug 25, 2025

Thanks for the pull request. Can you please give us more detail about what you changed and why?

@nzakas nzakas moved this from Needs Triage to Triaging in Triage Aug 25, 2025
@hyperz111
Copy link
Contributor Author

Thanks for the pull request. Can you please give us more detail about what you changed and why?

When we do ctrl + c:

@eslint/create-config: v1.9.0

✖ What do you want to lint? · No items were selected
node:internal/readline/interface:568
      throw new ERR_USE_AFTER_CLOSE('readline');
            ^

Error [ERR_USE_AFTER_CLOSE]: readline was closed
    at Interface.pause (node:internal/readline/interface:568:13)
    at MultiSelect.off [as stop] (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/lib/keypress.js:217:8)
    at Object.onceWrapper (node:events:622:28)
    at MultiSelect.emit (node:events:520:35)
    at prompt.emit (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/index.js:128:14)
    at MultiSelect.close (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/lib/prompt.js:182:10)
    at MultiSelect.cancel (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/lib/prompt.js:161:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async MultiSelect.keypress (/data/data/com.termux/files/home/.npm/_npx/abe235584debfe0e/node_modules/enquirer/lib/prompt.js:46:14) {
  code: 'ERR_USE_AFTER_CLOSE'
}

Node.js v24.6.0

In this change, this would be:

@eslint/create-config: v1.10.0

✖ What do you want to lint? · No items were selected
✖ Operation Cancelled.

@nzakas
Copy link
Member

nzakas commented Aug 26, 2025

Got it, thanks for explaining. In order to keep this PR focused, can you remove the changes that don't relate that?

@hyperz111 hyperz111 changed the title fix: exit gracefully & change prompt styles fix: exit gracefully Aug 26, 2025
@hyperz111 hyperz111 changed the title fix: exit gracefully fix: exit gracefully when press ctrl + c Aug 26, 2025
@nzakas
Copy link
Member

nzakas commented Aug 27, 2025

We probably want to catch SIGINT and SIGTERM, like in this post:
https://dev.to/superiqbal7/graceful-shutdown-in-nodejs-handling-stranger-danger-29jo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, could we add a brief test to check whether SIGINT and SIGTERM work as expected?

@hyperz111
Copy link
Contributor Author

We probably want to catch SIGINT and SIGTERM, like in this post:
https://dev.to/superiqbal7/graceful-shutdown-in-nodejs-handling-stranger-danger-29jo

But when we do ctrl + c (SIGINT), this is will throw

Error [ERR_USE_AFTER_CLOSE]: readline was closed

See this

@hyperz111
Copy link
Contributor Author

@nzakas, this is OK?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Triaging
Development

Successfully merging this pull request may close these issues.

4 participants