Skip to content

vibator namespace

This document is the reference of the vibator namespace and all its subnamespaces, properties, and functions as they are provided by the base vibator framework.

Namespaces

  • project — Navigate the files and folders in this project.
  • ts — Parse and manipulate TypeScript files.
  • json — Parse JSON files.
  • object — Utilities for plain objects.
  • text — Parse and manipulate files as plain text.
  • ignore — Check ignore markers for a rule at line, node, or file level.
  • git — Gateway to git functionality.
  • shell — Gateway to the shell.
  • package — Parse and manage package.json files.
  • module — Resolve module specifiers to files.
  • glob — Match paths against globs.

project

Navigate the files and folders in this project, and write to them.

DeclarationDescription
root: stringThe absolute path of the project root.
files: FileSetEvery file in scope for the current run.
folders: FolderSetEvery top-level folder in the project.
write(path: string, content: string): voidWrites content to an absolute path, creating the file when the path is new and overwriting it when the path exists.

ts

Parse and manipulate TypeScript files.

DeclarationDescription
parse(file: File): AstParses a TypeScript or JavaScript file into a syntax tree.
program(tsconfig: File): ProgramBuilds a type-checked program from a tsconfig file.

json

Parse JSON files.

DeclarationDescription
parse(file: File): unknownParses a JSON file into its value.
keys(value: unknown): string[]Flattens a value into its dotted key paths.

object

Utilities for plain objects.

DeclarationDescription
merge(base: T, override: T): TDeep-merges override onto base; objects merge by key, arrays and other values are replaced, and override wins.

text

Parse and manipulate files as plain text.

DeclarationDescription
lines(file: File): Line[]Splits a file into numbered lines.
maskComments(file: File): stringReturns the file content with JavaScript and TypeScript comments blanked, keeping line positions.
maskCode(file: File): stringReturns the file content with Markdown code fences and spans blanked, keeping line positions.
positionAt(file: File, offset: number): PositionResolves a character offset to a line and column.
matches(file: File, pattern: RegExp): Match[]Returns every match of a pattern with its position.
binary(file: File): booleanReports whether the file content is binary.

ignore

Check whether an ignore marker silences a rule. A marker reads vibator-ignore <rule-id>: <reason> on the line above the finding, or vibator-ignore-file <rule-id>: <reason> anywhere in the file. The reason is optional.

DeclarationDescription
line(file: File, line: number, rule: string): booleanReports whether a marker on the line above names the rule.
node(node: Node, rule: string): booleanReports whether a marker above the node or an enclosing class, function, method, interface, enum, or module names the rule.
file(file: File, rule: string): booleanReports whether a file-level marker names the rule.

git

Gateway to git functionality.

DeclarationDescription
isRepo(): booleanReports whether the project root sits inside a git repository.
files(): string[]The tracked and untracked-tracked-eligible paths git keeps.
untrackedFiles(): string[]The untracked paths git keeps.
changedFiles(): string[]The paths this working tree changed against HEAD, present on disk.
stagedFiles(): string[]The paths staged for the next commit, present on disk.
changedSince(base: string): string[]The paths this branch changed since it diverged from base.
status(paths: string[]): StatusEntry[]The working-tree status of the given paths.
restore(paths: string[]): voidRestores the given tracked paths from the index.

shell

Gateway to the shell.

DeclarationDescription
run(command: string, options: ShellOptions): ShellResultRuns a command and returns its outcome.

package

Parse and manage package.json files.

DeclarationDescription
root: PackageManifestThe parsed root package.json.
parse(file: File): PackageManifestParses a package.json file into a manifest.

module

Resolve module references and specifiers to files.

DeclarationDescription
resolve(specifier: string, from?: string): stringResolves a reference to an absolute file path, from from.

The four reference forms, in resolution order:

FormExampleMeaning
Absolute path/abs/biome.jsonThe path as it is.
package:path@vibator/gate:biome.base.jsonThe file inside the installed package, ignoring its exports map.
Starts with ../biome.json, .vibator/biome.jsonA local file, joined onto the directory of from.
Anything elsezod, @vibator/gate/biomeA package specifier resolved by Node, honoring the exports map.

glob

Match paths against globs; prefix a glob with ! to exclude.

DeclarationDescription
matches(path: string, globs: string | string[]): booleanWhether the path matches the globs and none of the exclusions.

