Skip to content

fix: bump minimum Node.js engine to 22.13.0 and ignore util.styleText in node-builtins lint rule#88

Merged
lirantal merged 2 commits intomainfrom
copilot/fix-lint-issue-ci
Mar 8, 2026
Merged

fix: bump minimum Node.js engine to 22.13.0 and ignore util.styleText in node-builtins lint rule#88
lirantal merged 2 commits intomainfrom
copilot/fix-lint-issue-ci

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 8, 2026

util.styleText was backported to ^22.13.0 but the declared engine range >=22.0.0 caused n/no-unsupported-features/node-builtins to fail. Updating to >=22.13.0 alone doesn't fully resolve it — the open-ended range includes 23.0–23.4 where util.styleText is absent, making the plugin's subset check fail.

Changes

  • package.jsonengines.node: >=22.0.0>=22.13.0
  • eslint.config.js — Override n/no-unsupported-features/node-builtins with ignores: ['util.styleText'] to explicitly permit this backported API regardless of the gap in 23.x coverage
'n/no-unsupported-features/node-builtins': ['error', { ignores: ['util.styleText'] }],

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…lint

Co-authored-by: lirantal <316371+lirantal@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix lint issue in failing CI fix: bump minimum Node.js engine to 22.13.0 and ignore util.styleText in node-builtins lint rule Mar 8, 2026
@lirantal lirantal marked this pull request as ready for review March 8, 2026 19:30
@lirantal lirantal self-requested a review as a code owner March 8, 2026 19:30
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Bump Node.js engine to 22.13.0 and ignore util.styleText in eslint

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Bump minimum Node.js engine to 22.13.0
• Explicitly ignore util.styleText in eslint node-builtins rule
• Resolves lint failures from backported API coverage gaps
Diagram
flowchart LR
  A["Node.js engine requirement"] -->|"Update to 22.13.0"| B["package.json"]
  C["ESLint node-builtins rule"] -->|"Add util.styleText ignore"| D["eslint.config.js"]
  B -->|"Resolves"| E["Lint failures fixed"]
  D -->|"Resolves"| E
Loading

Grey Divider

File Changes

1. package.json ⚙️ Configuration changes +1/-1

Bump minimum Node.js engine version

• Updated engines.node from >=22.0.0 to >=22.13.0
• Ensures minimum Node.js version supports backported util.styleText API

package.json


2. eslint.config.js 🐞 Bug fix +1/-0

Ignore util.styleText in node-builtins rule

• Added explicit ignore rule for util.styleText in n/no-unsupported-features/node-builtins
• Permits backported API despite coverage gaps in Node.js 23.x versions
• Resolves ESLint plugin subset check failures

eslint.config.js


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Mar 8, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Lint ignore masks runtime crash 🐞 Bug ✓ Correctness
Description
The new ESLint ignore allows util.styleText despite the package declaring an open-ended Node
range; because the CLI statically imports styleText from node:util, any allowed Node version
that lacks this export will crash at module load time.
Code

eslint.config.js[16]

+      'n/no-unsupported-features/node-builtins': ['error', { ignores: ['util.styleText'] }],
Evidence
The CLI uses a static named ESM import for styleText and calls it during interactive startup. With
an open-ended engines.node range, the project is declaring compatibility across future majors; the
added ESLint ignore explicitly suppresses the compatibility rule for this builtin, which can hide a
real runtime incompatibility (a missing named export causes immediate module instantiation failure).

src/bin/cli.ts[1-6]
src/bin/cli.ts[140-142]
package.json[26-28]
eslint.config.js[13-17]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`src/bin/cli.ts` statically imports `styleText` from `node:util`. If the running Node version does not export `styleText`, Node will fail to load the module (hard crash at startup). This PR suppresses the lint rule that was warning about exactly this risk, while `package.json` still declares an open-ended Node range.

## Issue Context
The intent is to fix CI lint failures caused by `eslint-plugin-n` doing a compatibility subset check across the engine range. Suppressing the rule removes the warning but doesn’t make runtime behavior safe.

