Skip to content

Commit

Permalink
Update dev-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 2, 2025
1 parent b151a90 commit e686551
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules/
.DS_Store
react-markdown.min.js
yarn.lock
!/test-types.d.ts
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ export function defaultUrlTransform(value) {

if (
// If there is no protocol, it’s relative.
colon < 0 ||
colon === -1 ||
// If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.
(slash > -1 && colon > slash) ||
(questionMark > -1 && colon > questionMark) ||
(numberSign > -1 && colon > numberSign) ||
(slash !== -1 && colon > slash) ||
(questionMark !== -1 && colon > questionMark) ||
(numberSign !== -1 && colon > numberSign) ||
// It is a protocol, it should be allowed.
safeProtocol.test(value.slice(0, colon))
) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@
},
"devDependencies": {
"@types/node": "^22.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"c8": "^10.0.0",
"esbuild": "^0.24.0",
"eslint-plugin-react": "^7.0.0",
"prettier": "^3.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rehype-raw": "^7.0.0",
"remark-cli": "^12.0.0",
"remark-gfm": "^4.0.0",
"remark-preset-wooorm": "^10.0.0",
"remark-toc": "^9.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"xo": "^0.59.0"
"xo": "^0.60.0"
},
"scripts": {
"build": "tsc --build --clean && tsc --build && type-coverage",
Expand Down
9 changes: 9 additions & 0 deletions test-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type {JSX as Jsx} from 'react/jsx-runtime'

declare global {
namespace JSX {
type ElementClass = Jsx.ElementClass
type Element = Jsx.Element
type IntrinsicElements = Jsx.IntrinsicElements
}
}
2 changes: 2 additions & 0 deletions test-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See `test-types.d.ts`.
export {}
13 changes: 8 additions & 5 deletions test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,24 @@ test('react-markdown', async function (t) {
await t.test('should support an image', function () {
assert.equal(
renderToStaticMarkup(<Markdown children="![a](b)" />),
'<p><img src="b" alt="a"/></p>'
// Note: React weirdly adds `rel="preload"`.
'<link rel="preload" as="image" href="b"/><p><img src="b" alt="a"/></p>'
)
})

await t.test('should support an image w/ a title', function () {
assert.equal(
renderToStaticMarkup(<Markdown children="![a](b (c))" />),
'<p><img src="b" alt="a" title="c"/></p>'
// Note: React weirdly adds `rel="preload"`.
'<link rel="preload" as="image" href="b"/><p><img src="b" alt="a" title="c"/></p>'
)
})

await t.test('should support an image reference / definition', function () {
assert.equal(
renderToStaticMarkup(<Markdown children={'![a]\n\n[a]: b'} />),
'<p><img src="b" alt="a"/></p>'
// Note: React weirdly adds `rel="preload"`.
'<link rel="preload" as="image" href="b"/><p><img src="b" alt="a"/></p>'
)
})

Expand Down Expand Up @@ -410,7 +413,7 @@ test('react-markdown', async function (t) {
}}
/>
),
'<p><img src="" alt="a" title="c"/></p>'
'<p><img alt="a" title="c"/></p>'
)
})

Expand Down Expand Up @@ -564,7 +567,7 @@ test('react-markdown', async function (t) {

console.error = warn

assert.match(String(message), /Warning: React.jsx: type is invalid/)
assert.match(String(message), /type is invalid/)

/**
* @param {unknown} d
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"target": "es2022"
},
"exclude": ["coverage/", "node_modules/"],
"include": ["**/*.js", "**/*.jsx", "lib/complex-types.d.ts"]
"include": ["**/*.js", "**/*.jsx", "test-types.d.ts"]
}

0 comments on commit e686551

Please sign in to comment.