microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.92k stars 595 forks source link

[eslint-patch] ESLint 9 - Failed to patch ESLint because the calling module was not recognized. #4965

Open Bwvolleyball opened 3 weeks ago

Bwvolleyball commented 3 weeks ago

Summary

Trying to use ESLint 9 with this plugin, which supposedly it should support now, but I can't get it to work.

Repro steps

Trying to import the plugin from eslint.config.mjs:

import '@rushstack/eslint-patch/eslint-bulk-suppressions.js';

but all I get when I run eslint \"src/**/*.{ts,tsx,js}\" is:

Oops! Something went wrong! :(

ESLint: 9.12.0

Error: Failed to patch ESLint because the calling module was not recognized.
If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:
https://github.com/microsoft/rushstack/issues
    at Object.<anonymous> (/Users/brandon.ward/Code/raptor-ui/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:167:19)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/Users/brandon.ward/Code/raptor-ui/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:11:23)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)

Details

We migrated ESLint to Version 9, and then this patch plugin started breaking.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
Package name: @rushstack/eslint-patch
Package version? 1.10.4
Operating system? Mac
Would you consider contributing a PR? Maybe? I don't understand the issue though
Node.js version (node -v)? 18.20.4
iclanton commented 1 week ago

Yeah eslint-bulk-suppressions currently don't support ESLint 9. @octogonz - can your team take a look at this?

kachkaev commented 1 week ago

Possibly related issue: https://github.com/eslint/config-inspector/issues/70 (see reproduction steps in the third comment).

kirill-konshin commented 5 days ago

@iclanton can you please elaborate why this ticket was marked as low priority?

It also fails in basic scenario of shareable config with ESLint 9...

Here's an example of such config: https://www.npmjs.com/package/@kirill.konshin/eslint-config-next-custom?activeTab=code

This is the usage:

import defaultConfig from '@kirill.konshin/eslint-config-next-custom';

export default [
  ...defaultConfig,
  {
    ignores: [ ... ],
  },
];

Error:

Error: Cannot read config file: /x/node_modules/eslint-config-next/index.js
Error: Failed to patch ESLint because the calling module was not recognized.
If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:
https://github.com/microsoft/rushstack/issues
Referenced from: 
    at Object.<anonymous> (/x/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:167:19)
kirill-konshin commented 5 days ago

Related issue https://github.com/microsoft/rushstack/issues/4635#issuecomment-2447939291 — I have added reproducible scenarios. It seems it has something to do with Yarn Berry.

boringplay commented 2 days ago

I also encountered the same error.