Skip to content

feat: add perttier to format the markdown files #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ Boot up the documentation site locally, with live reloading of the source code:
$ pnpm run docs:dev
```

If you made a lot of changes, run the following command to check for typos before submitting a pull request:
If you made a lot of changes, run the following command to check for typos & format the docs before submitting a pull request:

> Generally, `nix develop` will add a pre-commit hook to run the following command before you commit.

```sh
$ typos -w
$ prettier --write .
```

After executing the above command, visit <http://localhost:5173> and try modifying the source code. You'll get live update.
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LICENSE.md
dist
pnpm-lock.yaml
flake.lock
vercel.json
cache
temp
.temp
5 changes: 5 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# https://prettier.io/docs/en/options
semi: false
singleQuote: false
printWidth: 80
trailingComma: es5
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ An unofficial and opinionated NixOS & Flakes :book: for beginners: https://nixos
> If you're using macOS, [ryan4yin/nix-darwin-kickstarter](https://github.com/ryan4yin/nix-darwin-kickstarter) may be a good starting point for you,
> you can learn how to use Nix with this book and take nix-darwin-kickstarter as a start point to build your own Nix configuration.


## Feedback and Discussion

I’m not an expert on NixOS, and I’ve only been using NixOS for less than 9 months until now(2024-02),
I’m not an expert on NixOS, and I’ve only been using NixOS for less than 9 months until now(2024-02),
so there must be some misconceptions or inappropriate examples in the book.
If anyone finds anything incorrect or have any questions / suggestions, just let me know about it by open an issue or join the discussion on [GitHub Discussions](https://github.com/ryan4yin/nixos-and-flakes-book/discussions), I'm glad continue to optimize the content of this book.

Expand All @@ -24,7 +23,6 @@ Even though I knew I could make mistakes, it's much better than do nothing.
My hope is that this book can help more people, enabling them to experience the joys of NixOS.
Hope you like it!


## Introduction to Flakes

The flakes experimental feature is a major development for Nix, it introduces a policy for managing dependencies between Nix expressions, it improves reproducibility, composability and usability in the Nix ecosystem. Although it's still an experimental feature, flakes have been widely used by the Nix community.[^1]
Expand Down Expand Up @@ -58,7 +56,6 @@ Thank you to [all the people](https://github.com/ryan4yin/nixos-and-flakes-book/

[NixOS & Flakes Book](https://github.com/ryan4yin/nixos-and-flakes-book) © 2023 by Ryan Yin is licensed under [CC BY-SA 4.0](./LICENSE.md)


[^1]: [Flakes - NixOS Wiki](https://nixos.wiki/index.php?title=Flakes)
[^2]: [Flakes are such an obviously good thing](https://grahamc.com/blog/flakes-are-an-obviously-good-thing/)
[^3]: [Draft: 1 year roadmap - NixOS Foundation](https://nixos-foundation.notion.site/1-year-roadmap-0dc5c2ec265a477ea65c549cd5e568a9)
7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
nodejs = super.nodejs_20;
pnpm = super.nodePackages.pnpm;
yarn = super.yarn.override {inherit nodejs;};
prettier = super.nodePackages.prettier;
})
];
pkgs = import nixpkgs {inherit overlays system;};
Expand All @@ -28,6 +29,7 @@
nodejs
pnpm
yarn
prettier

git
typos
Expand All @@ -40,12 +42,17 @@
hooks = {
typos.enable = true; # Source code spell checker
alejandra.enable = true; # Nix linter
prettier.enable = true; # Markdown & TS formatter
};
settings = {
typos = {
write = true; # Automatically fix typos
ignored-words = [];
};
prettier = {
write = true; # Automatically format files
configPath = "./.prettierrc.yaml";
};
};
};
};
Expand Down