Skip to content

Commit

Permalink
Update @types/nlcst, unified, utilities, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 7, 2023
1 parent cb0e2b6 commit 2e4e264
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ const slashes = /^\/{1,3}$/
* @type {import('unified').Plugin<[], Root>}
*/
export default function retextSyntaxUrls() {
// @ts-expect-error: Assume attached.
// type-coverage:ignore-next-line
this.Parser.prototype.useFirst('tokenizeSentence', modifyChildren(mergeLinks))
// Register extension for parser.
let sentence = this.data('nlcstSentenceExtensions')

if (!sentence) {
this.data('nlcstSentenceExtensions', (sentence = []))
}

sentence.push(modifyChildren(mergeLinks))

/**
* @param {SentenceContent} child
Expand Down Expand Up @@ -157,7 +162,7 @@ export default function retextSyntaxUrls() {
const initial = pointStart(nodes[0])
const final = pointEnd(nodes[nodes.length - 1])

if (initial.line && final.line) {
if (initial && final) {
replacement.position = {start: initial, end: final}
}

Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"index.js"
],
"dependencies": {
"@types/nlcst": "^1.0.0",
"@types/unist": "^2.0.0",
"@types/nlcst": "^2.0.0",
"@types/unist": "^3.0.0",
"ccount": "^2.0.0",
"nlcst-to-string": "^3.0.0",
"unified": "^10.0.0",
"unist-util-modify-children": "^3.0.0",
"unist-util-position": "^4.0.0"
"nlcst-to-string": "^4.0.0",
"unified": "^11.0.0",
"unist-util-modify-children": "^4.0.0",
"unist-util-position": "^5.0.0"
},
"devDependencies": {
"@types/tape": "^5.0.0",
Expand All @@ -48,13 +48,13 @@
"prettier": "^3.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"retext": "^8.0.0",
"retext": "^9.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"unist-util-remove-position": "^4.0.0",
"unist-util-visit": "^4.0.0",
"unist-util-remove-position": "^5.0.0",
"unist-util-visit": "^5.0.0",
"xo": "^0.56.0"
},
"scripts": {
Expand Down
17 changes: 4 additions & 13 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ import retextSyntaxUrls from '../index.js'
import {correct, incorrect} from './lists.js'

const position = retext().use(retextSyntaxUrls)
const noPosition = retext()
.use(function () {
// @ts-expect-error: Assume attached.
// type-coverage:ignore-next-line
Object.assign(this.Parser.prototype, {position: false})
})
.use(retextSyntaxUrls)

test('retext-syntax-urls', (t) => {
t.test('Correct URLs', (t) => {
Expand Down Expand Up @@ -58,8 +51,11 @@ test('retext-syntax-urls', (t) => {
t.end()
})

const tree = position.parse('More.')
removePosition(tree, {force: true})

t.deepEqual(
noPosition.parse('More.'),
tree,
{
type: 'RootNode',
children: [
Expand Down Expand Up @@ -103,11 +99,6 @@ test('fixtures', (t) => {
)

t.deepLooseEqual(position.parse(input), base, name + ' w/ position')
t.deepLooseEqual(
noPosition.parse(input),
removePosition(base, true),
name + ' w/o position'
)
}

t.end()
Expand Down

0 comments on commit 2e4e264

Please sign in to comment.