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

no-cycle rule fails to recognize external module #1877

Open
davazp opened this issue Aug 12, 2020 · 3 comments
Open

no-cycle rule fails to recognize external module #1877

davazp opened this issue Aug 12, 2020 · 3 comments
Labels

Comments

@davazp
Copy link

davazp commented Aug 12, 2020

In a project setup with yarn workspaces, no-cycle fails to recognize a @scope/package package as external, even if the path is under node_modules. The reason is that no-cycle uses isExternalModule:

https://github.com/benmosher/eslint-plugin-import/blob/master/src/rules/no-cycle.js#L44

but there is a regex condition that says that module is not "external", but "scoped".

https://github.com/benmosher/eslint-plugin-import/blob/3e65a70bc73e404ace72ee858889e39732284d12/src/core/importType.js#L45

I think the right solution for consistency is to use resolveImportType from importType?

https://github.com/benmosher/eslint-plugin-import/blob/master/src/core/importType.js#L83-L93

Alternatively, replace the regular expression with "anything that does not start with a ..

@davazp
Copy link
Author

davazp commented Aug 12, 2020

Actually, my motivation is actually not necessarily considering the import external. But making sure that no-cycle reads the target file with the right settings from the target .eslintrc! This was more of a workaround.

@ljharb
Copy link
Member

ljharb commented Oct 3, 2020

@davazp any chance you could provide a repro repo, or a PR with a failing test case? :-)

@soryy708 soryy708 added the bug label Jan 28, 2025
@soryy708
Copy link
Collaborator

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

No branches or pull requests

3 participants