From 6d221f558b3bde687963077bf7841744655f829b Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sat, 15 Nov 2025 08:51:42 +0100 Subject: [PATCH] contributing.md: add code style guide --- .github/CONTRIBUTING.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d1affa686..d95366fb4 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,22 +2,33 @@ - Please, please, please, make multiple PRs if you have many features/fixes, and don't shove your personal changes along with the PR, including changed defaults - We can accept features that we do not personally want, but in that case we will ask you to make it configurable/optionally loaded. -- If you want to start working on something big to contribute, it might be a good idea to ask first to not waste your effort (but if you've already done it for yourself, it doesn't hurt to submit). +- If you want to start working on something _big_ to contribute, it might be a good idea to ask first to not waste your effort (but if you've already done it for yourself, it doesn't hurt to submit). -# Code details +# Translations -## Contributing to i18n +See `dots/.config/quickshell/ii/translations/tools` -For contributing in translation (i18n) for Quickshell, see also `dots/.config/quickshell/ii/translations/tools`. +# Code ## Dynamic loading -- If something's not always necessary, especially when guarded by a config option to enable/disable, put it in a `Loader`. One tip with `Loader`s is sometimes you will need to declare positioning properties (like `anchors`) in the `Loader`, not the `sourceComponent`. +- If something's not always necessary, especially when guarded by a config option to enable/disable, put it in a `Loader` + - Note that you will need to declare positioning properties (like `anchors`) in the `Loader`, not the `sourceComponent` + - When something that's to be dynamically loaded doesn't affect its parent layout, you can have a fading animation by using FadeLoader and set the `shown` prop instead of `active` and `visible` ## Practical concerns - Make sure what you add does not require significant resources for a minor purpose or harm usability just for the sake of looking nice. The dotfiles must remain practical for daily driving. -- If there is something really fancy and impractical anyway, add a config option for it and make sure it's disabled by default. +- If there is something really fancy and impractical anyway, add a config option for it and make sure it's disabled by default (example: constantly rotating background clock) + +## Style + +- Spaces + - Space properties and children data into meaningful groups. (but of course, don't use 2+ blanks in a row) + - Put spaces between text and operators: `if (condition) { ... } else { ... }` instead of `if(condition){ ... }else{ ... }` +- As you can see, it's pretty easy to use lots of nesting. There's no hard limit, end-4 himself nests a lot too, but avoid/mitigate that: + - Prefer early return: Use something like `if (!condition) return; doStuff();` instead of `if (condition) { doStuff() }` + - If you feel it's a bother to refractor something into a new file, remember there's `component` to declare reusable components in the same file. # Setting up