Skip to content

Commit 158adf4

Browse files
committed
Update dev-dependencies
1 parent c5fc0d4 commit 158adf4

File tree

9 files changed

+46
-41
lines changed

9 files changed

+46
-41
lines changed

lib/index.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/**
2-
* @typedef {import('parse5').Node} P5Node
3-
* @typedef {import('parse5').Document} P5Document
4-
* @typedef {import('parse5').DocumentFragment} P5Fragment
5-
* @typedef {import('parse5').DocumentType} P5Doctype
6-
* @typedef {import('parse5').CommentNode} P5Comment
7-
* @typedef {import('parse5').TextNode} P5Text
8-
* @typedef {import('parse5').Element} P5Element
9-
* @typedef {import('parse5').Attribute} P5Attribute
10-
* @typedef {import('parse5').ParentNode} P5Parent
2+
* @typedef {import('parse5').DefaultTreeAdapterMap} DefaultTreeAdapterMap
3+
* @typedef {DefaultTreeAdapterMap['document']} P5Document
4+
* @typedef {DefaultTreeAdapterMap['documentFragment']} P5Fragment
5+
* @typedef {DefaultTreeAdapterMap['element']} P5Element
6+
* @typedef {DefaultTreeAdapterMap['node']} P5Node
7+
* @typedef {DefaultTreeAdapterMap['documentType']} P5Doctype
8+
* @typedef {DefaultTreeAdapterMap['commentNode']} P5Comment
9+
* @typedef {DefaultTreeAdapterMap['textNode']} P5Text
10+
* @typedef {DefaultTreeAdapterMap['parentNode']} P5Parent
11+
* @typedef {import('parse5/dist/common/token.js').Attribute} P5Attribute
1112
* @typedef {Exclude<P5Node, P5Document|P5Fragment>} P5Child
1213
* @typedef {import('property-information').Schema} Schema
1314
* @typedef {import('property-information').Info} Info
@@ -59,11 +60,12 @@ export function toParse5(tree, space) {
5960
function root(node, schema) {
6061
/** @type {P5Document} */
6162
const p5 = {
63+
// @ts-expect-error: fine.
6264
nodeName: '#document',
65+
// @ts-expect-error: fine.
6366
mode: (node.data || {}).quirksMode ? 'quirks' : 'no-quirks',
6467
childNodes: []
6568
}
66-
// @ts-expect-error Assume correct children.
6769
p5.childNodes = all(node.children, p5, schema)
6870
return patch(node, p5)
6971
}
@@ -75,8 +77,11 @@ function root(node, schema) {
7577
*/
7678
function fragment(node, schema) {
7779
/** @type {P5Fragment} */
78-
const p5 = {nodeName: '#document-fragment', childNodes: []}
79-
// @ts-expect-error Assume correct children.
80+
const p5 = {
81+
// @ts-expect-error: fine.
82+
nodeName: '#document-fragment',
83+
childNodes: []
84+
}
8085
p5.childNodes = all(node.children, p5, schema)
8186
return patch(node, p5)
8287
}
@@ -87,11 +92,13 @@ function fragment(node, schema) {
8792
* @returns {P5Doctype}
8893
*/
8994
function doctype(node) {
95+
// @ts-expect-error: fine.
9096
return patch(node, {
9197
nodeName: '#documentType',
9298
name: 'html',
9399
publicId: '',
94100
systemId: '',
101+
// @ts-expect-error: change to `null` in a major?
95102
parentNode: undefined
96103
})
97104
}
@@ -201,7 +208,6 @@ function element(node, schema) {
201208
})
202209
)
203210

204-
// @ts-expect-error Assume correct children.
205211
p5.childNodes = all(node.children, p5, schema)
206212

