https://github.com/keep-starknet-strange/cairo-lint
A collection of lints to catch common mistakes and improve your Cairo code.
https://github.com/keep-starknet-strange/cairo-lint
cairo cairo-lang starknet zk zkp
Last synced: 6 months ago
JSON representation
A collection of lints to catch common mistakes and improve your Cairo code.
- Host: GitHub
- URL: https://github.com/keep-starknet-strange/cairo-lint
- Owner: keep-starknet-strange
- Created: 2024-08-02T15:09:31.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-18T14:43:24.000Z (8 months ago)
- Last Synced: 2024-09-19T15:34:22.262Z (8 months ago)
- Topics: cairo, cairo-lang, starknet, zk, zkp
- Language: Rust
- Homepage:
- Size: 114 KB
- Stars: 18
- Watchers: 4
- Forks: 25
- Open Issues: 43
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
cairo-lint
[](https://github.com/keep-starknet-strange/snos/actions/workflows/check.yml)
[](https://t.me/cairolint)[](https://github.com/keep-starknet-strange)
A collection of lints to catch common mistakes and improve your [Cairo](https://github.com/starkware-libs/cairo) code.
## Usage
cairo-lint can either be used as a library or as a standalone binary. It can either just detect or fix the detected
problems.To use it with scarb simply install it like so:
```sh
cargo install scarb-cairo-lint --git https://github.com/keep-starknet-strange/cairo-lint
```and then either run:
```sh
# Checks for bad patterns
scarb cairo-lint
``````sh
# Checks and fixes what it can
scarb cairo-lint --fix
```Note: You can also include test files with the `--test` flag
## Contributors
0xLucqs
💻
Marco Araya Jiménez
💻 ⚠️
Mathieu
💻 ⚠️ 📖
Lau Chaves
💻 ⚠️
Renzo Banegas
💻 ⚠️
Steven
💻 ⚠️
Lindsay Morales
💻 ⚠️
Bernal Hidalgo
💻 ⚠️
Charlotte
💻 ⚠️
Bruno Ambricca
💻 ⚠️
guha-rahul
💻 ⚠️
Yusuf Habib
💻 ⚠️
Tuan Tran
💻 ⚠️
BlockyJ
💻 ⚠️
Luis Jiménez
💻 ⚠️
Mariángela N.
💻 ⚠️
Gianfranco99
💻 ⚠️
## Contributing
**[Join the telegram group](t.me/cairo-lint)**
To run the tests you'll need to provide the path to the cairo corelib (at some point this should be automated but we're
not there yet).```sh
CORELIB_PATH="/path/to/corelib/src" cargo test
```### Cli instructions
To add a new test you can use the dev cli with:
```bash
cargo run --bin create_test
```### Manual instructions
Each lint should have its own tests and should be extensive. To create a new test for a lint you need to create a file
in the [test_files folder](./crates/cairo-lint-core/tests/test_files/) and should be named as your lint. The file should
have this format:```txt
//! > Test name//! > cairo_code
fn main() {
let a: Option = Option::Some(1);
}
```Then in the [test file](crates/cairo-lint-core/tests/tests.rs) declare your lint like so:
```rs
test_file!(if_let, "Test name");
```The first argument is the lint name (also the file name) and the other ones are the test names. After that you can run
```
FIX_TESTS=1 cargo test -p cairo-lint-core
```This will generate the expected values in your test file. Make sure it is correct.