Dependency Selector
The dependency metadata selector matches metadata about the dependency itself — the import kind, the relationship between importer and imported elements, the imported specifiers, and so on. It is the dependency key of a dependency selector:
{ dependency: { /* dependency metadata selector */ } }
All conditions inside the selector are combined with AND; arrays act as OR.
Properties
kind— Matches the dependency kind:"value","type", or"typeof". (<string | string[]>)relationship— Match the relationship between both elements. (<object>)from— The relationship from the importer's perspective. (<string | string[]>)to— The relationship from the imported element's perspective. (<string | string[]>)
specifiers— Matches the imported or exported specifier names. (<string | string[]>)nodeKind— Matches the dependency node name that produced the dependency. (<string | string[]>)source— Matches the literal source string written in theimport/exportstatement. (<string | string[]>)
Relationship values are: internal, child, descendant, sibling, parent, uncle, nephew, and ancestor. The from and to perspectives are inverses of each other (a child from one side is a parent from the other).
// Match type-only dependencies to helpers
{
to: { element: { type: "helper" } },
dependency: { kind: "type" }
}
// Match dependencies whose literal source matches "lodash/*"
{
dependency: { source: "lodash/*" }
}
// Match dependencies to a descendant element
{
dependency: { relationship: { to: "descendant" } }
}
The module property on a dependency metadata selector is deprecated. Use the module sub-selector with source in to instead — for example to: { module: { source: "react" } }. Read the Legacy Dependency Metadata Selector Syntax page for migration guidance.
All selector properties are optional. You can match on a single property, or combine several to target a more specific case. Remember that combined properties use AND logic — every one you specify must match.
Next Steps
- Selectors — the entity/dependency model, array queries, captured values, and templating.
- Policies — use
from/to/dependencytogether withallow/disallow. - Classification → Dependency — the runtime dependency metadata the plugin builds.