Skip to content

Commit

Permalink
[Refactor] clean up some of the jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 29, 2024
1 parent 4d99f6e commit e3927a3
Show file tree
Hide file tree
Showing 38 changed files with 155 additions and 155 deletions.
6 changes: 3 additions & 3 deletions lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module.exports = {
/**
* Checks if prop is declared in flow way
* @param {Object} prop Property object, single prop type declaration
* @returns {Boolean}
* @returns {boolean}
*/
function flowCheck(prop) {
return (
Expand All @@ -141,7 +141,7 @@ module.exports = {
/**
* Checks if prop is declared in regular way
* @param {Object} prop Property object, single prop type declaration
* @returns {Boolean}
* @returns {boolean}
*/
function regularCheck(prop) {
const propKey = getPropKey(prop);
Expand All @@ -165,7 +165,7 @@ module.exports = {
/**
* Checks if prop is nested
* @param {Object} prop Property object, single prop type declaration
* @returns {Boolean}
* @returns {boolean}
*/
function nestedPropTypes(prop) {
return (
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = {
/**
* Checks if React.forwardRef is nested inside React.memo
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} True if React.forwardRef is nested inside React.memo, false if not.
* @returns {boolean} True if React.forwardRef is nested inside React.memo, false if not.
*/
function isNestedMemo(node) {
const argumentIsCallExpression = node.arguments && node.arguments[0] && node.arguments[0].type === 'CallExpression';
Expand Down Expand Up @@ -111,7 +111,7 @@ module.exports = {
/**
* Checks if the component have a name set by the transpiler
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} True if component has a name, false if not.
* @returns {boolean} True if component has a name, false if not.
*/
function hasTranspilerName(node) {
const namedObjectAssignment = (
Expand Down
16 changes: 8 additions & 8 deletions lib/rules/jsx-closing-bracket-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module.exports = {
/**
* Get expected location for the closing bracket
* @param {Object} tokens Locations of the opening bracket, closing bracket and last prop
* @return {String} Expected location for the closing bracket
* @return {string} Expected location for the closing bracket
*/
function getExpectedLocation(tokens) {
let location;
Expand All @@ -121,7 +121,7 @@ module.exports = {
* Get the correct 0-indexed column for the closing bracket, given the
* expected location.
* @param {Object} tokens Locations of the opening bracket, closing bracket and last prop
* @param {String} expectedLocation Expected location for the closing bracket
* @param {string} expectedLocation Expected location for the closing bracket
* @return {?Number} The correct column for the closing bracket, or null
*/
function getCorrectColumn(tokens, expectedLocation) {
Expand All @@ -140,8 +140,8 @@ module.exports = {
/**
* Check if the closing bracket is correctly located
* @param {Object} tokens Locations of the opening bracket, closing bracket and last prop
* @param {String} expectedLocation Expected location for the closing bracket
* @return {Boolean} True if the closing bracket is correctly located, false if not
* @param {string} expectedLocation Expected location for the closing bracket
* @return {boolean} True if the closing bracket is correctly located, false if not
*/
function hasCorrectLocation(tokens, expectedLocation) {
switch (expectedLocation) {
Expand All @@ -163,9 +163,9 @@ module.exports = {
/**
* Get the characters used for indentation on the line to be matched
* @param {Object} tokens Locations of the opening bracket, closing bracket and last prop
* @param {String} expectedLocation Expected location for the closing bracket
* @param {Number} [correctColumn] Expected column for the closing bracket. Default to 0
* @return {String} The characters used for indentation
* @param {string} expectedLocation Expected location for the closing bracket
* @param {number} [correctColumn] Expected column for the closing bracket. Default to 0
* @return {string} The characters used for indentation
*/
function getIndentation(tokens, expectedLocation, correctColumn) {
const newColumn = correctColumn || 0;
Expand Down Expand Up @@ -235,7 +235,7 @@ module.exports = {
* Get an unique ID for a given JSXOpeningElement
*
* @param {ASTNode} node The AST node being checked.
* @returns {String} Unique ID (based on its range)
* @returns {string} Unique ID (based on its range)
*/
function getOpeningElementId(node) {
return node.range.join(':');
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/jsx-indent-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ module.exports = {
/**
* Reports a given indent violation and properly pluralizes the message
* @param {ASTNode} node Node violating the indent rule
* @param {Number} needed Expected indentation character count
* @param {Number} gotten Indentation character count in the actual node/code
* @param {number} needed Expected indentation character count
* @param {number} gotten Indentation character count in the actual node/code
*/
function report(node, needed, gotten) {
const msgContext = {
Expand All @@ -141,7 +141,7 @@ module.exports = {
/**
* Get node indent
* @param {ASTNode} node Node to examine
* @return {Number} Indent
* @return {number} Indent
*/
function getNodeIndent(node) {
let src = getText(context, node, node.loc.start.column + extraColumnStart);
Expand Down Expand Up @@ -173,7 +173,7 @@ module.exports = {
/**
* Check indent for nodes list
* @param {ASTNode[]} nodes list of node objects
* @param {Number} indent needed indent
* @param {number} indent needed indent
*/
function checkNodesIndent(nodes, indent) {
let nestedIndent = indent;
Expand Down
24 changes: 12 additions & 12 deletions lib/rules/jsx-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = {
/**
* Responsible for fixing the indentation issue fix
* @param {ASTNode} node Node violating the indent rule
* @param {Number} needed Expected indentation character count
* @param {number} needed Expected indentation character count
* @returns {Function} function to be executed by the fixer
* @private
*/
Expand Down Expand Up @@ -146,8 +146,8 @@ module.exports = {
/**
* Reports a given indent violation and properly pluralizes the message
* @param {ASTNode} node Node violating the indent rule
* @param {Number} needed Expected indentation character count
* @param {Number} gotten Indentation character count in the actual node/code
* @param {number} needed Expected indentation character count
* @param {number} gotten Indentation character count in the actual node/code
* @param {Object} [loc] Error line and column location
*/
function report(node, needed, gotten, loc) {
Expand All @@ -168,9 +168,9 @@ module.exports = {
/**
* Get node indent
* @param {ASTNode} node Node to examine
* @param {Boolean} [byLastLine] get indent of node's last line
* @param {Boolean} [excludeCommas] skip comma on start of line
* @return {Number} Indent
* @param {boolean} [byLastLine] get indent of node's last line
* @param {boolean} [excludeCommas] skip comma on start of line
* @return {number} Indent
*/
function getNodeIndent(node, byLastLine, excludeCommas) {
let src = getText(context, node, node.loc.start.column + extraColumnStart);
Expand All @@ -197,7 +197,7 @@ module.exports = {
/**
* Check if the node is the right member of a logical expression
* @param {ASTNode} node The node to check
* @return {Boolean} true if its the case, false if not
* @return {boolean} true if its the case, false if not
*/
function isRightInLogicalExp(node) {
return (
Expand All @@ -212,7 +212,7 @@ module.exports = {
/**
* Check if the node is the alternate member of a conditional expression
* @param {ASTNode} node The node to check
* @return {Boolean} true if its the case, false if not
* @return {boolean} true if its the case, false if not
*/
function isAlternateInConditionalExp(node) {
return (
Expand All @@ -227,7 +227,7 @@ module.exports = {
/**
* Check if the node is within a DoExpression block but not the first expression (which need to be indented)
* @param {ASTNode} node The node to check
* @return {Boolean} true if its the case, false if not
* @return {boolean} true if its the case, false if not
*/
function isSecondOrSubsequentExpWithinDoExp(node) {
/*
Expand Down Expand Up @@ -298,8 +298,8 @@ module.exports = {
/**
* Check indent for nodes list
* @param {ASTNode} node The node to check
* @param {Number} indent needed indent
* @param {Boolean} [excludeCommas] skip comma on start of line
* @param {number} indent needed indent
* @param {boolean} [excludeCommas] skip comma on start of line
*/
function checkNodesIndent(node, indent, excludeCommas) {
const nodeIndent = getNodeIndent(node, false, excludeCommas);
Expand All @@ -318,7 +318,7 @@ module.exports = {
/**
* Check indent for Literal Node or JSXText Node
* @param {ASTNode} node The node to check
* @param {Number} indent needed indent
* @param {number} indent needed indent
*/
function checkLiteralNodeIndent(node, indent) {
const value = node.value;
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-no-target-blank.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function hasDynamicLink(node, linkAttributes) {
* Get the string(s) from a value
* @param {ASTNode} value The AST node being checked.
* @param {ASTNode} targetValue The AST node being checked.
* @returns {String | String[] | null} The string value, or null if not a string.
* @returns {string | string[] | null} The string value, or null if not a string.
*/
function getStringFromValue(value, targetValue) {
if (value) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-sort-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = {
/**
* Get properties name
* @param {Object} node - Property.
* @returns {String} Property name.
* @returns {string} Property name.
*/
function getPropertyName(node) {
if (node.key || ['MethodDefinition', 'Property'].indexOf(node.type) !== -1) {
Expand All @@ -78,7 +78,7 @@ module.exports = {
/**
* Checks if the Identifier node passed in looks like a defaultProps declaration.
* @param {ASTNode} node The node to check. Must be an Identifier node.
* @returns {Boolean} `true` if the node is a defaultProps declaration, `false` if not
* @returns {boolean} `true` if the node is a defaultProps declaration, `false` if not
*/
function isDefaultPropsDeclaration(node) {
const propName = getPropertyName(node);
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-sort-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ function generateFixerFunction(node, context, reservedList) {
/**
* Checks if the `reservedFirst` option is valid
* @param {Object} context The context of the rule
* @param {Boolean|Array<String>} reservedFirst The `reservedFirst` option
* @return {Function|undefined} If an error is detected, a function to generate the error message, otherwise, `undefined`
* @param {boolean | string[]} reservedFirst The `reservedFirst` option
* @return {Function | undefined} If an error is detected, a function to generate the error message, otherwise, `undefined`
*/
// eslint-disable-next-line consistent-return
function validateReservedFirstConfig(context, reservedFirst) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-children-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const report = require('../util/report');
* Checks if the node is a createElement call with a props literal.
* @param {ASTNode} node - The AST node being checked.
* @param {Context} context - The AST node being checked.
* @returns {Boolean} - True if node is a createElement call with a props
* @returns {boolean} - True if node is a createElement call with a props
* object literal, False if not.
*/
function isCreateElementWithProps(node, context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-danger-with-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module.exports = {
/**
* Checks to see if a node is a line break
* @param {ASTNode} node The AST node being checked
* @returns {Boolean} True if node is a line break, false if not
* @returns {boolean} True if node is a line break, false if not
*/
function isLineBreak(node) {
const isLiteral = node.type === 'Literal' || node.type === 'JSXText';
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-danger.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DANGEROUS_PROPERTIES = fromEntries(DANGEROUS_PROPERTY_NAMES.map((prop) =>

/**
* Checks if a JSX attribute is dangerous.
* @param {String} name - Name of the attribute to check.
* @param {string} name - Name of the attribute to check.
* @returns {boolean} Whether or not the attribute is dangerous.
*/
function isDangerous(name) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-direct-mutation-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
/**
* Checks if the component is valid
* @param {Object} component The component to process
* @returns {Boolean} True if the component is valid, false if not.
* @returns {boolean} True if the component is valid, false if not.
*/
function isValid(component) {
return !!component && !component.mutateSetState;
Expand Down Expand Up @@ -73,7 +73,7 @@ module.exports = {
/**
* Determine if we should currently ignore assignments in this component.
* @param {?Object} component The component to process
* @returns {Boolean} True if we should skip assignment checks.
* @returns {boolean} True if we should skip assignment checks.
*/
function shouldIgnoreComponent(component) {
return !component || (component.inConstructor && !component.inCallExpression);
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-multi-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = {
/**
* Checks if the component is ignored
* @param {Object} component The component being checked.
* @returns {Boolean} True if the component is ignored, false if not.
* @returns {boolean} True if the component is ignored, false if not.
*/
function isIgnored(component) {
return (
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-redundant-should-component-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
/**
* Checks for shouldComponentUpdate property
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} Whether or not the property exists.
* @returns {boolean} Whether or not the property exists.
*/
function hasShouldComponentUpdate(node) {
const properties = astUtil.getComponentProperties(node);
Expand All @@ -49,7 +49,7 @@ module.exports = {
/**
* Get name of node if available
* @param {ASTNode} node The AST node being checked.
* @return {String} The name of the node
* @return {string} The name of the node
*/
function getNodeName(node) {
if (node.id) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-set-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
/**
* Checks if the component is valid
* @param {Object} component The component to process
* @returns {Boolean} True if the component is valid, false if not.
* @returns {boolean} True if the component is valid, false if not.
*/
function isValid(component) {
return !!component && !component.useSetState;
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/no-string-refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {
/**
* Checks if we are using refs
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} True if we are using refs, false if not.
* @returns {boolean} True if we are using refs, false if not.
*/
function isRefsUsage(node) {
return !!(
Expand All @@ -59,7 +59,7 @@ module.exports = {
/**
* Checks if we are using a ref attribute
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} True if we are using a ref attribute, false if not.
* @returns {boolean} True if we are using a ref attribute, false if not.
*/
function isRefAttribute(node) {
return !!(
Expand All @@ -72,7 +72,7 @@ module.exports = {
/**
* Checks if a node contains a string value
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} True if the node contains a string value, false if not.
* @returns {boolean} True if the node contains a string value, false if not.
*/
function containsStringLiteral(node) {
return !!(
Expand All @@ -85,7 +85,7 @@ module.exports = {
/**
* Checks if a node contains a string value within a jsx expression
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} True if the node contains a string value within a jsx expression, false if not.
* @returns {boolean} True if the node contains a string value within a jsx expression, false if not.
*/
function containsStringExpressionContainer(node) {
return !!(
Expand Down
Loading

0 comments on commit e3927a3

Please sign in to comment.