Skip to content

A collection of lints to catch common mistakes and improve your Cairo code.

Notifications You must be signed in to change notification settings

keep-starknet-strange/cairo-lint

Repository files navigation

cairo-lint

Check Workflow Status Telegram

Exploration_Team

A collection of lints to catch common mistakes and improve your 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:

cargo install scarb-cairo-lint --git https://github.com/keep-starknet-strange/cairo-lint

and then either run:

# Checks for bad patterns
scarb cairo-lint
# Checks and fixes what it can
scarb cairo-lint --fix

Note: You can also include test files with the --test flag

Contributors

0xLucqs
0xLucqs

💻
Marco Araya Jiménez
Marco Araya Jiménez

💻 ⚠️
Mathieu
Mathieu

💻 ⚠️ 📖
Lau Chaves
Lau Chaves

💻 ⚠️
Renzo Banegas
Renzo Banegas

💻 ⚠️
Steven
Steven

💻 ⚠️
Lindsay Morales
Lindsay Morales

💻 ⚠️
Bernal Hidalgo
Bernal Hidalgo

💻 ⚠️
Charlotte
Charlotte

💻 ⚠️
Bruno Ambricca
Bruno Ambricca

💻 ⚠️
guha-rahul
guha-rahul

💻 ⚠️
Yusuf Habib
Yusuf Habib

💻 ⚠️
Tuan Tran
Tuan Tran

💻 ⚠️
BlockyJ
BlockyJ

💻 ⚠️
Luis Jiménez
Luis Jiménez

💻 ⚠️
Mariángela N.
Mariángela N.

💻 ⚠️
Gianfranco99
Gianfranco99

💻 ⚠️

Contributing

Join the telegram group

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).

CORELIB_PATH="/path/to/corelib/src" cargo test

Cli instructions

To add a new test you can use the dev cli with:

cargo run --bin create_test <lint_name>

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 and should be named as your lint. The file should have this format:

//! > Test name

//! > cairo_code
fn main() {
    let a: Option<felt252> = Option::Some(1);
}

Then in the test file declare your lint like so:

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 <name_of_lint>

This will generate the expected values in your test file. Make sure it is correct.

About

A collection of lints to catch common mistakes and improve your Cairo code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages