Skip to content

Commit 3c72a49

Browse files
golopotljharb
authored andcommitted
[eslint] disable some options and manually fix valid-jsdoc
1 parent 61c7971 commit 3c72a49

7 files changed

+25
-7
lines changed

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
"no-param-reassign": 1,
3232
"no-mixed-operators": 1,
3333
"no-restricted-syntax": 1,
34-
"valid-jsdoc": 1,
34+
"valid-jsdoc": [2, {
35+
"requireReturn": false,
36+
"requireParamDescription": false,
37+
"requireReturnDescription": false,
38+
}],
3539
},
3640
"overrides": [
3741
{

lib/rules/boolean-prop-naming.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ module.exports = {
6969
* required: PropTypes.bool.isRequired
7070
* }
7171
* @param {Object} node The node we're getting the name of
72+
* @returns {string | null}
7273
*/
7374
function getPropKey(node) {
7475
// Check for `ExperimentalSpreadProperty` (ESLint 3/4) and `SpreadElement` (ESLint 5)
@@ -96,6 +97,7 @@ module.exports = {
9697
/**
9798
* Returns the name of the given node (prop)
9899
* @param {Object} node The node we're getting the name of
100+
* @returns {string}
99101
*/
100102
function getPropName(node) {
101103
// Due to this bug https://github.com/babel/babel-eslint/issues/307

lib/rules/no-danger-with-children.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = {
3030
* @param {object} node - ObjectExpression node
3131
* @param {string} propName - name of the prop to look for
3232
* @param {string[]} seenProps
33+
* @returns {object | boolean}
3334
*/
3435
function findObjectProp(node, propName, seenProps) {
3536
if (!node.properties) {
@@ -57,6 +58,7 @@ module.exports = {
5758
* Takes a JSXElement and returns the value of the prop if it has it
5859
* @param {object} node - JSXElement node
5960
* @param {string} propName - name of the prop to look for
61+
* @returns {object | boolean}
6062
*/
6163
function findJsxProp(node, propName) {
6264
const attributes = node.openingElement.attributes;

lib/rules/style-prop-object.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
create(context) {
2727
/**
2828
* @param {ASTNode} expression An Identifier node
29+
* @returns {boolean}
2930
*/
3031
function isNonNullaryLiteral(expression) {
3132
return expression.type === 'Literal' && expression.value !== null;

lib/util/Components.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ function componentRule(rule, context) {
415415
/**
416416
* Check if the node is returning JSX or null
417417
*
418-
* @param {ASTNode} ASTnode The AST node being checked
418+
* @param {ASTNode} ASTNode The AST node being checked
419419
* @param {Boolean} [strict] If true, in a ternary condition the node must return JSX in both cases
420420
* @returns {Boolean} True if the node is returning JSX or null, false if not
421421
*/
@@ -449,9 +449,9 @@ function componentRule(rule, context) {
449449
},
450450

451451
/**
452-
*
453-
* @param {object} node
454452
* Getting the first JSX element's name.
453+
* @param {object} node
454+
* @returns {string | null}
455455
*/
456456
getNameOfWrappedComponent(node) {
457457
if (node.length < 1) {
@@ -473,6 +473,7 @@ function componentRule(rule, context) {
473473

474474
/**
475475
* Get the list of names of components created till now
476+
* @returns {string | boolean}
476477
*/
477478
getDetectedComponents() {
478479
const list = components.list();
@@ -496,15 +497,15 @@ function componentRule(rule, context) {
496497
},
497498

498499
/**
499-
*
500-
* @param {object} node
501500
* It will check wheater memo/forwardRef is wrapping existing component or
502501
* creating a new one.
502+
* @param {object} node
503+
* @returns {boolean}
503504
*/
504505
nodeWrapsComponent(node) {
505506
const childComponent = this.getNameOfWrappedComponent(node.arguments);
506507
const componentList = this.getDetectedComponents();
507-
return childComponent && arrayIncludes(componentList, childComponent);
508+
return !!childComponent && arrayIncludes(componentList, childComponent);
508509
},
509510

510511
isPragmaComponentWrapper(node) {

lib/util/ast.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Find a return statment in the current node
99
*
1010
* @param {ASTNode} node The AST node being checked
11+
* @returns {ASTNode | false}
1112
*/
1213
function findReturnStatement(node) {
1314
if (
@@ -153,6 +154,7 @@ function isClass(node) {
153154
/**
154155
* Removes quotes from around an identifier.
155156
* @param {string} string the identifier to strip
157+
* @returns {string}
156158
*/
157159
function stripQuotes(string) {
158160
return string.replace(/^'|'$/g, '');

lib/util/usedPropTypes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function createPropVariables() {
3434
* Add a variable name to the current scope
3535
* @param {string} name
3636
* @param {string[]} allNames Example: `props.a.b` should be formatted as `['a', 'b']`
37+
* @returns {Map<string, string[]>}
3738
*/
3839
set(name, allNames) {
3940
if (!hasBeenWritten) {
@@ -75,6 +76,8 @@ function mustBeValidated(component) {
7576

7677
/**
7778
* Check if we are in a lifecycle method
79+
* @param {object} context
80+
* @param {boolean} checkAsyncSafeLifeCycles
7881
* @return {boolean} true if we are in a class constructor, false if not
7982
*/
8083
function inLifeCycleMethod(context, checkAsyncSafeLifeCycles) {
@@ -98,6 +101,7 @@ function inLifeCycleMethod(context, checkAsyncSafeLifeCycles) {
98101
/**
99102
* Returns true if the given node is a React Component lifecycle method
100103
* @param {ASTNode} node The AST node being checked.
104+
* @param {boolean} checkAsyncSafeLifeCycles
101105
* @return {Boolean} True if the node is a lifecycle method
102106
*/
103107
function isNodeALifeCycleMethod(node, checkAsyncSafeLifeCycles) {
@@ -120,6 +124,7 @@ function isNodeALifeCycleMethod(node, checkAsyncSafeLifeCycles) {
120124
* Returns true if the given node is inside a React Component lifecycle
121125
* method.
122126
* @param {ASTNode} node The AST node being checked.
127+
* @param {boolean} checkAsyncSafeLifeCycles
123128
* @return {Boolean} True if the node is inside a lifecycle method
124129
*/
125130
function isInLifeCycleMethod(node, checkAsyncSafeLifeCycles) {
@@ -188,6 +193,7 @@ function isThisDotProps(node) {
188193

189194
/**
190195
* Checks if the prop has spread operator.
196+
* @param {object} context
191197
* @param {ASTNode} node The AST node being marked.
192198
* @returns {Boolean} True if the prop has spread operator, false if not.
193199
*/

0 commit comments

Comments
 (0)