Skip to content

Commit 970d5cc

Browse files
committed
Update dev-dependencies
1 parent df9513e commit 970d5cc

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

convert.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Test, TestFunction} from './'
1+
import {Test, TestFunction} from '.'
22
import {Node} from 'unist'
33

44
declare function convert<T extends Node>(test: Test<T>): TestFunction<T>

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
"tape": "^5.0.0",
4747
"tinyify": "^3.0.0",
4848
"unified": "^9.0.0",
49-
"xo": "^0.34.0"
49+
"xo": "^0.35.0"
5050
},
5151
"scripts": {
5252
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
53-
"build-bundle": "browserify . -s unistUtilIs > unist-util-is.js",
54-
"build-mangle": "browserify . -s unistUtilIs -p tinyify > unist-util-is.min.js",
53+
"build-bundle": "browserify . -s unistUtilIs -o unist-util-is.js",
54+
"build-mangle": "browserify . -s unistUtilIs -o unist-util-is.min.js -p tinyify",
5555
"build": "npm run build-bundle && npm run build-mangle",
5656
"test-api": "node test",
5757
"test-coverage": "nyc --reporter lcov tape test.js",
@@ -70,6 +70,7 @@
7070
"prettier": true,
7171
"esnext": false,
7272
"rules": {
73+
"@typescript-eslint/no-unused-expressions": "off",
7374
"eqeqeq": [
7475
"error",
7576
"always",

unist-util-is-test.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import unified = require('unified')
44
import is = require('unist-util-is')
55
import convert = require('unist-util-is/convert')
66

7-
/*=== setup ===*/
7+
/* Setup. */
88
interface Element extends Parent {
99
type: 'element'
1010
tagName: string
11-
properties: {
12-
[key: string]: unknown
13-
}
11+
properties: Record<string, unknown>
1412
content: Node
1513
children: Node[]
1614
}
@@ -38,32 +36,32 @@ const isHeading = (node: unknown): node is Heading =>
3836
const isElement = (node: unknown): node is Element =>
3937
typeof node === 'object' && node !== null && (node as Node).type === 'element'
4038

41-
/*=== types cannot be narrowed without predicate ===*/
39+
/* Types cannot be narrowed without predicate. */
4240
// $ExpectError
4341
const maybeHeading: Heading = heading
4442
// $ExpectError
4543
const maybeElement: Element = element
4644

47-
/*=== missing params ===*/
45+
/* Missing parameters. */
4846
// $ExpectError
4947
is()
5048
// $ExpectError
5149
is<Node>()
5250
// $ExpectError
5351
is<Node>(heading)
5452

55-
/*=== invalid generic ===*/
53+
/* Incorrect generic. */
5654
// $ExpectError
5755
is<string>(heading, 'heading')
5856
// $ExpectError
5957
is<boolean>(heading, 'heading')
6058
// $ExpectError
61-
is<{}>(heading, 'heading')
59+
is<Record<string, unknown>>(heading, 'heading')
6260

63-
/*=== assignable to boolean ===*/
61+
/* Should be assignable to boolean. */
6462
const wasItAHeading: boolean = is<Heading>(heading, 'heading')
6563

66-
/*=== type string test ===*/
64+
/* Should support string tests. */
6765
is<Heading>(heading, 'heading')
6866
is<Heading>(element, 'heading')
6967
// $ExpectError
@@ -86,7 +84,7 @@ if (is<Element>(element, 'element')) {
8684
const maybeNotElement: Heading = element
8785
}
8886

89-
/*=== type predicate function test ===*/
87+
/* Should support function tests. */
9088
is(heading, isHeading)
9189
is(element, isHeading)
9290
// $ExpectError
@@ -109,7 +107,7 @@ if (is(element, isElement)) {
109107
const maybeNotElement: Heading = element
110108
}
111109

112-
/*=== type object test ===*/
110+
/* Should support object tests. */
113111
is<Heading>(heading, {type: 'heading', depth: 2})
114112
is<Heading>(element, {type: 'heading', depth: 2})
115113
// $ExpectError
@@ -132,12 +130,13 @@ if (is<Element>(element, {type: 'element', tagName: 'section'})) {
132130
const maybeNotElement: Heading = element
133131
}
134132

135-
/*=== type array of tests ===*/
133+
/* Should support array tests. */
136134
is<Heading | Element | Paragraph>(heading, [
137135
'heading',
138136
isElement,
139137
{type: 'ParagraphNode'}
140138
])
139+
141140
if (
142141
is<Heading | Element | Paragraph>(heading, [
143142
'heading',
@@ -150,30 +149,38 @@ if (
150149
heading // $ExpectType Heading
151150
break
152151
}
152+
153153
case 'element': {
154154
heading // $ExpectType Element
155155
break
156156
}
157+
157158
case 'ParagraphNode': {
158159
heading // $ExpectType Paragraph
159160
break
160161
}
162+
161163
// $ExpectError
162164
case 'dne': {
163165
break
164166
}
167+
168+
default: {
169+
break
170+
}
165171
}
166172
}
167173

168-
/*=== usable in unified transform ===*/
174+
/* Should support being used in a unified transform. */
169175
unified().use(() => (tree) => {
170176
if (is<Heading>(tree, 'heading')) {
171-
// do something
177+
// Do something
172178
}
179+
173180
return tree
174181
})
175182

176-
/*=== convert ===*/
183+
/* Should support `convert`. */
177184
convert<Heading>('heading')
178185
// $ExpectError
179186
convert<Heading>('element')

0 commit comments

Comments
 (0)