Types

The objects returned and accepted across the namespaces above.

FileSet

An ordered collection of files, with glob filtering and lookup by path.

DeclarationDescription
match(glob: string | string[]): FileSetFilters the set to files matching the glob or globs.
get(path: string): FileThe file at an absolute path.
length: numberThe count of files in the set.
forEach(visit: (file: File, index: number) => void): voidRuns a function over each file in order.
map(transform: (file: File, index: number) => T): T[]Maps each file to a value.
filter(keep: (file: File) => boolean): FileSetReturns the files that satisfy a predicate.
find(match: (file: File) => boolean): File | undefinedReturns the first file that satisfies a predicate.
paths(): string[]The absolute paths in the set, sorted.

File

One file in the project.

DeclarationDescription
path: stringThe absolute path, forward-slashed.
name: stringThe file base name.
ext: stringThe file extension, including the dot.
content: stringThe file content decoded as UTF-8 text.
bytes: BufferThe raw file content as bytes.

FolderSet

An ordered collection of folders, with glob filtering and lookup by path.

DeclarationDescription
match(glob: string | string[]): FolderSetFilters the set to folders matching the glob or globs.
get(path: string): Folder | undefinedThe folder at an absolute path.
length: numberThe count of folders in the set.
forEach(visit: (folder: Folder, index: number) => void): voidRuns a function over each folder in order.
map(transform: (folder: Folder, index: number) => T): T[]Maps each folder to a value.
filter(keep: (folder: Folder) => boolean): FolderSetReturns the folders that satisfy a predicate.
find(match: (folder: Folder) => boolean): Folder | undefinedReturns the first folder that satisfies a predicate.
paths(): string[]The absolute paths in the set, sorted.

Folder

One folder in the project.

DeclarationDescription
path: stringThe absolute path, forward-slashed.
name: stringThe folder base name.
files: FileSetThe files directly inside this folder.
folders: FolderSetThe folders directly inside this folder.

Ast

The syntax tree of a parsed file.

DeclarationDescription
source: SourceFileThe TypeScript source file.
nodes: NodeCursor[]Every node, flattened in source order.
lineAt(offset: number): numberThe 1-based line a character offset falls on.

NodeCursor

One node in a syntax tree with its position.

DeclarationDescription
node: NodeThe TypeScript node.
line: numberThe 1-based line the node starts on.

Program

A type-checked TypeScript program.

DeclarationDescription
checker: TypeCheckerThe program type checker.
files: FileSetThe files included in the program.
ast(file: File): AstThe syntax tree of a file in the program.

Line

One line of text with its number.

DeclarationDescription
number: numberThe 1-based line number.
text: stringThe line content.

Position

A line and column in a file.

DeclarationDescription
line: numberThe 1-based line.
column: numberThe 1-based column.

Match

One match of a pattern with its position.

DeclarationDescription
text: stringThe matched text.
index: numberThe character offset of the match.
line: numberThe 1-based line the match starts on.
column: numberThe 1-based column the match starts on.
groups: string[]The captured groups.

StatusEntry

The git status of one path.

DeclarationDescription
path: stringThe repo-relative path.
staged: booleanTrue when the path holds staged changes.
unstaged: booleanTrue when the path holds unstaged changes.
untracked: booleanTrue when git tracks the path for the first time.

ShellOptions

The options for a shell command.

DeclarationDescription
cwd: stringThe working directory, relative to the project root.
timeoutMs: numberThe time a command runs before it is stopped, in milliseconds.

ShellResult

The outcome of a shell command.

DeclarationDescription
ok: booleanTrue when the command exits with code 0.
stdout: stringThe captured standard output.
stderr: stringThe captured standard error.
code: numberThe exit code.

PackageManifest

A parsed package.json.

DeclarationDescription
name: stringThe package name.
version: stringThe package version.
scripts: Record<string, string>The scripts, keyed by name.
dependencies: Record<string, string>The runtime dependencies, keyed by name.
devDependencies: Record<string, string>The development dependencies, keyed by name.
peerDependencies: Record<string, string>The peer dependencies, keyed by name.

External types

Types provided by other packages.

TypeSource
BufferNode.js
SourceFileTypeScript
NodeTypeScript
TypeCheckerTypeScript

Released under the MIT License.