Skip to content

VFileMessage generates invalid position if no position is given #15

@remcohaszing

Description

@remcohaszing

Initial checklist

Affected packages and versions

3.1.2

Link to runnable example

No response

Steps to reproduce

import { VFileMessage } from 'vfile-message'

const message = new VFileMessage('reason')

console.log(message.position)

Expected behavior

The message position is undefined.

According to the type definitions it’s optional, but currently it’s always set.

Actual behavior

The message position is a unist position, but the start and end line and column are set to null.

According to the unist types, start and end line and column can’t be null.

This causes various type errors. For example:

This test explicitly asserts the incorrect behaviour:

vfile-message/test.js

Lines 63 to 66 in e5e87f2

t.deepEqual(m1.position, {
start: {line: null, column: null},
end: {line: null, column: null}
})

Affected runtime and version

[email protected]

Affected package manager and version

[email protected]

Affected OS and version

Pop!_OS 22.04

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions