(tpl*)
template literals matched by a pseudo-evaluated value that includes interpolations
(tpl* val tag?)Where:
- val: the text pattern to find when template parts are joined *
- tag: the tag function (the
gqlingql`...`) *
Matching:
- template literals, e.g.
`hello ${name}` - tagged template literals, e.g.
gql`query { ... }`
Behavior
- Pseudo-evaluates templates by concatenating literal fragments and interpolation identifiers/literals in order.
- Expressions that are not identifiers or literals contribute no text to the evaluated value.
Examples
Locate GraphQL queries that request PII fields.
(tpl* /email|ssn/i gql)Selects in lines { 1 } but not in { 2, 3 }:
const q1 = gql`query User { id email }`
const q2 = gql`query User { id name }`
const q3 = sql`SELECT email FROM users`Find URLs built via template strings before migrating to a URL builder.
(tpl* /https?:/)Selects in lines { 1, 2 } but not in { 3 }:
const url1 = `https://api.example.com/users/${id}`
const url2 = `http://localhost:${port}/health`
const url3 = `/users/${id}`Remove !important from styled-components templates.
(tpl* /!important/ (mem div styled))Selects in lines { 0 } but not in { 0, 0 }:
const Button = styled.div`
color: red !important;
`
const Badge = styled.span`
color: blue !important;
`
const Link = styled.div`
color: red;
`Arguments
val
• Identifier • String • Pattern
Does NOT support: Composition — Free-form Selection — Refinement — Replacement
tag
• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
• (:kind) • (:ref) • (:text) • (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) • (:into) • (:and) • (:or) • (:not) • (:replace) • (:capture)