Appendix F - Useful Development Tools

Di lampiran ini, kita akan membahas beberapa alat pengembangan yang berguna yang disediakan oleh proyek Cairo. Kita akan melihat pemformatan otomatis, cara cepat untuk menerapkan perbaikan peringatan, linter, dan integrasi dengan IDE.

Pemformatan otomatis dapat dilakukan dengan menggunakan perintahscarb fmt

Scarb projects can be formatted using the scarb fmt command. If you're using the Cairo binaries directly, you can run cairo-format instead. Many collaborative projects use scarb fmt to prevent arguments about which style to use when writing Cairo: everyone formats their code using the tool.

To format any Cairo project, enter the following inside the project directory:

scarb fmt

For things you do not want scarb fmt to mangle, use #[cairofmt::skip]:

#[cairofmt::skip]
let table: Array<ByteArray> = array![
    "oxo",
    "xox",
    "oxo",
];

Integrasi IDE Menggunakan cairo-language-server

To help IDE integration, the Cairo community recommends using the cairo-language-server. This tool is a set of compiler-centric utilities that speaks the Language Server Protocol, which is a specification for IDEs and programming languages to communicate with each other. Different clients can use cairo-language-server, such as the Cairo extension for Visual Studio Code.

Visit the vscode-cairo page to install it on VSCode. You will get abilities such as autocompletion, jump to definition, and inline errors.

Catatan: Jika Anda telah menginstal Scarb, seharusnya bekerja tanpa masalah dengan ekstensi Cairo untuk VSCode, tanpa instalasi manual server bahasa.