You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Opened a PR here that cleans up imports into our standard style where contracts, libraries, and interfaces are sorted nicely. It's useful to be able to quickly understand what's being imported but there's no automatic enforcement on this style. We don't like having styles that aren't enforced automatically!
Using forge fmt with the sort_imports option doesn't really work here because that option sorts alphabetically and not by import type which is generally way more useful when understanding what's being used in the contract.
A good tool here would live inside of scripts/checks. We need to be careful about how to implement this because the logic isn't immediately obvious for edge cases like a contract and an interface being imported from the same place. My recommendation for now is that if multiple things are imported from the same file then we use the type of the very first import to determine how to classify that import. It usually works well enough.
Import groups are:
Contracts (whenever a contract is imported)
Libraries (whenever a library is imported)
Errors count as libraries
Interfaces (whenever an interface is imported)
Scripts (whenever you import from the scripts folder)
Testing (whenever you import from the testing folder)
Scripts and Testing takes precedent over the rest. E.g., anything in the scripts folder should be under Scripts regardless of whether it's a contract, library, or interface.
The text was updated successfully, but these errors were encountered:
Opened a PR here that cleans up imports into our standard style where contracts, libraries, and interfaces are sorted nicely. It's useful to be able to quickly understand what's being imported but there's no automatic enforcement on this style. We don't like having styles that aren't enforced automatically!
Using
forge fmt
with thesort_imports
option doesn't really work here because that option sorts alphabetically and not by import type which is generally way more useful when understanding what's being used in the contract.A good tool here would live inside of
scripts/checks
. We need to be careful about how to implement this because the logic isn't immediately obvious for edge cases like a contract and an interface being imported from the same place. My recommendation for now is that if multiple things are imported from the same file then we use the type of the very first import to determine how to classify that import. It usually works well enough.Import groups are:
contract
is imported)library
is imported)interface
is imported)scripts
folder)testing
folder)Scripts and Testing takes precedent over the rest. E.g., anything in the
scripts
folder should be under Scripts regardless of whether it's a contract, library, or interface.The text was updated successfully, but these errors were encountered: