Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a379060

Browse files
committedMay 2, 2018
Refactor code-style
1 parent 6f51df6 commit a379060

File tree

14 files changed

+323
-362
lines changed

14 files changed

+323
-362
lines changed
 

‎.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage/
2+
unist-util-assert.js
3+
unist-util-assert.min.js

‎index.js

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,96 @@
1-
'use strict';
1+
'use strict'
22

33
/* Dependencies. */
4-
var assert = require('assert');
5-
var array = require('x-is-array');
6-
var object = require('x-is-object');
4+
var assert = require('assert')
5+
var array = require('x-is-array')
6+
var object = require('x-is-object')
77

8-
var inspect;
8+
var inspect
99

1010
try {
1111
// eslint-disable-next-line import/no-dynamic-require, no-useless-concat
12-
inspect = require('ut' + 'il').inspect;
13-
} catch (err) { /* Empty. */ }
12+
inspect = require('ut' + 'il').inspect
13+
} catch (err) {
14+
/* Empty. */
15+
}
1416

1517
/* Expose. */
16-
exports = wrap(unist);
17-
module.exports = exports;
18+
exports = wrap(unist)
19+
module.exports = exports
1820

19-
exports.parent = wrap(parent);
20-
exports.text = wrap(text);
21-
exports.void = wrap(empty);
22-
exports.wrap = wrap;
21+
exports.parent = wrap(parent)
22+
exports.text = wrap(text)
23+
exports.void = wrap(empty)
24+
exports.wrap = wrap
2325

2426
/* Identifier to check if a value is seen. */
25-
var ID = '__unist__';
27+
var ID = '__unist__'
2628

2729
/* List of specced properties. */
28-
var defined = ['type', 'value', 'children', 'position'];
30+
var defined = ['type', 'value', 'children', 'position']
2931

3032
/* Wrapper around `Node` which adds the current node
3133
* (and parent, if available), to the message. */
3234
function wrap(fn) {
33-
return wrapped;
35+
return wrapped
3436

3537
function wrapped(node, parent) {
3638
try {
37-
fn(node, parent);
39+
fn(node, parent)
3840
} catch (err) {
3941
if (!err[ID]) {
40-
err[ID] = true;
42+
err[ID] = true
4143

42-
err.message += ': `' + view(node) + '`';
44+
err.message += ': `' + view(node) + '`'
4345

4446
if (parent) {
45-
err.message += ' in `' + view(parent) + '`';
47+
err.message += ' in `' + view(parent) + '`'
4648
}
4749
}
4850

49-
throw err;
51+
throw err
5052
}
5153
}
5254
}
5355

