contributing.md: add code style guide

This commit is contained in:
end-4
2025-11-15 08:51:42 +01:00
committed by GitHub
parent f3ad9f27f6
commit 6d221f558b
+17 -6
View File
@@ -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 - 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. - 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 ## 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 ## 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. - 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 # Setting up