Skip to content

Commit

Permalink
Update @types/mdast, mdast-util-{from,to}-markdown, unified, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 12, 2023
1 parent 13542c3 commit 943f6ac
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 50 deletions.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,28 @@
"packages/remark-cli/"
],
"devDependencies": {
"@types/mdast": "^3.0.0",
"@types/mdast": "^4.0.0",
"@types/node": "^20.0.0",
"c8": "^8.0.0",
"camelcase": "^8.0.0",
"execa": "^8.0.0",
"mdast-util-assert": "^4.0.0",
"mdast-util-gfm": "^2.0.0",
"micromark-extension-gfm": "^2.0.0",
"mdast-util-assert": "^5.0.0",
"mdast-util-gfm": "^3.0.0",
"micromark-extension-gfm": "^3.0.0",
"prettier": "^3.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"unified": "^10.0.0",
"unist-util-remove-position": "^4.0.0",
"unified": "^11.0.0",
"unist-util-remove-position": "^5.0.0",
"xo": "^0.56.0"
},
"scripts": {
"#": "./packages/remark-cli/cli.js . -qfo",
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "./packages/remark-cli/cli.js . -qfo && prettier . -w --log-level warn && xo --fix",
"format": "prettier . -w --log-level warn && xo --fix",
"test-api": "npm run test --workspaces && node --conditions development test/index.js",
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
Expand Down
2 changes: 1 addition & 1 deletion packages/remark-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"markdown-extensions": "^2.0.0",
"remark": "^14.0.0",
"unified-args": "^10.0.0"
"unified-args": "^11.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
35 changes: 18 additions & 17 deletions packages/remark-cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,32 @@ test('remark-cli', async (t) => {
'',
'Options:',
'',
' --[no-]color specify color in report (on by default)',
' --[no-]config search for configuration files (on by default)',
' -e --ext <extensions> specify extensions',
' --file-path <path> specify path to process as',
' -f --frail exit with 1 on warnings',
' -h --help output usage information',
' -v --version output version number',
' --[no-]ignore search for ignore files (on by default)',
' -i --ignore-path <path> specify ignore file',
' --ignore-path-resolve-from cwd|dir resolve patterns in `ignore-path` from its directory or cwd',
' --ignore-pattern <globs> specify ignore patterns',
' --inspect output formatted syntax tree',
' -o --output [path] specify output location',
' -q --quiet output only warnings and errors',
' -r --rc-path <path> specify configuration file',
' -i --ignore-path <path> specify ignore file',
' --report <reporter> specify reporter',
' -s --setting <settings> specify settings',
' -e --ext <extensions> specify extensions',
' -u --use <plugins> use plugins',
' -w --watch watch for changes and reprocess',
' -q --quiet output only warnings and errors',
' -S --silent output only errors',
' -f --frail exit with 1 on warnings',
' -t --tree specify input and output as syntax tree',
' --report <reporter> specify reporter',
' --file-path <path> specify path to process as',
' --ignore-path-resolve-from dir|cwd resolve patterns in `ignore-path` from its directory or cwd',
' --ignore-pattern <globs> specify ignore patterns',
' --silently-ignore do not fail when given ignored files',
' --[no-]stdout specify writing to stdout (on by default)',
' -t --tree specify input and output as syntax tree',
' --tree-in specify input as syntax tree',
' --tree-out output syntax tree',
' --inspect output formatted syntax tree',
' --[no-]stdout specify writing to stdout (on by default)',
' --[no-]color specify color in report (on by default)',
' --[no-]config search for configuration files (on by default)',
' --[no-]ignore search for ignore files (on by default)',
' -u --use <plugins> use plugins',
' --verbose report extra info for messages',
' -v --version output version number',
' -w --watch watch for changes and reprocess',
'',
'Examples:',
'',
Expand Down
4 changes: 3 additions & 1 deletion packages/remark-parse/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {fromMarkdown} from 'mdast-util-from-markdown'
* @type {import('unified').Plugin<[Options?] | void[], string, Root>}
*/
export default function remarkParse(options) {
/** @type {import('unified').ParserFunction<Root>} */
/** @type {import('unified').Parser<Root>} */
const parser = (doc) => {
// Assume options.
const settings = /** @type {Options} */ (this.data('settings'))
Expand All @@ -21,7 +21,9 @@ export default function remarkParse(options) {
// Note: these options are not in the readme.
// The goal is for them to be set by plugins on `data` instead of being
// passed by users.
// @ts-expect-error: to do: type.
extensions: this.data('micromarkExtensions') || [],
// @ts-expect-error: to do: type.
mdastExtensions: this.data('fromMarkdownExtensions') || []
})
)
Expand Down
6 changes: 3 additions & 3 deletions packages/remark-parse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-from-markdown": "^1.0.0",
"unified": "^10.0.0"
"@types/mdast": "^4.0.0",
"mdast-util-from-markdown": "^2.0.0",
"unified": "^11.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
4 changes: 3 additions & 1 deletion packages/remark-parse/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ test('remarkParse', async (t) => {

await t.test('extensions', () => {
const tree = unified()
// @ts-expect-error: to do: type settings.
.data('micromarkExtensions', [gfm()])
// @ts-expect-error: to do: type settings.
.data('fromMarkdownExtensions', [gfmFromMarkdown()])
.use(remarkParse)
.parse('* [x] contact@example.com ~~strikethrough~~')

removePosition(tree, true)
removePosition(tree, {force: true})

assert.deepEqual(
tree,
Expand Down
4 changes: 3 additions & 1 deletion packages/remark-stringify/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {toMarkdown} from 'mdast-util-to-markdown'
* @type {import('unified').Plugin<[Options?]|void[], Node, string>}
*/
export default function remarkStringify(options) {
/** @type {import('unified').CompilerFunction<Node, string>} */
/** @type {import('unified').Compiler<Node, string>} */
const compiler = (tree) => {
// Assume options.
const settings = /** @type {Options} */ (this.data('settings'))
Expand All @@ -23,7 +23,9 @@ export default function remarkStringify(options) {
// The goal is for it to be set by plugins on `data` instead of being
// passed by users.
extensions:
// @ts-expect-error: to do: type.
/** @type {ToMarkdownOptions['extensions']} */ (
// @ts-expect-error: to do: type.
this.data('toMarkdownExtensions')
) || []
})
Expand Down
6 changes: 3 additions & 3 deletions packages/remark-stringify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-to-markdown": "^1.0.0",
"unified": "^10.0.0"
"@types/mdast": "^4.0.0",
"mdast-util-to-markdown": "^2.0.0",
"unified": "^11.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
31 changes: 20 additions & 11 deletions packages/remark-stringify/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test('remarkStringify', async (t) => {
() => {
unified()
.use(remarkStringify)
// @ts-expect-error: to do: type settings.
.data('settings', {bullet: true})
.stringify({
type: 'root',
Expand All @@ -63,6 +64,7 @@ test('remarkStringify', async (t) => {
() => {
unified()
.use(remarkStringify)
// @ts-expect-error: to do: type settings.
.data('settings', {listItemIndent: 'foo'})
.stringify({
type: 'root',
Expand All @@ -79,6 +81,7 @@ test('remarkStringify', async (t) => {
() => {
unified()
.use(remarkStringify)
// @ts-expect-error: to do: type settings.
.data('settings', {rule: true})
.stringify({type: 'root', children: [{type: 'thematicBreak'}]})
},
Expand All @@ -90,6 +93,7 @@ test('remarkStringify', async (t) => {
() => {
unified()
.use(remarkStringify)
// @ts-expect-error: to do: type settings.
.data('settings', {ruleRepetition: 1})
.stringify({type: 'root', children: [{type: 'thematicBreak'}]})
},
Expand All @@ -101,6 +105,7 @@ test('remarkStringify', async (t) => {
() => {
unified()
.use(remarkStringify)
// @ts-expect-error: to do: type settings.
.data('settings', {ruleRepetition: true})
.stringify({type: 'root', children: [{type: 'thematicBreak'}]})
},
Expand All @@ -112,6 +117,7 @@ test('remarkStringify', async (t) => {
() => {
unified()
.use(remarkStringify)
// @ts-expect-error: to do: type settings.
.data('settings', {emphasis: '-'})
.stringify({type: 'root', children: [{type: 'emphasis', children: []}]})
},
Expand All @@ -123,6 +129,7 @@ test('remarkStringify', async (t) => {
() => {
unified()
.use(remarkStringify)
// @ts-expect-error: to do: type settings.
.data('settings', {strong: '-'})
.stringify({type: 'root', children: [{type: 'strong', children: []}]})
},
Expand All @@ -134,6 +141,7 @@ test('remarkStringify', async (t) => {
() => {
unified()
.use(remarkStringify)
// @ts-expect-error: to do: type settings.
.data('settings', {fence: '-'})
.stringify({type: 'root', children: [{type: 'code', value: ''}]})
},
Expand All @@ -154,7 +162,7 @@ test('remarkStringify', async (t) => {
}
]
}),
'* alpha\n',
'* alpha\n',
'no ordered, start, or spread'
)

Expand All @@ -171,7 +179,7 @@ test('remarkStringify', async (t) => {
}
]
}),
'* bravo\n',
'* bravo\n',
'start; no ordered or spread'
)

Expand All @@ -194,7 +202,7 @@ test('remarkStringify', async (t) => {
}
]
}),
'* charlie\n\n* delta\n',
'* charlie\n\n* delta\n',
'spread; no ordered or start'
)

Expand All @@ -214,7 +222,7 @@ test('remarkStringify', async (t) => {
}
]
}),
'1. echo\n',
'1. echo\n',
'ordered; no start or spread'
)

Expand All @@ -238,7 +246,7 @@ test('remarkStringify', async (t) => {
}
]
}),
'1. foxtrot\n\n2. golf\n',
'1. foxtrot\n\n2. golf\n',
'ordered and spread; no start'
)

Expand All @@ -263,7 +271,7 @@ test('remarkStringify', async (t) => {
}
]
}),
'3. hotel\n\n4. india\n',
'3. hotel\n\n4. india\n',
'ordered, spread, and start'
)
})
Expand All @@ -282,19 +290,19 @@ test('remarkStringify', async (t) => {

assert.equal(
toString({type: 'listItem', children}),
'* alpha\n\n > bravo\n',
'* alpha\n\n > bravo\n',
'no spread'
)

assert.equal(
toString({type: 'listItem', spread: true, children}),
'* alpha\n\n > bravo\n',
'* alpha\n\n > bravo\n',
'spread: true'
)

assert.equal(
toString({type: 'listItem', spread: false, children}),
'* alpha\n > bravo\n',
'* alpha\n > bravo\n',
'spread: false'
)
})
Expand Down Expand Up @@ -466,6 +474,7 @@ test('stringify escapes', () => {

test('extensions', () => {
const doc = unified()
// @ts-expect-error: to do: type settings.
.data('toMarkdownExtensions', [gfmToMarkdown()])
.use(remarkStringify)
.stringify({
Expand Down Expand Up @@ -591,8 +600,8 @@ test('extensions', () => {
'',
'## Tasklist',
'',
'* [ ] to do',
'* [x] done',
'* [ ] to do',
'* [x] done',
''
].join('\n')
)
Expand Down
4 changes: 2 additions & 2 deletions packages/remark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"index.js"
],
"dependencies": {
"@types/mdast": "^3.0.0",
"@types/mdast": "^4.0.0",
"remark-parse": "^10.0.0",
"remark-stringify": "^10.0.0",
"unified": "^10.0.0"
"unified": "^11.0.0"
},
"scripts": {
"test": "node --conditions development test.js"
Expand Down
6 changes: 5 additions & 1 deletion packages/remark/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ test('remark', () => {
)

assert.equal(
remark().data('settings', {closeAtx: true}).processSync('# foo').toString(),
remark()
// @ts-expect-error: to do: type settings.
.data('settings', {closeAtx: true})
.processSync('# foo')
.toString(),
'# foo #\n',
'should accept stringify options'
)
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ test('fixtures', async (t) => {
const reparsedTree = remark().parse(actualOutput)

assert(reparsedTree)
removePosition(actualTree, true)
removePosition(reparsedTree, true)
removePosition(actualTree, {force: true})
removePosition(reparsedTree, {force: true})

assert.deepEqual(
actualTree,
Expand Down

0 comments on commit 943f6ac

Please sign in to comment.