diff --git a/lib/index.js b/lib/index.js index 620a309..c3e9cbd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -62,10 +62,10 @@ * Sizes for message columns. */ -import width from 'string-width' +import stringWidth from 'string-width' import {stringifyPosition} from 'unist-util-stringify-position' -import {statistics} from 'vfile-statistics' import {sort} from 'vfile-sort' +import {statistics} from 'vfile-statistics' import {color} from './color.js' import {platform} from './platform.js' @@ -86,7 +86,7 @@ const labels = { /** * Create a report from an error, one file, or multiple files. * - * @param {Error | VFile | Array | null | undefined} [files] + * @param {Array | Error | VFile | null | undefined} [files] * Files or error to report. * @param {Options | null | undefined} [options] * Configuration. @@ -336,5 +336,5 @@ function format(map, one, options) { */ function size(value) { const match = /\r?\n|\r/.exec(value) - return width(match ? value.slice(0, match.index) : value) + return stringWidth(match ? value.slice(0, match.index) : value) } diff --git a/test.js b/test.js index a81c1f3..9c7d077 100644 --- a/test.js +++ b/test.js @@ -1,11 +1,9 @@ import assert from 'node:assert/strict' -import path from 'node:path' import process from 'node:process' import test from 'node:test' import strip from 'strip-ansi' import {VFile} from 'vfile' import {reporter} from './index.js' -import * as mod from './index.js' // `log-symbols` without chalk, ignored for Windows: /* c8 ignore next 4 */ @@ -52,7 +50,9 @@ try { } /* eslint-enable no-undef */ -test('reporter', () => { +test('reporter', async function () { + const mod = await import('./index.js') + assert.deepEqual( Object.keys(mod).sort(), ['default', 'reporter'], @@ -418,7 +418,7 @@ test('reporter', () => { */ function cleanStack(stack, max) { return (stack || '') - .replace(new RegExp('\\(.+\\' + path.sep, 'g'), '(') + .replace(/\(.+[/\\]/g, '(') .replace(/file:.+\//g, '') .replace(/\d+:\d+/g, '1:1') .split('\n')