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

Errors when running on elint.config.mjs #52

Open
vicary opened this issue May 17, 2024 · 4 comments
Open

Errors when running on elint.config.mjs #52

vicary opened this issue May 17, 2024 · 4 comments

Comments

@vicary
Copy link

vicary commented May 17, 2024

My project is not ESM ready, therefore I have to use the .mjs extension to let only eslint use ESM.

The analyzer fails to pick up the config file, but fails with an irrelevant error message.

image

You can also run this command directly using 'npx @eslint/config-inspector' in the same directory as your configuration file.
ℹ Starting ESLint config inspector at http://127.0.0.1:7777 

ℹ Reading ESLint config from [REDACTED]/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: Dynamic require of "tty" is not supported
    at file:///[REDACTED]/eslint.config.bundled_u7zfo621b2d.mjs:12:9
    at node_modules/debug/src/node.js (file:///[REDACTED]/eslint.config.bundled_u7zfo621b2d.mjs:610:15)
    at __require2 (file:///[REDACTED]/eslint.config.bundled_u7zfo621b2d.mjs:15:50)
    at node_modules/debug/src/index.js (file:///[REDACTED]/eslint.config.bundled_u7zfo621b2d.mjs:787:24)
    at __require2 (file:///[REDACTED]/eslint.config.bundled_u7zfo621b2d.mjs:15:50)
    at node_modules/@eslint/eslintrc/dist/eslintrc.cjs (file:///[REDACTED]/eslint.config.bundled_u7zfo621b2d.mjs:10517:21)
    at __require2 (file:///[REDACTED]/eslint.config.bundled_u7zfo621b2d.mjs:15:50)
    at file:///[REDACTED]/eslint.config.bundled_u7zfo621b2d.mjs:546154:31
    at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:474:24)

Is it possible to support eslint.config.mjs?

@antfu
Copy link
Collaborator

antfu commented May 17, 2024

Can you share a minimal reproduction? Thanks

@vicary
Copy link
Author

vicary commented May 17, 2024

@antfu It turns out to be a unique combination of seemingly unrelated issues, please checkout this minrep https://github.com/vicary/eslint-config-inspector-mjs

All of the followings must be true to trigger this bug:

  1. Use eslint.config.mjs instead of eslint.config.js
  2. import @eslint/eslintrc in the file
  3. Add a tsconfig.json with a path of * pointing to anywhere

I am not sure how does tsconfig.json affects the require path of eslint.config.mjs, but it seems to be the culprit.

@antfu
Copy link
Collaborator

antfu commented May 17, 2024

Why you are having "*": ["node_modules/*"] - it looks problematic to me. The config inspector use bundle-require to import the config file, which is powered by esbuild and respects your tsconfig.json. I would try to see if it's possible to disable tsconfig looking up - but I am not sure if your tsconfig.json is correct in the mean time

@vicary
Copy link
Author

vicary commented May 18, 2024

It is for a specific issue when the project root contains a directory with the same name as one of those inside node_modules.

When we have node_modules/graphql/ installed, our graphql/index.ts would break at the following import statement because the bare module identifier resolves to itself.

import * as graphql from "graphql";

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

2 participants