diff --git a/.README/rules/no-missing-syntax.md b/.README/rules/no-missing-syntax.md index bd801e574..afc214dc9 100644 --- a/.README/rules/no-missing-syntax.md +++ b/.README/rules/no-missing-syntax.md @@ -42,7 +42,8 @@ Use the `minimum` property (defaults to 1) to indicate how many are required for the rule to be reported. Use the `message` property to indicate the specific error to be shown when an -error is reported for that context being found missing. +error is reported for that context being found missing. You may use +`{{context}}` and `{{comment}}` with such messages. Set to `"any"` if you want the rule to apply to any jsdoc block throughout your files (as is necessary for finding function blocks not attached to a diff --git a/README.md b/README.md index f08c5781e..b7c347384 100644 --- a/README.md +++ b/README.md @@ -7601,7 +7601,8 @@ Use the `minimum` property (defaults to 1) to indicate how many are required for the rule to be reported. Use the `message` property to indicate the specific error to be shown when an -error is reported for that context being found missing. +error is reported for that context being found missing. You may use +`{{context}}` and `{{comment}}` with such messages. Set to `"any"` if you want the rule to apply to any jsdoc block throughout your files (as is necessary for finding function blocks not attached to a @@ -7628,7 +7629,7 @@ function quux () { } // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JSDocBlock[postDelimiter=\"\"]:has(JSDocTypeUnion[left.name=\"Foo\"])","context":"FunctionDeclaration"}]}] -// Message: Syntax is required: FunctionDeclaration +// Message: Syntax is required: FunctionDeclaration with JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Foo"]) /** * @implements {Bar|Foo} @@ -7636,8 +7637,8 @@ function quux () { function quux () { } -// "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JSDocBlock[postDelimiter=\"\"]:has(JSDocTypeUnion[left.name=\"Foo\"])","context":"FunctionDeclaration","message":"Problematic function syntax: `{{context}}`."}]}] -// Message: Problematic function syntax: `FunctionDeclaration`. +// "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JSDocBlock[postDelimiter=\"\"]:has(JSDocTypeUnion[left.name=\"Foo\"])","context":"FunctionDeclaration","message":"Problematically missing function syntax: `{{context}}` with `{{comment}}`."}]}] +// Message: Problematically missing function syntax: `FunctionDeclaration` with `JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Foo"])`. /** * @implements {Bar|Foo} @@ -7663,7 +7664,7 @@ function quux () { } // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JSDocBlock[postDelimiter=\"\"]:has(JSDocTypeUnion[left.name=\"Bar\"])","context":"FunctionDeclaration","minimum":2}]}] -// Message: Syntax is required: FunctionDeclaration +// Message: Syntax is required: FunctionDeclaration with JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Bar"]) ```` The following patterns are not considered problems: diff --git a/src/rules/noMissingSyntax.js b/src/rules/noMissingSyntax.js index 3654796d7..807255e57 100644 --- a/src/rules/noMissingSyntax.js +++ b/src/rules/noMissingSyntax.js @@ -56,9 +56,11 @@ export default iterateJsdoc(({ !state.selectorMap[contextStr][comment] || state.selectorMap[contextStr][comment] < (cntxt?.minimum ?? 1) ) { - const message = cntxt?.message ?? 'Syntax is required: {{context}}'; + const message = cntxt?.message ?? 'Syntax is required: {{context}}' + + (comment ? ' with {{comment}}' : ''); context.report({ data: { + comment, context: contextStr, }, loc: { diff --git a/test/rules/assertions/checkLineAlignment.js b/test/rules/assertions/checkLineAlignment.js index ec553937d..5849aa6b1 100644 --- a/test/rules/assertions/checkLineAlignment.js +++ b/test/rules/assertions/checkLineAlignment.js @@ -12,6 +12,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -42,6 +43,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -72,6 +74,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -101,6 +104,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -130,6 +134,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -159,6 +164,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -188,6 +194,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -217,6 +224,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -248,6 +256,7 @@ export default { `, errors: [ { + line: 3, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -281,6 +290,7 @@ export default { `, errors: [ { + line: 3, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -312,6 +322,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -344,6 +355,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -377,6 +389,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -410,6 +423,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -445,6 +459,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -477,10 +492,12 @@ export default { `, errors: [ { + line: 5, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, { + line: 6, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, @@ -510,6 +527,7 @@ export default { `, errors: [ { + line: 6, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, @@ -539,6 +557,7 @@ export default { `, errors: [ { + line: 6, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, @@ -568,6 +587,7 @@ export default { `, errors: [ { + line: 6, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, @@ -595,6 +615,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -628,6 +649,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -659,6 +681,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, @@ -718,6 +741,7 @@ export default { `, errors: [ { + line: 6, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, @@ -745,6 +769,7 @@ export default { `, errors: [ { + line: 6, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, @@ -772,6 +797,7 @@ export default { `, errors: [ { + line: 5, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, @@ -800,6 +826,7 @@ export default { `, errors: [ { + line: 7, message: 'Expected JSDoc block lines to not be aligned.', type: 'Block', }, @@ -873,6 +900,7 @@ export default { `, errors: [ { + line: 2, message: 'Expected JSDoc block lines to be aligned.', type: 'Block', }, diff --git a/test/rules/assertions/checkParamNames.js b/test/rules/assertions/checkParamNames.js index 869d63f54..db76c4146 100644 --- a/test/rules/assertions/checkParamNames.js +++ b/test/rules/assertions/checkParamNames.js @@ -753,15 +753,19 @@ export default { `, errors: [ { + line: 4, message: 'Missing @param "bbox.x"', }, { + line: 4, message: 'Missing @param "bbox.y"', }, { + line: 4, message: 'Missing @param "bbox.width"', }, { + line: 4, message: 'Missing @param "bbox.height"', }, ], @@ -783,15 +787,19 @@ export default { `, errors: [ { + line: 4, message: 'Missing @param "bbox.x"', }, { + line: 4, message: 'Missing @param "bbox.y"', }, { + line: 4, message: 'Missing @param "bbox.width"', }, { + line: 4, message: 'Missing @param "bbox.height"', }, ], @@ -809,9 +817,11 @@ export default { `, errors: [ { + line: 4, message: 'Missing @param "fetchOptions.url"', }, { + line: 4, message: 'Missing @param "fetchOptions.options"', }, ], @@ -905,9 +915,11 @@ export default { `, errors: [ { + line: 4, message: 'Missing @param "options.foo"', }, { + line: 4, message: 'Missing @param "options.foo.bar"', }, ], @@ -958,9 +970,11 @@ export default { `, errors: [ { + line: 6, message: '@param "props.prop.a" does not exist on props', }, { + line: 7, message: '@param "props.prop.b" does not exist on props', }, ], diff --git a/test/rules/assertions/checkTagNames.js b/test/rules/assertions/checkTagNames.js index 0d7848bbc..65f4684f3 100644 --- a/test/rules/assertions/checkTagNames.js +++ b/test/rules/assertions/checkTagNames.js @@ -8,6 +8,10 @@ const buildTagBlock = (tags) => { }).join('') + '\n */'; }; +const lineCount = (code) => { + return code.match(/\n/g).length; +}; + // We avoid testing all closure tags as too many const ALL_JSDOC_TAGS_COMMENT = buildTagBlock(jsdocTags); const ALL_TYPESCRIPT_TAGS_COMMENT = buildTagBlock(typeScriptTags); @@ -296,6 +300,7 @@ export default { `, errors: [ { + line: 3, message: 'Blacklisted tag found (`@todo`)', }, ], @@ -318,6 +323,7 @@ export default { `, errors: [ { + line: 3, message: 'Please resolve to-dos or add to the tracker', }, ], @@ -342,6 +348,7 @@ export default { `, errors: [ { + line: 3, message: 'Please use x-todo instead of todo', }, ], @@ -375,6 +382,7 @@ export default { `, errors: [ { + line: 3, message: 'Please use x-todo instead of todo', }, ], @@ -412,6 +420,7 @@ export default { message: 'Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.', }, { + line: 3, message: 'Invalid JSDoc tag (preference). Replace "todo" JSDoc tag with "55".', }, ], @@ -537,6 +546,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return".', }, ], @@ -556,6 +566,7 @@ export default { code: `${ALL_JSDOC_TAGS_COMMENT}\nfunction quux (foo) {}`, errors: [ { + line: 1, message: 'Unrecognized value `badMode` for `settings.jsdoc.mode`.', }, ], @@ -569,6 +580,7 @@ export default { code: `${ALL_TYPESCRIPT_TAGS_COMMENT}\nfunction quux (foo) {}`, errors: [ { + line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT), message: 'Invalid JSDoc tag name "template".', }, ], @@ -577,6 +589,7 @@ export default { code: `${ONE_CLOSURE_TAGS_COMMENT}\nfunction quux (foo) {}`, errors: [ { + line: lineCount(ONE_CLOSURE_TAGS_COMMENT), message: 'Invalid JSDoc tag name "externs".', }, ], @@ -589,10 +602,22 @@ export default { /** @jsxRuntime automatic */ `, errors: [ - {message: 'Invalid JSDoc tag name "jsx".'}, - {message: 'Invalid JSDoc tag name "jsxFrag".'}, - {message: 'Invalid JSDoc tag name "jsxImportSource".'}, - {message: 'Invalid JSDoc tag name "jsxRuntime".'}, + { + line: 2, + message: 'Invalid JSDoc tag name "jsx".', + }, + { + line: 3, + message: 'Invalid JSDoc tag name "jsxFrag".', + }, + { + line: 4, + message: 'Invalid JSDoc tag name "jsxImportSource".', + }, + { + line: 5, + message: 'Invalid JSDoc tag name "jsxRuntime".', + }, ], }, ], diff --git a/test/rules/assertions/checkTypes.js b/test/rules/assertions/checkTypes.js index 913c160f1..365d8c024 100644 --- a/test/rules/assertions/checkTypes.js +++ b/test/rules/assertions/checkTypes.js @@ -605,6 +605,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".', }, ], @@ -635,6 +636,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".', }, ], @@ -666,6 +668,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".', }, ], @@ -696,6 +699,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".', }, ], @@ -726,6 +730,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".', }, ], @@ -756,6 +761,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".', }, ], @@ -789,6 +795,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "SpecialTypeArray".', }, ], @@ -822,6 +829,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -852,6 +860,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -883,6 +892,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -914,6 +924,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -944,6 +955,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -974,6 +986,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -1004,6 +1017,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -1034,6 +1048,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -1067,6 +1082,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -1100,6 +1116,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -1133,6 +1150,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object".', }, ], @@ -1158,6 +1176,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object".', }, ], @@ -1180,6 +1199,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -1213,6 +1233,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', }, ], @@ -1247,9 +1268,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.".', }, ], @@ -1282,9 +1305,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.<>".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.<>".', }, ], @@ -1317,9 +1342,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array<>".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array<>".', }, ], @@ -1352,9 +1379,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object".', }, ], @@ -1387,9 +1416,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".', }, ], @@ -1422,9 +1453,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object.".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object.".', }, ], @@ -1457,9 +1490,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', }, ], @@ -1492,9 +1527,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array<>".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array<>".', }, ], @@ -1527,9 +1564,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".', }, ], @@ -1562,6 +1601,7 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".', }, ], @@ -1594,6 +1634,7 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "MyArray"; prefer: "<>".', }, ], @@ -1626,9 +1667,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".', }, ], @@ -1661,9 +1704,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".', }, ], @@ -1699,9 +1744,11 @@ export default { `, errors: [ { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', }, { + line: 4, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', }, ], @@ -1725,7 +1772,10 @@ export default { { code: '/** @typedef {String} foo */', errors: [ - {message: 'Invalid JSDoc @typedef "foo" type "String"; prefer: "string".'}, + { + line: 1, + message: 'Invalid JSDoc @typedef "foo" type "String"; prefer: "string".', + }, ], output: '/** @typedef {string} foo */', }, @@ -1904,6 +1954,7 @@ export default { `, errors: [ { + line: 3, message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', }, ], diff --git a/test/rules/assertions/noMissingSyntax.js b/test/rules/assertions/noMissingSyntax.js index ee1f34d3e..a41855a36 100644 --- a/test/rules/assertions/noMissingSyntax.js +++ b/test/rules/assertions/noMissingSyntax.js @@ -11,7 +11,9 @@ export default { `, errors: [ { - message: 'Syntax is required: FunctionDeclaration', + line: 1, + message: 'Syntax is required: FunctionDeclaration with ' + + 'JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Foo"])', }, ], options: [{ @@ -34,7 +36,8 @@ export default { `, errors: [ { - message: 'Problematic function syntax: `FunctionDeclaration`.', + line: 1, + message: 'Problematically missing function syntax: `FunctionDeclaration` with `JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Foo"])`.', }, ], options: [{ @@ -42,7 +45,7 @@ export default { { comment: 'JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Foo"])', context: 'FunctionDeclaration', - message: 'Problematic function syntax: `{{context}}`.', + message: 'Problematically missing function syntax: `{{context}}` with `{{comment}}`.', }, ], }], @@ -58,6 +61,7 @@ export default { `, errors: [ { + line: 1, message: 'Syntax is required: FunctionDeclaration', }, ], @@ -78,6 +82,7 @@ export default { `, errors: [ { + line: 1, message: 'Rule `no-restricted-syntax` is missing a `context` option.', }, ], @@ -94,7 +99,9 @@ export default { `, errors: [ { - message: 'Syntax is required: FunctionDeclaration', + line: 1, + message: 'Syntax is required: FunctionDeclaration with ' + + 'JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Bar"])', }, ], options: [{ diff --git a/test/rules/assertions/requireJsdoc.js b/test/rules/assertions/requireJsdoc.js index 76227836a..8c46c2b6b 100644 --- a/test/rules/assertions/requireJsdoc.js +++ b/test/rules/assertions/requireJsdoc.js @@ -19,6 +19,7 @@ export default { `, errors: [ { + line: 6, message: 'Missing JSDoc comment.', type: 'TSMethodSignature', }, @@ -64,6 +65,7 @@ export default { `, errors: [ { + line: 6, message: 'Missing JSDoc comment.', type: 'TSPropertySignature', }, @@ -107,6 +109,7 @@ export default { `, errors: [ { + line: 4, message: 'Missing JSDoc comment.', type: 'TSMethodSignature', }, @@ -143,6 +146,7 @@ export default { `, errors: [ { + line: 4, message: 'Missing JSDoc comment.', type: 'TSPropertySignature', }, @@ -187,6 +191,7 @@ export default { `, errors: [ { + line: 11, message: 'Missing JSDoc comment.', }, ], @@ -247,6 +252,7 @@ function quux (foo) { `, errors: [ { + line: 5, message: 'Missing JSDoc comment.', }, ], @@ -282,6 +288,7 @@ function quux (foo) { `, errors: [ { + line: 7, message: 'Missing JSDoc comment.', }, ], @@ -312,6 +319,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', }, ], @@ -337,6 +345,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', }, ], @@ -359,6 +368,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }, @@ -390,6 +400,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }, @@ -421,6 +432,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'ArrowFunctionExpression', }, @@ -451,6 +463,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'ArrowFunctionExpression', }, @@ -479,6 +492,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'ArrowFunctionExpression', }, @@ -509,6 +523,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'ClassExpression', }, @@ -537,6 +552,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }, @@ -567,6 +583,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'ArrowFunctionExpression', }, @@ -597,6 +614,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }, @@ -627,6 +645,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', type: 'ClassDeclaration', }, @@ -726,6 +745,7 @@ function quux (foo) { function myFunction() {} `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -747,6 +767,7 @@ function quux (foo) { } }`, errors: [{ + line: 5, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -784,6 +805,7 @@ function quux (foo) { } }`, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ClassDeclaration', }], @@ -822,6 +844,7 @@ function quux (foo) { } }`, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ClassDeclaration', }], @@ -860,6 +883,7 @@ function quux (foo) { } }`, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ClassDeclaration', }], @@ -898,6 +922,7 @@ function quux (foo) { } }`, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ClassDeclaration', }], @@ -929,6 +954,7 @@ function quux (foo) { var myFunction = () => {} `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ArrowFunctionExpression', }], @@ -952,6 +978,7 @@ function quux (foo) { var myFunction = () => () => {} `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ArrowFunctionExpression', }], @@ -975,6 +1002,7 @@ function quux (foo) { var foo = function() {} `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -995,6 +1023,7 @@ function quux (foo) { const foo = {bar() {}} `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1018,6 +1047,7 @@ function quux (foo) { var foo = {bar: function() {}} `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1038,6 +1068,7 @@ function quux (foo) { function foo (abc) {} `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1058,6 +1089,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1083,6 +1115,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1111,6 +1144,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1143,6 +1177,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 3, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1177,6 +1212,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 4, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1213,6 +1249,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 4, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1247,6 +1284,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1280,6 +1318,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 9, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1316,6 +1355,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1350,6 +1390,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ArrowFunctionExpression', }], @@ -1384,6 +1425,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 3, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1412,6 +1454,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1440,6 +1483,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1471,6 +1515,7 @@ function quux (foo) { export default quux; `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1500,6 +1545,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1528,6 +1574,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1561,6 +1608,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', }, ], @@ -1592,6 +1640,7 @@ function quux (foo) { export { test as test2 } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1621,6 +1670,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ClassDeclaration', }], @@ -1649,6 +1699,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'ClassDeclaration', }], @@ -1679,6 +1730,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1709,6 +1761,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1739,6 +1792,7 @@ function quux (foo) { } `, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1769,6 +1823,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionExpression', }], @@ -1801,6 +1856,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1837,6 +1893,7 @@ function quux (foo) { node: true, }, errors: [{ + line: 2, message: 'Missing JSDoc comment.', type: 'FunctionDeclaration', }], @@ -1871,6 +1928,7 @@ function quux (foo) { `, errors: [ { + line: 3, message: 'Missing JSDoc comment.', type: 'Property', }, @@ -1907,6 +1965,7 @@ function quux (foo) { `, errors: [ { + line: 11, message: 'Missing JSDoc comment.', }, ], @@ -1941,6 +2000,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', }, ], @@ -1970,6 +2030,7 @@ function quux (foo) { `, errors: [ { + line: 3, message: 'Missing JSDoc comment.', }, ], @@ -2013,6 +2074,7 @@ function quux (foo) { `, errors: [ { + line: 3, message: 'Missing JSDoc comment.', }, ], @@ -2057,6 +2119,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', }, ], @@ -2091,6 +2154,7 @@ function quux (foo) { `, errors: [ { + line: 8, message: 'Missing JSDoc comment.', }, ], @@ -2132,6 +2196,7 @@ function quux (foo) { `, errors: [ { + line: 3, message: 'Missing JSDoc comment.', }, ], @@ -2162,6 +2227,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', }, ], @@ -2188,6 +2254,7 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', }, ], @@ -2220,15 +2287,19 @@ function quux (foo) { `, errors: [ { + line: 2, message: 'Missing JSDoc comment.', }, { + line: 3, message: 'Missing JSDoc comment.', }, { + line: 4, message: 'Missing JSDoc comment.', }, { + line: 5, message: 'Missing JSDoc comment.', }, ], @@ -2979,6 +3050,7 @@ function quux (foo) { } `, errors: [{ + line: 4, message: 'Missing JSDoc comment.', }], output: ` diff --git a/test/rules/assertions/requireParam.js b/test/rules/assertions/requireParam.js index e4f9304a7..b8903ebb3 100644 --- a/test/rules/assertions/requireParam.js +++ b/test/rules/assertions/requireParam.js @@ -17,6 +17,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -40,6 +41,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -68,9 +70,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.foo" declaration.', }, ], @@ -95,9 +99,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "bar" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, ], @@ -128,6 +134,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "bar" declaration.', }, ], @@ -157,9 +164,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.foo" declaration.', }, ], @@ -188,9 +197,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.foo" declaration.', }, ], @@ -215,9 +226,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.foo" declaration.', }, ], @@ -242,9 +255,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "root1" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root1.foo" declaration.', }, ], @@ -298,15 +313,19 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.foo" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.bar" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.bar.baz" declaration.', }, ], @@ -333,15 +352,19 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "arg0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "arg0.foo" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "arg1" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "arg1.bar" declaration.', }, ], @@ -373,15 +396,19 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "arg" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "arg.foo" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "config0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "config0.bar" declaration.', }, ], @@ -413,15 +440,19 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "arg" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "arg.foo" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "config0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "config0.bar" declaration.', }, ], @@ -452,9 +483,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "bar" declaration.', }, ], @@ -479,6 +512,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "bar" declaration.', }, ], @@ -503,9 +537,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "baz" declaration.', }, ], @@ -532,6 +568,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "baz" declaration.', }, ], @@ -557,9 +594,11 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "bar" declaration.', }, ], @@ -585,6 +624,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @arg "foo" declaration.', }, ], @@ -616,6 +656,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "bar" declaration.', }, ], @@ -640,6 +681,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -669,6 +711,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -698,6 +741,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -722,6 +766,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -751,6 +796,7 @@ export default { `, errors: [ { + line: 6, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -789,6 +835,7 @@ export default { `, errors: [ { + line: 6, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -827,6 +874,7 @@ export default { `, errors: [ { + line: 6, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -860,6 +908,7 @@ export default { `, errors: [ { + line: 6, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -888,6 +937,7 @@ export default { `, errors: [ { + line: 3, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -916,6 +966,7 @@ export default { `, errors: [ { + line: 3, message: 'Unexpected tag `@param`', }, ], @@ -937,15 +988,19 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.bar" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.baz" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -970,15 +1025,19 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.bar" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0.baz" declaration.', }, ], @@ -1003,15 +1062,19 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "root0" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0."0"" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "root0."1"" declaration.', }, { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -1664,6 +1727,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "foo" declaration.', }, ], @@ -1695,9 +1759,11 @@ export default { `, errors: [ { + line: 3, message: 'Missing JSDoc @param "data" declaration.', }, { + line: 3, message: 'Missing JSDoc @param "data.last_modified" declaration.', }, ], @@ -1822,6 +1888,7 @@ export default { `, errors: [ { + line: 2, message: 'Missing JSDoc @param "extra" declaration.', }, ], @@ -1971,6 +2038,7 @@ export default { `, errors: [ { + line: 3, message: 'Missing JSDoc @param "param" declaration.', }, ],