5456
/* Assert. */
5557
function unist(node) {
56-
var type;
57-
var children;
58-
var value;
59-
var key;
60-
var index;
61-
var length;
58+
var type
59+
var children
60+
var value
61+
var key
62+
var index
63+
var length
6264

63-
assert.ok(object(node), 'node should be an object');
65+
assert.ok(object(node), 'node should be an object')
6466

65-
type = node.type;
66-
children = node.children;
67-
value = node.value;
67+
type = node.type
68+
children = node.children
69+
value = node.value
6870

69-
assert.ok('type' in node, 'node should have a type');
70-
assert.equal(typeof type, 'string', '`type` should be a string');
71-
assert.notEqual(type, '', '`type` should not be empty');
71+
assert.ok('type' in node, 'node should have a type')
72+
assert.equal(typeof type, 'string', '`type` should be a string')
73+
assert.notEqual(type, '', '`type` should not be empty')
7274

7375
if (value != null) {
74-
assert.equal(typeof value, 'string', '`value` should be a string');
76+
assert.equal(typeof value, 'string', '`value` should be a string')
7577
}
7678

77-
location(node.position);
79+
location(node.position)
7880

7981
for (key in node) {
8082
if (defined.indexOf(key) === -1) {
81-
vanilla(key, node[key]);
83+
vanilla(key, node[key])
8284
}
8385
}
8486

8587
if (children != null) {
86-
assert.ok(array(children), '`children` should be an array');
87-
index = -1;
88-
length = children.length;
88+
assert.ok(array(children), '`children` should be an array')
89+
index = -1
90+
length = children.length
8991

9092
while (++index < length) {
91-
exports(children[index], node);
93+
exports(children[index], node)
9294
}
9395
}
9496
}
@@ -97,9 +99,9 @@ function unist(node) {
9799
* and re-parsed to the same (deep) value. */
98100
function vanilla(key, value) {
99101
try {
100-
assert.deepEqual(value, JSON.parse(JSON.stringify(value)));
102+
assert.deepEqual(value, JSON.parse(JSON.stringify(value)))
101103
} catch (err) {
102-
assert.fail('', '', 'non-specced property `' + key + '` should be JSON');
104+
assert.fail('', '', 'non-specced property `' + key + '` should be JSON')
103105
}
104106
}
105107

@@ -111,64 +113,67 @@ function view(value) {
111113
/* eslint-disable no-else-return */
112114
/* istanbul ignore else - Browser. */
113115
if (inspect) {
114-
return inspect(value, {colors: false});
116+
return inspect(value, {colors: false})
115117
} else {
116-
return JSON.stringify(value);
118+
return JSON.stringify(value)
117119
}
118120
} catch (err) {
119121
/* istanbul ignore next - Cyclical. */
120-
return String(value);
122+
return String(value)
121123
}
122124
}
123125

124126
/* Assert `node` is a parent node. */
125127
function parent(node) {
126-
unist(node);
128+
unist(node)
127129

128-
assert.equal('value' in node, false, 'parent should not have `value`');
129-
assert.ok('children' in node, 'parent should have `children`');
130+
assert.equal('value' in node, false, 'parent should not have `value`')
131+
assert.ok('children' in node, 'parent should have `children`')
130132
}
131133

132134
/* Assert `node` is a text node. */
133135
function text(node) {
134-
unist(node);
136+
unist(node)
135137

136-
assert.equal('children' in node, false, 'text should not have `children`');
137-
assert.ok('value' in node, 'text should have `value`');
138+
assert.equal('children' in node, false, 'text should not have `children`')
139+
assert.ok('value' in node, 'text should have `value`')
138140
}
139141

140142
/* Assert `node` is a Unist node, but neither parent nor
141143
* text. */
142144
function empty(node) {
143-
unist(node);
145+
unist(node)
144146

145-
assert.equal('value' in node, false, 'void should not have `value`');
146-
assert.equal('children' in node, false, 'void should not have `children`');
147+
assert.equal('value' in node, false, 'void should not have `value`')
148+
assert.equal('children' in node, false, 'void should not have `children`')
147149
}
148150

149151
/* Assert `location` is a Unist Location. */
150152
function location(location) {
151153
if (location != null) {
152-
assert.ok(object(location), '`position` should be an object');
154+
assert.ok(object(location), '`position` should be an object')
153155

154-
position(location.start, 'position.start');
155-
position(location.end, 'position.end');
156+
position(location.start, 'position.start')
157+
position(location.end, 'position.end')
156158
}
157159
}
158160

159161
/* Assert `location` is a Unist Location. */
160162
function position(position, name) {
161163
if (position != null) {
162-
assert.ok(object(position), '`' + name + '` should be an object');
164+
assert.ok(object(position), '`' + name + '` should be an object')
163165

164166
if (position.line != null) {
165-
assert.ok('line' in position, '`' + name + '` should have numeric `line`');
166-
assert.ok(position.line >= 1, '`' + name + '.line` should be gte `1`');
167+
assert.ok('line' in position, '`' + name + '` should have numeric `line`')
168+
assert.ok(position.line >= 1, '`' + name + '.line` should be gte `1`')
167169
}
168170

169171
if (position.column != null) {
170-
assert.ok('column' in position, '`' + name + '` should have numeric `column`');
171-
assert.ok(position.column >= 1, '`' + name + '.column` should be gte `1`');
172+
assert.ok(
173+
'column' in position,
174+
'`' + name + '` should have numeric `column`'
175+
)
176+
assert.ok(position.column >= 1, '`' + name + '.column` should be gte `1`')
172177
}
173178
}
174179
}

