Skip to content

Commit 8e07e9c

Browse files
committed
Refactor
1 parent 2a1f5b2 commit 8e07e9c

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

lib/ast-to-react.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @callback TransformLink
2929
* @param {string} href
30-
* @param {Array.<ElementContent>} children
30+
* @param {Array<ElementContent>} children
3131
* @param {string?} title
3232
* @returns {string}
3333
*
@@ -37,11 +37,11 @@
3737
* @param {string?} title
3838
* @returns {string}
3939
*
40-
* @typedef {import("react").HTMLAttributeAnchorTarget} TransformLinkTargetType
40+
* @typedef {import('react').HTMLAttributeAnchorTarget} TransformLinkTargetType
4141
*
4242
* @callback TransformLinkTarget
4343
* @param {string} href
44-
* @param {Array.<ElementContent>} children
44+
* @param {Array<ElementContent>} children
4545
* @param {string?} title
4646
* @returns {TransformLinkTargetType|undefined}
4747
*
@@ -53,7 +53,7 @@
5353
* @typedef {JSX.IntrinsicElements['h1'] & ReactMarkdownProps & {level: number}} HeadingProps
5454
* @typedef {JSX.IntrinsicElements['li'] & ReactMarkdownProps & {checked: boolean|null, index: number, ordered: boolean}} LiProps
5555
* @typedef {JSX.IntrinsicElements['ol'] & ReactMarkdownProps & {depth: number, ordered: true}} OrderedListProps
56-
* @typedef {JSX.IntrinsicElements['table'] & ReactMarkdownProps & {style?: Object.<string, unknown>, isHeader: boolean}} TableCellProps
56+
* @typedef {JSX.IntrinsicElements['table'] & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: boolean}} TableCellProps
5757
* @typedef {JSX.IntrinsicElements['tr'] & ReactMarkdownProps & {isHeader: boolean}} TableRowProps
5858
* @typedef {JSX.IntrinsicElements['ul'] & ReactMarkdownProps & {depth: number, ordered: false}} UnorderedListProps
5959
*
@@ -80,7 +80,7 @@
8080
* @property {TableRowComponent|ReactMarkdownNames} tr
8181
* @property {UnorderedListComponent|ReactMarkdownNames} ul
8282
*
83-
* @typedef {Partial<Omit<import("./complex-types").NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components
83+
* @typedef {Partial<Omit<import('./complex-types').NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components
8484
*
8585
* @typedef Options
8686
* @property {boolean} [sourcePos=false]
@@ -112,7 +112,7 @@ const tableElements = new Set(['table', 'thead', 'tbody', 'tfoot', 'tr'])
112112
* @param {Element|Root} node
113113
*/
114114
export function childrenToReact(context, node) {
115-
/** @type {Array.<ReactNode>} */
115+
/** @type {Array<ReactNode>} */
116116
const children = []
117117
let childIndex = -1
118118
/** @type {Comment|Doctype|Element|Raw|Text} */
@@ -159,7 +159,7 @@ function toReact(context, node, index, parent) {
159159
/** @type {ReactMarkdownNames} */
160160
// @ts-expect-error assume a known HTML/SVG element.
161161
const name = node.tagName
162-
/** @type {Object.<string, unknown>} */
162+
/** @type {Record<string, unknown>} */
163163
const properties = {}
164164
let schema = parentSchema
165165
/** @type {string} */
@@ -355,7 +355,7 @@ function getElementsBeforeCount(parent, node) {
355355
}
356356

357357
/**
358-
* @param {Object.<string, unknown>} props
358+
* @param {Record<string, unknown>} props
359359
* @param {string} prop
360360
* @param {unknown} value
361361
* @param {Context} ctx
@@ -393,10 +393,10 @@ function addProperty(props, prop, value, ctx) {
393393

394394
/**
395395
* @param {string} value
396-
* @returns {Object.<string, string>}
396+
* @returns {Record<string, string>}
397397
*/
398398
function parseStyle(value) {
399-
/** @type {Object.<string, string>} */
399+
/** @type {Record<string, string>} */
400400
const result = {}
401401

402402
try {

lib/react-markdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const own = {}.hasOwnProperty
3939
const changelog =
4040
'https://github.com/remarkjs/react-markdown/blob/main/changelog.md'
4141

42-
/** @type {Object.<string, Deprecation>} */
42+
/** @type {Record<string, Deprecation>} */
4343
const deprecated = {
4444
renderers: {to: 'components', id: 'change-renderers-to-components'},
4545
astPlugins: {id: 'remove-buggy-html-in-markdown-parser'},

lib/rehype-filter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {visit} from 'unist-util-visit'
1212
* @returns {boolean|undefined}
1313
*
1414
* @typedef Options
15-
* @property {Array.<string>} [allowedElements]
16-
* @property {Array.<string>} [disallowedElements=[]]
15+
* @property {Array<string>} [allowedElements]
16+
* @property {Array<string>} [disallowedElements=[]]
1717
* @property {AllowElement} [allowElement]
1818
* @property {boolean} [unwrapDisallowed=false]
1919
*/

test/test.jsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ test('should skip nodes that are defined as disallowed', () => {
915915
hr: {input: '\n-----\nAnd with that...', shouldNotContain: '<hr'}
916916
}
917917

918-
/** @type {string[]} */
918+
/** @type {Array<string>} */
919919
const inputs = []
920920
/** @type {keyof samples} */
921921
let key
@@ -1008,7 +1008,7 @@ test('should be able to override components', () => {
10081008
const heading = (level) => {
10091009
/**
10101010
* @param {object} props
1011-
* @param {ReactNode[]} props.children
1011+
* @param {Array<ReactNode>} props.children
10121012
*/
10131013
const component = (props) => (
10141014
<span className={`heading level-${level}`}>{props.children}</span>
@@ -1220,7 +1220,7 @@ test('should support formatting at the start of a GFM tasklist (GH-494)', () =>
12201220
test('should support aria properties', () => {
12211221
const input = 'c'
12221222

1223-
/** @type {import('unified').Plugin<void[], Root>} */
1223+
/** @type {import('unified').Plugin<Array<void>, Root>} */
12241224
const plugin = () => (root) => {
12251225
root.children.unshift({
12261226
type: 'element',
@@ -1238,7 +1238,7 @@ test('should support aria properties', () => {
12381238
test('should support data properties', () => {
12391239
const input = 'b'
12401240

1241-
/** @type {import('unified').Plugin<void[], Root>} */
1241+
/** @type {import('unified').Plugin<Array<void>, Root>} */
12421242
const plugin = () => (root) => {
12431243
root.children.unshift({
12441244
type: 'element',
@@ -1256,7 +1256,7 @@ test('should support data properties', () => {
12561256
test('should support comma separated properties', () => {
12571257
const input = 'c'
12581258

1259-
/** @type {import('unified').Plugin<void[], Root>} */
1259+
/** @type {import('unified').Plugin<Array<void>, Root>} */
12601260
const plugin = () => (root) => {
12611261
root.children.unshift({
12621262
type: 'element',
@@ -1274,7 +1274,7 @@ test('should support comma separated properties', () => {
12741274
test('should support `style` properties', () => {
12751275
const input = 'a'
12761276

1277-
/** @type {import('unified').Plugin<void[], Root>} */
1277+
/** @type {import('unified').Plugin<Array<void>, Root>} */
12781278
const plugin = () => (root) => {
12791279
root.children.unshift({
12801280
type: 'element',
@@ -1292,7 +1292,7 @@ test('should support `style` properties', () => {
12921292
test('should support `style` properties w/ vendor prefixes', () => {
12931293
const input = 'a'
12941294

1295-
/** @type {import('unified').Plugin<void[], Root>} */
1295+
/** @type {import('unified').Plugin<Array<void>, Root>} */
12961296
const plugin = () => (root) => {
12971297
root.children.unshift({
12981298
type: 'element',
@@ -1310,7 +1310,7 @@ test('should support `style` properties w/ vendor prefixes', () => {
13101310
test('should support broken `style` properties', () => {
13111311
const input = 'a'
13121312

1313-
/** @type {import('unified').Plugin<void[], Root>} */
1313+
/** @type {import('unified').Plugin<Array<void>, Root>} */
13141314
const plugin = () => (root) => {
13151315
root.children.unshift({
13161316
type: 'element',
@@ -1328,7 +1328,7 @@ test('should support broken `style` properties', () => {
13281328
test('should support SVG elements', () => {
13291329
const input = 'a'
13301330

1331-
/** @type {import('unified').Plugin<void[], Root>} */
1331+
/** @type {import('unified').Plugin<Array<void>, Root>} */
13321332
const plugin = () => (root) => {
13331333
root.children.unshift({
13341334
type: 'element',
@@ -1367,7 +1367,7 @@ test('should support SVG elements', () => {
13671367
test('should support (ignore) comments', () => {
13681368
const input = 'a'
13691369

1370-
/** @type {import('unified').Plugin<void[], Root>} */
1370+
/** @type {import('unified').Plugin<Array<void>, Root>} */
13711371
const plugin = () => (root) => {
13721372
root.children.unshift({type: 'comment', value: 'things!'})
13731373
}
@@ -1380,7 +1380,7 @@ test('should support (ignore) comments', () => {
13801380
test('should support table cells w/ style', () => {
13811381
const input = '| a |\n| :- |'
13821382

1383-
/** @type {import('unified').Plugin<void[], Root>} */
1383+
/** @type {import('unified').Plugin<Array<void>, Root>} */
13841384
const plugin = () => (root) => {
13851385
visit(root, {type: 'element', tagName: 'th'}, (node) => {
13861386
node.properties = {...node.properties, style: 'color: red'}
@@ -1398,7 +1398,7 @@ test('should support table cells w/ style', () => {
13981398

13991399
test('should crash on a plugin replacing `root`', () => {
14001400
const input = 'a'
1401-
/** @type {import('unified').Plugin<void[], Root>} */
1401+
/** @type {import('unified').Plugin<Array<void>, Root>} */
14021402
// @ts-expect-error: runtime.
14031403
const plugin = () => () => ({type: 'comment', value: 'things!'})
14041404
assert.throws(() => {

0 commit comments

Comments
 (0)