Skip to main content
Version: 7.0.0

File Selector

The file sub-selector matches the file itself, based on the file descriptors you configure. It is the file key of an entity selector:

{ file: { /* file sub-selector */ } }

File descriptors categorize files independently from the element they belong to — a single file can carry several categories. All conditions inside the selector are combined with AND; arrays act as OR.

Properties

  • categories — Matches against the file's category array. Accepts a micromatch pattern (matches if any category matches) or an array query object for richer constraints. (<string | string[] | null | ArrayQuery>)
  • path — Matches the file path. (<string | string[] | null>)
  • captured — Match captured values. (<object | object[] | null>)
  • isIgnored — Whether the file is ignored. (<boolean>)
  • isUnknown — Whether the file matches no file descriptor. (<boolean>)
// Match test files (a file descriptor with category "test")
{ file: { categories: "test" } }

// Match style files
{ file: { categories: "style" } }

// Match files in any category whose name starts with "test"
{ file: { categories: "test*" } }
info

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.

note

File categories are the recommended replacement for the deprecated element-level category. Read the Element Selector Legacy Syntax section for migration guidance.

Next Steps

  • Selectors — the entity/dependency model, array queries, captured values, and templating.
  • Element selector — match the element a file belongs to.
  • Module selector — match external and core module imports.
  • Files — define file descriptors and read the file description properties.