microsoft / rushstack

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

[eslint-patch] Error: Failed to patch ESLint because the calling module was not recognized. #4905

Closed Zuojiangtao closed 2 weeks ago

Zuojiangtao commented 3 weeks ago

An error is thrown when trying to use @rushstack/eslint-patch version 1.10.4 together with the version of eslint 9.9.0

Summary

Expected result: git commit success.

Actual result:

× eslint --cache --fix:
Oops! Something went wrong! :(
ESLint: 9.9.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> (D:\GItHub\create-vite-starter\node_modules\.pnpm\@rushstack+eslint-patch@1.10.4\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> (D:\GItHub\create-vite-starter\node_modules\.pnpm\@rushstack+eslint-patch@1.10.4\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)
husky - pre-commit script failed (code 1)

Details

my eslint.config.cjs config:

/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
    es6: true,
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    parser: '@typescript-eslint/parser',
    ecmaVersion: 2020,
    sourceType: 'module',
    jsxPragma: 'React',
    ecmaFeatures: {
      jsx: true,
      tsx: true,
    },
  },
  extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
  rules: {},
};

my package.json config:

// ...
"devDependencies": {
  // ...
  "@rushstack/eslint-patch": "^1.10.4",
  "@typescript-eslint/eslint-plugin": "^8.1.0",
  "@typescript-eslint/parser": "^8.1.0",
  "eslint": "^9.9.0",
  "eslint-config-prettier": "^9.1.0",
  "eslint-plugin-prettier": "^5.2.1",
  "husky": "^9.1.4",
  "prettier": "^3.3.3",
  "typescript": "~5.5.4"
}

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? Windows
Would you consider contributing a PR? No
Node.js version (node -v)? 18.20.4
### Tasks
- [ ] https://github.com/microsoft/rushstack/issues/4764
Zuojiangtao commented 3 weeks ago

When I delete first two lines in eslint.config.cjs, I can commit success.So, should I remove @rushstack/eslint-patch plugin?

iclanton commented 2 weeks ago

@D4N14L - Do we support ESLint 9 yet?

D4N14L commented 2 weeks ago

@iclanton we haven't done any work to directly support it yet, no. It will probably be a bit until I get a chance to add support there, unless someone else in the community wants to take a look first (that is how we got ESLint 8 support 😃 )

Zuojiangtao commented 2 weeks ago

OK, I think I should downgrade ESlint to version 8 first.