feat: add perttier to format the markdown files (#124)

This commit is contained in:
Ryan Yin 2024-03-16 18:00:32 +08:00 committed by GitHub
parent a9f4bb9233
commit af650be728
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 5 deletions

View File

@ -46,10 +46,13 @@ Boot up the documentation site locally, with live reloading of the source code:
$ pnpm run docs:dev $ 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 ```sh
$ typos -w $ typos -w
$ prettier --write .
``` ```
After executing the above command, visit <http://localhost:5173> and try modifying the source code. You'll get live update. After executing the above command, visit <http://localhost:5173> and try modifying the source code. You'll get live update.

8
.prettierignore Normal file
View File

@ -0,0 +1,8 @@
LICENSE.md
dist
pnpm-lock.yaml
flake.lock
vercel.json
cache
temp
.temp

5
.prettierrc.yaml Normal file
View File

@ -0,0 +1,5 @@
# https://prettier.io/docs/en/options
semi: false
singleQuote: false
printWidth: 80
trailingComma: es5

View File

@ -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, > 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. > 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 ## Feedback and Discussion
Im not an expert on NixOS, and Ive only been using NixOS for less than 9 months until now(2024-02), Im not an expert on NixOS, and Ive 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. 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. 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.
@ -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. My hope is that this book can help more people, enabling them to experience the joys of NixOS.
Hope you like it! Hope you like it!
## Introduction to Flakes ## 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] 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]
@ -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) [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) [^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/) [^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) [^3]: [Draft: 1 year roadmap - NixOS Foundation](https://nixos-foundation.notion.site/1-year-roadmap-0dc5c2ec265a477ea65c549cd5e568a9)

View File

@ -19,6 +19,7 @@
nodejs = super.nodejs_20; nodejs = super.nodejs_20;
pnpm = super.nodePackages.pnpm; pnpm = super.nodePackages.pnpm;
yarn = super.yarn.override {inherit nodejs;}; yarn = super.yarn.override {inherit nodejs;};
prettier = super.nodePackages.prettier;
}) })
]; ];
pkgs = import nixpkgs {inherit overlays system;}; pkgs = import nixpkgs {inherit overlays system;};
@ -28,6 +29,7 @@
nodejs nodejs
pnpm pnpm
yarn yarn
prettier
git git
typos typos
@ -40,12 +42,17 @@
hooks = { hooks = {
typos.enable = true; # Source code spell checker typos.enable = true; # Source code spell checker
alejandra.enable = true; # Nix linter alejandra.enable = true; # Nix linter
prettier.enable = true; # Markdown & TS formatter
}; };
settings = { settings = {
typos = { typos = {
write = true; # Automatically fix typos write = true; # Automatically fix typos
ignored-words = []; ignored-words = [];
}; };
prettier = {
write = true; # Automatically format files
configPath = "./.prettierrc.yaml";
};
}; };
}; };
}; };