## Fix Focus Areas
- Decide on one of the following:
 - **Constrain engines** to versions that actually include `util.styleText` (e.g., exclude the known 23.0–23.4 gap), and then you likely won’t need the ignore.
 - **Add a runtime fallback**: avoid static named import; access `util.styleText` dynamically with a safe fallback (e.g., identity function) so the CLI can run even if the API is missing.
 - Optionally **extend CI matrix** to test the minimum supported Node and any declared majors.

### Code locations
- package.json[26-28]
- eslint.config.js[13-17]
- src/bin/cli.ts[1-6]
- src/bin/cli.ts[140-142]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Release workflow Node mismatch 🐞 Bug ⛯ Reliability
Description
The release workflow runs on Node 20.x, which is below the package’s declared minimum Node version
(>=22.13.0); this can cause fragile releases and artifacts built with an unsupported toolchain.
Code

package.json[27]

+    "node": ">=22.13.0"
Evidence
After the PR, the package explicitly declares Node >=22.13.0. However, the release workflow
configures Node 20.x for building and publishing, which is below the declared supported
runtime/tooling baseline.

package.json[26-28]
.github/workflows/release.yml[21-28]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The release pipeline is building/publishing with Node 20.x while the package declares `engines.node: &gt;=22.13.0`. This mismatch can break releases or produce artifacts that weren’t built under the supported runtime.

## Issue Context
CI tests on Node 22.x, but releases use Node 20.x. Aligning the release job with the declared engines avoids drift.

## Fix Focus Areas
- Update `actions/setup-node` in the release workflow to `22.x` (or an explicit `22.13.0`+) to satisfy `engines.node`.

### Code locations
- .github/workflows/release.yml[21-28]
- package.json[26-28]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.34%. Comparing base (942c95c) to head (04126c4).
⚠️ Report is 21 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #88   +/-   ##
=======================================
  Coverage   80.34%   80.34%           
=======================================
  Files           9        9           
  Lines        1628     1628           
  Branches       96       96           
=======================================
  Hits         1308     1308           
  Misses        314      314           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 8, 2026

Open in StackBlitz

npm i https://pkg.pr.new/agent-rules@88

commit: 88051f1

