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

Scope not considered when checking existence of ESLint/Prettier plugins #581

Closed
6 of 7 tasks
paescuj opened this issue Aug 16, 2024 · 0 comments · Fixed by #583
Closed
6 of 7 tasks

Scope not considered when checking existence of ESLint/Prettier plugins #581

paescuj opened this issue Aug 16, 2024 · 0 comments · Fixed by #583

Comments

@paescuj
Copy link
Contributor

paescuj commented Aug 16, 2024

Describe the bug

Hey, thank you very much for this awesome project ❤️

I plan to create a customized ESLint config package based on @antfu/eslint-config.
While doing so, I noticed that the existence checks for the ESLint/Prettier plugins packages (e.g. eslint-plugin-format) are not considering the module scope. Since the plugins are imported from within @antfu/eslint-config, these packages should be expected in the same scope.

my-package                    ← is looking here for plugins
└── my-eslint-config
    ├── @antfu/eslint-config
    ├── eslint-plugin-format  ← should look here
    ├── prettier
    └── ...

While the setup above technically works, @antfu/eslint-config wants to install the "missing" plugins when called from my-package.

This is due to the fact that the function used to check the packages, isPackageExists from local-pkg using mlly, is using the current working directory as the resolving path by default: https://github.com/unjs/mlly/blob/d13b8bcfa61c23b2f3a0893942e22fa0e1b79d5b/src/resolve.ts#L98-L100

Obviously, this is only an issue when the node modules are organized in a non-flat structure, like with pnpm.

Repro is based on local-pkg. Let me know if you'd like one for @antfu/eslint-config instead.

Reproduction

https://github.com/paescuj/is-package-exists-scope-repro

System Info

N/A

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
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

Successfully merging a pull request may close this issue.

1 participant