Skip to content

Commit 3fa4b6b

Browse files
committed
Refactor code-style
1 parent d98c548 commit 3fa4b6b

File tree

3 files changed

+412
-344
lines changed

3 files changed

+412
-344
lines changed

lib/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
* @typedef {import('mdast-util-to-markdown').ConstructName} ConstructName
1111
* @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension
1212
*
13-
* @typedef {import('mdast-util-find-and-replace').ReplaceFunction} ReplaceFunction
1413
* @typedef {import('mdast-util-find-and-replace').RegExpMatchObject} RegExpMatchObject
14+
* @typedef {import('mdast-util-find-and-replace').ReplaceFunction} ReplaceFunction
1515
*/
1616

1717
import {ccount} from 'ccount'
18-
import {findAndReplace} from 'mdast-util-find-and-replace'
18+
import {ok as assert} from 'devlop'
1919
import {unicodePunctuation, unicodeWhitespace} from 'micromark-util-character'
20+
import {findAndReplace} from 'mdast-util-find-and-replace'
2021

2122
/** @type {ConstructName} */
2223
const inConstruct = 'phrasing'
@@ -101,7 +102,8 @@ function exitLiteralAutolinkHttp(token) {
101102
*/
102103
function exitLiteralAutolinkWww(token) {
103104
this.config.exit.data.call(this, token)
104-
const node = /** @type {Link} */ (this.stack[this.stack.length - 1])
105+
const node = this.stack[this.stack.length - 1]
106+
assert(node.type === 'link')
105107
node.url = 'http://' + this.sliceSerialize(token)
106108
}
107109

@@ -140,7 +142,7 @@ function transformGfmAutolinkLiterals(tree) {
140142
* @param {string} domain
141143
* @param {string} path
142144
* @param {RegExpMatchObject} match
143-
* @returns {Link | Array<PhrasingContent> | false}
145+
* @returns {Array<PhrasingContent> | Link | false}
144146
*/
145147
// eslint-disable-next-line max-params
146148
function findUrl(_, protocol, domain, path, match) {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"dependencies": {
4242
"@types/mdast": "^4.0.0",
4343
"ccount": "^2.0.0",
44+
"devlop": "^1.0.0",
4445
"mdast-util-find-and-replace": "^3.0.0",
4546
"micromark-util-character": "^2.0.0"
4647
},

0 commit comments

Comments
 (0)