(tpl*) - JavaScript
template literals matched by a pseudo-evaluated value that includes interpolations
clojure
(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.
clojure
(tpl* /email|ssn/i gql)Selects in lines { 1 } but not in { 2, 3 }:
typescript
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.
clojure
(tpl* /https?:/)Selects in lines { 1, 2 } but not in { 3 }:
typescript
const url1 = `https://api.example.com/users/${id}`
const url2 = `http://localhost:${port}/health`
const url3 = `/users/${id}`Remove !important from styled-components templates.
clojure
(tpl* /!important/ (mem div styled))Selects in lines { 0 } but not in { 0, 0 }:
typescript
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