Skip to content

Commit f77144d

Browse files
brettz9golopot
authored andcommitted
fix: avoid highlighting whole function block upon missing jsdoc block in favor of highlighting first line only; fixes #386
1 parent c523384 commit f77144d

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/rules/requireJsdoc.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ export default {
172172
return fixer.insertTextBefore(baseNode, insertion);
173173
};
174174

175+
const report = () => {
176+
const loc = {
177+
end: node.loc.start,
178+
start: node.loc.start,
179+
};
180+
context.report({
181+
fix,
182+
messageId: 'missingJsDoc',
183+
node,
184+
loc,
185+
});
186+
};
187+
175188
if (publicOnly) {
176189
const opt = {
177190
ancestorsOnly: Boolean(_.get(publicOnly, 'ancestorsOnly', false)),
@@ -183,18 +196,10 @@ export default {
183196
const exported = exportParser.isExported(node, parseResult, opt);
184197

185198
if (exported) {
186-
context.report({
187-
fix,
188-
messageId: 'missingJsDoc',
189-
node,
190-
});
199+
report();
191200
}
192201
} else {
193-
context.report({
194-
fix,
195-
messageId: 'missingJsDoc',
196-
node,
197-
});
202+
report();
198203
}
199204
};
200205

test/rules/assertions/requireJsdoc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export default {
263263
}`,
264264
errors: [
265265
{
266+
endLine: 2,
266267
line: 2,
267268
message: 'Missing JSDoc comment.',
268269
},

0 commit comments

Comments
 (0)