‎package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,31 @@
2626
"browserify": "^16.0.0",
2727
"esmangle": "^1.0.1",
2828
"nyc": "^11.0.0",
29+
"prettier": "^1.12.1",
2930
"remark-cli": "^5.0.0",
3031
"remark-preset-wooorm": "^4.0.0",
3132
"tape": "^4.0.0",
3233
"xo": "^0.20.0"
3334
},
3435
"scripts": {
35-
"build-md": "remark . -qfo",
36+
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
3637
"build-bundle": "browserify index.js -s unistUtilAssert > unist-util-assert.js",
3738
"build-mangle": "esmangle < unist-util-assert.js > unist-util-assert.min.js",
38-
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
39-
"lint": "xo",
39+
"build": "npm run build-bundle && npm run build-mangle",
4040
"test-api": "node test",
4141
"test-coverage": "nyc --reporter lcov tape test",
42-
"test": "npm run build && npm run lint && npm run test-coverage"
42+
"test": "npm run format && npm run build && npm run test-coverage"
43+
},
44+
"prettier": {
45+
"tabWidth": 2,
46+
"useTabs": false,
47+
"singleQuote": true,
48+
"bracketSpacing": false,
49+
"semi": false,
50+
"trailingComma": "none"
4351
},
4452
"xo": {
45-
"space": true,
53+
"prettier": true,
4654
"esnext": false,
4755
"rules": {
4856
"guard-for-in": "off",

‎readme.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ npm install unist-util-assert
1313
## Usage
1414

1515
```javascript
16-
var assert = require('unist-util-assert');
16+
var assert = require('unist-util-assert')
1717

18-
assert({type: 'root', children: []});
19-
assert({type: 'break'});
20-
assert({type: 'element', properties: {}, children: []});
18+
assert({type: 'root', children: []})
19+
assert({type: 'break'})
20+
assert({type: 'element', properties: {}, children: []})
2121
// All OK.
2222

23-
assert({children: []});
23+
assert({children: []})
2424
// AssertionError: node should have a type: `{ children: [] }`
2525

26-
assert.parent({type: 'break'});
26+
assert.parent({type: 'break'})
2727
// AssertionError: parent should have `children`: `{ type: 'break' }`
2828

29-
assert({type: 'element', properties: function () {}});
29+
assert({type: 'element', properties: function() {}})
3030
// AssertionError: non-specced property `properties` should be JSON: `{ type: 'element', properties: [Function] }`
3131

32-
assert.void({type: 'text', value: 'Alpha'});
32+
assert.void({type: 'text', value: 'Alpha'})
3333
// AssertionError: void should not have `value`: `{ type: 'text', value: 'Alpha' }`
3434

35-
assert({type: 'paragraph', children: ['foo']});
35+
assert({type: 'paragraph', children: ['foo']})
3636
// AssertionError: node should be an object: `'foo'` in `{ type: 'paragraph', children: [ 'foo' ] }`
3737
```
3838

‎test/children.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var assert = require('..');
3+
var test = require('tape')
4+
var assert = require('..')
55

6-
test('children', function (t) {
6+
test('children', function(t) {
77
t.throws(
8-
function () {
9-
assert({type: 'foo', children: {alpha: 'bravo'}});
8+
function() {
9+
assert({type: 'foo', children: {alpha: 'bravo'}})
1010
},
1111
/`children` should be an array: `{ type: 'foo', children: { alpha: 'bravo' } }`$/,
1212
'should throw if given a non-node child in children'
13-
);
13+
)
1414

1515
t.throws(
16-
function () {
17-
assert({type: 'foo', children: ['one']});
16+
function() {
17+
assert({type: 'foo', children: ['one']})
1818
},
1919
/node should be an object: `'one'` in `{ type: 'foo', children: \[ 'one' ] }`$/,
2020
'should throw if given a non-node child in children'
21-
);
21+
)
2222

23-
t.doesNotThrow(
24-
function () {
25-
assert({type: 'parent', children: [{type: 'text', value: 'alpha'}]});
26-
},
27-
'should not throw on vald children'
28-
);
23+
t.doesNotThrow(function() {
24+
assert({type: 'parent', children: [{type: 'text', value: 'alpha'}]})
25+
}, 'should not throw on vald children')
2926

3027
t.throws(
31-
function () {
32-
assert({type: 'foo', children: [{
33-
type: 'bar',
34-
children: ['one']
35-
}]});
28+
function() {
29+
assert({
30+
type: 'foo',
31+
children: [
32+
{
33+
type: 'bar',
34+
children: ['one']
35+
}
36+
]
37+
})
3638
},
3739
/node should be an object: `'one'` in `{ type: 'bar', children: \[ 'one' ] }`$/,
3840
'should throw on invalid descendants'
39-
);
41+
)
4042

41-
t.end();
42-
});
43+
t.end()
44+
})

‎test/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
'use strict';
1+
'use strict'
22

33
/* eslint-disable import/no-unassigned-import */
44

5-
require('./node');
6-
require('./type');
7-
require('./value');
8-
require('./children');
9-
require('./position');
10-
require('./non-defined');
11-
require('./parent');
12-
require('./text');
13-
require('./void');
5+
require('./node')
6+
require('./type')
7+
require('./value')
8+
require('./children')
9+
require('./position')
10+
require('./non-defined')
11+
require('./parent')
12+
require('./text')
13+
require('./void')

‎test/node.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var assert = require('..');
3+
var test = require('tape')
4+
var assert = require('..')
55

6-
test('node', function (t) {
6+
test('node', function(t) {
77
t.throws(
8-
function () {
9-
assert();
8+
function() {
9+
assert()
1010
},
1111
/node should be an object: `undefined`$/,
1212
'should throw if not given a node (#1)'
13-
);
13+
)
1414

1515
t.throws(
16-
function () {
17-
assert(null);
16+
function() {
17+
assert(null)
1818
},
1919
/node should be an object: `null`$/,
2020
'should throw if not given a node (#2)'
21-
);
21+
)
2222

2323
t.throws(
24-
function () {
25-
assert('foo');
24+
function() {
25+
assert('foo')
2626
},
2727
/node should be an object: `'foo'`$/,
2828
'should throw if given a non-node (#1)'
29-
);
29+
)
3030

3131
t.throws(
32-
function () {
33-
assert(6);
32+
function() {
33+
assert(6)
3434
},
3535
/node should be an object: `6`$/,
3636
'should throw if not given a non-node (#2)'
37-
);
37+
)
3838

39-
t.end();
40-
});
39+
t.end()
40+
})

‎test/non-defined.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var assert = require('..');
3+
var test = require('tape')
4+
var assert = require('..')
55

6-
test('non-defined', function (t) {
7-
t.doesNotThrow(
8-
function () {
9-
assert({
10-
type: 'element',
11-
properties: {
12-
className: ['alpha'],
13-
id: 'bravo'
14-
},
15-
children: [],
16-
position: {},
17-
data: {
18-
charlie: 'delta'
19-
}
20-
});
21-
},
22-
'should not throw if non-defined properties are found'
23-
);
6+
test('non-defined', function(t) {
7+
t.doesNotThrow(function() {
8+
assert({
9+
type: 'element',
10+
properties: {
11+
className: ['alpha'],
12+
id: 'bravo'
13+
},
14+
children: [],
15+
position: {},
16+
data: {
17+
charlie: 'delta'
18+
}
19+
})
20+
}, 'should not throw if non-defined properties are found')
2421

2522
t.throws(
26-
function () {
23+
function() {
2724
assert({
2825
type: 'break',
2926
data: {foo: Function}
30-
});
27+
})
3128
},
3229
/non-specced property `data` should be JSON: `{ type: 'break', data: { foo: \[Function: Function] } }`$/,
3330
'should throw if non-defined properties are not serialisable'
34-
);
31+
)
3532

36-
t.end();
37-
});
33+
t.end()
34+
})

