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

Add a custom eslint rule to forbid imports from <package>/src #2273

Open
fvictorio opened this issue Jan 19, 2022 · 6 comments
Open

Add a custom eslint rule to forbid imports from <package>/src #2273

fvictorio opened this issue Jan 19, 2022 · 6 comments
Labels
status:ready This issue is ready to be worked on type:chore A task related to code quality, tooling, CI, or anything that doesn't directly impact the end users

Comments

@fvictorio
Copy link
Member

When a plugin imports something from hardhat, it can import both from hardhat/foo and from hardhat/src/foo, but only the first one is correct. The second one works, but it can cause some issues (see #2260, for example).

More generally, we should forbid any import that starts with package/src or @org/package/src.

@kanej
Copy link
Member

kanej commented Jan 24, 2022

Maybe something like https://eslint.org/docs/rules/no-restricted-imports or maybe there is something in the eslint import plugin.

@fvictorio
Copy link
Member Author

Great find @kanej. I think that won't work for avoiding all package/src imports, because allowing things like ../src seems hard with gitignore-like patterns. But it works pretty well for preventing hardhat/src, which is the more likely error for us. I added it to #2272, but let's keep this issue open for now in case we want to do a custom rule for this at some point.

@github-actions
Copy link
Contributor

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

@github-actions github-actions bot added the Stale label May 25, 2022
@fvictorio
Copy link
Member Author

Not stale.

@github-actions github-actions bot removed the Stale label May 26, 2022
@fvictorio fvictorio added type:chore A task related to code quality, tooling, CI, or anything that doesn't directly impact the end users priority:low status:ready This issue is ready to be worked on and removed priority:low labels Dec 28, 2022
@jrocca82
Copy link

I'll work on this one if no one else is

@fvictorio
Copy link
Member Author

@jrocca82 this is about implementing a custom eslint rule, similar to this one. A contribution for this would be super welcome, but keep in mind that it's not a very straightforward thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on type:chore A task related to code quality, tooling, CI, or anything that doesn't directly impact the end users
Projects
Status: No status
Development

No branches or pull requests

3 participants