Fix an error in local environments where running npm run lint shows…#293
Open
ann-kilzer wants to merge 1 commit intomainfrom
Open
Fix an error in local environments where running npm run lint shows…#293ann-kilzer wants to merge 1 commit intomainfrom
npm run lint shows…#293ann-kilzer wants to merge 1 commit intomainfrom
Conversation
… an error like: ESLint: 9.37.0 Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/annkilzer/dev/womeninsoftwarejp/home/node_modules/@stylistic/eslint-plugin/dist/index.js from /Users/annkilzer/dev/womeninsoftwarejp/home/eslint.config.cjs not supported. Instead change the require of index.js in /Users/annkilzer/dev/womeninsoftwarejp/home/eslint.config.cjs to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/Users/annkilzer/dev/womeninsoftwarejp/home/eslint.config.cjs:14:19) The solution is to use EcmaScript module format rather than a Common JS file. Used GitHub Copilot to make this change
Contributor
There was a problem hiding this comment.
Pull request overview
This PR resolves an ESLint runtime error in local environments caused by loading an ESM-only plugin (@stylistic/eslint-plugin) from a CommonJS ESLint flat config.
Changes:
- Replaced the CommonJS flat config (
eslint.config.cjs) with an ESM flat config (eslint.config.js) usingimport/export. - Added ESM-compatible
__dirnamehandling viafileURLToPath(import.meta.url)forFlatCompat’sbaseDirectory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| eslint.config.js | New ESM flat config to prevent require()-of-ESM errors when loading ESM-only ESLint plugins. |
| eslint.config.cjs | Removed prior CommonJS flat config that triggered the local lint failure. |
Merged
Contributor
|
@ann-kilzer was the error showing when you run the Node version from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed 🧐
Fix an error in local environments where running
npm run lintshows an error like:The solution is to use EcmaScript module format rather than a Common JS file.
Used GitHub Copilot to make this change
How did you test it? 🧪
locally please run