‎test/parent.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var assert = require('..');
3+
var test = require('tape')
4+
var assert = require('..')
55

6-
test('assert.parent()', function (t) {
6+
test('assert.parent()', function(t) {
77
t.throws(
8-
function () {
9-
assert.parent({});
8+
function() {
9+
assert.parent({})
1010
},
1111
/node should have a type: `{}`$/,
1212
'should throw the same errors as `assert()`'
13-
);
13+
)
1414

1515
t.throws(
16-
function () {
17-
assert.parent({type: 'text', value: 'foo'});
16+
function() {
17+
assert.parent({type: 'text', value: 'foo'})
1818
},
1919
/parent should not have `value`: `{ type: 'text', value: 'foo' }`$/,
2020
'should throw if the given node has a `value`'
21-
);
21+
)
2222

2323
t.throws(
24-
function () {
25-
assert.parent({type: 'break'});
24+
function() {
25+
assert.parent({type: 'break'})
2626
},
2727
/parent should have `children`: `{ type: 'break' }`$/,
2828
'should throw if the given node has `children`'
29-
);
29+
)
3030

31-
t.doesNotThrow(
32-
function () {
33-
assert.parent({type: 'strong', children: []});
34-
},
35-
'should not throw on valid void nodes'
36-
);
31+
t.doesNotThrow(function() {
32+
assert.parent({type: 'strong', children: []})
33+
}, 'should not throw on valid void nodes')
3734

38-
t.end();
39-
});
35+
t.end()
36+
})

