oakmac / oakmac/standard-clojure-style-js
metadata before a multi-platform reader conditional attaches to only one branch
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 137
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
follow-up to Issue #125
Reader semantics: ^:kw #?(:clj [a] :cljs [b]) applies the metadata to whichever form the conditional yields, i.e. both branches. Your branch currently attaches it only to :clj and silently drops it from :cljs. The expected output below follows the formatter's existing aligned multi-platform style (verified that shape against your build, minus the second ^:kw).
# metadata before a multi-platform reader conditional
> metadata attached to a reader conditional applies to every branch,
> per Clojure reader semantics
--Input
(ns com.example.my-app
(:require
^:kw #?(:clj [aaa.jvm] :cljs [aaa.js])
[bbb.core]))
--Input
--Expected
(ns com.example.my-app
(:require
[bbb.core]
#?(:clj ^:kw [aaa.jvm]
:cljs ^:kw [aaa.js])))
--Expected
# metadata before a multi-platform reader conditional
--Input
(ns com.example.my-app
(:require
^:kw #?(:clj [aaa.jvm] :cljs [aaa.js])
[bbb.core]))
--Input
--Expected
{
"nsSymbol": "com.example.my-app",
"requires": [
{
"metadata": ["^:kw"],
"platform": ":clj",
"symbol": "aaa.jvm"
},
{
"metadata": ["^:kw"],
"platform": ":cljs",
"symbol": "aaa.js"
},
{
"symbol": "bbb.core"
}
]
}
--Expected
duplicating the metadata onto every require object in the parse structure is the pragmatic choice — it means sorting and formatting need no special casing — but it does mean parseNs can't distinguish "metadata on the conditional" from "metadata written inside each branch"; the alternative (a metadata key on some conditional-level structure) doesn't exist in the current data model, so duplication seems right.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at parseNs and trace how metadata before a multi-platform reader conditional enters the parse structure, then follow the existing aligned multi-platform formatting path. Done means the metadata is represented on both the :clj and :cljs require objects, with the formatter producing the shown expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 66/100