vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
  • Attribute Selectors
  • Combinators
  • ID Selectors
  • Security Insights
  • Syntax
  • Examples
  • Match by name
  • Match by version
  • Match by any property
  • Case-insensitive matching
  • What gets selected
  • Combining with other selectors
  • Nested properties
  • See also
  1. Client
  2. /
  3. Selectors
  4. /
  5. Attribute Selectors

Attribute Selectors

Attribute selectors match packages based on values found in their package.json metadata. They work similarly to CSS attribute selectors but operate on package metadata fields instead of HTML attributes.

Syntax

SelectorDescription
[attr]Has the property attr
[attr=value]Property attr exactly equals value
[attr^=value]Property attr starts with value
[attr$=value]Property attr ends with value
[attr~=value]Property attr is a whitespace-separated list containing value
[attr|=value]Property attr equals value or starts with value-
[attr*=value]Property attr contains value
[attr=value i]Case-insensitive comparison
[attr=value s]Case-sensitive comparison (default)

Examples

Match by name

Select a package with an exact name:

Terminal
$ vlt query '[name=react]'

Select all scoped packages:

Terminal
$ vlt query '[name^="@"]'

Select packages in the @vltpkg scope:

Terminal
$ vlt query '[name^="@vltpkg"]'

Match by version

Select packages on a specific version:

Terminal
$ vlt query '[version=1.0.0]'

Select packages with major version 2:

Terminal
$ vlt query '[version^=2]'

Match by any property

Select packages that have a repository field:

Terminal
$ vlt query '[repository]'

Select packages with a specific license:

Terminal
$ vlt query '[license=MIT]'

Select packages whose description mentions "parser":

Terminal
$ vlt query '[description*=parser]'

Case-insensitive matching

Find packages with "React" in the description regardless of case:

Terminal
$ vlt query '[description*=react i]'

What gets selected

Given a project with these dependencies:

Text
my-app
├── @vltpkg/cli@1.0.0
├── react@18.2.0
├── react-dom@18.2.0
└── typescript@5.3.0

The query [name^=react] selects:

Text
my-app
├── @vltpkg/cli@1.0.0
├── react@18.2.0          ✅ name starts with "react"
├── react-dom@18.2.0      ✅ name starts with "react"
└── typescript@5.3.0

Combining with other selectors

Attribute selectors can be combined with combinators and pseudo-classes:

Terminal
$ vlt query ':root > [license=MIT]'

This selects only direct dependencies with an MIT license.

Nested properties

For nested package.json properties (like engines.node or peerDependenciesMeta), use the :attr() pseudo-class:

Terminal
$ vlt query ':attr(peerDependenciesMeta, foo, [optional=true])'

See also

  • :attr() pseudo-class — match nested package.json properties
  • ID Selectors — shorthand for [name=value]

PreviousOverviewNextCombinators

On this page

  • Syntax
  • Examples
  • Match by name
  • Match by version
  • Match by any property
  • Case-insensitive matching
  • What gets selected
  • Combining with other selectors
  • Nested properties
  • See also
Edit this page

Deploy your package on vlt.io

Publish scoped and private packages, manage organizations and access, and give every developer and CI environment a consistent source for public and private JavaScript dependencies.

Publish now