‎test/position.js

Lines changed: 57 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,104 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var assert = require('..');
3+
var test = require('tape')
4+
var assert = require('..')
55

6-
test('position', function (t) {
6+
test('position', function(t) {
77
t.throws(
8-
function () {
9-
assert({type: 'foo', position: 1});
8+
function() {
9+
assert({type: 'foo', position: 1})
1010
},
1111
/`position` should be an object: `{ type: 'foo', position: 1 }`$/,
1212
'should throw if given a non-object `position`'
13-
);
13+
)
1414

15-
t.doesNotThrow(
16-
function () {
17-
assert({type: 'foo', position: null});
18-
},
19-
'should not throw if given a null `position`'
20-
);
15+
t.doesNotThrow(function() {
16+
assert({type: 'foo', position: null})
17+
}, 'should not throw if given a null `position`')
2118

22-
t.doesNotThrow(
23-
function () {
24-
assert({type: 'foo', position: {}});
25-
},
26-
'should not throw if given an empty `position` object'
27-
);
19+
t.doesNotThrow(function() {
20+
assert({type: 'foo', position: {}})
21+
}, 'should not throw if given an empty `position` object')
2822

2923
t.throws(
30-
function () {
31-
assert({type: 'foo', position: {start: 1}});
24+
function() {
25+
assert({type: 'foo', position: {start: 1}})
3226
},
3327
/`position.start` should be an object: `{ type: 'foo', position: { start: 1 } }`$/,
3428
'should throw if given a non-object `position.start`'
35-
);
29+
)
3630

37-
t.doesNotThrow(
38-
function () {
39-
assert({type: 'foo', position: {start: null}});
40-
},
41-
'should not throw if given a null `position.start`'
42-
);
31+
t.doesNotThrow(function() {
32+
assert({type: 'foo', position: {start: null}})
33+
}, 'should not throw if given a null `position.start`')
4334

44-
t.doesNotThrow(
45-
function () {
46-
assert({type: 'foo', position: {start: {}}});
47-
},
48-
'should not throw if given an empty `position.start` object'
49-
);
35+
t.doesNotThrow(function() {
36+
assert({type: 'foo', position: {start: {}}})
37+
}, 'should not throw if given an empty `position.start` object')
5038

5139
t.throws(
52-
function () {
53-
assert({type: 'foo', position: {end: 1}});
40+
function() {
41+
assert({type: 'foo', position: {end: 1}})
5442
},
5543
/`position.end` should be an object: `{ type: 'foo', position: { end: 1 } }`$/,
5644
'should throw if given a non-object `position.end`'
57-
);
45+
)
5846

59-
t.doesNotThrow(
60-
function () {
61-
assert({type: 'foo', position: {end: null}});
62-
},
63-
'should not throw if given a null `position.end`'
64-
);
47+
t.doesNotThrow(function() {
48+
assert({type: 'foo', position: {end: null}})
49+
}, 'should not throw if given a null `position.end`')
6550

66-
t.doesNotThrow(
67-
function () {
68-
assert({type: 'foo', position: {end: {}}});
69-
},
70-
'should not throw if given an empty `position.end` object'
71-
);
51+
t.doesNotThrow(function() {
52+
assert({type: 'foo', position: {end: {}}})
53+
}, 'should not throw if given an empty `position.end` object')
7254

73-
t.doesNotThrow(
74-
function () {
75-
assert({type: 'foo', position: {start: {line: null}}});
76-
},
77-
'should not throw if given a `position.start.line` to `null`'
78-
);
55+
t.doesNotThrow(function() {
56+
assert({type: 'foo', position: {start: {line: null}}})
57+
}, 'should not throw if given a `position.start.line` to `null`')
7958

80-
t.doesNotThrow(
81-
function () {
82-
assert({type: 'foo', position: {start: {column: null}}});
83-
},
84-
'should not throw if given a `position.start.column` to `null`'
85-
);
59+
t.doesNotThrow(function() {
60+
assert({type: 'foo', position: {start: {column: null}}})
61+
}, 'should not throw if given a `position.start.column` to `null`')
8662

87-
t.doesNotThrow(
88-
function () {
89-
assert({type: 'foo', position: {end: {line: null}}});
90-
},
91-
'should not throw if given a `position.end.line` to `null`'
92-
);
63+
t.doesNotThrow(function() {
64+
assert({type: 'foo', position: {end: {line: null}}})
65+
}, 'should not throw if given a `position.end.line` to `null`')
9366

94-
t.doesNotThrow(
95-
function () {
96-
assert({type: 'foo', position: {end: {column: null}}});
97-
},
98-
'should not throw if given a `position.end.column` to `null`'
99-
);
67+
t.doesNotThrow(function() {
68+
assert({type: 'foo', position: {end: {column: null}}})
69+
}, 'should not throw if given a `position.end.column` to `null`')
10070

10171
t.throws(
102-
function () {
103-
assert({type: 'foo', position: {start: {line: 0}}});
72+
function() {
73+
assert({type: 'foo', position: {start: {line: 0}}})
10474
},
10575
/`position.start.line` should be gte `1`: `{ type: 'foo', position: { start: { line: 0 } } }`$/,
10676
'should throw if `position.start.line` is less than 1'
107-
);
77+
)
10878

10979
t.throws(
110-
function () {
111-
assert({type: 'foo', position: {start: {column: 0}}});
80+
function() {
81+
assert({type: 'foo', position: {start: {column: 0}}})
11282
},
11383
/`position.start.column` should be gte `1`: `{ type: 'foo', position: { start: { column: 0 } } }`$/,
11484
'should throw if `position.start.column` is less than 1'
115-
);
85+
)
11686

11787
t.throws(
118-
function () {
119-
assert({type: 'foo', position: {end: {line: 0}}});
88+
function() {
89+
assert({type: 'foo', position: {end: {line: 0}}})
12090
},
12191
/`position.end.line` should be gte `1`: `{ type: 'foo', position: { end: { line: 0 } } }`$/,
12292
'should throw if `position.end.line` is less than 1'
123-
);
93+
)
12494

12595
t.throws(
126-
function () {
127-
assert({type: 'foo', position: {end: {column: 0}}});
96+
function() {
97+
assert({type: 'foo', position: {end: {column: 0}}})
12898
},
12999
/`position.end.column` should be gte `1`: `{ type: 'foo', position: { end: { column: 0 } } }`$/,
130100
'should throw if `position.end.column` is less than 1'
131-
);
101+
)
132102

133-
t.end();
134-
});
103+
t.end()
104+
})

