From 2f104f8ad16bfd14b5c67a82e09ba261293d89e0 Mon Sep 17 00:00:00 2001 From: Caleb Hearon Date: Mon, 18 Apr 2022 18:46:40 -0400 Subject: [PATCH] fix(`require-param-type`): report column=1 (#875) * fix(`require-param-type`): report column=1 Source ```js /** * @param {a xxx * @param {bc */ ``` Before ``` 2:0 error Missing JSDoc @param "" type jsdoc/require-param-type 3:0 error Missing JSDoc @param "" type jsdoc/require-param-type ``` After ``` 2:1 error Missing JSDoc @param "" type jsdoc/require-param-type 3:1 error Missing JSDoc @param "" type jsdoc/require-param-type ``` Co-authored-by: Brett Zamir --- README.md | 7 +++++++ src/iterateJsdoc.js | 2 ++ test/rules/assertions/requireParamType.js | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/README.md b/README.md index f5974abbc..dd1daa485 100644 --- a/README.md +++ b/README.md @@ -14867,6 +14867,13 @@ function quux (foo) { } // Message: Missing JSDoc @param "foo" type. +/** + * @param {a xxx + */ +function quux () { +} +// Message: Missing JSDoc @param "" type. + /** * @param foo */ diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index 819a83498..0a6e848c7 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -844,9 +844,11 @@ const makeReport = (context, commentNode) => { loc = { end: { + column: 0, line: lineNumber, }, start: { + column: 0, line: lineNumber, }, }; diff --git a/test/rules/assertions/requireParamType.js b/test/rules/assertions/requireParamType.js index c6f4afbf9..b63012e73 100644 --- a/test/rules/assertions/requireParamType.js +++ b/test/rules/assertions/requireParamType.js @@ -11,11 +11,28 @@ export default { `, errors: [ { + column: 1, line: 3, message: 'Missing JSDoc @param "foo" type.', }, ], }, + { + code: ` + /** + * @param {a xxx + */ + function quux () { + } + `, + errors: [ + { + column: 1, + line: 3, + message: 'Missing JSDoc @param "" type.', + }, + ], + }, { code: ` /** @@ -27,6 +44,7 @@ export default { `, errors: [ { + column: 1, line: 3, message: 'Missing JSDoc @param "foo" type.', }, @@ -48,6 +66,7 @@ export default { `, errors: [ { + column: 1, line: 4, message: 'Missing JSDoc @param "foo" type.', }, @@ -69,6 +88,7 @@ export default { `, errors: [ { + column: 1, line: 4, message: 'Missing JSDoc @param "foo" type.', }, @@ -92,6 +112,7 @@ export default { `, errors: [ { + column: 1, line: 3, message: 'Missing JSDoc @arg "foo" type.', }, @@ -115,6 +136,7 @@ export default { `, errors: [ { + column: 1, line: 3, message: 'Unexpected tag `@param`', },