mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-03-11 16:39:10 +00:00
1.7 KiB
1.7 KiB
htmx Coding Standards
- Prefer
forloop toforEach(easier to debug) - Assign complex expressions to a local variable rather than using them directly in statements (easier to debug)
- Private methods should be prefixed with
__. Thedisttask will replace double underscore with#when it builds the final script. This allows us to unit test private methods. - "Internal" methods should be prefixed with a
_. These methods are not guaranteed to never change, but may be useful for special cases (e.g. thequirkshtmx 2.0 compatibility extension) - Public methods are forever, be very careful with them
- Use
letrather thanconst - Publicly surfaced properties should not be shortened, except "Configuration" which can be shortened to "Config"
- Local variables should have descriptive names in most cases.
ctxandeltare acceptable. - Generally all state in the trigger -> request -> swap life cycle should be stored on ctx. Try to avoid overwrighting an existing property, pick a new property name. These properties are part of the public API and must be documented.
AI Policy
AI may not be used to generate any significant amount of code that is added to htmx.js. It may be used to suggest code, but that code must be audited and every line understood by the author.
AI may be used to generate tests for htmx. These tests should follow the existing standards as much as possible and should ideally be relatively small. No more than one test should be added at a time, and the test should be reviewed for correctness.
In general, try to keep any AI contributions small and well understood.
“A computer can never be held accountable, therefore a computer must never make a management decision.”