‎test/text.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var assert = require('..');
3+
var test = require('tape')
4+
var assert = require('..')
55

6-
test('assert.text()', function (t) {
6+
test('assert.text()', function(t) {
77
t.throws(
8-
function () {
9-
assert.text({});
8+
function() {
9+
assert.text({})
1010
},
1111
/node should have a type: `{}`$/,
1212
'should throw the same errors as `assert()`'
13-
);
13+
)
1414

1515
t.throws(
16-
function () {
17-
assert.text({type: 'strong', children: []});
16+
function() {
17+
assert.text({type: 'strong', children: []})
1818
},
1919
/text should not have `children`: `{ type: 'strong', children: \[] }`$/,
2020
'should throw if the given node has `children`'
21-
);
21+
)
2222

2323
t.throws(
24-
function () {
25-
assert.text({type: 'break'});
24+
function() {
25+
assert.text({type: 'break'})
2626
},
2727
/text should have `value`: `{ type: 'break' }`$/,
2828
'should throw if the given node has no `value`'
29-
);
29+
)
3030

31-
t.doesNotThrow(
32-
function () {
33-
assert.text({type: 'text', value: 'foo'});
34-
},
35-
'should not throw on valid text nodes'
36-
);
31+
t.doesNotThrow(function() {
32+
assert.text({type: 'text', value: 'foo'})
33+
}, 'should not throw on valid text nodes')
3734

38-
t.end();
39-
});
35+
t.end()
36+
})

