Skip to content

Commit 2ba2924

Browse files
committed
fix: check parents of ClassExpression for comment blocks
This fix is to ensure not only comments immediately above a class expression are checked, but also, e.g., a variable assigning to a class expression
1 parent 9b6bcc3 commit 2ba2924

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/eslint/getJSDocComment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const looksLikeExport = function (astNode) {
2525
astNode.type === 'ExportAllDeclaration' || astNode.type === 'ExportSpecifier';
2626
};
2727

28+
/* eslint-disable complexity */
2829
/**
2930
* Retrieves the JSDoc comment for a given node.
3031
*
@@ -67,10 +68,8 @@ const getJSDocComment = function (sourceCode, node) {
6768
return findJSDocComment(looksLikeExport(parent) ? parent : node);
6869

6970
case 'ClassExpression':
70-
return findJSDocComment(parent.parent);
71-
72-
case 'ArrowFunctionExpression':
7371
case 'ObjectExpression':
72+
case 'ArrowFunctionExpression':
7473
case 'FunctionExpression':
7574
if (
7675
parent.type !== 'CallExpression' &&
@@ -102,5 +101,6 @@ const getJSDocComment = function (sourceCode, node) {
102101
return null;
103102
}
104103
};
104+
/* eslint-enable complexity */
105105

106106
export default getJSDocComment;

0 commit comments

Comments
 (0)