Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP2stack specificStack: TypeScript / cheerio
readabilitylibrary-usagedom
Use the library's data accessors instead of manual attribute strings
With cheerio/jQuery-style APIs, prefer element.data('id') / element.data('id', v) over manually reading and writing data-* attributes; it's cleaner and less error-prone.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const id = element.attr('data-id'); |
| 2 | element.attr('data-id', String(id)); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const id = element.data('id'); |
| 2 | element.data('id', id); |
Explanation (EN)
Objašnjenje (HR)