Skip to content

Commit 40029ea

Browse files
committed
Update dev-dependencies
1 parent e88e196 commit 40029ea

File tree

6 files changed

+24
-58
lines changed

6 files changed

+24
-58
lines changed

lib/any.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ import {nest} from './nest.js'
1515
import {pseudo} from './pseudo.js'
1616
import {test} from './test.js'
1717

18+
/** @type {(query: Selectors|RuleSet|Rule, element: HastNode, state: SelectState) => Array<Element>} */
1819
const type = zwitch('type', {
19-
// @ts-expect-error: hush.
2020
unknown: unknownType,
2121
invalid: invalidType,
22-
// @ts-expect-error: hush.
2322
handlers: {selectors, ruleSet, rule}
2423
})
2524

@@ -30,7 +29,6 @@ const type = zwitch('type', {
3029
* @returns {Array<Element>}
3130
*/
3231
export function any(query, node, state) {
33-
// @ts-expect-error zwitch types are off.
3432
return query && node ? type(query, node, state) : []
3533
}
3634

@@ -133,11 +131,13 @@ function rule(query, tree, state) {
133131
}
134132

135133
// Shouldn’t be called, all data is handled.
136-
/* c8 ignore next 6 */
137134
/**
138-
* @param {{[x: string]: unknown, type: string}} query
135+
* @param {unknown} query
136+
* @returns {never}
139137
*/
138+
/* c8 ignore next 4 */
140139
function unknownType(query) {
140+
// @ts-expect-error: `type` guaranteed.
141141
throw new Error('Unknown type `' + query.type + '`')
142142
}
143143

lib/attribute.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,17 @@ import {find} from 'property-information'
1313
import {stringify as spaces} from 'space-separated-tokens'
1414
import {zwitch} from 'zwitch'
1515

16+
/** @type {(query: RuleAttr, element: Element, info: Info) => boolean} */
1617
const handle = zwitch('operator', {
17-
// @ts-expect-error: hush.
1818
unknown: unknownOperator,
1919
// @ts-expect-error: hush.
2020
invalid: exists,
2121
handlers: {
22-
// @ts-expect-error: hush.
2322
'=': exact,
24-
// @ts-expect-error: hush.
2523
'~=': spaceSeparatedList,
26-
// @ts-expect-error: hush.
2724
'|=': exactOrPrefix,
28-
// @ts-expect-error: hush.
2925
'^=': begins,
30-
// @ts-expect-error: hush.
3126
'$=': ends,
32-
// @ts-expect-error: hush.
3327
'*=': contains
3428
}
3529
})
@@ -190,11 +184,12 @@ function contains(query, element, info) {
190184

191185
// Shouldn’t be called, Parser throws an error instead.
192186
/**
193-
* @param {RuleAttr} query
194-
* @returns {boolean}
187+
* @param {unknown} query
188+
* @returns {never}
195189
*/
196-
/* c8 ignore next 3 */
190+
/* c8 ignore next 4 */
197191
function unknownOperator(query) {
192+
// @ts-expect-error: `operator` guaranteed.
198193
throw new Error('Unknown operator `' + query.operator + '`')
199194
}
200195

lib/nest.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* @typedef {import('./types.js').Parent} Parent
66
* @typedef {import('./types.js').SelectState} SelectState
77
* @typedef {import('./types.js').SelectIterator} SelectIterator
8+
* @typedef {import('./types.js').HastNode} HastNode
89
* @typedef {import('./types.js').Handler} Handler
910
*/
1011

@@ -14,19 +15,15 @@ import {parent, element} from './util.js'
1415

1516
const own = {}.hasOwnProperty
1617

18+
/** @type {(query: Rule, node: HastNode, index: number|null, parent: Parent|null, state: SelectState) => void} */
1719
const handle = zwitch('nestingOperator', {
18-
// @ts-expect-error: hush.
1920
unknown: unknownNesting,
2021
// @ts-expect-error: hush.
2122
invalid: topScan, // `undefined` is the top query selector.
2223
handlers: {
23-
// @ts-expect-error: hush.
2424
null: descendant, // `null` is the descendant combinator.
25-
// @ts-expect-error: hush.
2625
'>': child,
27-
// @ts-expect-error: hush.
2826
'+': adjacentSibling,
29-
// @ts-expect-error: hush.
3027
'~': generalSibling
3128
}
3229
})
@@ -37,11 +34,13 @@ export function nest(query, node, index, parent, state) {
3734
}
3835

3936
// Shouldn’t be called, parser gives correct data.
40-
/* c8 ignore next 6 */
4137
/**
42-
* @param {{[x: string]: unknown, type: string}} query
38+
* @param {unknown} query
39+
* @returns {never}
4340
*/
41+
/* c8 ignore next 4 */
4442
function unknownNesting(query) {
43+
// @ts-expect-error: `nestingOperator` guaranteed.
4544
throw new Error('Unexpected nesting `' + query.nestingOperator + '`')
4645
}
4746

lib/parse.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* @typedef {import('./types.js').Selectors} Selectors
44
* @typedef {import('./types.js').RuleSet} RuleSet
55
* @typedef {import('./types.js').Rule} Rule
6-
* @typedef {import('./types.js').RulePseudo} RulePseudo
7-
* @typedef {import('./types.js').RulePseudoNth} RulePseudoNth
86
*/
97

108
import {CssSelectorParser} from 'css-selector-parser'
@@ -24,7 +22,7 @@ const nth = new Set([
2422

2523
const parser = new CssSelectorParser()
2624

27-
// @ts-expect-error: hush.
25+
/** @type {<Q extends Selectors|RuleSet|Rule|undefined>(query: Q) => Q} */
2826
const compile = zwitch('type', {handlers: {selectors, ruleSet, rule}})
2927

3028
parser.registerAttrEqualityMods('~', '|', '^', '$', '*')
@@ -40,7 +38,6 @@ export function parse(selector) {
4038
throw new TypeError('Expected `string` as selector, not `' + selector + '`')
4139
}
4240

43-
// @ts-expect-error types are wrong.
4441
return compile(parser.parse(selector))
4542
}
4643

lib/pseudo.js

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,66 +19,38 @@ import {whitespace} from 'hast-util-whitespace'
1919
import {zwitch} from 'zwitch'
2020
import {any} from './any.js'
2121

22+
/** @type {(rule: Rule|RulePseudo, element: Element, index: number|null, parent: Parent|null, state: SelectState) => boolean} */
2223
const handle = zwitch('name', {
23-
// @ts-expect-error: hush.
2424
unknown: unknownPseudo,
2525
invalid: invalidPseudo,
2626
handlers: {
27-
// @ts-expect-error: hush.
2827
any: matches,
29-
// @ts-expect-error: hush.
3028
'any-link': anyLink,
31-
// @ts-expect-error: hush.
3229
blank,
33-
// @ts-expect-error: hush.
3430
checked,
35-
// @ts-expect-error: hush.
3631
dir,
37-
// @ts-expect-error: hush.
3832
disabled,
39-
// @ts-expect-error: hush.
4033
empty,
41-
// @ts-expect-error: hush.
4234
enabled,
43-
// @ts-expect-error: hush.
4435
'first-child': firstChild,
45-
// @ts-expect-error: hush.
4636
'first-of-type': firstOfType,
47-
// @ts-expect-error: hush.
4837
has,
49-
// @ts-expect-error: hush.
5038
lang,
51-
// @ts-expect-error: hush.
5239
'last-child': lastChild,
53-
// @ts-expect-error: hush.
5440
'last-of-type': lastOfType,
55-
// @ts-expect-error: hush.
5641
matches,
57-
// @ts-expect-error: hush.
5842
not,
59-
// @ts-expect-error: hush.
6043
'nth-child': nthChild,
61-
// @ts-expect-error: hush.
6244
'nth-last-child': nthLastChild,
63-
// @ts-expect-error: hush.
6445
'nth-of-type': nthOfType,
65-
// @ts-expect-error: hush.
6646
'nth-last-of-type': nthLastOfType,
67-
// @ts-expect-error: hush.
6847
'only-child': onlyChild,
69-
// @ts-expect-error: hush.
7048
'only-of-type': onlyOfType,
71-
// @ts-expect-error: hush.
7249
optional,
73-
// @ts-expect-error: hush.
7450
'read-only': readOnly,
75-
// @ts-expect-error: hush.
7651
'read-write': readWrite,
77-
// @ts-expect-error: hush.
7852
required,
79-
// @ts-expect-error: hush.
8053
root,
81-
// @ts-expect-error: hush.
8254
scope
8355
}
8456
})
@@ -527,10 +499,13 @@ function invalidPseudo() {
527499
}
528500

529501
/**
530-
* @param {RulePseudo} query
502+
* @param {unknown} query
503+
* @returns {never}
531504
*/
532505
function unknownPseudo(query) {
506+
// @ts-expect-error: indexable.
533507
if (query.name) {
508+
// @ts-expect-error: indexable.
534509
throw new Error('Unknown pseudo-selector `' + query.name + '`')
535510
}
536511

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@
6060
"c8": "^7.0.0",
6161
"hastscript": "^7.0.0",
6262
"prettier": "^2.0.0",
63-
"remark-cli": "^10.0.0",
63+
"remark-cli": "^11.0.0",
6464
"remark-preset-wooorm": "^9.0.0",
6565
"rimraf": "^3.0.0",
6666
"tape": "^5.0.0",
6767
"type-coverage": "^2.0.0",
6868
"typescript": "^4.0.0",
6969
"unist-builder": "^3.0.0",
70-
"xo": "^0.49.0"
70+
"xo": "^0.53.0"
7171
},
7272
"scripts": {
7373
"prepack": "npm run build && npm run format",

0 commit comments

Comments
 (0)