vfile-sort is a utility package within the unified/vfile ecosystem designed for ordering `VFile` objects and `VFileMessage` objects. Its current stable version is 4.0.0. The package primarily exposes comparator functions, `compareFile` and `compareMessage`, which can be used with array sorting methods (e.g., `Array.prototype.sort` or `toSorted`) to arrange files or messages by properties like line, column, severity, and other metadata. It follows the Node.js LTS release cycle for compatibility and ships with TypeScript types, making it suitable for modern JavaScript and TypeScript projects. Key differentiators include its tight integration with the `vfile` specification and its focus on providing precise, consistent sorting logic for diagnostics and file-related metadata, ensuring human-readable reports.
npm install vfile-sortVerified import paths — ran on the pinned version, not inferred.
Demonstrates sorting `VFileMessage` and `VFile` instances using `compareMessage` and `compareFile` respectively.
Migrate calls from `sort(file)` to `file.messages.sort(compareMessage)` or `array.toSorted(compareFile/compareMessage)` for explicit sorting.
Migrate your project to use ESM `import` statements (e.g., `import { compareMessage } from 'vfile-sort'`) or a compatible bundler. Ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions for your code.Update your Node.js environment to version 16 or higher to ensure compatibility.
Always import directly from the main package entry point (`vfile-sort`) to use only the public API as specified in the package's `export` map.
Review the `vfile` v6 changelog for specific migration steps and ensure all `vfile` ecosystem packages in your project are compatible.
Instead of `sort(file)`, use `file.messages.sort(compareMessage)` or `myArray.toSorted(compareMessage/compareFile)`.
Ensure your project is configured for ESM (add `"type": "module"` to your `package.json` or use `.mjs` file extensions) and upgrade Node.js to v16+.
Use `import` statements instead of `require()`. If in a CommonJS context, consider upgrading to a newer Node.js version and migrating to ESM for your project.
No dependency data recorded yet.