(jsx) - JavaScript
JSX elements and fragments, matched by name, attributes, and children
clojure
(jsx name? attrs? children?)Where:
- name: element name (the
Buttonin<Button />, or<>for fragments) * - attrs: attributes on the element *
- children: child nodes within the element *
Matching:
- elements, e.g.
<div>...</div> - self-closing elements, e.g.
<Button /> - member and namespaced elements, e.g.
<A.B /> - fragments, e.g.
<>...</>
Behavior
- Fragments only match when the name selector is
<>. - Self-closing elements cannot match when a
childrenselector is provided.
Examples
Find components rendered as fragments so they can be wrapped for styling.
clojure
(jsx <>)Selects in lines { 1 } but not in { 2 }:
typescript
const A = () => <>Hello</>
const B = () => <div>Hello</div>Identify buttons that still pass inline handlers for refactoring.
clojure
(jsx Button (attr onClick))Selects in lines { 1 } but not in { 2, 3 }:
typescript
<Button onClick={track}>Save</Button>
<Button disabled>Save</Button>
<Link onClick={track}>Save</Link>Find dialog components that render translated children.
clojure
(jsx Dialog _ (child _ (call t)))Selects in lines { 1 } but not in { 2, 3 }:
typescript
<Dialog>{t("welcome")}</Dialog>
<Dialog>{"Welcome"}</Dialog>
<Modal>{t("welcome")}</Modal>Arguments
name
- Identifier: shorthand for (id)
- Pattern: shorthand for (id)
- (id)
- (:into)
- (:nearest)
- (:and)
- (:or)
- (:not)
- (:text)
- (:kind)
- (:replace)
- (:replace-in)
- (:capture)
- (:ref)
- (arr)
- (attr)
- (bool)
- (call)
- (child)
- (comp)
- (export)
- (fun)
- (id)
- (id+)
- (import)
- (jsx)
- (mem)
- (null)
- (num)
- (obj)
- (of)
- (prop)
- (regex)
- (regex+)
- (str)
- (str*)
- (str+)
- (tpl)
- (tpl*)
- (var)