Crates.io | scopelint |
lib.rs | scopelint |
version | 0.0.21 |
source | src |
created_at | 2022-10-06 16:15:03.303705 |
updated_at | 2024-06-20 15:11:05.810811 |
description | An opinionated formatting and linting tool for foundry projects |
homepage | |
repository | https://github.com/ScopeLift/scopelint |
max_upload_size | |
id | 681456 |
size | 109,243 |
ScopeLint
A simple and opinionated tool designed for basic formatting/linting of Solidity and TOML code in foundry projects.
When using the ScopeLift Foundry template scopelint will automatically be ran in CI. To run locally:
cargo install scopelint
Once installed there are three commands:
scopelint fmt
scopelint check
scopelint spec
For all commands, please open issues for any bug reports, suggestions, or feature requests.
scopelint fmt
This command will format:
foundry.toml
.scopelint check
This command ensures that development best practices are consistently followed by validating that:
^test(Fork)?(Fuzz)?(_Revert(If|When|On))?_(\w+)*$
. (To see a list of example valid test names, see here).ALL_CAPS
.run
method per script.src/
directory start with a leading underscore.More checks are planned for the future.
Scopelint is opinionated in that it does not currently let you configure these checks or turn any off. However, if there is demand for this it may be added in a future version.
scopelint spec
Most developers don't have formal specifications they are building towards, and instead only have a general idea of what they want their contracts to do. As a result, documentation and tests are the closest things many protocols have to a specification (unless they go through the formal verification process). And because documentation is often not written until the end of the development process, it is often incomplete or inaccurate, and therefore tests are typically the closest thing to a specification.
scopelint spec
embraces this philosophy of "your tests are your spec" to help developers come up with a spec with minimal effort—structure your tests contracts and test names and described in the Best Practices guide, and scopelint spec
will generate a specification for you!
This specification can be shared with other stakeholders to make sure everyone is on the same page about what the contract should do.
Below is a simple example for an ERC-20 token, the full example repo can be found here.
Currently this feature is in beta, and we are looking for feedback on how to improve it. Right now it's focused on specifications for unit tests, which are very useful for developers but less useful for higher-level stakeholders. As a result, it does not yet include information about protocol invariants or integration test / user-story types of specifications. If you have any thoughts or ideas, please open an issue here.