Registry / testing / vfile-message

vfile-message

JSON →
library4.0.3jsnpmunverified

vfile-message is a JavaScript utility for creating standardized lint messages within the `vfile` ecosystem. It provides a `VFileMessage` class, extending `Error`, that can be used to represent warnings or errors, particularly when a full `VFile` instance is not available or desired. Currently at version 4.0.3, the package maintains an active release cadence with frequent updates focusing on type improvements and minor fixes. Its core differentiator is the ability to generate structured messages with fields like `reason`, `line`, `column`, `ruleId`, and `source`, making them consumable by linters and other processing tools that operate on virtual files. It integrates well with the Unified (unist) ecosystem, offering TypeScript definitions for robust development.

npm install vfile-message
INSTALL
IMPORT
SIG · VFILE-MESSAGE
V
vfile-message
testingjavascriptv4.0.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

VFileMessage
✓ import { VFileMessage } from 'vfile-message'
✗ const VFileMessage = require('vfile-message')
vfile-message is ESM-only since v4.0.0. CommonJS `require()` is not supported.
Options
✓ import type { Options } from 'vfile-message'
This is a TypeScript type for configuring VFileMessage instances.

Demonstrates creating a new `VFileMessage` instance with a reason and detailed positional information, then logging it to the console.

import { VFileMessage } from 'vfile-message'; const message = new VFileMessage( 'Unexpected unknown word `braavo`, did you mean `bravo`?', {place: {column: 8, line: 1}, ruleId: 'typo', source: 'spell'} ); console.log(message); /* Yields: [1:8: Unexpected unknown word `braavo`, did you mean `bravo`?] { reason: 'Unexpected unknown word `braavo`, did you mean `bravo`?', line: 1, column: 8, ancestors: undefined, cause: undefined, fatal: undefined, place: {line: 1, column: 8}, ruleId: 'typo', source: 'spell' } */
Debug
Known issues
breakingvfile-message v4.0.0 and later require Node.js 16 or higher due to the transition to ESM and export maps.
fix
Upgrade your Node.js environment to version 16 or later. If unable to upgrade, pin vfile-message to a version below 4.0.0 (e.g., `npm install vfile-message@^3`).
affects: >=4.0.0
breakingThe `position` field on `VFileMessage` instances was removed in v4.0.0. It has been replaced by the `place` field, which accepts `Point` or `Position` objects from unist.
fix
Migrate code accessing `message.position` to `message.place`. For example, `message.position.line` should become `message.place.line`.
affects: >=4.0.0
breakingvfile-message v4.0.0 is ESM-only and utilizes export maps. This means CommonJS `require()` syntax will no longer work, and consumers must use `import` statements.
fix
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or using `.mjs` extensions) and switch all imports to use `import { VFileMessage } from 'vfile-message'`.
affects: >=4.0.0
breakingProperties on `VFileMessage` that could previously be `null` are now `undefined` in v4.0.0, aligning with modern JavaScript practices.
fix
Update any comparisons or checks that specifically relied on `null` (e.g., `property === null`) to check for `undefined` or general falsiness if applicable (e.g., `property == null` to catch both `null` and `undefined`).
affects: >=4.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to import `vfile-message` using CommonJS `require()` in an ESM context, which is not supported since v4.0.0.
fix
Switch to ESM `import` syntax: `import { VFileMessage } from 'vfile-message'`. Ensure your project's `package.json` specifies `"type": "module"` or your file uses the `.mjs` extension.
TypeError: Cannot read properties of undefined (reading 'start') OR Property 'position' does not exist on type 'VFileMessage'
Accessing the deprecated `position` property on a `VFileMessage` instance after upgrading to v4.0.0.
fix
The `position` property was replaced by `place`. Update your code to use `message.place.line`, `message.place.column`, etc., instead of `message.position`.
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'vfile-message' from '/path/to/your/file.js'
This error can occur when using `vfile-message` v4.0.0 or higher in a Node.js environment older than v16, which lacks full support for ESM and export maps.
fix
Upgrade your Node.js environment to version 16 or newer. Alternatively, if upgrading Node.js is not feasible, downgrade `vfile-message` to a v3 release (e.g., `npm install vfile-message@^3`).
Upgrade
Version history
4.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
vfile-message — npm install vfile-message · libregistry