Skip to content

Commit

Permalink
[Chore]: fix some jsdoc errors
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed May 10, 2019
1 parent d1e79b9 commit b189e12
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/rules/destructuring-assignment.js
Expand Up @@ -127,7 +127,7 @@ module.exports = {
handleSFCUsage(node);
}
if (classComponent) {
handleClassUsage(node, classComponent);
handleClassUsage(node);
}
},

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -110,7 +110,7 @@ module.exports = {

/**
* Report and fix an unnecessary curly brace violation on a node
* @param {ASTNode} node - The AST node with an unnecessary JSX expression
* @param {ASTNode} JSXExpressionNode - The AST node with an unnecessary JSX expression
*/
function reportUnnecessaryCurly(JSXExpressionNode) {
context.report({
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/jsx-curly-spacing.js
Expand Up @@ -183,6 +183,7 @@ module.exports = {
* Reports that there shouldn't be a newline after the first token
* @param {ASTNode} node - The node to report in the event of an error.
* @param {Token} token - The token to use for the report.
* @param {string} spacing
* @returns {void}
*/
function reportNoBeginningNewline(node, token, spacing) {
Expand All @@ -201,6 +202,7 @@ module.exports = {
* Reports that there shouldn't be a newline before the last token
* @param {ASTNode} node - The node to report in the event of an error.
* @param {Token} token - The token to use for the report.
* @param {string} spacing
* @returns {void}
*/
function reportNoEndingNewline(node, token, spacing) {
Expand Down
1 change: 0 additions & 1 deletion lib/rules/jsx-indent-props.js
Expand Up @@ -126,7 +126,6 @@ module.exports = {
* Check indent for nodes list
* @param {ASTNode[]} nodes list of node objects
* @param {Number} indent needed indent
* @param {Boolean} excludeCommas skip comma on start of line
*/
function checkNodesIndent(nodes, indent) {
nodes.forEach(node => {
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/jsx-indent.js
Expand Up @@ -110,7 +110,7 @@ module.exports = {
* @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 {Object} loc Error line and column location
* @param {Object} [loc] Error line and column location
*/
function report(node, needed, gotten, loc) {
const msgContext = {
Expand Down Expand Up @@ -141,8 +141,8 @@ 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
* @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) {
Expand Down Expand Up @@ -204,7 +204,7 @@ 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 {Boolean} [excludeCommas] skip comma on start of line
*/
function checkNodesIndent(node, indent, excludeCommas) {
const nodeIndent = getNodeIndent(node, false, excludeCommas);
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-sort-props.js
Expand Up @@ -75,7 +75,7 @@ function contextCompare(a, b, options) {
* Create an array of arrays where each subarray is composed of attributes
* that are considered sortable.
* @param {Array<JSXSpreadAttribute|JSXAttribute>} attributes
* @return {Array<Array<JSXAttribute>}
* @return {Array<Array<JSXAttribute>>}
*/
function getGroupsOfSortableAttributes(attributes) {
const sortableAttributeGroups = [];
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-danger-with-children.js
Expand Up @@ -28,6 +28,7 @@ module.exports = {
* Takes a ObjectExpression and returns the value of the prop if it has it
* @param {object} node - ObjectExpression node
* @param {string} propName - name of the prop to look for
* @param {any[]} seenProps
*/
function findObjectProp(node, propName, seenProps) {
if (!node.properties) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/static-property-placement.js
Expand Up @@ -102,8 +102,8 @@ module.exports = {

/**
* Check if we should report this property node
* @param node
* @param expectedRule
* @param {ASTNode} node
* @param {string} expectedRule
*/
function reportNodeIncorrectlyPositioned(node, expectedRule) {
// Detect if this node is an expected property declaration adn return the property name
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/style-prop-object.js
Expand Up @@ -24,7 +24,7 @@ module.exports = {

create: function(context) {
/**
* @param {object} node An Identifier node
* @param {ASTNode} expression An Identifier node
*/
function isNonNullaryLiteral(expression) {
return expression.type === 'Literal' && expression.value !== null;
Expand Down
6 changes: 3 additions & 3 deletions lib/util/Components.js
Expand Up @@ -257,7 +257,7 @@ function componentRule(rule, context) {
/**
* Check if variable is destructured from pragma import
*
* @param {variable} String The variable name to check
* @param {string} variable The variable name to check
* @returns {Boolean} True if createElement is destructured from the pragma
*/
isDestructuredFromPragmaImport: function(variable) {
Expand Down Expand Up @@ -350,7 +350,7 @@ function componentRule(rule, context) {
* Check if the node is returning JSX
*
* @param {ASTNode} ASTnode The AST node being checked
* @param {Boolean} strict If true, in a ternary condition the node must return JSX in both cases
* @param {Boolean} [strict] If true, in a ternary condition the node must return JSX in both cases
* @returns {Boolean} True if the node is returning JSX, false if not
*/
isReturningJSX: function(ASTnode, strict) {
Expand Down Expand Up @@ -412,7 +412,7 @@ function componentRule(rule, context) {
* Check if the node is returning JSX or null
*
* @param {ASTNode} ASTnode The AST node being checked
* @param {Boolean} strict If true, in a ternary condition the node must return JSX in both cases
* @param {Boolean} [strict] If true, in a ternary condition the node must return JSX in both cases
* @returns {Boolean} True if the node is returning JSX or null, false if not
*/
isReturningJSXOrNull(ASTNode, strict) {
Expand Down
1 change: 1 addition & 0 deletions lib/util/annotations.js
Expand Up @@ -8,6 +8,7 @@
/**
* Checks if we are declaring a `props` argument with a flow type annotation.
* @param {ASTNode} node The AST node being checked.
* @param {Object} context
* @returns {Boolean} True if the node is a type annotated props declaration, false if not.
*/
function isAnnotatedFunctionPropsDeclaration(node, context) {
Expand Down
10 changes: 5 additions & 5 deletions lib/util/ast.js
Expand Up @@ -6,7 +6,7 @@
/**
* Find a return statment in the current node
*
* @param {ASTNode} ASTnode The AST node being checked
* @param {ASTNode} node The AST node being checked
*/
function findReturnStatement(node) {
if (
Expand Down Expand Up @@ -114,7 +114,7 @@ function isNodeFirstInLine(context, node) {

/**
* Checks if the node is a function or arrow function expression.
* @param {Object} context The node to check
* @param {ASTNode} node The node to check
* @return {Boolean} true if it's a function-like expression
*/
function isFunctionLikeExpression(node) {
Expand All @@ -123,7 +123,7 @@ function isFunctionLikeExpression(node) {

/**
* Checks if the node is a function.
* @param {Object} context The node to check
* @param {ASTNode} node The node to check
* @return {Boolean} true if it's a function
*/
function isFunction(node) {
Expand All @@ -132,7 +132,7 @@ function isFunction(node) {

/**
* Checks if the node is an arrow function.
* @param {Object} context The node to check
* @param {ASTNode} node The node to check
* @return {Boolean} true if it's an arrow function
*/
function isArrowFunction(node) {
Expand All @@ -141,7 +141,7 @@ function isArrowFunction(node) {

/**
* Checks if the node is a class.
* @param {Object} context The node to check
* @param {ASTNode} node The node to check
* @return {Boolean} true if it's a class
*/
function isClass(node) {
Expand Down
2 changes: 1 addition & 1 deletion lib/util/defaultProps.js
Expand Up @@ -70,7 +70,7 @@ module.exports = function defaultPropsInstructions(context, components, utils) {
/**
* Adds defaultProps to the component passed in.
* @param {ASTNode} component The component to add the defaultProps to.
* @param {String[]|String} defaultProps defaultProps to add to the component or the string "unresolved"
* @param {Object[]|'unresolved'} defaultProps defaultProps to add to the component or the string "unresolved"
* if this component has defaultProps that can't be resolved.
* @returns {void}
*/
Expand Down
9 changes: 7 additions & 2 deletions lib/util/propTypes.js
Expand Up @@ -26,14 +26,15 @@ function isSuperTypeParameterPropsDeclaration(node) {

/**
* Removes quotes from around an identifier.
* @param {string} the identifier to strip
* @param {string} string the identifier to strip
*/
function stripQuotes(string) {
return string.replace(/^\'|\'$/g, '');
}

/**
* Retrieve the name of a key node
* @param {Object} context The AST node with the key.
* @param {ASTNode} node The AST node with the key.
* @return {string} the name of the key
*/
Expand All @@ -51,6 +52,7 @@ function getKeyValue(context, node) {

/**
* Iterates through a properties node, like a customized forEach.
* @param {Object} context Array of properties to iterate.
* @param {Object[]} properties Array of properties to iterate.
* @param {Function} fn Function to call on each property, receives property key
and property value. (key, value) => void
Expand Down Expand Up @@ -236,6 +238,8 @@ module.exports = function propTypesInstructions(context, components, utils) {
* Creates the representation of the React props type annotation for the component.
* The representation is used to verify nested used properties.
* @param {ASTNode} annotation Type annotation for the props class property.
* @param {ASTNode} parentName
* @param {Set<any>} [seen]
* @return {Object} The representation of the declaration, empty object means
* the property is declared without the need for further analysis.
*/
Expand Down Expand Up @@ -325,6 +329,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
* Creates the representation of the React propTypes for the component.
* The representation is used to verify nested used properties.
* @param {ASTNode} value Node of the PropTypes for the desired property
* @param {string} parentName
* @return {Object} The representation of the declaration, empty object means
* the property is declared without the need for further analysis.
*/
Expand Down Expand Up @@ -443,7 +448,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
/**
* Mark a prop type as declared
* @param {ASTNode} node The AST node being checked.
* @param {propTypes} node The AST node containing the proptypes
* @param {ASTNode} propTypes The AST node containing the proptypes
*/
function markPropTypesAsDeclared(node, propTypes) {
let componentNode = node;
Expand Down
2 changes: 1 addition & 1 deletion lib/util/props.js
Expand Up @@ -65,7 +65,7 @@ function isDefaultPropsDeclaration(node) {

/**
* Checks if we are declaring a display name
* @param {node} node The AST node being checked.
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} True if we are declaring a display name, false if not.
*/
function isDisplayNameDeclaration(node) {
Expand Down
5 changes: 3 additions & 2 deletions lib/util/usedPropTypes.js
Expand Up @@ -177,7 +177,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils)

/**
* Removes quotes from around an identifier.
* @param {string} the identifier to strip
* @param {string} string the identifier to strip
*/
function stripQuotes(string) {
return string.replace(/^\'|\'$/g, '');
Expand All @@ -203,7 +203,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils)
/**
* Retrieve the name of a property node
* @param {ASTNode} node The AST node with the property.
* @return {string} the name of the property or undefined if not found
* @return {string|undefined} the name of the property or undefined if not found
*/
function getPropertyName(node) {
const isDirectProp = DIRECT_PROPS_REGEX.test(sourceCode.getText(node));
Expand Down Expand Up @@ -283,6 +283,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils)
/**
* Mark a prop type as used
* @param {ASTNode} node The AST node being marked.
* @param {string[]} [parentNames]
*/
function markPropTypesAsUsed(node, parentNames) {
parentNames = parentNames || [];
Expand Down
4 changes: 2 additions & 2 deletions lib/util/variable.js
Expand Up @@ -7,7 +7,7 @@
/**
* Search a particular variable in a list
* @param {Array} variables The variables list.
* @param {Array} name The name of the variable to search.
* @param {string} name The name of the variable to search.
* @returns {Boolean} True if the variable was found, false if not.
*/
function findVariable(variables, name) {
Expand All @@ -17,7 +17,7 @@ function findVariable(variables, name) {
/**
* Find and return a particular variable in a list
* @param {Array} variables The variables list.
* @param {Array} name The name of the variable to search.
* @param {string} name The name of the variable to search.
* @returns {Object} Variable if the variable was found, null if not.
*/
function getVariable(variables, name) {
Expand Down

0 comments on commit b189e12

Please sign in to comment.