Fix ESLint v9 incompatibility and Node20 ES module compatibility#184
Fix ESLint v9 incompatibility and Node20 ES module compatibility#184
Conversation
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Dependency ReviewThe following issues were found:
|
|
@copilot it still fails build-test https://github.com/advanced-security/codeql-sarif-security-standard-annotator/blob/731f9173009e86a7f7b81afce7aaa48867077fac/.github/workflows/test.yml |
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
…ype to commonjs Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
... 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. |
felickz
left a comment
There was a problem hiding this comment.
I'll be a happy man the day I never see another commonjs issue
There was a problem hiding this comment.
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.
|
Looks like yargs package causing problems here too |
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:
eslint9.39.2 → 8.57.0eslint-plugin-github6.0.0 → 5.1.8typescript-eslintwith explicit@typescript-eslint/eslint-pluginand@typescript-eslint/parserat v8.0.0@eslint/js(ESLint v8 incompatible)yargs18.0.0 → 17.7.2 (yargs 18+ is ESM-only, incompatible with CommonJS bundling)"type": "commonjs"to package.json to explicitly declare CommonJS module type for Node20ESLint configuration:
func-call-spacing,semi,type-annotation-spacing) removed in typescript-eslint v8import/no-unresolved(TypeScript handles import validation, avoids false positives with package.json exports)GitHub Actions:
action.ymlto usenode20instead ofnode16(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 bundleddist/index.jsfrom yargs 18.0.0 and attempting to load it as an ES module, causingReferenceError: 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.jsonsupport, avoiding migration to flat config.Original prompt
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.