‎test/type.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var assert = require('..');
3+
var test = require('tape')
4+
var assert = require('..')
55

6-
test('type', function (t) {
6+
test('type', function(t) {
77
t.throws(
8-
function () {
9-
assert([1, 5]);
8+
function() {
9+
assert([1, 5])
1010
},
1111
/node should have a type: `\[ 1, 5 ]`$/,
1212
'should throw if not given a `type` (#1)'
13-
);
13+
)
1414

1515
t.throws(
16-
function () {
17-
assert({value: 'foo'});
16+
function() {
17+
assert({value: 'foo'})
1818
},
1919
/node should have a type: `{ value: 'foo' }`$/,
2020
'should throw if not given a type (#2)'
21-
);
21+
)
2222

2323
t.throws(
24-
function () {
25-
assert({type: 1});
24+
function() {
25+
assert({type: 1})
2626
},
2727
/`type` should be a string: `{ type: 1 }`$/,
2828
'should throw if not given a non-string type'
29-
);
29+
)
3030

3131
t.throws(
32-
function () {
33-
assert({type: ''});
32+
function() {
33+
assert({type: ''})
3434
},
3535
/`type` should not be empty: `{ type: '' }`$/,
3636
'should throw if given an empty string type'
37-
);
37+
)
3838

39-
t.doesNotThrow(
40-
function () {
41-
assert({type: 'foo'});
42-
},
43-
'should not throw if given a non-empty type string'
44-
);
39+
t.doesNotThrow(function() {
40+
assert({type: 'foo'})
41+
}, 'should not throw if given a non-empty type string')
4542

46-
t.end();
47-
});
43+
t.end()
44+
})

