Skip to content

Commit be8d9a3

Browse files
committed
fix: avoid errors with getReducedASTNode; fixes #528
1 parent fdf129b commit be8d9a3

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,11 @@ function quux () {
12861286

12871287
}
12881288
// Options: [{"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
1289+
1290+
// Comment
1291+
a();
1292+
1293+
export default {};
12891294
````
12901295

12911296

src/eslint/getJSDocComment.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ const getReducedASTNode = function (node, sourceCode) {
153153
break;
154154
}
155155
}
156-
157156
if (parent) {
158-
if (parent.parent.type === 'ExportNamedDeclaration') {
157+
if (parent.parent && parent.parent.type === 'ExportNamedDeclaration') {
159158
return parent.parent;
160159
}
161160

test/rules/assertions/checkExamples.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,5 +1008,16 @@ export default {
10081008
noDefaultExampleRules: false,
10091009
}],
10101010
},
1011+
{
1012+
code: `
1013+
// Comment
1014+
a();
1015+
1016+
export default {};
1017+
`,
1018+
parserOptions: {
1019+
sourceType: 'module',
1020+
},
1021+
},
10111022
],
10121023
};

0 commit comments

Comments
 (0)