Function Parameter Conventions¶
To keep call sites predictable, functions across extension/ should take the
same domain concepts in the same order and under the same name. The
scanner at scripts/check-param-order.mjs
reports where the codebase drifts from the convention below. It is report
only — it never edits code.
Run it with:
npm run lint:params # scan all of extension/
node scripts/check-param-order.mjs <path> # scan specific files/dirs
It exits non-zero when any violation is found.
The convention¶
The source of truth is the data in
scripts/param-conventions.mjs. Each
recognized concept has one canonical name. The order of the concept list
is the canonical parameter order: a concept listed earlier must appear
earlier in a function’s parameter list.
Order |
Canonical name |
Meaning |
|---|---|---|
1 |
|
The DOM element being operated on |
2 |
|
A subreddit’s bare name ( |
3 |
|
A subreddit path ( |
4 |
|
A user / account |
5 |
|
A link or self post |
6 |
|
A comment |
7 |
|
A prefixed thing id ( |
8 |
|
A bare base-36 id ( |
A handful of legacy synonyms (e.g. an old sub, username, or post
parameter) are also recognized in scripts/param-conventions.mjs and reported
as rename candidates. The codebase is currently fully compliant — none remain —
but the synonyms stay defined so the scanner catches any regression.
Any other data parameters (text, reason, title, …) and a destructured
options object may appear among these; their positions are not enforced.
id and fullname are deliberately separate concepts, not synonyms: a
fullname carries a type prefix (t1_, t3_, …) while an id is the bare
base-36 string. subredditPath is likewise distinct from subreddit.
Some names that look like concepts are intentionally unrecognized because they are overloaded and cannot be classified by name alone:
thing— a Reddit “thing”: the.thingDOM element in the DOM layers, or the raw API data object in the API/data layers. Never a barefullnamestring.target— sometimes a DOMElement, but also a flair payload, anEventTarget, aNode, or an arbitrary config object.node— a DOMNode(broader thanElement; includes text nodes).author— sometimes a boolean flag (an “author context” prop), and elsewhere the precise term for a content author, distinct from a genericuser.link/postLink—linkis sometimes a raw URL being submitted (not a reference to a submission);postLinkis a submission’sfullname.subredditName— an explicit name often paired with a siblingsubredditUrl, and threaded through JSX props / custom-event detail contracts.
What the scanner checks¶
ORDER — only the relative order of recognized concepts is enforced (e.g.
subredditbeforesubmission, or anidbefore asubreddit). Generic data params and the options object are skipped, so a leading unrecognized param never triggers an order flag.NAMING — a parameter (or a destructured object key) uses a synonym instead of the canonical name.
JSDOC — a function’s
@paramtags drift from its real signature (missing, extra, or mis-ordered tags). Only checked when the function already documents at least one@param.
Tuning the convention¶
The convention is intended to be adjusted as the report is reviewed — nothing is
auto-fixed, so changes here only affect what gets reported. Edit
scripts/param-conventions.mjs to:
add or remove synonyms (overloaded names are deliberately left out — only add a synonym when one name unambiguously means one concept),
reorder concepts, or
introduce new concepts.
*ID-suffixed names (postID, commentID, templateID) are intentionally
left unrecognized for now; map them to concepts here once their meaning is
settled.