Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 6, 2023
1 parent c31e10a commit c121374
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -86,7 +86,7 @@ const labels = {
/**
* Create a report from an error, one file, or multiple files.
*
* @param {Error | VFile | Array<VFile> | null | undefined} [files]
* @param {Array<VFile> | Error | VFile | null | undefined} [files]
* Files or error to report.
* @param {Options | null | undefined} [options]
* Configuration.
Expand Down Expand Up @@ -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)
}
8 changes: 4 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit c121374

Please # to comment.