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

Using eslint-plugin-import in a monorepo #2247

Closed
cmdcolin opened this issue Oct 6, 2021 · 6 comments
Closed

Using eslint-plugin-import in a monorepo #2247

cmdcolin opened this issue Oct 6, 2021 · 6 comments

Comments

@cmdcolin
Copy link

cmdcolin commented Oct 6, 2021

Hi there
I was wondering if there is any way I can use eslint-plugin-import to catch errors from bad imports in a monorepo

I noticed if I have a monorepo setup like this

  • packages/app1 has is-even in it's package.json
  • packages/app2 does not have is-even in its package.json
  • packages/app2 tries to use is-even

I'd like to get a warning from packages/app2's bad usage of is-even, but I don't get this

I made a small reproducible repo here https://github.com/cmdcolin/yarn_workspaces_eslint_plugin_import (run yarn && yarn lint from root of the repo) and there are no warnings from lint, though it would be cool to see if I can get warnings from this...

Note: I tried cross-posting this to stackoverflow too

https://stackoverflow.com/questions/69457844/using-eslint-plugin-import-in-a-monorepo-not-reporting-errors-when-it-should

@ljharb
Copy link
Member

ljharb commented Oct 6, 2021

no-extraneous-dependencies should be handling this.

@cmdcolin
Copy link
Author

cmdcolin commented Oct 6, 2021

I see! I think that helps a lot. Is this rule disabled by default? Enabling it definitely seems to fix the issue in my small demo repo and probably also in my larger repo

@cmdcolin
Copy link
Author

cmdcolin commented Oct 6, 2021

will close for now as I think this is effectively solved, thanks!

@cmdcolin cmdcolin closed this as completed Oct 6, 2021
@ljharb
Copy link
Member

ljharb commented Oct 6, 2021

All rules are disabled by default.

@cmdcolin
Copy link
Author

cmdcolin commented Oct 6, 2021

I meant, is it not part of plugin:import/recommended?
my small demo repo only had that enabled and it didn't catch the error but manually adding the import/no-extraneous-dependencies did fix

@ljharb
Copy link
Member

ljharb commented Oct 6, 2021

I don't believe it is, no. I'd suggest using the airbnb config :-)

we can't update the recommended config without a major bump, so it's quite behind.

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

No branches or pull requests

2 participants