‎test/value.js

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,32 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var assert = require('..');
3+
var test = require('tape')
4+
var assert = require('..')
55

6-
test('value', function (t) {
6+
test('value', function(t) {
77
t.throws(
8-
function () {
9-
assert({type: 'foo', value: 1});
8+
function() {
9+
assert({type: 'foo', value: 1})
1010
},
1111
/`value` should be a string: `{ type: 'foo', value: 1 }`$/,
1212
'should throw if given a non-string `value`'
13-
);
13+
)
1414

15-
t.doesNotThrow(
16-
function () {
17-
assert({type: 'foo', value: ''});
18-
},
19-
'should not throw if given an empty string `value`'
20-
);
15+
t.doesNotThrow(function() {
16+
assert({type: 'foo', value: ''})
17+
}, 'should not throw if given an empty string `value`')
2118

22-
t.doesNotThrow(
23-
function () {
24-
assert({type: 'foo', value: 'foo'});
25-
},
26-
'should not throw if given an string `value`'
27-
);
19+
t.doesNotThrow(function() {
20+
assert({type: 'foo', value: 'foo'})
21+
}, 'should not throw if given an string `value`')
2822

29-
t.doesNotThrow(
30-
function () {
31-
assert({type: 'foo', value: undefined});
32-
},
33-
'should not throw if given an undefined `value`'
34-
);
23+
t.doesNotThrow(function() {
24+
assert({type: 'foo', value: undefined})
25+
}, 'should not throw if given an undefined `value`')
3526

36-
t.doesNotThrow(
37-
function () {
38-
assert({type: 'foo', value: null});
39-
},
40-
'should not throw if given an null `value`'
41-
);
27+
t.doesNotThrow(function() {
28+
assert({type: 'foo', value: null})
29+
}, 'should not throw if given an null `value`')
4230

43-
t.end();
44-
});
31+
t.end()
32+
})

‎test/void.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,42 @@
66
* @fileoverview Test suite for `unist-util-assert`.
77
*/
88

9-
'use strict';
9+
'use strict'
1010

1111
/* eslint-env node */
1212

1313
/* Dependencies. */
14-
var test = require('tape');
15-
var assert = require('..');
14+
var test = require('tape')
15+
var assert = require('..')
1616

17-
test('assert.void()', function (t) {
17+
test('assert.void()', function(t) {
1818
t.throws(
19-
function () {
20-
assert.void({});
19+
function() {
20+
assert.void({})
2121
},
2222
/node should have a type: `{}`$/,
2323
'should throw the same errors as `assert()`'
24-
);
24+
)
2525

2626
t.throws(
27-
function () {
28-
assert.void({type: 'text', value: 'foo'});
27+
function() {
28+
assert.void({type: 'text', value: 'foo'})
2929
},
3030
/void should not have `value`: `{ type: 'text', value: 'foo' }`$/,
3131
'should throw if the given node has a `value`'
32-
);
32+
)
3333

3434
t.throws(
35-
function () {
36-
assert.void({type: 'strong', children: []});
35+
function() {
36+
assert.void({type: 'strong', children: []})
3737
},
3838
/void should not have `children`: `{ type: 'strong', children: \[] }`$/,
3939
'should throw if the given node has `children`'
40-
);
40+
)
4141

42-
t.doesNotThrow(
43-
function () {
44-
assert.void({type: 'break'});
45-
},
46-
'should not throw on valid void nodes'
47-
);
42+
t.doesNotThrow(function() {
43+
assert.void({type: 'break'})
44+
}, 'should not throw on valid void nodes')
4845

49-
t.end();
50-
});
46+
t.end()
47+
})

0 commit comments

Comments
 (0)
Please sign in to comment.