rules: {
'n/no-process-exit': 'warn',
'n/no-unsupported-features': 'off',
'n/no-unsupported-features/node-builtins': ['error', { ignores: ['util.styleText'] }],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Lint ignore masks runtime crash 🐞 Bug ✓ Correctness

The new ESLint ignore allows util.styleText despite the package declaring an open-ended Node
range; because the CLI statically imports styleText from node:util, any allowed Node version
that lacks this export will crash at module load time.
Agent Prompt
## Issue description
`src/bin/cli.ts` statically imports `styleText` from `node:util`. If the running Node version does not export `styleText`, Node will fail to load the module (hard crash at startup). This PR suppresses the lint rule that was warning about exactly this risk, while `package.json` still declares an open-ended Node range.

## Issue Context
The intent is to fix CI lint failures caused by `eslint-plugin-n` doing a compatibility subset check across the engine range. Suppressing the rule removes the warning but doesn’t make runtime behavior safe.

## Fix Focus Areas
- Decide on one of the following:
  - **Constrain engines** to versions that actually include `util.styleText` (e.g., exclude the known 23.0–23.4 gap), and then you likely won’t need the ignore.
  - **Add a runtime fallback**: avoid static named import; access `util.styleText` dynamically with a safe fallback (e.g., identity function) so the CLI can run even if the API is missing.
  - Optionally **extend CI matrix** to test the minimum supported Node and any declared majors.

### Code locations
- package.json[26-28]
- eslint.config.js[13-17]
- src/bin/cli.ts[1-6]
- src/bin/cli.ts[140-142]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot you should likely not ignore it, we already added an engines rule, right?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Implementation 🛠️

Implementation: Replace the ignores: ['util.styleText'] exception with an explicit Node.js version range for the node-builtins rule so util.styleText is only considered supported in versions where it actually exists.

Suggested change
'n/no-unsupported-features/node-builtins': ['error', { ignores: ['util.styleText'] }],
'n/no-unsupported-features/node-builtins': ['error', { version: '>=22.13.0 <23.0.0 || >=23.5.0' }],

See review comment here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The ignores is unfortunately still needed alongside the engines bump. The reason: >=22.13.0 is an open-ended range that includes Node.js 23.0–23.4, which lack util.styleText. The eslint-plugin-n rule uses a semver subset check — it verifies the entire configured version range is covered by the feature's supported versions (^22.13.0 || ^21.7.0 || ^20.12.0 || >=23.5.0). Since >=22.13.0 includes 23.0–23.4 which aren't in that set, the check fails even with the engines update.

I tested reverting the ignores while keeping only engines.node: ">=22.13.0" and lint still errors. The ignores: ['util.styleText'] is the surgical fix — it keeps the rule active for all other builtins while acknowledging that util.styleText is intentionally used within the supported LTS range.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot what if instead we used this rule though for the ignores:

      'n/no-unsupported-features/node-builtins': ['error', { version: '>=22.13.0 <23.0.0 || >=23.5.0' }],

will it work?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ask

@copilot what if instead we used this rule though for the ignores: 'n/no-unsupported-features/node-builtins': ['error', { version: '>=22.13.0 <23.0.0 || >=23.5.0' }], will it work?

Answer:

Yes — that approach should work for ESLint (and is preferable to ignores) if eslint-plugin-n in your repo supports the version option for n/no-unsupported-features/node-builtins (it does in current versions).

What it does:

  • The rule normally infers the Node range from package.json#engines.node.
  • By providing { version: '...' }, you override the inferred engine range for this rule only, so the rule’s “subset” check no longer has to consider Node 23.0–23.4, and util.styleText won’t be flagged.

Suggested config (your snippet is basically right):

'n/no-unsupported-features/node-builtins': [
  'error',
  { version: '>=22.13.0 <23.0.0 || >=23.5.0' }
],

Two important caveats:

  1. This only fixes linting, not runtime safety. If package.json still says "node": ">=22.13.0", users can run Node 23.0–23.4 and your CLI can still crash on startup if it statically imports styleText. The lint rule override would just “look away” from that reality.

  2. Make sure the semver expression is accepted by the plugin’s semver parser (it should be; it’s a standard npm range with ||).

Recommendation:

  • If the project truly does not support Node 23.0–23.4, the cleanest solution is to also change engines.node to match the same range (>=22.13.0 <23.0.0 || >=23.5.0). Then you likely don’t need ignores, and the lint rule and runtime contract are aligned.
  • If you want to keep an open-ended engine range, then you should add a runtime fallback (avoid static named import) rather than relying on lint configuration to paper over the gap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tested it — unfortunately it doesn't work. Even with version: '>=22.13.0 <23.0.0 || >=23.5.0', eslint-plugin-n still errors:

The 'util.styleText' is still an experimental feature and is not supported until Node.js 23.5.0 (backported: ^22.13.0, ^21.7.0, ^20.12.0). The configured version range is '>=22.13.0 <23.0.0 || >=23.5.0'

The plugin classifies util.styleText as "experimental" in the 22.x backport range — it only considers it stable from 23.5.0. The version option narrows the semver range but doesn't change the plugin's experimental classification of the API, so it still fails.

The ignores: ['util.styleText'] is the only option that works here, explicitly opting out of the check for this specific backported API.

Copy link
Copy Markdown
Owner

@lirantal lirantal left a comment

Choose a reason for hiding this comment

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

@copilot review the comment

rules: {
'n/no-process-exit': 'warn',
'n/no-unsupported-features': 'off',
'n/no-unsupported-features/node-builtins': ['error', { ignores: ['util.styleText'] }],
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot you should likely not ignore it, we already added an engines rule, right?

Copy link
Copy Markdown
Owner

@lirantal lirantal left a comment

Choose a reason for hiding this comment

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

@copilot review my comment

rules: {
'n/no-process-exit': 'warn',
'n/no-unsupported-features': 'off',
'n/no-unsupported-features/node-builtins': ['error', { ignores: ['util.styleText'] }],
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot what if instead we used this rule though for the ignores:

      'n/no-unsupported-features/node-builtins': ['error', { version: '>=22.13.0 <23.0.0 || >=23.5.0' }],

will it work?

@lirantal lirantal merged commit 9c7de75 into main Mar 8, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants