@futdevpro/dynamo-eslint 1.14.24 → 1.14.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -228,6 +228,39 @@ const rule: Rule.RuleModule = {
228
228
  }
229
229
  }
230
230
 
231
+ /**
232
+ * Get node name location for error reporting
233
+ */
234
+ function getNodeNameLoc(node: any): { start: { line: number; column: number }; end: { line: number; column: number } } | null {
235
+ try {
236
+ // For MethodDefinition, use key.loc
237
+ if (node.key && node.key.loc) {
238
+ return node.key.loc;
239
+ }
240
+
241
+ // For declarations with id (FunctionDeclaration, ClassDeclaration, etc.)
242
+ if (node.id && node.id.loc) {
243
+ return node.id.loc;
244
+ }
245
+
246
+ // For VariableDeclarator
247
+ if (node.id && node.id.loc) {
248
+ return node.id.loc;
249
+ }
250
+
251
+ // Fallback to node location if name location not found
252
+ if (node.loc) {
253
+ return node.loc;
254
+ }
255
+
256
+ return null;
257
+ } catch (error) {
258
+ console.error('[require-jsdoc-description] Error in getNodeNameLoc:', error);
259
+
260
+ return null;
261
+ }
262
+ }
263
+
231
264
  /**
232
265
  * Get node type for error messages
233
266
  */
@@ -299,22 +332,26 @@ const rule: Rule.RuleModule = {
299
332
  try {
300
333
  const name = getNodeName(node);
301
334
  const type = getNodeType(node);
335
+ const nameLoc = getNodeNameLoc(node);
336
+
337
+ // Fallback to node location if name location not found
338
+ const reportLoc = nameLoc || node.loc;
302
339
 
303
340
  if (!jsdocResult.hasJSDoc) {
304
341
  context.report({
305
- node,
342
+ loc: reportLoc,
306
343
  messageId: 'missingJSDoc',
307
344
  data: { type, name },
308
345
  });
309
346
  } else if (!jsdocResult.isOnPreviousLine) {
310
347
  context.report({
311
- node,
348
+ loc: reportLoc,
312
349
  messageId: 'invalidJSDocPosition',
313
350
  data: { type, name },
314
351
  });
315
352
  } else if (!jsdocResult.isValid) {
316
353
  context.report({
317
- node,
354
+ loc: reportLoc,
318
355
  messageId: 'emptyJSDoc',
319
356
  data: { type, name },
320
357
  });
Binary file