Skip to content

Commit 3b28c25

Browse files
committed
Refactor to use @imports
1 parent bb9649b commit 3b28c25

File tree

10 files changed

+28
-58
lines changed

10 files changed

+28
-58
lines changed

lib/attribute.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstAttribute} AstAttribute
3-
*
4-
* @typedef {import('hast').Element} Element
5-
* @typedef {import('hast').Properties} Properties
6-
*
7-
* @typedef {import('property-information').Info} Info
8-
* @typedef {import('property-information').Schema} Schema
2+
* @import {AstAttribute} from 'css-selector-parser'
3+
* @import {Element, Properties} from 'hast'
4+
* @import {Info, Schema} from 'property-information'
95
*/
106

117
import {stringify as commas} from 'comma-separated-tokens'

lib/class-name.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstClassName} AstClassName
3-
* @typedef {import('hast').Element} Element
2+
* @import {AstClassName} from 'css-selector-parser'
3+
* @import {Element} from 'hast'
44
*/
55

66
/** @type {Array<never>} */

lib/enter-state.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/**
2-
* @typedef {import('hast').ElementContent} ElementContent
3-
* @typedef {import('hast').Nodes} Nodes
4-
*
5-
* @typedef {import('unist-util-visit').Visitor<ElementContent>} Visitor
6-
*
7-
* @typedef {import('./index.js').Direction} Direction
8-
* @typedef {import('./index.js').State} State
2+
* @import {Visitor} from 'unist-util-visit'
3+
* @import {ElementContent, Nodes} from 'hast'
4+
* @import {Direction, State} from './index.js'
95
*/
106

117
import {direction} from 'direction'
@@ -112,7 +108,7 @@ export function enterState(state, node) {
112108
state.editableOrEditingHost = editableOrEditingHost
113109
}
114110

115-
/** @type {Visitor} */
111+
/** @type {Visitor<ElementContent>} */
116112
function inferDirectionality(child) {
117113
if (child.type === 'text') {
118114
directionInferred = directionBidi(child.value)

lib/id.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstId} AstId
3-
*
4-
* @typedef {import('hast').Element} Element
2+
* @import {AstId} from 'css-selector-parser'
3+
* @import {Element} from 'hast'
54
*/
65

7-
// Workaround to show references to above types in VS Code.
8-
''
9-
106
/**
117
* Check whether an element has an ID.
128
*

lib/index.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstSelector} AstSelector
3-
*
4-
* @typedef {import('hast').Element} Element
5-
* @typedef {import('hast').Nodes} Nodes
6-
* @typedef {import('hast').RootContent} RootContent
7-
*
8-
* @typedef {import('property-information').Schema} Schema
2+
* @import {AstSelector} from 'css-selector-parser'
3+
* @import {Element, Nodes, RootContent} from 'hast'
4+
* @import {Schema} from 'property-information'
95
*/
106

117
/**

lib/name.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstTagName} AstTagName
3-
*
4-
* @typedef {import('hast').Element} Element
2+
* @import {AstTagName} from 'css-selector-parser'
3+
* @import {Element} from 'hast'
54
*/
65

7-
// Workaround to show references to above types in VS Code.
8-
''
9-
106
/**
117
* Check whether an element has a tag name.
128
*

lib/parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstSelector} AstSelector
2+
* @import {AstSelector} from 'css-selector-parser'
33
*/
44

55
import {createParser} from 'css-selector-parser'

lib/pseudo.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstPseudoClass} AstPseudoClass
3-
*
4-
* @typedef {import('hast').Element} Element
5-
* @typedef {import('hast').ElementContent} ElementContent
6-
* @typedef {import('hast').Parents} Parents
7-
*
8-
* @typedef {import('./index.js').State} State
2+
* @import {AstPseudoClass} from 'css-selector-parser'
3+
* @import {default as NthCheck} from 'nth-check'
4+
* @import {ElementContent, Element, Parents} from 'hast'
5+
* @import {State} from './index.js'
96
*/
107

118
import {extendedFilter} from 'bcp-47-match'
@@ -17,7 +14,7 @@ import fauxEsmNthCheck from 'nth-check'
1714
import {zwitch} from 'zwitch'
1815
import {walk} from './walk.js'
1916

20-
/** @type {import('nth-check').default} */
17+
/** @type {NthCheck} */
2118
// @ts-expect-error: types are broken.
2219
const nthCheck = fauxEsmNthCheck.default || fauxEsmNthCheck
2320

lib/test.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstRule} AstRule
3-
*
4-
* @typedef {import('hast').Element} Element
5-
* @typedef {import('hast').Parents} Parents
6-
*
7-
* @typedef {import('./index.js').State} State
2+
* @import {AstRule} from 'css-selector-parser'
3+
* @import {Element, Parents} from 'hast'
4+
* @import {State} from './index.js'
85
*/
96

107
import {attribute} from './attribute.js'

lib/walk.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/**
2-
* @typedef {import('css-selector-parser').AstRule} AstRule
3-
*
4-
* @typedef {import('hast').Element} Element
5-
* @typedef {import('hast').Nodes} Nodes
6-
* @typedef {import('hast').Parents} Parents
7-
*
8-
* @typedef {import('./index.js').State} State
2+
* @import {AstRule} from 'css-selector-parser'
3+
* @import {Element, Nodes, Parents} from 'hast'
4+
* @import {State} from './index.js'
95
*/
106

117
/**

0 commit comments

Comments
 (0)