Skip to content

Commit 7e080f9

Browse files
committed
feat: add nix fmt
1 parent 298821f commit 7e080f9

4 files changed

Lines changed: 49 additions & 1 deletion

File tree

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,43 @@ npm test
207207

208208
### Formatting and Linting
209209

210+
You can format and lint the entire project at once using **Nix** (if you have it installed and flakes enabled):
211+
212+
```bash
213+
# Format and lint everything (Python, JavaScript, Nix)
214+
nix fmt
215+
```
216+
217+
Alternatively, you can run the tools individually for each language:
218+
219+
#### Python (ruff)
220+
221+
```bash
222+
# Format Python code
223+
ruff format .
224+
225+
# Lint and fix Python code
226+
ruff check --fix .
227+
```
228+
229+
#### Nix (alejandra)
230+
231+
```bash
232+
# Format Nix files
233+
alejandra .
234+
```
235+
236+
#### JavaScript & Assets (ESLint/Prettier)
237+
210238
```bash
211239
# Lint the project
212240
npm run lint
213241

214242
# Format the code
215243
npm run format
244+
245+
# Lint and fix JavaScript
246+
npm run lint:fix
216247
```
217248

218249
## License

docs/usage/book.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ Hi
5555
This examples are available in the [template](https://github.com/daniqss/stepcode/tree/main/template) folder of the repository.
5656

5757
### nix
58+
5859
If you are a [nix](https://nixos.org/download/) user, the repo flake exposes a `devShell` to download all the dependencies and have a ready to use environment. You can enter it with:
5960

6061
```sh
6162
nix develop .
6263
```
6364

6465
# Template
66+
6567
Furthermore, the template book is available using:
6668

6769
```sh

flake.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
python314
3232
uv
3333
ruff
34+
alejandra
3435

3536
nodejs
3637
];
@@ -41,6 +42,19 @@
4142
};
4243
});
4344

45+
formatter = eachSystem (pkgs:
46+
with pkgs;
47+
writeShellScriptBin "format" ''
48+
set -e
49+
${alejandra}/bin/alejandra .
50+
51+
${ruff}/bin/ruff format .
52+
${ruff}/bin/ruff check --fix .
53+
54+
npm run format
55+
npm run lint:fix
56+
'');
57+
4458
templates.default = {
4559
path = ./template;
4660
description = "basic template to create a new stepcode book";

template/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: My blog about stepcode
55
# {{title}}
66

77
## my posts
8+
89
- [first post](./blog/first-post.html)
910
- [second post](./blog/second-post.html)
10-
- [first recipe](./cooking/first-recipe.html)
11+
- [first recipe](./cooking/first-recipe.html)

0 commit comments

Comments
 (0)