Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load eslint.config.js when shareable config uses @rushstack/eslint-patch #70

Open
r34son opened this issue Jun 21, 2024 · 2 comments

Comments

@r34son
Copy link

r34son commented Jun 21, 2024

image

eslint.config.mjs:

import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { fixupConfigRules, includeIgnoreFile } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
  baseDirectory: __dirname,
  recommendedConfig: js.configs.recommended,
  allConfig: js.configs.all,
});
const gitignorePath = path.resolve(__dirname, '.gitignore');

/** @type { import("eslint").Linter.FlatConfig[] } */
export default [
  includeIgnoreFile(gitignorePath),
  ...fixupConfigRules(
    compat.extends('next/core-web-vitals'),
  ),
];
Full error
Failed to load eslint.config.js
Error: Cannot read config file: /Users/seitasanov/ownProjects/profile/node_modules/.pnpm/[email protected][email protected][email protected]/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: /Users/seitasanov/ownProjects/profile/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/eslint-config-next/core-web-vitals.js
@voxpelli
Copy link
Contributor

Can you make a more minimal reproduction of the issue?

@kachkaev
Copy link

kachkaev commented Oct 28, 2024

@voxpelli I can observe this issue in the latest Config Inspector (0.5.5) when creating a new Next.js project (15.0.1). Versions below are pinned for reproducibility:

cd /tmp

npx [email protected] --use-npm --yes config-inspector-issue-70
cd config-inspector-issue-70

npx @eslint/migrate-config .eslintrc.json
npm install @eslint/js @eslint/eslintrc -D
rm .eslintrc.json

npm install

npx @eslint/[email protected]
ℹ Starting ESLint config inspector at http://localhost:7777 

ℹ Reading ESLint config from /private/tmp/config-inspector-issue-70/eslint.config.mjs
Failed to load `eslint.config.js`.
Note that `@eslint/config-inspector` only works with the flat config format:
https://eslint.org/docs/latest/use/configure/configuration-files-new
Error: Cannot read config file: /private/tmp/config-inspector-issue-70/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: /private/tmp/config-inspector-issue-70/node_modules/eslint-config-next/core-web-vitals.js
    at Object.<anonymous> (/private/tmp/config-inspector-issue-70/node_modules/@rushstack/eslint-patch/lib/_patch-base.js:167:19)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/private/tmp/config-inspector-issue-70/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js:11:23)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)

Must be this line: https://github.com/vercel/next.js/blob/655b808c5b352350fe85c0fadc7b92ff251e675b/packages/eslint-config-next/index.js#L53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants