Skip to content

Commit 2cc7dd1

Browse files
authored
Merge pull request #267 from golopot/patch-1
fix: false positive with optional chaining
2 parents be9c24e + 7015225 commit 2cc7dd1

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3913,6 +3913,10 @@ function quux (foo) {
39133913

39143914
}
39153915
// Settings: {"jsdoc":{"ignorePrivate":true}}
3916+
3917+
// issue 182: optional chaining
3918+
/** @const {boolean} test */
3919+
const test = something?.find(_ => _)
39163920
````
39173921

39183922

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
1818
"@babel/preset-env": "^7.4.5",
1919
"@babel/register": "^7.4.4",
20+
"babel-eslint": "^10.0.1",
2021
"babel-plugin-add-module-exports": "^1.0.2",
2122
"babel-plugin-istanbul": "^5.1.4",
2223
"chai": "^4.2.0",

src/eslint/getJSDocComment.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ const getJSDocComment = function (sourceCode, node) {
7171

7272
case 'ArrowFunctionExpression':
7373
case 'FunctionExpression':
74-
if (parent.type !== 'CallExpression' && parent.type !== 'NewExpression') {
74+
if (
75+
parent.type !== 'CallExpression' &&
76+
parent.type !== 'OptionalCallExpression' &&
77+
parent.type !== 'NewExpression'
78+
) {
7579
while (
7680
!sourceCode.getCommentsBefore(parent).length &&
7781
!/Function/u.test(parent.type) &&

test/rules/assertions/requireParam.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,14 @@ export default {
559559
ignorePrivate: true
560560
}
561561
}
562+
},
563+
{
564+
code: `
565+
// issue 182: optional chaining
566+
/** @const {boolean} test */
567+
const test = something?.find(_ => _)
568+
`,
569+
parser: 'babel-eslint'
562570
}
563571
]
564572
};

0 commit comments

Comments
 (0)