207213
// @ts-expect-error Types are wrong.
@@ -228,7 +234,6 @@ function all(children, p5, schema) {
228234
// @ts-expect-error Assume child.
229235
const child = one(children[index], schema)
230236

231-
// @ts-expect-error types are wrong.
232237
child.parentNode = p5
233238

234239
result.push(child)
@@ -250,13 +255,14 @@ function patch(node, p5) {
250255
const position = node.position
251256

252257
if (position && position.start && position.end) {
253-
// @ts-expect-error Types are wrong.
254258
p5.sourceCodeLocation = {
255259
startLine: position.start.line,
256260
startCol: position.start.column,
261+
// @ts-expect-error assume this is set.
257262
startOffset: position.start.offset,
258263
endLine: position.end.line,
259264
endCol: position.end.column,
265+
// @ts-expect-error assume this is set.
260266
endOffset: position.end.offset
261267
}
262268
}

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
],
3636
"dependencies": {
3737
"@types/hast": "^2.0.0",
38-
"@types/parse5": "^6.0.0",
3938
"hast-to-hyperscript": "^10.0.0",
4039
"property-information": "^6.0.0",
4140
"web-namespaces": "^2.0.0",
@@ -46,15 +45,15 @@
4645
"@types/tape": "^4.0.0",
4746
"c8": "^7.0.0",
4847
"json-stringify-safe": "^5.0.0",
49-
"parse5": "^6.0.0",
48+
"parse5": "^7.0.0",
5049
"prettier": "^2.0.0",
51-
"remark-cli": "^9.0.0",
52-
"remark-preset-wooorm": "^8.0.0",
50+
"remark-cli": "^10.0.0",
51+
"remark-preset-wooorm": "^9.0.0",
5352
"rimraf": "^3.0.0",
5453
"tape": "^5.0.0",
5554
"type-coverage": "^2.0.0",
5655
"typescript": "^4.0.0",
57-
"xo": "^0.42.0"
56+
"xo": "^0.49.0"
5857
},
5958
"scripts": {
6059
"prepack": "npm run build && npm run format",

test/comment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import test from 'tape'
2-
import parse5 from 'parse5'
2+
import {parseFragment} from 'parse5'
33
import {toParse5} from '../index.js'
44

55
test('comment', (t) => {
66
const actual = toParse5({type: 'comment', value: 'Alpha'})
7-
const expected = parse5.parseFragment('<!--Alpha-->').childNodes[0]
7+
const expected = parseFragment('<!--Alpha-->').childNodes[0]
88

99
Object.assign(expected, {parentNode: undefined})
1010

test/doctype.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'tape'
2-
import parse5 from 'parse5'
2+
import {parse} from 'parse5'
33
import {toParse5} from '../index.js'
44

55
test('doctype', (t) => {
@@ -10,7 +10,7 @@ test('doctype', (t) => {
1010
// @ts-expect-error legacy property is not recognized by @types/hast
1111
system: 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd'
1212
})
13-
const expected = parse5.parse('<!DOCTYPE html>').childNodes[0]
13+
const expected = parse('<!DOCTYPE html>').childNodes[0]
1414

1515
Object.assign(expected, {parentNode: undefined})
1616

@@ -21,7 +21,7 @@ test('doctype', (t) => {
2121

2222
t.test('should transform a doctype (modern)', (st) => {
2323
const actual = toParse5({type: 'doctype', name: 'html'})
24-
const expected = parse5.parse('<!doctypehtml>').childNodes[0]
24+
const expected = parse('<!doctypehtml>').childNodes[0]
2525

2626
Object.assign(expected, {parentNode: undefined})
2727

test/element.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'tape'
2-
import parse5 from 'parse5'
2+
import {parseFragment} from 'parse5'
33
import {toParse5} from '../index.js'
44
import {json} from './json.js'
55

@@ -10,7 +10,7 @@ test('element', (t) => {
1010
tagName: 'h1',
1111
children: [{type: 'text', value: 'Alpha'}]
1212
})
13-
const expected = parse5.parseFragment('<h1>Alpha').childNodes[0]
13+
const expected = parseFragment('<h1>Alpha').childNodes[0]
1414

1515
Object.assign(expected, {parentNode: undefined})
1616

@@ -72,7 +72,7 @@ test('element', (t) => {
7272
]
7373
})
7474

75-
const expected = parse5.parseFragment(
75+
const expected = parseFragment(
7676
[
7777
'<div>',
7878
'<h1 id="a" class="b c" hidden height="2">',
@@ -101,7 +101,7 @@ test('element', (t) => {
101101
tagName: 'img',
102102
properties: {src: '#', alt: ''}
103103
})
104-
const expected = parse5.parseFragment('<img src=# alt="">').childNodes[0]
104+
const expected = parseFragment('<img src=# alt="">').childNodes[0]
105105

106106
Object.assign(expected, {parentNode: undefined})
107107

@@ -121,7 +121,7 @@ test('element', (t) => {
121121
children: [{type: 'text', value: 'Alpha'}]
122122
}
123123
})
124-
const expected = parse5.parseFragment('<template id="a">Alpha</template>')
124+
const expected = parseFragment('<template id="a">Alpha</template>')
125125
.childNodes[0]
126126

127127
Object.assign(expected, {parentNode: undefined})
@@ -155,7 +155,7 @@ test('element', (t) => {
155155
}
156156
})
157157

158-
const expected = parse5.parseFragment(
158+
const expected = parseFragment(
159159
'<template id="b"><b>bold</b> and <i>italic</i></template>'
160160
).childNodes[0]
161161

test/position.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'tape'
2-
import parse5 from 'parse5'
2+
import {parseFragment} from 'parse5'
33
import {toParse5} from '../index.js'
44
import {json} from './json.js'
55

@@ -23,7 +23,7 @@ test('position', (t) => {
2323
}
2424
})
2525

26-
const expected = parse5.parseFragment('<h1>Alpha', {
26+
const expected = parseFragment('<h1>Alpha', {
2727
sourceCodeLocationInfo: true
2828
}).childNodes[0]
2929

test/root.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import test from 'tape'
2-
import parse5 from 'parse5'
2+
import {parse} from 'parse5'
33
import {toParse5} from '../index.js'
44
import {json} from './json.js'
55

66
test('root', (t) => {
77
t.test('should transform a root (quirks)', (st) => {
8-
const expected = parse5.parse('')
8+
const expected = parse('')
99

1010
st.deepEqual(
1111
json(
@@ -31,7 +31,7 @@ test('root', (t) => {
3131
})
3232

3333
t.test('should transform a root (no-quirks)', (st) => {
34-
const expected = parse5.parse('<!doctypehtml>')
34+
const expected = parse('<!doctypehtml>')
3535

3636
st.deepEqual(
3737
json(

test/svg.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'tape'
2-
import parse5 from 'parse5'
2+
import {parseFragment} from 'parse5'
33
import {toParse5} from '../index.js'
44
import {json} from './json.js'
55

@@ -30,7 +30,7 @@ test('svg', (t) => {
3030
]
3131
})
3232

33-
const expected = parse5.parseFragment(
33+
const expected = parseFragment(
3434
[
3535
'<svg width="230" height="120" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">',
3636
'<circle cx="60" cy="60" r="50" fill="red"/>',
@@ -56,7 +56,7 @@ test('svg', (t) => {
5656
'svg'
5757
)
5858

59-
const expected = parse5.parseFragment(
59+
const expected = parseFragment(
6060
'<svg><circle cx="60" cy="60" r="50" fill="red"/></svg>'
6161
// @ts-expect-error runtime.
6262
).childNodes[0].childNodes[0]

test/text.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import test from 'tape'
2-
import parse5 from 'parse5'
2+
import {parseFragment} from 'parse5'
33
import {toParse5} from '../index.js'
44

55
test('text', (t) => {
6-
const expected = parse5.parseFragment('Alpha').childNodes[0]
6+
const expected = parseFragment('Alpha').childNodes[0]
77

88
Object.assign(expected, {parentNode: undefined})
99

0 commit comments

Comments
 (0)