Skip to content

Commit

Permalink
Update @types/hast, utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 1, 2023
1 parent 42748d4 commit 04a40a5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 27 deletions.
1 change: 0 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export function core(schema, defaultTagName, caseSensitive) {

for (key in properties) {
if (own.call(properties, key)) {
// @ts-expect-error `node.properties` is set.
addProperty(schema, node.properties, key, properties[key])
}
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@
"index.js"
],
"dependencies": {
"@types/hast": "^2.0.0",
"@types/hast": "^3.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^3.0.0",
"hast-util-parse-selector": "^4.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0"
},
"devDependencies": {
"@types/node": "^20.0.0",
"acorn-jsx": "^5.0.0",
"c8": "^8.0.0",
"esast-util-from-js": "^1.0.0",
"estree-util-build-jsx": "^2.0.0",
"estree-util-to-js": "^1.0.0",
"esast-util-from-js": "^2.0.0",
"estree-util-build-jsx": "^3.0.0",
"estree-util-to-js": "^2.0.0",
"prettier": "^3.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"svg-tag-names": "^3.0.0",
"tsd": "^0.28.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"unist-builder": "^3.0.0",
"unist-builder": "^4.0.0",
"xo": "^0.55.0"
},
"scripts": {
Expand Down
61 changes: 41 additions & 20 deletions script/generate-jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,50 @@ const doc = String(
await fs.readFile(new URL('../test/jsx.jsx', import.meta.url))
)

await fs.writeFile(
new URL('../test/jsx-build-jsx-classic.js', import.meta.url),
toJs(
buildJsx(
fromJs(doc.replace(/'name'/, "'jsx (estree-util-build-jsx, classic)'"), {
plugins: [acornJsx()],
module: true
}),
{pragma: 'h', pragmaFrag: 'null'}
)
).value
const treeAutomatic = fromJs(
doc.replace(/'name'/, "'jsx (estree-util-build-jsx, automatic)'"),
{plugins: [acornJsx()], module: true}
)

const treeAutomaticDevelopment = fromJs(
doc.replace(
/'name'/,
"'jsx (estree-util-build-jsx, automatic, development)'"
),
{plugins: [acornJsx()], module: true}
)

const treeClassic = fromJs(
doc.replace(/'name'/, "'jsx (estree-util-build-jsx, classic)'"),
{
plugins: [acornJsx()],
module: true
}
)

buildJsx(treeAutomatic, {
runtime: 'automatic',
importSource: 'hastscript'
})
buildJsx(treeAutomaticDevelopment, {
runtime: 'automatic',
importSource: 'hastscript',
development: true
})
buildJsx(treeClassic, {pragma: 'h', pragmaFrag: 'null'})

await fs.writeFile(
new URL('../test/jsx-build-jsx-automatic.js', import.meta.url),
toJs(treeAutomatic).value
)

await fs.writeFile(
new URL('../test/jsx-build-jsx-automatic-development.js', import.meta.url),
// There’s a problem with `this` that TS doesn’t like.
'// @ts-nocheck\n\n' + toJs(treeAutomaticDevelopment).value
)

toJs(
buildJsx(
fromJs(
doc.replace(/'name'/, "'jsx (estree-util-build-jsx, automatic)'"),
{plugins: [acornJsx()], module: true}
),
{runtime: 'automatic', importSource: 'hastscript'}
)
).value
await fs.writeFile(
new URL('../test/jsx-build-jsx-classic.js', import.meta.url),
toJs(treeClassic).value
)
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
import './core.js'
import './jsx-build-jsx-classic.js'
import './jsx-build-jsx-automatic.js'
import './jsx-build-jsx-automatic-development.js'
/* eslint-enable import/no-unassigned-import */

0 comments on commit 04a40a5

Please sign in to comment.