Skip to content

Commit 7241a3a

Browse files
committed
Refactor code-style
1 parent 8b0351f commit 7241a3a

18 files changed

+106
-111
lines changed

index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function literal(node, parent) {
6565
export {_void, wrap}
6666

6767
// Construct.
68-
var mdast = zwitch('type', {
68+
const mdast = zwitch('type', {
6969
// Core interface.
7070
unknown,
7171
invalid: unknown,
@@ -102,7 +102,7 @@ var mdast = zwitch('type', {
102102
}
103103
})
104104

105-
var all = mapz(mdast, {key: 'children'})
105+
const all = mapz(mdast, {key: 'children'})
106106

107107
/**
108108
* @param {unknown} node
@@ -439,21 +439,18 @@ function footnoteReference(node) {
439439
* @returns {asserts node is Table}
440440
*/
441441
function table(node) {
442-
var index = -1
443-
/** @type {Array.<unknown>} */
444-
var align
445-
/** @type {unknown} */
446-
var value
442+
let index = -1
447443

448444
parent(node)
449445
indexable(node)
450446

451447
if (node.align != null) {
452448
nodeAssert.ok(Array.isArray(node.align), '`align` must be `array`')
453-
align = node.align // type-coverage:ignore-line
449+
/** @type {Array.<unknown>} */
450+
const align = node.align // type-coverage:ignore-line
454451

455452
while (++index < align.length) {
456-
value = align[index]
453+
const value = align[index]
457454

458455
if (value != null) {
459456
nodeAssert.notStrictEqual(

index.test-d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import {expectType, expectNotType} from 'tsd'
22
import {Parent} from 'mdast'
33
import {Node, assert, parent} from './index.js'
44

5-
var emptyNode = {type: 'doctype'}
6-
var literalNode = {type: 'text', value: 'a'}
7-
var parentNode = {type: 'element', children: [emptyNode, literalNode]}
5+
const emptyNode = {type: 'doctype'}
6+
const literalNode = {type: 'text', value: 'a'}
7+
const parentNode = {type: 'element', children: [emptyNode, literalNode]}
88

99
expectNotType<Node>(emptyNode)
1010
expectNotType<Node>(literalNode)

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@
7171
"rules": {
7272
"capitalized-comments": "off",
7373
"eqeqeq": "off",
74-
"no-eq-null": "off",
75-
"no-var": "off",
76-
"prefer-arrow-callback": "off"
74+
"no-eq-null": "off"
7775
}
7876
},
7977
"remarkConfig": {

test/children.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import test from 'tape'
22
import {assert} from '../index.js'
33

4-
test('children', function (t) {
4+
test('children', (t) => {
55
t.throws(
6-
function () {
6+
() => {
77
assert({type: 'paragraph', children: {alpha: 'bravo'}})
88
},
99
/`children` should be an array: `{ type: 'paragraph', children: { alpha: 'bravo' } }`$/,
1010
'should throw if given a non-node child in children'
1111
)
1212

1313
t.throws(
14-
function () {
14+
() => {
1515
assert({type: 'paragraph', children: ['one']})
1616
},
1717
/node should be an object: `'one'` in `{ type: 'paragraph', children: \[ 'one' ] }`$/,
1818
'should throw if given a non-node child in children'
1919
)
2020

21-
t.doesNotThrow(function () {
21+
t.doesNotThrow(() => {
2222
assert({type: 'paragraph', children: [{type: 'text', value: 'alpha'}]})
2323
}, 'should not throw on vald children')
2424

2525
t.throws(
26-
function () {
26+
() => {
2727
assert({
2828
type: 'paragraph',
2929
children: [{type: 'bar', children: ['one']}]

test/code.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
import test from 'tape'
22
import {assert} from '../index.js'
33

4-
test('assert(code)', function (t) {
4+
test('assert(code)', (t) => {
55
t.throws(
6-
function () {
6+
() => {
77
assert({type: 'code'})
88
},
99
/literal should have `value`: `{ type: 'code' }`$/,
1010
'should throw if `code` is not a text'
1111
)
1212

13-
t.doesNotThrow(function () {
13+
t.doesNotThrow(() => {
1414
assert({type: 'code', value: ''})
1515
}, 'should not throw if `code` has no extra properties')
1616

1717
t.throws(
18-
function () {
18+
() => {
1919
assert({type: 'code', lang: 0, value: ''})
2020
},
2121
/`lang` must be `string`: `{ type: 'code', lang: 0, value: '' }`$/,
2222
'should throw if `lang` is not a string'
2323
)
2424

2525
t.throws(
26-
function () {
26+
() => {
2727
assert({type: 'code', lang: 'js', meta: 1, value: ''})
2828
},
2929
/`meta` must be `string`: `{ type: 'code', lang: 'js', meta: 1, value: '' }`$/,
3030
'should throw if `meta` is not a string'
3131
)
3232

3333
t.throws(
34-
function () {
34+
() => {
3535
assert({type: 'code', meta: '', value: ''})
3636
},
3737
/code with `meta` must also have `lang`: `{ type: 'code', meta: '', value: '' }`$/,

test/definition.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
import test from 'tape'
22
import {assert} from '../index.js'
33

4-
test('assert(definition)', function (t) {
4+
test('assert(definition)', (t) => {
55
t.throws(
6-
function () {
6+
() => {
77
assert({type: 'definition'})
88
},
99
/`identifier` must be `string`: `{ type: 'definition' }`$/,
1010
'should throw if `definition` has no `identifier`'
1111
)
1212

1313
t.throws(
14-
function () {
14+
() => {
1515
assert({type: 'definition', identifier: '1'})
1616
},
1717
/`url` must be `string`: `{ type: 'definition', identifier: '1' }`$/,
1818
'should throw if `definition` has no `url`'
1919
)
2020

2121
t.throws(
22-
function () {
22+
() => {
2323
assert({type: 'definition', identifier: 1})
2424
},
2525
/`identifier` must be `string`: `{ type: 'definition', identifier: 1 }`$/,
2626
'should throw if `identifier` is not a `string`'
2727
)
2828

2929
t.throws(
30-
function () {
30+
() => {
3131
assert({type: 'definition', url: 1})
3232
},
3333
/`identifier` must be `string`: `{ type: 'definition', url: 1 }`$/,
3434
'should throw if `url` is not a `string`'
3535
)
3636

37-
t.doesNotThrow(function () {
37+
t.doesNotThrow(() => {
3838
assert({type: 'definition', identifier: '1', url: '1'})
3939
}, 'should not throw if `definition` has no other properties')
4040

4141
t.throws(
42-
function () {
42+
() => {
4343
assert({type: 'definition', identifier: '1', url: '1', title: 1})
4444
},
4545
/`title` must be `string`: `{ type: 'definition', identifier: '1', url: '1', title: 1 }`$/,
4646
'should throw if `title` is not a `string`'
4747
)
4848

4949
t.throws(
50-
function () {
50+
() => {
5151
assert({type: 'definition', identifier: '1', url: '1', label: 1})
5252
},
5353
/`label` must be `string`: `{ type: 'definition', identifier: '1', url: '1', label: 1 }`$/,

test/footnote-definition.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
import test from 'tape'
22
import {assert} from '../index.js'
33

4-
test('assert(footnoteDefinition)', function (t) {
4+
test('assert(footnoteDefinition)', (t) => {
55
t.throws(
6-
function () {
6+
() => {
77
assert({type: 'footnoteDefinition'})
88
},
99
/parent should have `children`: `{ type: 'footnoteDefinition' }`$/,
1010
'should throw if `footnoteDefinition` is not a parent'
1111
)
1212

1313
t.throws(
14-
function () {
14+
() => {
1515
assert({type: 'footnoteDefinition', children: []})
1616
},
1717
/`footnoteDefinition` must have `identifier`: `{ type: 'footnoteDefinition', children: \[] }`$/,
1818
'should throw if `footnoteDefinition` has no identifier'
1919
)
2020

2121
t.throws(
22-
function () {
22+
() => {
2323
assert({type: 'footnoteDefinition', identifier: 1, children: []})
2424
},
2525
/`footnoteDefinition` must have `identifier`: `{ type: 'footnoteDefinition', identifier: 1, children: \[] }`$/,
2626
'should throw if `identifier` is not a `string`'
2727
)
2828

29-
t.doesNotThrow(function () {
29+
t.doesNotThrow(() => {
3030
assert({type: 'footnoteDefinition', identifier: '1', children: []})
3131
}, 'should not throw if `footnoteDefinition` has an identifier')
3232

3333
t.throws(
34-
function () {
34+
() => {
3535
assert({
3636
type: 'footnoteDefinition',
3737
identifier: '1',

test/footnote-reference.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import test from 'tape'
22
import {assert} from '../index.js'
33

4-
test('assert(footnoteReference)', function (t) {
4+
test('assert(footnoteReference)', (t) => {
55
t.throws(
6-
function () {
6+
() => {
77
assert({type: 'footnoteReference'})
88
},
99
/`identifier` must be `string`: `{ type: 'footnoteReference' }`$/,
1010
'should throw if `footnoteReference` has no `identifier`'
1111
)
1212

1313
t.throws(
14-
function () {
14+
() => {
1515
assert({type: 'footnoteReference', identifier: 1})
1616
},
1717
/`identifier` must be `string`: `{ type: 'footnoteReference', identifier: 1 }`$/,
1818
'should throw if `identifier` is not a `string`'
1919
)
2020

21-
t.doesNotThrow(function () {
21+
t.doesNotThrow(() => {
2222
assert({type: 'footnoteReference', identifier: '1'})
2323
}, 'should not throw if `footnoteReference` has no other properties')
2424

2525
t.throws(
26-
function () {
26+
() => {
2727
assert({type: 'footnoteReference', identifier: '1', label: 1})
2828
},
2929
/`label` must be `string`: `{ type: 'footnoteReference', identifier: '1', label: 1 }`$/,

test/heading.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
import test from 'tape'
22
import {assert} from '../index.js'
33

4-
test('assert(heading)', function (t) {
4+
test('assert(heading)', (t) => {
55
t.throws(
6-
function () {
6+
() => {
77
assert({type: 'heading'})
88
},
99
/parent should have `children`: `{ type: 'heading' }`$/,
1010
'should throw if a `heading` is not a parent'
1111
)
1212

1313
t.throws(
14-
function () {
14+
() => {
1515
assert({type: 'heading', depth: 0, children: []})
1616
},
1717
/`depth` should be gte `1`: `{ type: 'heading', depth: 0, children: \[] }`$/,
1818
'should throw if `depth` is lower than 1'
1919
)
2020

2121
t.throws(
22-
function () {
22+
() => {
2323
assert({type: 'heading', depth: 7, children: []})
2424
},
2525
/`depth` should be lte `6`: `{ type: 'heading', depth: 7, children: \[] }`$/,
2626
'should throw if `depth` is lower than 7'
2727
)
2828

29-
t.doesNotThrow(function () {
29+
t.doesNotThrow(() => {
3030
assert({type: 'heading', depth: 1, children: []})
3131
}, 'should not throw if `heading` is between 0 and 7')
3232

test/image-reference.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
import test from 'tape'
22
import {assert} from '../index.js'
33

4-
test('assert(imageReference)', function (t) {
4+
test('assert(imageReference)', (t) => {
55
t.throws(
6-
function () {
6+
() => {
77
assert({type: 'imageReference'})
88
},
99
/`identifier` must be `string`: `{ type: 'imageReference' }`$/,
1010
'should throw if `imageReference` has no `identifier`'
1111
)
1212

1313
t.throws(
14-
function () {
14+
() => {
1515
assert({type: 'imageReference', identifier: 1})
1616
},
1717
/`identifier` must be `string`: `{ type: 'imageReference', identifier: 1 }`$/,
1818
'should throw if `identifier` is not a `string`'
1919
)
2020

21-
t.doesNotThrow(function () {
21+
t.doesNotThrow(() => {
2222
assert({type: 'imageReference', identifier: '1'})
2323
}, 'should not throw if `imageReference` has no other properties')
2424

2525
t.throws(
26-
function () {
26+
() => {
2727
assert({type: 'imageReference', identifier: '1', alt: 1})
2828
},
2929
/`alt` must be `string`: `{ type: 'imageReference', identifier: '1', alt: 1 }`$/,
3030
'should throw if `alt` is not a `string`'
3131
)
3232

3333
t.throws(
34-
function () {
34+
() => {
3535
assert({type: 'imageReference', identifier: '1', referenceType: 1})
3636
},
3737
/`referenceType` must be `shortcut`, `collapsed`, or `full`: `{ type: 'imageReference', identifier: '1', referenceType: 1 }`$/,
3838
'should throw if `referenceType` is not a `string`'
3939
)
4040

41-
t.doesNotThrow(function () {
41+
t.doesNotThrow(() => {
4242
assert({
4343
type: 'imageReference',
4444
identifier: '1',
@@ -47,7 +47,7 @@ test('assert(imageReference)', function (t) {
4747
}, 'should not throw if `referenceType` is valid')
4848

4949
t.throws(
50-
function () {
50+
() => {
5151
assert({type: 'imageReference', identifier: '1', label: 1})
5252
},
5353
/`label` must be `string`: `{ type: 'imageReference', identifier: '1', label: 1 }`$/,

0 commit comments

Comments
 (0)