Skip to content

Commit cffffc7

Browse files
docs: tidy JSDoc and TSDoc
1 parent 93f632f commit cffffc7

9 files changed

+36
-36
lines changed

Diff for: index.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export interface HTMLReactParserOptions {
4343
/**
4444
* Converts HTML string to JSX element(s).
4545
*
46-
* @param html - HTML string.
47-
* @param options - Parser options.
48-
* @return - JSX element(s), empty array, or string.
46+
* @param html - HTML string.
47+
* @param options - Parser options.
48+
* @returns - JSX element(s), empty array, or string.
4949
*/
5050
export default function HTMLReactParser(
5151
html: string,

Diff for: index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ var domParserOptions = { lowerCaseAttributeNames: false };
1212
/**
1313
* Converts HTML string to React elements.
1414
*
15-
* @param {String} html - HTML string.
16-
* @param {Object} [options] - Parser options.
17-
* @param {Object} [options.htmlparser2] - htmlparser2 options.
18-
* @param {Object} [options.library] - Library for React, Preact, etc.
19-
* @param {Function} [options.replace] - Replace method.
20-
* @return {JSX.Element|JSX.Element[]|String} - React element(s), empty array, or string.
15+
* @param {string} html - HTML string.
16+
* @param {object} [options] - Parser options.
17+
* @param {object} [options.htmlparser2] - htmlparser2 options.
18+
* @param {object} [options.library] - Library for React, Preact, etc.
19+
* @param {Function} [options.replace] - Replace method.
20+
* @returns {JSX.Element|JSX.Element[]|string} - React element(s), empty array, or string.
2121
*/
2222
function HTMLReactParser(html, options) {
2323
if (typeof html !== 'string') {

Diff for: lib/attributes-to-props.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type Props = Record<string, string> & {
99
/**
1010
* Converts HTML/SVG DOM attributes to React props.
1111
*
12-
* @param attributes - HTML/SVG DOM attributes.
13-
* @return - React props.
12+
* @param attributes - HTML/SVG DOM attributes.
13+
* @returns - React props.
1414
*/
1515
export default function attributesToProps(attributes: Attributes): Props;

Diff for: lib/attributes-to-props.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ var utilities = require('./utilities');
44
/**
55
* Converts HTML/SVG DOM attributes to React props.
66
*
7-
* @param {object} [attributes={}] - HTML/SVG DOM attributes.
8-
* @return {object} - React props.
7+
* @param {object} [attributes={}] - HTML/SVG DOM attributes.
8+
* @returns - React props.
99
*/
1010
module.exports = function attributesToProps(attributes) {
1111
attributes = attributes || {};
@@ -79,7 +79,7 @@ module.exports = function attributesToProps(attributes) {
7979
* Gets prop name from lowercased attribute name.
8080
*
8181
* @param {string} attributeName - Lowercased attribute name.
82-
* @return {string}
82+
* @returns - Prop name.
8383
*/
8484
function getPropName(attributeName) {
8585
return reactProperty.possibleStandardNames[attributeName];

Diff for: lib/dom-to-react.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export { DOMNode, HTMLReactParserOptions };
77
/**
88
* Converts DOM nodes to JSX element(s).
99
*
10-
* @param nodes - DOM nodes.
11-
* @param options - Parser options.
12-
* @return - JSX element(s).
10+
* @param nodes - DOM nodes.
11+
* @param options - Parser options.
12+
* @returns - JSX element(s).
1313
*/
1414
export default function domToReact(
1515
nodes: DOMNode[],

Diff for: lib/dom-to-react.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ var canTextBeChildOfNode = utilities.canTextBeChildOfNode;
88
/**
99
* Converts DOM nodes to JSX element(s).
1010
*
11-
* @param {DomElement[]} nodes - DOM nodes.
12-
* @param {object} [options={}] - Options.
13-
* @param {Function} [options.replace] - Replacer.
14-
* @param {object} [options.library] - Library (React/Preact/etc.).
15-
* @return {string|JSX.Element|JSX.Element[]}
11+
* @param {DomElement[]} nodes - DOM nodes.
12+
* @param {object} [options={}] - Options.
13+
* @param {Function} [options.replace] - Replacer.
14+
* @param {object} [options.library] - Library (React, Preact, etc.).
15+
* @returns - String or JSX element(s).
1616
*/
1717
function domToReact(nodes, options) {
1818
options = options || {};
@@ -125,8 +125,8 @@ function domToReact(nodes, options) {
125125
* Determines whether DOM element attributes should be transformed to props.
126126
* Web Components should not have their attributes transformed except for `style`.
127127
*
128-
* @param {DomElement} node
129-
* @return {boolean}
128+
* @param {DomElement} node
129+
* @returns - Whether node attributes should be converted to props.
130130
*/
131131
function skipAttributesToProps(node) {
132132
return (

Diff for: lib/utilities.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var styleToJS = require('style-to-js').default;
44
/**
55
* Swap key with value in an object.
66
*
7-
* @param {Object} obj - The object.
8-
* @param {Function} [override] - The override method.
9-
* @return {Object} - The inverted object.
7+
* @param {object} obj - The object.
8+
* @param {Function} [override] - The override method.
9+
* @returns - The inverted object.
1010
*/
1111
function invertObject(obj, override) {
1212
if (!obj || typeof obj !== 'object') {
@@ -44,8 +44,8 @@ function invertObject(obj, override) {
4444
* @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
4545
*
4646
* @param {string} tagName - The name of the html tag.
47-
* @param {Object} props - The props being passed to the element.
48-
* @return {boolean}
47+
* @param {object} props - The props being passed to the element.
48+
* @returns - Whether tag is custom component.
4949
*/
5050
function isCustomComponent(tagName, props) {
5151
if (tagName.indexOf('-') === -1) {
@@ -113,8 +113,8 @@ var elementsWithNoTextChildren = new Set([
113113
/**
114114
* Checks if the given node can contain text nodes
115115
*
116-
* @param {DomElement} node
117-
* @returns {boolean}
116+
* @param {DomElement} node - Node.
117+
* @returns - Whether node can contain text nodes.
118118
*/
119119
function canTextBeChildOfNode(node) {
120120
return !elementsWithNoTextChildren.has(node.name);

Diff for: rollup.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { terser } from 'rollup-plugin-terser';
55
/**
66
* Build rollup config for development (default) or production (minify = true).
77
*
8-
* @param {Boolean} [minify=false]
9-
* @return {Object}
8+
* @param {boolean} [minify=false]
9+
* @returns - Rollup config.
1010
*/
1111
const getConfig = (minify = false) => ({
1212
external: ['react'],

Diff for: test/helpers/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { renderToStaticMarkup } = require('react-dom/server');
33
/**
44
* Renders a React element to static HTML markup.
55
*
6-
* @param {ReactElement} reactElement - React element.
7-
* @return {string} - HTML markup.
6+
* @param {ReactElement} reactElement - React element.
7+
* @returns {string} - HTML markup.
88
*/
9-
module.exports.render = reactElement => renderToStaticMarkup(reactElement);
9+
exports.render = reactElement => renderToStaticMarkup(reactElement);

0 commit comments

Comments
 (0)