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 11, 2022
1 parent 9384289 commit 96202cf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
24 changes: 15 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
* @typedef {import('vfile-message').VFileMessage} VFileMessage
*
* @typedef Statistics
* @property {number} fatal Fatal errors (`fatal: true`)
* @property {number} warn warning errors (`fatal: false`)
* @property {number} info informational messages (`fatal: null|undefined`)
* @property {number} nonfatal warning + info
* @property {number} total nonfatal + fatal
* Statistics.
* @property {number} fatal
* Fatal errors (`fatal: true`)
* @property {number} warn
* Warnings (`fatal: false`)
* @property {number} info
* Informational messages (`fatal: null|undefined`)
* @property {number} nonfatal
* Warning + info
* @property {number} total
* Nonfatal + fatal
*/

/**
* Get stats for a file, list of files, or list of messages.
*
* @param {Array.<VFile|VFileMessage>|VFile|VFileMessage} [value]
* @param {Array<VFile|VFileMessage>|VFile|VFileMessage} [value]
* @returns {Statistics}
*/
export function statistics(value) {
var result = {true: 0, false: 0, null: 0}
const result = {true: 0, false: 0, null: 0}

if (value) {
if (Array.isArray(value)) {
Expand All @@ -36,11 +42,11 @@ export function statistics(value) {
}

/**
* @param {Array.<VFile|VFileMessage>} value
* @param {Array<VFile|VFileMessage>} value
* @returns {void}
*/
function list(value) {
var index = -1
let index = -1

while (++index < value.length) {
one(value[index])
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@
"trailingComma": "none"
},
"xo": {
"prettier": true,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},
"remarkConfig": {
"plugins": [
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {VFile} from 'vfile'
import {statistics} from './index.js'

test('statistics()', function (t) {
var file = new VFile()
var other = new VFile()
const file = new VFile()
const other = new VFile()

t.deepEqual(statistics(), {fatal: 0, nonfatal: 0, warn: 0, info: 0, total: 0})

Expand Down

0 comments on commit 96202cf

Please sign in to comment.