rushstack
rushstack copied to clipboard
[eslint-patch] ESLint 9 - Failed to patch ESLint because the calling module was not recognized.
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 |
Yeah eslint-bulk-suppressions currently don't support ESLint 9. @octogonz - can your team take a look at this?
Possibly related issue: https://github.com/eslint/config-inspector/issues/70 (see reproduction steps in the third comment).
@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)
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.
I also encountered the same error.
Same issue here!
import js from "@eslint/js"; import tseslint from "@typescript-eslint/eslint-plugin"; import tsParser from "@typescript-eslint/parser"; import next from "eslint-config-next"; import '@rushstack/eslint-patch/eslint-bulk-suppressions.js';
export default [ js.configs.recommended, // ✅ Use built-in JS recommendations next(), // ✅ Next.js ESLint rules { files: ["/*.ts", "/*.tsx"], languageOptions: { parser: tsParser, sourceType: "module", }, plugins: { "@typescript-eslint": tseslint, }, rules: { "@typescript-eslint/no-unused-vars": "warn", }, }, ];
what can we do
Linting and checking validity of types .. ⨯ ESLint: 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 Linting and checking validity of types ..Failed to compile.
@faisal1441 @patrickelectric @boringplay it works for me somehow. I managed to get everything together in this package: https://github.com/kirill-konshin/utils/tree/main/packages/eslint-config-next-custom, here's the config: https://github.com/kirill-konshin/utils/blob/main/packages/eslint-config-next-custom/index.js
Works as expected... no issues.
I'm encountering the same issue with ESLint 9.23.0 and eslint-config-next. The error occurs when trying to use @rushstack/eslint-patch with the new required flat config format.
Package versions:
eslint: 9.23.0@rushstack/eslint-patch: 1.11.0 viaeslint-config-next: 15.2.4
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> ([...]/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:167:19)
at Module._compile (node:internal/modules/cjs/loader:1554:14)
at Object..js (node:internal/modules/cjs/loader:1706:10)
at Module.load (node:internal/modules/cjs/loader:1289:32)
at Function._load (node:internal/modules/cjs/loader:1108:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
at Module.require (node:internal/modules/cjs/loader:1311:12)
at require (node:internal/modules/helpers:136:16)
at Object.<anonymous> ([...]node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:11:23)
For now, I've commented out the eslint-config-next import and its rules.
Hi @gregorybolkenstijn, can you share the eslint config? I wonder how you try to use eslint-config-next in flat config.
@talatkuyuk Sorry for the late reply, below is a shortened version of our config that still errors.
Should we do something different? This config works with a lot of other packages from the ESLint ecosystem.
eslint-config-next @ 15.4.5, which uses @rushstack/eslint-patch here: https://github.com/vercel/next.js/blob/canary/packages/eslint-config-next/package.json
❯ yarn why @rushstack/eslint-patch
├─ eslint-config-next@npm:15.4.5
│ └─ @rushstack/eslint-patch@npm:1.11.0 (via npm:^1.10.3)
│
└─ eslint-config-next@npm:15.4.5 [b1f86]
└─ @rushstack/eslint-patch@npm:1.11.0 (via npm:^1.10.3)
import js from '@eslint/js'
import nextConfig from 'eslint-config-next'
import prettierConfig from 'eslint-config-prettier'
import prettierPlugin from 'eslint-plugin-prettier'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
globalIgnores([
'.next/**',
'next-env.d.ts',
'node_modules/**',
'storybook-static/**',
'**/i18next-resources.ts',
'.history/**',
]),
// Global configs that apply to all files
js.configs.recommended,
nextConfig,
prettierConfig, // Keep this last
// Shared configuration for JavaScript and TypeScript files
{
files: ['**/*.{cjs,mjs,js,jsx,cts,mts,ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
JSX: true,
__dirname: 'readonly',
__filename: 'readonly',
console: 'readonly',
module: 'readonly',
process: 'readonly',
require: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
react: {
version: 'detect',
},
},
plugins: {
'prettier': prettierPlugin,
},
rules: {
...js.configs.recommended.rules, // Keep this first
...prettierConfig.rules, // Keep this last
'prettier/prettier': 'error',
},
},
])
Produces this error:
Oops! Something went wrong! :(
ESLint: 9.32.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/gregorybolkenstijn/Code/restor2-frontend/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:167:19)
at Module._compile (node:internal/modules/cjs/loader:1554:14)
at Object..js (node:internal/modules/cjs/loader:1706:10)
at Module.load (node:internal/modules/cjs/loader:1289:32)
at Function._load (node:internal/modules/cjs/loader:1108:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
at Module.require (node:internal/modules/cjs/loader:1311:12)
at require (node:internal/modules/helpers:136:16)
at Object.<anonymous> (/Users/gregorybolkenstijn/Code/restor2-frontend/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:11:23)
There are other tools like @oxlint/migrate who want to access the ESLint config too. See https://github.com/oxc-project/oxlint-migrate/issues/160 for the same problem with eslint-config-next and this package.
This is blocking me from upgrading to eslint >=9.34.0 which introduces concurrency would be extremely helpful for my project.