Skip to content

Fix ESLint v9 incompatibility and Node20 ES module compatibility#184

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/fix-eslint-error-in-ci
Closed

Fix ESLint v9 incompatibility and Node20 ES module compatibility#184
Copilot wants to merge 5 commits intomainfrom
copilot/fix-eslint-error-in-ci

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 16, 2025

CI failing due to ESLint v9 requiring flat config format (eslint.config.js) instead of legacy .eslintrc.json, and Node20 incompatibility with ES module detection.

Changes

Package dependencies:

  • Downgrade eslint 9.39.2 → 8.57.0
  • Downgrade eslint-plugin-github 6.0.0 → 5.1.8
  • Replace typescript-eslint with explicit @typescript-eslint/eslint-plugin and @typescript-eslint/parser at v8.0.0
  • Remove @eslint/js (ESLint v8 incompatible)
  • Downgrade yargs 18.0.0 → 17.7.2 (yargs 18+ is ESM-only, incompatible with CommonJS bundling)
  • Add "type": "commonjs" to package.json to explicitly declare CommonJS module type for Node20

ESLint configuration:

  • Remove deprecated formatting rules (func-call-spacing, semi, type-annotation-spacing) removed in typescript-eslint v8
  • Disable import/no-unresolved (TypeScript handles import validation, avoids false positives with package.json exports)

GitHub Actions:

  • Update action.yml to use node20 instead of node16 (Node16 is deprecated and GitHub Actions now runs all actions on Node20)

Node20 Compatibility Fix

GitHub Actions now automatically runs Node16 actions on Node20, which has stricter ES module detection. Node20 was detecting ES module syntax (import.meta) in the bundled dist/index.js from yargs 18.0.0 and attempting to load it as an ES module, causing ReferenceError: require is not defined in ES module scope. The fix downgrades yargs to the last CommonJS-compatible version (17.7.2) and explicitly sets "type": "commonjs" to ensure Node20 loads the action as CommonJS.

ESLint v8 maintains .eslintrc.json support, avoiding migration to flat config.

Original prompt

The CI build is failing due to an ESLint error that results in exit code 2. Log output references the ESLint migration guide, suggesting a misconfiguration or plugin version mismatch. Steps to resolve:

  1. Verify and update package.json to ensure compatibility among eslint, eslint-plugin-github, @typescript-eslint/eslint-plugin, and @typescript-eslint/parser. Example:

"devDependencies": {
"eslint": "^8.0.0",
"eslint-plugin-github": "^4.3.1",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0"
}

  1. Run npm install after updating dependencies.
  2. Review .eslintrc.json for correct use of plugin:github/recommended and relevant rules.
  3. Run npx eslint . locally to confirm there are no additional errors. If any plugin errors occur, install the missing plugins.

This should resolve the ESLint error and allow CI to pass.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 16, 2025 16:46
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI build failing due to ESLint error Fix ESLint v9 incompatibility with legacy .eslintrc.json configuration Dec 16, 2025
Copilot AI requested a review from felickz December 16, 2025 16:59
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 17, 2025

Dependency Review

The following issues were found:

  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ✅ 0 package(s) with unknown licenses.
  • ⚠️ 4 packages with OpenSSF Scorecard issues.

View full job summary

@felickz
Copy link
Copy Markdown
Contributor

felickz commented Dec 19, 2025

@copilot it still fails build-test https://github.com/advanced-security/codeql-sarif-security-standard-annotator/blob/731f9173009e86a7f7b81afce7aaa48867077fac/.github/workflows/test.yml

Run ./
file:///home/runner/work/codeql-sarif-security-standard-annotator/codeql-sarif-security-standard-annotator/dist/index.js:1
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
^

ReferenceError: require is not defined in ES module scope, you can use import instead
    at file:///home/runner/work/codeql-sarif-security-standard-annotator/codeql-sarif-security-standard-annotator/dist/index.js:1:1
    at ModuleJob.run (node:internal/modules/esm/module_job:325:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:606:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v20.19.5

Copilot AI and others added 2 commits December 19, 2025 23:50
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
…ype to commonjs

Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot it still fails build-test https://github.com/advanced-security/codeql-sarif-security-standard-annotator/blob/731f9173009e86a7f7b81afce7aaa48867077fac/.github/workflows/test.yml

...

Fixed in commit 5c1aa28. The issue was caused by yargs 18.0.0 being ESM-only and ncc bundling ES module code (import.meta) that's incompatible with CommonJS. Downgraded yargs to 17.7.2 and added "type": "commonjs" to package.json to ensure Node20 loads the action as CommonJS.

Copilot AI changed the title Fix ESLint v9 incompatibility with legacy .eslintrc.json configuration Fix ESLint v9 incompatibility and Node20 ES module compatibility Dec 20, 2025
Copy link
Copy Markdown
Contributor

@felickz felickz left a comment

Choose a reason for hiding this comment

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

I'll be a happy man the day I never see another commonjs issue

@felickz felickz marked this pull request as ready for review December 24, 2025 06:31
Copilot AI review requested due to automatic review settings December 24, 2025 06:31
Copy link
Copy Markdown
Contributor

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 resolves CI build failures by downgrading ESLint to version 8 to maintain compatibility with the existing .eslintrc.json configuration format, and fixes Node20 ES module compatibility issues by ensuring the action uses CommonJS.

Key changes:

  • Downgrade ESLint and related plugins to versions compatible with legacy configuration format
  • Downgrade yargs from 18.0.0 to 17.7.2 to avoid ES module-only version incompatible with CommonJS bundling
  • Update action.yml to explicitly use Node20 runtime

Reviewed changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated no comments.

File Description
package.json Downgrades ESLint from v9 to v8, yargs from v18 to v17, replaces typescript-eslint package with explicit plugin/parser packages, and adds explicit CommonJS type declaration
action.yml Updates runtime from node16 to node20
.eslintrc.json Removes deprecated typescript-eslint formatting rules and disables import/no-unresolved rule

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@felickz felickz requested a review from a team December 24, 2025 06:34
@felickz
Copy link
Copy Markdown
Contributor

felickz commented Jan 20, 2026

Looks like yargs package causing problems here too

@felickz felickz closed this Jan 20, 2026
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