Pseudo-class Selectors
Pseudo-class selectors are functional selectors that accept arguments to filter packages. They work similarly to CSS pseudo-classes but operate on dependency graph nodes.
Available pseudo-class selectors
:attr() Match packages by nested package.json properties
:dist() Match packages by registry dist-tag
:has() Match packages that have descendants matching a selector
:host() Switch graph context to another project or scope
:is() Match any element in a forgiving selector list
:not() Negation — exclude packages matching a selector
:outdated() Match packages with newer versions available
:published() Match packages by publication date
:semver() Match packages by semver comparisons
:spec() Match edges by their package specifier
:path() Match workspace and file packages by file path
:type() Match packages by type (registry, file, git, etc.)
:diff() Match packages whose files have changed
:hostname() Match packages by upstream hostname
:registry() Match packages by registry configuration name
Quick reference
| Selector | Description | Example |
|---|---|---|
:attr() | Nested property match | :attr(engines, [node]) |
:dist() | By registry dist-tag | :dist(latest) |
:has() | Has matching descendants | :has(.peer[name=react]) |
:host() | Switch graph context | :host(local) :malware |
:is() | Match any in list | :is([name=a], [name=b]) |
:not() | Negation | :not([license=MIT]) |
:outdated() | Newer version exists | :outdated(major) |
:published() | By publish date | :published(">2024") |
:semver() | Semver comparison | :semver(^1.0.0) |
:spec() | By specifier string | :spec(^1.0.0) |
:path() | By file path | :path("packages/**") |
:type() | By package type | :type(git) |
:diff() | Changed files | :diff(main) |
:hostname() | By upstream hostname | :hostname(github.com) |
:registry() | By registry name | :registry(npm) |
See also
- Pseudo-state Selectors — simple
state-based selectors (
:root,:dev, etc.) - Security Insights — Socket-powered security pseudo-selectors