From f5c485da9f91f15da50f88c218a461252ffe5faf Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Thu, 4 Jul 2019 19:33:17 +0700 Subject: [PATCH 01/23] feat(valid-types): Add more type checks --- src/iterateJsdoc.js | 19 ++++- src/jsdocUtils.js | 35 +++++++- src/rules/validTypes.js | 30 +++++-- test/rules/assertions/validTypes.js | 123 +++++++++++++++++++++++++--- 4 files changed, 187 insertions(+), 20 deletions(-) diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index 29c6589aa..196a25dc5 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -9,11 +9,21 @@ const parseComment = (commentNode, indent) => { // @see https://github.com/yavorskiy/comment-parser/issues/21 parsers: [ commentParser.PARSERS.parse_tag, - commentParser.PARSERS.parse_type, + (str, data) => { + if (data.tag === 'see') { + // @see can't contain types, only names or links which might be confused with types + return null; + } + + return commentParser.PARSERS.parse_type(str, data); + }, (str, data) => { if (['return', 'returns', 'throws', 'exception'].includes(data.tag)) { return null; } + if (data.tag === 'see' && str.match(/{@link.+?}/)) { + return null; + } return commentParser.PARSERS.parse_name(str, data); }, @@ -145,12 +155,19 @@ const getUtils = ( utils.isTagWithType = (tagName) => { return jsdocUtils.isTagWithType(tagName); }; + utils.isPotentiallyEmptyTypeTag = (tagName) => { + return jsdocUtils.isPotentiallyEmptyTypeTag(tagName); + }; utils.passesEmptyNamepathCheck = (tag) => { return !tag.name && allowEmptyNamepaths && jsdocUtils.isPotentiallyEmptyNamepathTag(tag.tag); }; + utils.isTagWithMandatoryNamepathOrType = (tagName) => { + return jsdocUtils.isTagWithMandatoryNamepathOrType(tagName); + }; + utils.hasDefinedTypeReturnTag = (tag) => { return jsdocUtils.hasDefinedTypeReturnTag(tag); }; diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index b77321912..71b2257cd 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -186,13 +186,18 @@ const potentiallyEmptyNamepathTags = [ 'event', 'callback', 'class', 'constructor', + 'extends', 'augments', 'constant', 'const', 'function', 'func', 'method', 'interface', 'member', 'var', 'mixin', 'namespace', - 'listens', 'fires', 'emits' + 'listens', 'fires', 'emits', + 'see', + + // GCC syntax allows typedef to be named through variable declaration rather than jsdoc name + 'typedef' ]; const isPotentiallyEmptyNamepathTag = (tag) => { @@ -200,6 +205,7 @@ const isPotentiallyEmptyNamepathTag = (tag) => { }; let tagsWithTypes = [ + 'augments', 'extends', 'class', 'constant', 'enum', @@ -234,10 +240,35 @@ const tagsWithTypesAliases = [ tagsWithTypes = tagsWithTypes.concat(tagsWithTypesAliases, closureTagsWithTypes); +const potentiallyEmptyTypeTags = [ + 'class', 'constructor', + 'constant', 'const', + 'extends', 'augments', + 'namespace', + 'param', 'arg', + 'return', 'returns', + 'throws', 'exception', + 'yields', 'yield', + 'package', 'private', 'protected', 'public', 'static' +]; + +const isPotentiallyEmptyTypeTag = (tag) => { + return potentiallyEmptyTypeTags.includes(tag); +}; + const isTagWithType = (tagName) => { return tagsWithTypes.includes(tagName); }; +const tagsWithMandatoryNamepathOrType = [ + 'augments', 'extends', + 'param', 'arg', + 'typedef' +]; +const isTagWithMandatoryNamepathOrType = (tagName) => { + return tagsWithMandatoryNamepathOrType.includes(tagName); +}; + const LOOP_STATEMENTS = ['WhileStatement', 'DoWhileStatement', 'ForStatement', 'ForInStatement', 'ForOfStatement']; const STATEMENTS_WITH_CHILDREN = [ @@ -530,6 +561,8 @@ export default { isNamepathDefiningTag, isNamepathTag, isPotentiallyEmptyNamepathTag, + isPotentiallyEmptyTypeTag, + isTagWithMandatoryNamepathOrType, isTagWithType, isValidTag, parseClosureTemplateTag diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index 1e162b1f6..7a96e1179 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -52,6 +52,15 @@ export default iterateJsdoc(({ return true; }; + const hasType = Boolean(tag.type); + const mustHaveType = utils.isTagWithType(tag.tag) && !utils.isPotentiallyEmptyTypeTag(tag.tag); + + const hasNamePath = Boolean(tag.name); + const mustHaveNamepath = utils.isNamepathTag(tag.tag) && !utils.passesEmptyNamepathCheck(tag); + + const hasEither = hasType || hasNamePath; + const mustHaveEither = utils.isTagWithMandatoryNamepathOrType(tag.tag); + if (tag.tag === 'borrows') { const thisNamepath = tag.description.replace(asExpression, ''); @@ -66,13 +75,24 @@ export default iterateJsdoc(({ validTypeParsing(thatNamepath); } - } else if (utils.isNamepathTag(tag.tag)) { - if (utils.passesEmptyNamepathCheck(tag)) { + } else { + if (mustHaveEither && !hasEither) { + report(`Tag @${tag.tag} must have either a type or namepath`); + return; } - validTypeParsing(tag.name, tag.tag); - } else if (tag.type && utils.isTagWithType(tag.tag)) { - validTypeParsing(tag.type); + + if (hasType) { + validTypeParsing(tag.type); + } else if (mustHaveType) { + report(`Tag @${tag.tag} must have a type`); + } + + if (hasNamePath) { + validTypeParsing(tag.name, tag.tag); + } else if (mustHaveNamepath) { + report(`Tag @${tag.tag} must have a namepath`); + } } }); }, { diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index a676d4b6f..bf9ace805 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -161,14 +161,82 @@ export default { } `, errors: [{ - line: 3, - message: 'Syntax error in type: ' + line: 2, + message: 'Tag @callback must have a namepath' }], settings: { jsdoc: { allowEmptyNamepaths: false } } + }, + { + code: ` + /** + * @constant {str%ng} + */ + const FOO = 'foo'; + `, + errors: [ + { + line: 3, + message: 'Syntax error in type: str%ng' + } + ] + }, + { + code: ` + /** + * @typedef {str%ng} UserString + */ + `, + errors: [ + { + line: 3, + message: 'Syntax error in type: str%ng' + } + ] + }, + { + code: ` + /** + * @typedef {string} UserStr%ng + */ + `, + errors: [ + { + line: 3, + message: 'Syntax error in type: UserStr%ng' + } + ] + }, + { + code: ` + /** + * @extends + */ + class Bar {}; + `, + errors: [ + { + line: 2, + message: 'Tag @extends must have either a type or namepath' + } + ] + }, + { + code: ` + /** + * @type + */ + let foo; + `, + errors: [ + { + line: 2, + message: 'Tag @type must have a type' + } + ] } ], valid: [ @@ -222,16 +290,6 @@ export default { } ` }, - { - code: ` - /** - * @see foo% - */ - function quux() { - - } - ` - }, { code: ` /** @@ -245,7 +303,7 @@ export default { { code: ` /** - * @callback + * @callback foo */ function quux() { @@ -312,6 +370,45 @@ export default { } ` + }, + { + code: ` + /** + * @constant {string} + */ + const FOO = 'foo'; + ` + }, + { + code: ` + /** + * @extends Foo + */ + class Bar {}; + ` + }, + { + code: ` + /** + * @extends {Foo} + */ + class Bar {}; + ` + }, + { + code: ` + /** + * @typedef {number|string} UserDefinedType + */ + ` + }, + { + code: ` + /** + * @typedef {number|string} + */ + let UserDefinedGCCType; + ` } ] }; From 4f71560c15f40cc14256eebadfe58e6520426cb4 Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Fri, 5 Jul 2019 16:34:13 +0700 Subject: [PATCH 02/23] Fix reported line numbers --- src/rules/validTypes.js | 6 +++--- test/rules/assertions/validTypes.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index 7a96e1179..6b4cc2513 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -77,7 +77,7 @@ export default iterateJsdoc(({ } } else { if (mustHaveEither && !hasEither) { - report(`Tag @${tag.tag} must have either a type or namepath`); + report(`Tag @${tag.tag} must have either a type or namepath`, null, tag); return; } @@ -85,13 +85,13 @@ export default iterateJsdoc(({ if (hasType) { validTypeParsing(tag.type); } else if (mustHaveType) { - report(`Tag @${tag.tag} must have a type`); + report(`Tag @${tag.tag} must have a type`, null, tag); } if (hasNamePath) { validTypeParsing(tag.name, tag.tag); } else if (mustHaveNamepath) { - report(`Tag @${tag.tag} must have a namepath`); + report(`Tag @${tag.tag} must have a namepath`, null, tag); } } }); diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index bf9ace805..aa72b8fe3 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -161,7 +161,7 @@ export default { } `, errors: [{ - line: 2, + line: 3, message: 'Tag @callback must have a namepath' }], settings: { @@ -219,7 +219,7 @@ export default { `, errors: [ { - line: 2, + line: 3, message: 'Tag @extends must have either a type or namepath' } ] @@ -233,7 +233,7 @@ export default { `, errors: [ { - line: 2, + line: 3, message: 'Tag @type must have a type' } ] From 4549593222e9a55cf1b76d0df46ebdc64b7cb1e0 Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Fri, 5 Jul 2019 16:34:13 +0700 Subject: [PATCH 03/23] docs: generate docs --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b8af0e083..b7d42eb10 100644 --- a/README.md +++ b/README.md @@ -6373,7 +6373,35 @@ function quux() { } // Settings: {"jsdoc":{"allowEmptyNamepaths":false}} -// Message: Syntax error in type: +// Message: Tag @callback must have a namepath + +/** +* @constant {str%ng} +*/ +const FOO = 'foo'; +// Message: Syntax error in type: str%ng + +/** +* @typedef {str%ng} UserString +*/ +// Message: Syntax error in type: str%ng + +/** +* @typedef {string} UserStr%ng +*/ +// Message: Syntax error in type: UserStr%ng + +/** +* @extends +*/ +class Bar {}; +// Message: Tag @extends must have either a type or namepath + +/** +* @type +*/ +let foo; +// Message: Tag @type must have a type ```` The following patterns are not considered problems: @@ -6414,13 +6442,6 @@ function quux() { } -/** - * @see foo% - */ -function quux() { - -} - /** * @alias module:namespace.SomeClass#event:ext_anevent */ @@ -6429,7 +6450,7 @@ function quux() { } /** - * @callback + * @callback foo */ function quux() { @@ -6477,6 +6498,30 @@ function quux() { function quux() { } + +/** +* @constant {string} +*/ +const FOO = 'foo'; + +/** +* @extends Foo +*/ +class Bar {}; + +/** +* @extends {Foo} +*/ +class Bar {}; + +/** +* @typedef {number|string} UserDefinedType +*/ + +/** + * @typedef {number|string} + */ +let UserDefinedGCCType; ```` From ea3e05775259df18ce19ffe8e1918cdc520a38d7 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 21 Jul 2019 19:04:28 -0700 Subject: [PATCH 04/23] fix(require-example): add fixer for missing declaration (though can do nothing with missing description); fixes part of #336 --- .README/rules/require-example.md | 5 +++++ README.md | 6 ++++++ src/rules/requireExample.js | 16 +++++++++++++++- test/rules/assertions/requireExample.js | 10 +++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.README/rules/require-example.md b/.README/rules/require-example.md index e49cf0b0b..9e90b5133 100644 --- a/.README/rules/require-example.md +++ b/.README/rules/require-example.md @@ -26,6 +26,11 @@ Set this to an array of strings representing the AST context where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes). Overrides the default contexts (see below). +#### Fixer + +The fixer for `require-example` will add an empty `@example`, but it will still +report a missing example description after this is added. + ||| |---|---| |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled| diff --git a/README.md b/README.md index d99ad21b9..ffe930c19 100644 --- a/README.md +++ b/README.md @@ -4441,6 +4441,12 @@ Set this to an array of strings representing the AST context where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes). Overrides the default contexts (see below). + +#### Fixer + +The fixer for `require-example` will add an empty `@example`, but it will still +report a missing example description after this is added. + ||| |---|---| |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled| diff --git a/src/rules/requireExample.js b/src/rules/requireExample.js index 819ea695c..a710d244d 100644 --- a/src/rules/requireExample.js +++ b/src/rules/requireExample.js @@ -33,7 +33,20 @@ export default iterateJsdoc(({ } if (!functionExamples.length) { - report(`Missing JSDoc @${targetTagName} declaration.`); + utils.reportJSDoc(`Missing JSDoc @${targetTagName} declaration.`, null, () => { + if (!jsdoc.tags) { + jsdoc.tags = []; + } + const line = jsdoc.tags.length ? jsdoc.tags[jsdoc.tags.length - 1].line + 1 : 0; + jsdoc.tags.push({ + description: '', + line, + name: '', + optional: false, + tag: targetTagName, + type: '' + }); + }); return; } @@ -48,6 +61,7 @@ export default iterateJsdoc(({ }, { contextDefaults: true, meta: { + fixable: 'code', schema: [ { additionalProperties: false, diff --git a/test/rules/assertions/requireExample.js b/test/rules/assertions/requireExample.js index 45f7454c4..5f9c85493 100644 --- a/test/rules/assertions/requireExample.js +++ b/test/rules/assertions/requireExample.js @@ -13,7 +13,15 @@ export default { { message: 'Missing JSDoc @example declaration.' } - ] + ], + output: ` + /** + * @example + */ + function quux () { + + } + ` }, { code: ` From c8d06116f114809d96aa87e76ce8cadf719c232d Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 22 Jul 2019 16:39:24 -0700 Subject: [PATCH 05/23] fix(require-param): skip destructuring; fixes #352 (though still need to handle #11 ) --- README.md | 11 +++++++++++ src/rules/requireParam.js | 3 +++ test/rules/assertions/requireParam.js | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/README.md b/README.md index ffe930c19..6f2646cce 100644 --- a/README.md +++ b/README.md @@ -6237,6 +6237,17 @@ export class SomeClass { */ constructor(private property: string) {} } + +/** + * Assign the project to an employee. + * + * @param {object} employee - The employee who is responsible for the project. + * @param {string} employee.name - The name of the employee. + * @param {string} employee.department - The employee's department. + */ +function assign({name, department}) { + // ... +} ```` diff --git a/src/rules/requireParam.js b/src/rules/requireParam.js index 574ac8d5a..4291ccf78 100644 --- a/src/rules/requireParam.js +++ b/src/rules/requireParam.js @@ -21,6 +21,9 @@ export default iterateJsdoc(({ } functionParameterNames.forEach((functionParameterName) => { + if (['', ''].includes(functionParameterName)) { + return; + } if (!jsdocParameterNames.includes(functionParameterName)) { report(`Missing JSDoc @${utils.getPreferredTagName({tagName: 'param'})} "${functionParameterName}" declaration.`); } diff --git a/test/rules/assertions/requireParam.js b/test/rules/assertions/requireParam.js index a8294964d..2cb4b7d17 100644 --- a/test/rules/assertions/requireParam.js +++ b/test/rules/assertions/requireParam.js @@ -788,6 +788,20 @@ export default { parserOptions: { sourceType: 'module' } + }, + { + code: ` + /** + * Assign the project to an employee. + * + * @param {object} employee - The employee who is responsible for the project. + * @param {string} employee.name - The name of the employee. + * @param {string} employee.department - The employee's department. + */ + function assign({name, department}) { + // ... + } + ` } ] }; From 19a6590eaa2863faaa41d21977b220faa1c8464a Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Tue, 23 Jul 2019 22:18:37 +0900 Subject: [PATCH 06/23] feat: allow empty line between jsdoc and jscode (#353) feat(*): have doc block retrieval allow or require additional preceding empty lines via min/max line setting API --- README.md | 59 ++++++++++++ src/eslint/getJSDocComment.js | 8 +- src/iterateJsdoc.js | 14 ++- src/rules/requireJsdoc.js | 5 +- test/eslint/getJSDocComment.js | 4 +- test/rules/assertions/requireJsdoc.js | 125 ++++++++++++++++++++++++++ 6 files changed, 207 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6f2646cce..6ffbbb6d4 100644 --- a/README.md +++ b/README.md @@ -4757,6 +4757,32 @@ Accepts one optional options object with the following optional keys. The following patterns are considered problems: ````js +/** + * @func myFunction + */ +function myFunction() { + +} +// Settings: {"jsdoc":{"maxLines":3,"minLines":2}} +// Message: Missing JSDoc comment. + +/** + * @func myFunction + */ + + +function myFunction() { + +} +// Settings: {"jsdoc":{"maxLines":2}} +// Message: Missing JSDoc comment. + +/** @func myFunction */ function myFunction() { + +} +// Settings: {"jsdoc":{"minLines":1}} +// Message: Missing JSDoc comment. + export var test = function () { }; @@ -5181,6 +5207,39 @@ Object.keys(this.options.rules || {}).forEach(function(name) {}.bind(this)); var object = { name: 'key'}; Object.keys(object).forEach(function() {}) +/** + * @func myFunction + */ + +function myFunction() { + +} +// Settings: {"jsdoc":{"maxLines":2,"minLines":0}} + +/** + * @func myFunction + */ + + +function myFunction() { + +} +// Settings: {"jsdoc":{"maxLines":3,"minLines":0}} + +/** @func myFunction */ function myFunction() { + +} +// Settings: {"jsdoc":{"maxLines":0,"minLines":0}} + +/** + * @func myFunction + */ + +function myFunction() { + +} +// Settings: {"jsdoc":{"maxLines":3,"minLines":2}} + function myFunction() {} // Options: [{"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}] diff --git a/src/eslint/getJSDocComment.js b/src/eslint/getJSDocComment.js index 49fef7ca1..7e42875a2 100644 --- a/src/eslint/getJSDocComment.js +++ b/src/eslint/getJSDocComment.js @@ -32,12 +32,13 @@ const looksLikeExport = function (astNode) { * * @param {SourceCode} sourceCode The ESLint SourceCode * @param {ASTNode} node The AST node to get the comment for. + * @param {object} settings The settings in context * @returns {Token|null} The Block comment token containing the JSDoc comment * for the given node or null if not found. * @public * @deprecated */ -const getJSDocComment = function (sourceCode, node) { +const getJSDocComment = function (sourceCode, node, settings) { /** * Checks for the presence of a JSDoc comment for the given node and returns it. * @@ -48,13 +49,14 @@ const getJSDocComment = function (sourceCode, node) { */ const findJSDocComment = (astNode) => { const tokenBefore = sourceCode.getTokenBefore(astNode, {includeComments: true}); - + const {minLines, maxLines} = settings; if ( tokenBefore && isCommentToken(tokenBefore) && tokenBefore.type === 'Block' && tokenBefore.value.charAt(0) === '*' && - astNode.loc.start.line - tokenBefore.loc.end.line <= 1 + astNode.loc.start.line - tokenBefore.loc.end.line >= minLines && + astNode.loc.start.line - tokenBefore.loc.end.line <= maxLines ) { return tokenBefore; } diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index a76a5e61c..c4df79acc 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -78,7 +78,9 @@ const getUtils = ( tagNamePreference, overrideReplacesDocs, implementsReplacesDocs, - augmentsExtendsReplacesDocs + augmentsExtendsReplacesDocs, + maxLines, + minLines }, report, context @@ -263,7 +265,10 @@ const getUtils = ( utils.getClassJsdoc = () => { const classNode = utils.getClassNode(); - const classJsdocNode = getJSDocComment(sourceCode, classNode); + const classJsdocNode = getJSDocComment(sourceCode, classNode, { + maxLines, + minLines + }); if (classJsdocNode) { const indent = ' '.repeat(classJsdocNode.loc.start.column); @@ -319,6 +324,8 @@ const getSettings = (context) => { // All rules settings.ignorePrivate = Boolean(_.get(context, 'settings.jsdoc.ignorePrivate')); + settings.minLines = Number(_.get(context, 'settings.jsdoc.minLines', 0)); + settings.maxLines = Number(_.get(context, 'settings.jsdoc.maxLines', 1)); // `check-tag-names` and many returns/param rules settings.tagNamePreference = _.get(context, 'settings.jsdoc.tagNamePreference') || {}; @@ -435,6 +442,7 @@ const iterateAllJsdocs = (iterator, ruleConfig) => { }; export { + getSettings, parseComment }; @@ -478,7 +486,7 @@ export default function iterateJsdoc (iterator, ruleConfig) { const settings = getSettings(context); const checkJsdoc = (node) => { - const jsdocNode = getJSDocComment(sourceCode, node); + const jsdocNode = getJSDocComment(sourceCode, node, settings); if (!jsdocNode) { return; diff --git a/src/rules/requireJsdoc.js b/src/rules/requireJsdoc.js index e4b5ebbca..abc6c0b70 100644 --- a/src/rules/requireJsdoc.js +++ b/src/rules/requireJsdoc.js @@ -3,6 +3,7 @@ import jsdocUtils from '../jsdocUtils'; import exportParser from '../exportParser'; import getJSDocComment from '../eslint/getJSDocComment'; import warnRemovedSettings from '../warnRemovedSettings'; +import {getSettings} from '../iterateJsdoc'; const OPTIONS_SCHEMA = { additionalProperties: false, @@ -141,8 +142,10 @@ export default { const {require: requireOption, publicOnly, exemptEmptyFunctions} = getOptions(context); + const settings = getSettings(context); + const checkJsDoc = (node) => { - const jsDocNode = getJSDocComment(sourceCode, node); + const jsDocNode = getJSDocComment(sourceCode, node, settings); if (jsDocNode) { return; diff --git a/test/eslint/getJSDocComment.js b/test/eslint/getJSDocComment.js index 82f2f4150..98df2d135 100644 --- a/test/eslint/getJSDocComment.js +++ b/test/eslint/getJSDocComment.js @@ -2,6 +2,7 @@ import { RuleTester } from 'eslint'; import getJSDocComment from '../../src/eslint/getJSDocComment'; +import {getSettings} from '../../src/iterateJsdoc'; /* eslint-disable sort-keys */ const rule = { @@ -13,10 +14,11 @@ const rule = { }, create (context) { const sourceCode = context.getSourceCode(); + const settings = getSettings(context); return { ObjectExpression: (node) => { - const comment = getJSDocComment(sourceCode, node); + const comment = getJSDocComment(sourceCode, node, settings); if (comment !== null) { return; } diff --git a/test/rules/assertions/requireJsdoc.js b/test/rules/assertions/requireJsdoc.js index 5bdebb74a..a6d215573 100644 --- a/test/rules/assertions/requireJsdoc.js +++ b/test/rules/assertions/requireJsdoc.js @@ -4,6 +4,66 @@ export default { invalid: [ + { + code: ` + /** + * @func myFunction + */ + function myFunction() { + + } + `, + errors: [ + { + message: 'Missing JSDoc comment.' + } + ], + settings: { + jsdoc: { + maxLines: 3, + minLines: 2 + } + } + }, + { + code: ` + /** + * @func myFunction + */ + + + function myFunction() { + + } + `, + errors: [ + { + message: 'Missing JSDoc comment.' + } + ], + settings: { + jsdoc: { + maxLines: 2 + } + } + }, + { + code: ` + /** @func myFunction */ function myFunction() { + + } + `, + errors: [ + { + message: 'Missing JSDoc comment.' + } + ], + settings: { + jsdoc: { + minLines: 1 + } + } + }, { code: ` export var test = function () { @@ -1130,6 +1190,71 @@ export default { Object.keys(object).forEach(function() {}) ` }, + { + code: ` + /** + * @func myFunction + */ + + function myFunction() { + + } + `, + settings: { + jsdoc: { + maxLines: 2, + minLines: 0 + } + } + }, + { + code: ` + /** + * @func myFunction + */ + + + function myFunction() { + + } + `, + settings: { + jsdoc: { + maxLines: 3, + minLines: 0 + } + } + }, + { + code: ` + /** @func myFunction */ function myFunction() { + + } + `, + settings: { + jsdoc: { + maxLines: 0, + minLines: 0 + } + } + }, + { + code: ` + /** + * @func myFunction + */ + + function myFunction() { + + } + `, + settings: { + jsdoc: { + maxLines: 3, + minLines: 2 + } + } + }, { code: 'function myFunction() {}', options: [{ From 37e830008d388c473c8222e5ebe6f15ec4d39c1c Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Tue, 23 Jul 2019 14:29:31 -0700 Subject: [PATCH 07/23] fix(require-returns-check): check `WithStatement` for `return` statements --- README.md | 10 ++++++++++ src/jsdocUtils.js | 12 ++++++++++-- test/rules/assertions/requireReturnsCheck.js | 13 +++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6ffbbb6d4..876238b53 100644 --- a/README.md +++ b/README.md @@ -6622,6 +6622,16 @@ function quux () { } } +/** + * @returns {true} + */ +function quux () { + var a = {}; + with (a) { + return true; + } +} + /** * @returns {true} */ diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index 4ba3445a6..5faa8be36 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -276,7 +276,8 @@ const STATEMENTS_WITH_CHILDREN = [ 'SwitchStatement', 'IfStatement', 'BlockStatement', - 'TryStatement' + 'TryStatement', + 'WithStatement' ]; const RETURNFREE_STATEMENTS = [ @@ -288,7 +289,6 @@ const RETURNFREE_STATEMENTS = [ 'LabeledStatement', 'DebuggerStatement', 'EmptyStatement', - 'WithStatement', 'ThrowStatement', 'ExpressionStatement' ]; @@ -316,6 +316,14 @@ const lookupTable = { return true; } }, + WithStatement: { + is (node) { + return node.type === 'WithStatement'; + }, + check (node, context) { + return lookupTable.BlockStatement.check(node.body, context); + } + }, IfStatement: { is (node) { return node.type === 'IfStatement'; diff --git a/test/rules/assertions/requireReturnsCheck.js b/test/rules/assertions/requireReturnsCheck.js index b59d9fbec..cff5278a7 100755 --- a/test/rules/assertions/requireReturnsCheck.js +++ b/test/rules/assertions/requireReturnsCheck.js @@ -457,6 +457,19 @@ export default { } ` }, + { + code: ` + /** + * @returns {true} + */ + function quux () { + var a = {}; + with (a) { + return true; + } + } + ` + }, { code: ` /** From b48cf1d624f84ff9badefe29e1bd4043971f9238 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Tue, 23 Jul 2019 20:18:45 -0700 Subject: [PATCH 08/23] fix(require-jsdoc): add fixer to add empty jsdoc block --- README.md | 15 ++++-- src/iterateJsdoc.js | 4 +- src/jsdocUtils.js | 9 ++++ src/rules/requireJsdoc.js | 16 ++++++ test/rules/assertions/requireJsdoc.js | 71 +++++++++++++++++++++------ 5 files changed, 93 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 876238b53..142ba7cc8 100644 --- a/README.md +++ b/README.md @@ -4769,8 +4769,8 @@ function myFunction() { /** * @func myFunction */ - - + + function myFunction() { } @@ -4839,6 +4839,13 @@ function quux (foo) { // Options: [{"exemptEmptyFunctions":true}] // Message: Missing JSDoc comment. +function quux (foo) { + +} +// Settings: {"jsdoc":{"minLines":2}} +// Options: [{"exemptEmptyFunctions":true}] +// Message: Missing JSDoc comment. + function myFunction() {} // Message: Missing JSDoc comment. @@ -5231,10 +5238,10 @@ function myFunction() { } // Settings: {"jsdoc":{"maxLines":0,"minLines":0}} -/** +/** * @func myFunction */ - + function myFunction() { } diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index c4df79acc..ab14d88c7 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -91,9 +91,7 @@ const getUtils = ( const utils = {}; utils.stringify = (tagBlock) => { - let indent = sourceCode.text.match(/^\n*([ \t]+)/); - /* istanbul ignore next */ - indent = indent ? indent[1] + indent[1].charAt() : ' '; + const indent = jsdocUtils.getIndent(sourceCode); return commentStringify([tagBlock], {indent}).slice(indent.length - 1); }; diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index 5faa8be36..e31e1f6af 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -601,12 +601,21 @@ const getAncestor = (sourceCode, nde, depth, idx = 0) => { return null; }; +const getIndent = (sourceCode) => { + let indent = sourceCode.text.match(/^\n*([ \t]+)/); + /* istanbul ignore next */ + indent = indent ? indent[1] + indent[1].charAt() : ' '; + + return indent; +}; + export default { enforcedContexts, filterTags, getAncestor, getContextObject, getFunctionParameterNames, + getIndent, getJsdocParameterNames, getJsdocParameterNamesDeep, getPreferredTagName, diff --git a/src/rules/requireJsdoc.js b/src/rules/requireJsdoc.js index abc6c0b70..bf7ab2d40 100644 --- a/src/rules/requireJsdoc.js +++ b/src/rules/requireJsdoc.js @@ -125,6 +125,8 @@ export default { url: 'https://github.com/gajus/eslint-plugin-jsdoc' }, + fixable: 'code', + messages: { missingJsDoc: 'Missing JSDoc comment.' }, @@ -158,6 +160,18 @@ export default { } } + const fix = (fixer) => { + // Default to one line break if the `minLines`/`maxLines` settings allow + const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines; + const indent = jsdocUtils.getIndent(sourceCode); + const insertion = `/**\n${indent}*\n${indent}*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`; + const baseNode = [ + 'ExportDefaultDeclaration', 'ExportNamedDeclaration' + ].includes(node.parent && node.parent.type) ? node.parent : node; + + return fixer.insertTextBefore(baseNode, insertion); + }; + if (publicOnly) { const opt = { ancestorsOnly: Boolean(_.get(publicOnly, 'ancestorsOnly', false)), @@ -170,12 +184,14 @@ export default { if (exported && !jsDocNode) { context.report({ + fix, messageId: 'missingJsDoc', node }); } } else { context.report({ + fix, messageId: 'missingJsDoc', node }); diff --git a/test/rules/assertions/requireJsdoc.js b/test/rules/assertions/requireJsdoc.js index a6d215573..b10e0383a 100644 --- a/test/rules/assertions/requireJsdoc.js +++ b/test/rules/assertions/requireJsdoc.js @@ -10,7 +10,7 @@ export default { * @func myFunction */ function myFunction() { - + } `, errors: [ @@ -30,10 +30,10 @@ export default { /** * @func myFunction */ - - + + function myFunction() { - + } `, errors: [ @@ -50,7 +50,7 @@ export default { { code: ` /** @func myFunction */ function myFunction() { - + } `, errors: [ @@ -245,6 +245,12 @@ export default { ClassDeclaration: true } }], + output: ` + /** + * + */ + export default class {} + `, parserOptions: { sourceType: 'module' } @@ -288,7 +294,42 @@ export default { ], options: [ {exemptEmptyFunctions: true} - ] + ], + output: ` + /** + * + */ + function quux (foo) { + + }` + }, + { + code: ` + function quux (foo) { + + }`, + errors: [ + { + line: 2, + message: 'Missing JSDoc comment.' + } + ], + options: [ + {exemptEmptyFunctions: true} + ], + output: ` + /** + * + */ + + function quux (foo) { + + }`, + settings: { + jsdoc: { + minLines: 2 + } + } }, { code: 'function myFunction() {}', @@ -1195,9 +1236,9 @@ export default { /** * @func myFunction */ - + function myFunction() { - + } `, settings: { @@ -1212,10 +1253,10 @@ export default { /** * @func myFunction */ - - + + function myFunction() { - + } `, settings: { @@ -1228,7 +1269,7 @@ export default { { code: ` /** @func myFunction */ function myFunction() { - + } `, settings: { @@ -1240,12 +1281,12 @@ export default { }, { code: ` - /** + /** * @func myFunction */ - + function myFunction() { - + } `, settings: { From e456c50befc34220629e8b5017ff31897987ba0b Mon Sep 17 00:00:00 2001 From: golopot Date: Wed, 24 Jul 2019 14:33:23 +0800 Subject: [PATCH 09/23] docs(`require-returns-check`): update docs --- .README/rules/require-returns-check.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.README/rules/require-returns-check.md b/.README/rules/require-returns-check.md index f28a5a740..7fd00ba29 100644 --- a/.README/rules/require-returns-check.md +++ b/.README/rules/require-returns-check.md @@ -1,6 +1,6 @@ ### `require-returns-check` -Checks if the return expression exists in function body and in the comment. +Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment. Will also report if multiple `@returns` tags are present. diff --git a/README.md b/README.md index 142ba7cc8..dae0ded91 100644 --- a/README.md +++ b/README.md @@ -6320,7 +6320,7 @@ function assign({name, department}) { ### require-returns-check -Checks if the return expression exists in function body and in the comment. +Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment. Will also report if multiple `@returns` tags are present. From c3b56c6e0939b986307f34ceb19a8a9ba3fe786f Mon Sep 17 00:00:00 2001 From: Chiawen Chen Date: Thu, 25 Jul 2019 21:40:25 +0800 Subject: [PATCH 10/23] refactor(`require-returns`): simplify util.hasReturnValue --- README.md | 51 ++++ src/iterateJsdoc.js | 4 +- src/jsdocUtils.js | 278 ++++--------------- src/rules/requireReturns.js | 21 +- src/rules/requireReturnsCheck.js | 4 + test/rules/assertions/requireReturnsCheck.js | 71 +++++ 6 files changed, 198 insertions(+), 231 deletions(-) diff --git a/README.md b/README.md index dae0ded91..3afa00484 100644 --- a/README.md +++ b/README.md @@ -6394,6 +6394,20 @@ function quux () { } // Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}} // Message: Unexpected tag `@returns` + +/** + * @returns {string} + */ +function f () { + function g() { + return 'foo' + } + + () => { + return 5 + } +} +// Message: JSDoc @returns declaration present but return expression not available in function. ```` The following patterns are not considered problems: @@ -6610,6 +6624,43 @@ function quux () { return; } +/** + * @returns {true} + */ +function quux () { + for (const a in b) { + return true; + } +} + +/** + * @returns {true} + */ +function quux () { + for (let i=0; i { - return jsdocUtils.hasReturnValue(node, context, ignoreAsync); + utils.hasReturnValue = () => { + return jsdocUtils.hasReturnValue(node); }; utils.isAsync = () => { diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index e31e1f6af..3f4fb451c 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -269,237 +269,63 @@ const isTagWithMandatoryNamepathOrType = (tagName) => { return tagsWithMandatoryNamepathOrType.includes(tagName); }; -const LOOP_STATEMENTS = ['WhileStatement', 'DoWhileStatement', 'ForStatement', 'ForInStatement', 'ForOfStatement']; - -const STATEMENTS_WITH_CHILDREN = [ - '@loop', - 'SwitchStatement', - 'IfStatement', - 'BlockStatement', - 'TryStatement', - 'WithStatement' -]; - -const RETURNFREE_STATEMENTS = [ - 'VariableDeclaration', - 'ThrowStatement', - 'FunctionDeclaration', - 'BreakStatement', - 'ContinueStatement', - 'LabeledStatement', - 'DebuggerStatement', - 'EmptyStatement', - 'ThrowStatement', - 'ExpressionStatement' -]; - -const ENTRY_POINTS = ['FunctionDeclaration', 'ArrowFunctionExpression', 'FunctionExpression']; - -/* eslint-disable sort-keys */ -const lookupTable = { - ReturnStatement: { - is (node) { - return node.type === 'ReturnStatement'; - }, - check (node) { - /* istanbul ignore next */ - if (!lookupTable.ReturnStatement.is(node)) { - return false; - } - - // A return without any arguments just exits the function - // and is typically not documented at all in jsdoc. - if (node.argument === null) { - return false; - } - - return true; - } - }, - WithStatement: { - is (node) { - return node.type === 'WithStatement'; - }, - check (node, context) { - return lookupTable.BlockStatement.check(node.body, context); - } - }, - IfStatement: { - is (node) { - return node.type === 'IfStatement'; - }, - check (node) { - /* istanbul ignore next */ - if (!lookupTable.IfStatement.is(node)) { - return false; - } - - if (lookupTable['@default'].check(node.consequent)) { - return true; - } - - if (node.alternate && lookupTable['@default'].check(node.alternate)) { - return true; - } - - return false; - } - }, - '@loop': { - is (node) { - return LOOP_STATEMENTS.includes(node.type); - }, - check (node) { - return lookupTable['@default'].check(node.body); - } - }, - SwitchStatement: { - is (node) { - return node.type === 'SwitchStatement'; - }, - check (node) { - for (const item of node.cases) { - for (const statement of item.consequent) { - if (lookupTable['@default'].check(statement)) { - return true; - } - } - } - - return false; - } - }, - TryStatement: { - is (node) { - return node.type === 'TryStatement'; - }, - check (node) { - /* istanbul ignore next */ - if (!lookupTable.TryStatement.is(node)) { - return false; - } - - if (lookupTable.BlockStatement.check(node.block)) { - return true; - } - - if (node.handler && node.handler.body) { - if (lookupTable['@default'].check(node.handler.body)) { - return true; - } - } - if (lookupTable.BlockStatement.check(node.finalizer)) { - return true; - } - - return false; - } - }, - BlockStatement: { - is (node) { - return node.type === 'BlockStatement'; - }, - check (node, context) { - // E.g. the catch block statement is optional. - /* istanbul ignore next */ - if (typeof node === 'undefined' || node === null) { - return false; - } - - /* istanbul ignore next */ - if (!lookupTable.BlockStatement.is(node)) { - return false; - } - - for (const item of node.body) { - if (lookupTable['@default'].check(item, context)) { - return true; - } - } - - return false; - } - }, - FunctionExpression: { - is (node) { - return node.type === 'FunctionExpression'; - }, - check (node, context, ignoreAsync) { - return !ignoreAsync && node.async || lookupTable.BlockStatement.check(node.body, context); - } - }, - ArrowFunctionExpression: { - is (node) { - return node.type === 'ArrowFunctionExpression'; - }, - check (node, context, ignoreAsync) { - // An expression always has a return value. - return node.expression || - !ignoreAsync && node.async || - lookupTable.BlockStatement.check(node.body, context); - } - }, - FunctionDeclaration: { - is (node) { - return node.type === 'FunctionDeclaration'; - }, - check (node, context, ignoreAsync) { - return !ignoreAsync && node.async || lookupTable.BlockStatement.check(node.body, context); - } - }, - '@default': { - check (node, context) { - // In case it is a `ReturnStatement`, we found what we were looking for - if (lookupTable.ReturnStatement.is(node)) { - return lookupTable.ReturnStatement.check(node, context); - } - - // In case the element has children, we need to traverse them. - // Examples are BlockStatement, Choices, TryStatement, Loops, ... - for (const item of STATEMENTS_WITH_CHILDREN) { - if (lookupTable[item].is(node)) { - return lookupTable[item].check(node, context); - } - } - - // Everything else cannot return anything. - /* istanbul ignore next */ - if (RETURNFREE_STATEMENTS.includes(node.type)) { - return false; - } - - /* istanbul ignore next */ - // If we end up here, we stumbled upon an unknown element. - // Most likely it is enough to add it to the blacklist. - // - // throw new Error('Unknown node type: ' + node.type); - return false; - } - } -}; - /** - * Checks if the source code returns a return value. - * It traverses the parsed source code and returns as - * soon as it stumbles upon the first return statement. + * Checks if a node has a return statement. Void return does not count. * * @param {object} node - * the node which should be checked. - * @param {object} context - * @param {boolean} ignoreAsync - * ignore implicit async return. * @returns {boolean} - * true in case the code returns a return value */ -const hasReturnValue = (node, context, ignoreAsync) => { - // Loop through all of our entry points - for (const item of ENTRY_POINTS) { - if (lookupTable[item].is(node)) { - return lookupTable[item].check(node, context, ignoreAsync); +// eslint-disable-next-line complexity +const hasReturnValue = (node) => { + if (!node) { + return false; + } + switch (node.type) { + case 'FunctionExpression': + case 'FunctionDeclaration': + case 'ArrowFunctionExpression': { + return node.expression || hasReturnValue(node.body); + } + case 'BlockStatement': { + return node.body.some((bodyNode) => { + return bodyNode.type !== 'FunctionDeclaration' && hasReturnValue(bodyNode); + }); + } + case 'WhileStatement': + case 'DoWhileStatement': + case 'ForStatement': + case 'ForInStatement': + case 'ForOfStatement': + case 'WithStatement': { + return hasReturnValue(node.body); + } + case 'IfStatement': { + return hasReturnValue(node.consequent) || hasReturnValue(node.alternate); + } + case 'TryStatement': { + return hasReturnValue(node.block) || + hasReturnValue(node.handler && node.handler.body) || + hasReturnValue(node.finalizer); + } + case 'SwitchStatement': { + return node.cases.some( + (someCase) => { + return someCase.consequent.some(hasReturnValue); + } + ); + } + case 'ReturnStatement': { + // void return does not count. + if (node.argument === null) { + return false; } + + return true; + } + default: { + return false; + } } - /* istanbul ignore next */ - throw new Error(`Unknown element ${node.type}`); }; /** @param {string} tag */ @@ -584,8 +410,8 @@ const getTagsByType = (tags, tagPreference) => { }); return { - tagsWithoutNames, - tagsWithNames + tagsWithNames, + tagsWithoutNames }; }; diff --git a/src/rules/requireReturns.js b/src/rules/requireReturns.js index 6127f6134..10fde682c 100644 --- a/src/rules/requireReturns.js +++ b/src/rules/requireReturns.js @@ -72,9 +72,24 @@ export default iterateJsdoc(({ // In case the code returns something, we expect a return value in JSDoc. const [tag] = tags; const missingReturnTag = typeof tag === 'undefined' || tag === null; - if (missingReturnTag && - ((utils.isAsync() && !utils.hasReturnValue(true) ? forceReturnsWithAsync : utils.hasReturnValue()) || forceRequireReturn) - ) { + + const shouldReport = () => { + if (!missingReturnTag) { + return false; + } + + if (forceRequireReturn) { + return true; + } + + if (forceReturnsWithAsync && utils.isAsync() && !utils.hasReturnValue()) { + return true; + } + + return utils.hasReturnValue(); + }; + + if (shouldReport()) { report(`Missing JSDoc @${tagName} declaration.`); } }, { diff --git a/src/rules/requireReturnsCheck.js b/src/rules/requireReturnsCheck.js index 60aeee673..410745324 100755 --- a/src/rules/requireReturnsCheck.js +++ b/src/rules/requireReturnsCheck.js @@ -26,6 +26,10 @@ export default iterateJsdoc(({ return; } + if (utils.isAsync()) { + return; + } + const tagName = utils.getPreferredTagName({tagName: 'returns'}); if (!tagName) { return; diff --git a/test/rules/assertions/requireReturnsCheck.js b/test/rules/assertions/requireReturnsCheck.js index cff5278a7..0dcfa5a1a 100755 --- a/test/rules/assertions/requireReturnsCheck.js +++ b/test/rules/assertions/requireReturnsCheck.js @@ -128,6 +128,28 @@ export default { } } } + }, + { + code: ` + /** + * @returns {string} + */ + function f () { + function g() { + return 'foo' + } + + () => { + return 5 + } + } + `, + errors: [ + { + line: 2, + message: 'JSDoc @returns declaration present but return expression not available in function.' + } + ] } ], valid: [ @@ -432,6 +454,55 @@ export default { } ` }, + { + code: ` + /** + * @returns {true} + */ + function quux () { + for (const a in b) { + return true; + } + } + ` + }, + { + code: ` + /** + * @returns {true} + */ + function quux () { + for (let i=0; i Date: Mon, 29 Jul 2019 11:26:27 -0700 Subject: [PATCH 11/23] feat(`check-types`): Add `symbol` and `bigint` to native types (fixes #360) --- .README/rules/check-types.md | 2 ++ README.md | 2 ++ src/rules/checkTypes.js | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.README/rules/check-types.md b/.README/rules/check-types.md index 21e1d8c21..8752f3ff1 100644 --- a/.README/rules/check-types.md +++ b/.README/rules/check-types.md @@ -9,7 +9,9 @@ undefined null boolean number +bigint string +symbol object Array Function diff --git a/README.md b/README.md index 3afa00484..ae54e3d89 100644 --- a/README.md +++ b/README.md @@ -1565,7 +1565,9 @@ undefined null boolean number +bigint string +symbol object Array Function diff --git a/src/rules/checkTypes.js b/src/rules/checkTypes.js index 21a70f354..d75895952 100644 --- a/src/rules/checkTypes.js +++ b/src/rules/checkTypes.js @@ -7,7 +7,9 @@ const strictNativeTypes = [ 'null', 'boolean', 'number', + 'bigint', 'string', + 'symbol', 'object', 'Array', 'Function', From 982debb974d67580fb4c4c5943ba36369efdda12 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Wed, 7 Aug 2019 11:25:24 -0700 Subject: [PATCH 12/23] chore: update devDeps and apply `comma-dangle` linting rule --- package.json | 12 +- src/bin/generateReadme.js | 6 +- src/exportParser.js | 8 +- src/index.js | 10 +- src/iterateJsdoc.js | 44 +- src/jsdocUtils.js | 22 +- src/rules/checkAlignment.js | 8 +- src/rules/checkExamples.js | 48 +- src/rules/checkIndentation.js | 8 +- src/rules/checkParamNames.js | 6 +- src/rules/checkSyntax.js | 6 +- src/rules/checkTagNames.js | 18 +- src/rules/checkTypes.js | 26 +- src/rules/implementsOnClasses.js | 8 +- src/rules/matchDescription.js | 40 +- src/rules/newlineAfterDescription.js | 14 +- src/rules/noTypes.js | 6 +- src/rules/noUndefinedTypes.js | 18 +- src/rules/requireDescription.js | 26 +- .../requireDescriptionCompleteSentence.js | 20 +- src/rules/requireExample.js | 28 +- .../requireHyphenBeforeParamDescription.js | 10 +- src/rules/requireJsdoc.js | 66 +- src/rules/requireParam.js | 16 +- src/rules/requireParamDescription.js | 6 +- src/rules/requireParamName.js | 6 +- src/rules/requireParamType.js | 6 +- src/rules/requireReturns.js | 24 +- src/rules/requireReturnsCheck.js | 8 +- src/rules/requireReturnsDescription.js | 6 +- src/rules/requireReturnsType.js | 6 +- src/rules/validTypes.js | 18 +- src/tagNames.js | 34 +- src/warnRemovedSettings.js | 8 +- test/eslint/getJSDocComment.js | 18 +- test/iterateJsdoc.js | 8 +- test/jsdocUtils.js | 6 +- test/rules/assertions/checkAlignment.js | 54 +- test/rules/assertions/checkExamples.js | 292 +++--- test/rules/assertions/checkIndentation.js | 28 +- test/rules/assertions/checkParamNames.js | 116 +-- test/rules/assertions/checkSyntax.js | 16 +- test/rules/assertions/checkTagNames.js | 226 ++-- test/rules/assertions/checkTypes.js | 854 +++++++-------- test/rules/assertions/implementsOnClasses.js | 42 +- test/rules/assertions/jsdoc3Tags.js | 2 +- test/rules/assertions/matchDescription.js | 522 +++++----- .../assertions/newlineAfterDescription.js | 60 +- test/rules/assertions/noTypes.js | 20 +- test/rules/assertions/noUndefinedTypes.js | 178 ++-- test/rules/assertions/requireDescription.js | 244 ++--- .../requireDescriptionCompleteSentence.js | 240 ++--- test/rules/assertions/requireExample.js | 90 +- .../requireHyphenBeforeParamDescription.js | 66 +- test/rules/assertions/requireJsdoc.js | 974 +++++++++--------- test/rules/assertions/requireParam.js | 270 ++--- .../assertions/requireParamDescription.js | 40 +- test/rules/assertions/requireParamName.js | 34 +- test/rules/assertions/requireParamType.js | 40 +- test/rules/assertions/requireReturns.js | 242 ++--- test/rules/assertions/requireReturnsCheck.js | 142 +-- .../assertions/requireReturnsDescription.js | 44 +- test/rules/assertions/requireReturnsType.js | 44 +- test/rules/assertions/validTypes.js | 102 +- test/rules/index.js | 6 +- 65 files changed, 2813 insertions(+), 2803 deletions(-) diff --git a/package.json b/package.json index d32afe9b5..a17e2be9b 100644 --- a/package.json +++ b/package.json @@ -21,19 +21,19 @@ "@babel/plugin-transform-flow-strip-types": "^7.4.4", "@babel/preset-env": "^7.5.5", "@babel/register": "^7.5.5", - "@typescript-eslint/parser": "^1.12.0", + "@typescript-eslint/parser": "^1.13.0", "babel-eslint": "^10.0.2", "babel-plugin-add-module-exports": "^1.0.2", - "babel-plugin-istanbul": "^5.1.4", + "babel-plugin-istanbul": "^5.2.0", "chai": "^4.2.0", - "eslint": "^6.0.1", - "eslint-config-canonical": "^17.1.4", + "eslint": "^6.1.0", + "eslint-config-canonical": "^17.3.3", "gitdown": "^3.1.1", "glob": "^7.1.4", - "husky": "^3.0.1", + "husky": "^3.0.2", "mocha": "^6.2.0", "nyc": "^14.1.1", - "semantic-release": "^15.13.18", + "semantic-release": "^15.13.19", "typescript": "^3.5.3" }, "engines": { diff --git a/src/bin/generateReadme.js b/src/bin/generateReadme.js index 986d6336b..f285dd8f8 100644 --- a/src/bin/generateReadme.js +++ b/src/bin/generateReadme.js @@ -60,7 +60,7 @@ const getAssertions = () => { return { invalid: _.map(codes.invalid, formatCodeSnippet), - valid: _.map(codes.valid, formatCodeSnippet) + valid: _.map(codes.valid, formatCodeSnippet), }; }); @@ -81,8 +81,8 @@ const generateReadme = async () => { gitdown.setConfig({ gitinfo: { defaultBranchName: getSomeBranch() || 'master', - gitPath: path.join(__dirname, '../../.git') - } + gitPath: path.join(__dirname, '../../.git'), + }, }); let documentBody = await gitdown.get(); diff --git a/src/exportParser.js b/src/exportParser.js index 1af6debd9..4fa4fddbf 100644 --- a/src/exportParser.js +++ b/src/exportParser.js @@ -4,7 +4,7 @@ const debug = debugModule('requireExportJsdoc'); const createNode = function () { return { - props: {} + props: {}, }; }; @@ -392,7 +392,7 @@ const parse = function (ast, node, opt) { ancestorsOnly: false, esm: true, initModuleExports: true, - initWindow: true + initWindow: true, }; const globalVars = createNode(); @@ -414,7 +414,7 @@ const parse = function (ast, node, opt) { } return { - globalVars + globalVars, }; }; @@ -424,5 +424,5 @@ const isExported = function (node, parseResult, opt) { export default { isExported, - parse + parse, }; diff --git a/src/index.js b/src/index.js index 999238626..3ea820610 100644 --- a/src/index.js +++ b/src/index.js @@ -56,9 +56,9 @@ export default { 'jsdoc/require-returns-check': 'warn', 'jsdoc/require-returns-description': 'warn', 'jsdoc/require-returns-type': 'warn', - 'jsdoc/valid-types': 'warn' - } - } + 'jsdoc/valid-types': 'warn', + }, + }, }, rules: { 'check-alignment': checkAlignment, @@ -86,6 +86,6 @@ export default { 'require-returns-check': requireReturnsCheck, 'require-returns-description': requireReturnsDescription, 'require-returns-type': requireReturnsType, - 'valid-types': validTypes - } + 'valid-types': validTypes, + }, }; diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index d6d3fce4d..d2d12659f 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -55,18 +55,18 @@ const parseComment = (commentNode, indent, trim = true) => { if (result) { return { data: { - description: result[1] === undefined ? '' : result[1] + description: result[1] === undefined ? '' : result[1], }, - source: result[0] + source: result[0], }; } // Always has at least whitespace due to `indent` we've added /* istanbul ignore next */ return null; - } + }, ], - trim + trim, })[0] || {}; }; @@ -80,7 +80,7 @@ const getUtils = ( implementsReplacesDocs, augmentsExtendsReplacesDocs, maxLines, - minLines + minLines, }, report, context @@ -142,7 +142,7 @@ const getUtils = ( if (skipReportingBlockedTag) { return { blocked: true, - tagName + tagName, }; } const message = isObject && ret.message || defaultMessage; @@ -265,7 +265,7 @@ const getUtils = ( const classNode = utils.getClassNode(); const classJsdocNode = getJSDocComment(sourceCode, classNode, { maxLines, - minLines + minLines, }); if (classJsdocNode) { @@ -286,7 +286,7 @@ const getUtils = ( utils.forEachPreferredTag = (tagName, arrayHandler, skipReportingBlockedTag = false) => { const targetTagName = utils.getPreferredTagName({ skipReportingBlockedTag, - tagName + tagName, }); if (!targetTagName || skipReportingBlockedTag && targetTagName && typeof targetTagName === 'object' @@ -294,7 +294,7 @@ const getUtils = ( return; } const matchingJsdocTags = _.filter(jsdoc.tags || [], { - tag: targetTagName + tag: targetTagName, }); matchingJsdocTags.forEach((matchingJsdocTag) => { @@ -307,10 +307,10 @@ const getUtils = ( loc: { start: { column: 1, - line: 1 - } + line: 1, + }, }, - message + message, }); }; @@ -354,7 +354,7 @@ const makeReport = (context, commentNode) => { loc = { end: {line: lineNumber}, - start: {line: lineNumber} + start: {line: lineNumber}, }; if (jsdocLoc.column) { const colNumber = commentNode.loc.start.column + jsdocLoc.column; @@ -369,7 +369,7 @@ const makeReport = (context, commentNode) => { fix, loc, message, - node: commentNode + node: commentNode, }); }; @@ -429,19 +429,19 @@ const iterateAllJsdocs = (iterator, ruleConfig) => { report, settings, sourceCode, - utils: getUtils(null, jsdoc, jsdocNode, settings, report, context) + utils: getUtils(null, jsdoc, jsdocNode, settings, report, context), }); }); - } + }, }; }, - meta: ruleConfig.meta + meta: ruleConfig.meta, }; }; export { getSettings, - parseComment + parseComment, }; /** @@ -464,7 +464,7 @@ export default function iterateJsdoc (iterator, ruleConfig) { if (ruleConfig.iterateAllJsdocs) { return iterateAllJsdocs(iterator, { meta: ruleConfig.meta, - noTrim: ruleConfig.noTrim + noTrim: ruleConfig.noTrim, }); } @@ -521,7 +521,7 @@ export default function iterateJsdoc (iterator, ruleConfig) { report, settings, sourceCode, - utils + utils, }); }; @@ -534,9 +534,9 @@ export default function iterateJsdoc (iterator, ruleConfig) { return { ArrowFunctionExpression: checkJsdoc, FunctionDeclaration: checkJsdoc, - FunctionExpression: checkJsdoc + FunctionExpression: checkJsdoc, }; }, - meta: ruleConfig.meta + meta: ruleConfig.meta, }; } diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index 3f4fb451c..2b8662254 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -40,7 +40,7 @@ const getJsdocParameterNamesDeep = (jsdoc : Object, targetTagName : string) : Ar let jsdocParameterNames; jsdocParameterNames = _.filter(jsdoc.tags, { - tag: targetTagName + tag: targetTagName, }); jsdocParameterNames = _.map(jsdocParameterNames, 'name'); @@ -144,7 +144,7 @@ const namepathDefiningTags = [ 'interface', 'member', 'var', 'mixin', - 'namespace' + 'namespace', ]; const namepathPointingTags = [ @@ -163,7 +163,7 @@ const namepathPointingTags = [ // MAY BE USEFUL WITHOUT NAMEPATH 'emits', 'fires', - 'listens' + 'listens', ]; const isNamepathDefiningTag = (tagName) => { @@ -219,11 +219,11 @@ let tagsWithTypes = [ 'throws', 'type', 'typedef', - 'yields' + 'yields', ]; const closureTagsWithTypes = [ - 'package', 'private', 'protected', 'public', 'static' + 'package', 'private', 'protected', 'public', 'static', ]; const tagsWithTypesAliases = [ @@ -235,7 +235,7 @@ const tagsWithTypesAliases = [ 'prop', 'return', 'exception', - 'yield' + 'yield', ]; tagsWithTypes = tagsWithTypes.concat(tagsWithTypesAliases, closureTagsWithTypes); @@ -366,8 +366,8 @@ const enforcedContexts = (context, defaultContexts) => { contexts = defaultContexts === true ? [ 'ArrowFunctionExpression', 'FunctionDeclaration', - 'FunctionExpression' - ] : defaultContexts + 'FunctionExpression', + ] : defaultContexts, } = context.options[0] || {}; return contexts; @@ -393,7 +393,7 @@ const tagsWithNamesAndDescriptions = [ 'param', 'arg', 'argument', 'property', 'prop', // These two are parsed by our custom parser as though having a `name` - 'returns', 'return' + 'returns', 'return', ]; const getTagsByType = (tags, tagPreference) => { @@ -411,7 +411,7 @@ const getTagsByType = (tags, tagPreference) => { return { tagsWithNames, - tagsWithoutNames + tagsWithoutNames, }; }; @@ -457,5 +457,5 @@ export default { isTagWithMandatoryNamepathOrType, isTagWithType, isValidTag, - parseClosureTemplateTag + parseClosureTemplateTag, }; diff --git a/src/rules/checkAlignment.js b/src/rules/checkAlignment.js index 2b7b7db87..aa29c8f13 100644 --- a/src/rules/checkAlignment.js +++ b/src/rules/checkAlignment.js @@ -5,7 +5,7 @@ export default iterateJsdoc(({ sourceCode, jsdocNode, report, - indent + indent, }) => { // `indent` is whitespace from line 1 (`/**`), so slice and account for "/". const indentLevel = indent.length + 1; @@ -34,7 +34,7 @@ export default iterateJsdoc(({ sourceLines.some((line, lineNum) => { if (line.length !== indentLevel) { report('Expected JSDoc block to be aligned.', fix, { - line: lineNum + 1 + line: lineNum + 1, }); return true; @@ -46,6 +46,6 @@ export default iterateJsdoc(({ iterateAllJsdocs: true, meta: { fixable: 'code', - type: 'layout' - } + type: 'layout', + }, }); diff --git a/src/rules/checkExamples.js b/src/rules/checkExamples.js index 87ab72de7..f0f172480 100644 --- a/src/rules/checkExamples.js +++ b/src/rules/checkExamples.js @@ -17,13 +17,13 @@ const countChars = (str, ch) => { export default iterateJsdoc(({ report, utils, - context + context, }) => { warnRemovedSettings(context, 'check-examples'); const options = context.options[0] || {}; let { exampleCodeRegex = null, - rejectExampleCodeRegex = null + rejectExampleCodeRegex = null, } = options; const { noDefaultExampleRules = false, @@ -34,7 +34,7 @@ export default iterateJsdoc(({ configFile, allowInlineConfig = true, reportUnusedDisableDirectives = true, - captionRequired = false + captionRequired = false, } = options; // Make this configurable? @@ -64,7 +64,7 @@ export default iterateJsdoc(({ 'node/no-missing-require': 0, // Can generally look nicer to pad a little even if code imposes more stringency - 'padded-blocks': 0 + 'padded-blocks': 0, }; exampleCodeRegex = exampleCodeRegex && new RegExp(exampleCodeRegex, ''); @@ -146,7 +146,7 @@ export default iterateJsdoc(({ reportUnusedDisableDirectives, rulePaths, rules, - useEslintrc: eslintrcForExamples + useEslintrc: eslintrcForExamples, }); let messages; @@ -168,7 +168,7 @@ export default iterateJsdoc(({ reportUnusedDisableDirectives, rulePaths, rules, - useEslintrc: eslintrcForExamples + useEslintrc: eslintrcForExamples, }); const linter = new Linter(); @@ -196,7 +196,7 @@ export default iterateJsdoc(({ // Could also support `disableFixes` and `allowInlineConfig` messages = linter.verify(source, config, { filename, - reportUnusedDisableDirectives + reportUnusedDisableDirectives, }); } else { ({results: [{messages}]} = @@ -223,7 +223,7 @@ export default iterateJsdoc(({ null, { column: startCol, - line: startLine + line: startLine, } ); }); @@ -237,48 +237,48 @@ export default iterateJsdoc(({ properties: { allowInlineConfig: { default: true, - type: 'boolean' + type: 'boolean', }, baseConfig: { - type: 'object' + type: 'object', }, captionRequired: { default: false, - type: 'boolean' + type: 'boolean', }, configFile: { - type: 'string' + type: 'string', }, eslintrcForExamples: { default: true, - type: 'boolean' + type: 'boolean', }, exampleCodeRegex: { - type: 'string' + type: 'string', }, matchingFileName: { - type: 'string' + type: 'string', }, noDefaultExampleRules: { default: false, - type: 'boolean' + type: 'boolean', }, paddedIndent: { default: 0, - type: 'integer' + type: 'integer', }, rejectExampleCodeRegex: { - type: 'string' + type: 'string', }, reportUnusedDisableDirectives: { default: true, - type: 'boolean' - } + type: 'boolean', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' + type: 'suggestion', }, - noTrim: true + noTrim: true, }); diff --git a/src/rules/checkIndentation.js b/src/rules/checkIndentation.js index d0e2d2c98..13d6319c6 100644 --- a/src/rules/checkIndentation.js +++ b/src/rules/checkIndentation.js @@ -3,7 +3,7 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ sourceCode, jsdocNode, - report + report, }) => { const reg = new RegExp(/^(?:\/?\**|[ \t]*)\*[ \t]{2}/gm); const text = sourceCode.getText(jsdocNode); @@ -11,12 +11,12 @@ export default iterateJsdoc(({ if (reg.test(text)) { const lineBreaks = text.slice(0, reg.lastIndex).match(/\n/g) || []; report('There must be no indentation.', null, { - line: lineBreaks.length + line: lineBreaks.length, }); } }, { iterateAllJsdocs: true, meta: { - type: 'layout' - } + type: 'layout', + }, }); diff --git a/src/rules/checkParamNames.js b/src/rules/checkParamNames.js index 9f215e4f3..6247fa5dc 100644 --- a/src/rules/checkParamNames.js +++ b/src/rules/checkParamNames.js @@ -105,7 +105,7 @@ export default iterateJsdoc(({ jsdoc, jsdocNode, report, - utils + utils, }) => { const functionParameterNames = utils.getFunctionParameterNames(); const jsdocParameterNamesDeep = utils.getJsdocParameterNamesDeep(); @@ -123,6 +123,6 @@ export default iterateJsdoc(({ }, { meta: { fixable: 'code', - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/checkSyntax.js b/src/rules/checkSyntax.js index b42b9a9a3..6624f3ce8 100644 --- a/src/rules/checkSyntax.js +++ b/src/rules/checkSyntax.js @@ -2,7 +2,7 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ jsdoc, - report + report, }) => { if (!jsdoc.tags) { return; @@ -17,6 +17,6 @@ export default iterateJsdoc(({ }, { iterateAllJsdocs: true, meta: { - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/checkTagNames.js b/src/rules/checkTagNames.js index afa605930..11db457c1 100644 --- a/src/rules/checkTagNames.js +++ b/src/rules/checkTagNames.js @@ -8,7 +8,7 @@ export default iterateJsdoc(({ utils, context, settings, - jsdocNode + jsdocNode, }) => { if (!jsdoc.tags) { return; @@ -48,7 +48,7 @@ export default iterateJsdoc(({ let preferredTagName = utils.getPreferredTagName({ allowObjectReturn: true, defaultMessage: `Blacklisted tag found (\`@${tagName}\`)`, - tagName + tagName, }); let message = `Invalid JSDoc tag (preference). Replace "${tagName}" JSDoc tag with "${preferredTagName}".`; if (!preferredTagName) { @@ -82,14 +82,14 @@ export default iterateJsdoc(({ properties: { definedTags: { items: { - type: 'string' + type: 'string', }, - type: 'array' - } + type: 'array', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/checkTypes.js b/src/rules/checkTypes.js index d75895952..2f40654b5 100644 --- a/src/rules/checkTypes.js +++ b/src/rules/checkTypes.js @@ -14,7 +14,7 @@ const strictNativeTypes = [ 'Array', 'Function', 'Date', - 'RegExp' + 'RegExp', ]; export default iterateJsdoc(({ @@ -23,7 +23,7 @@ export default iterateJsdoc(({ report, utils, settings, - context + context, }) => { const jsdocTags = utils.filterTags((tag) => { return utils.isTagWithType(tag.tag); @@ -56,7 +56,7 @@ export default iterateJsdoc(({ [ ['.', 'ANGLE_BRACKET_WITH_DOT'], ['.<>', 'ANGLE_BRACKET_WITH_DOT'], - ['<>', 'ANGLE_BRACKET'] + ['<>', 'ANGLE_BRACKET'], ].some(([checkPostFix, syn]) => { isGenericMatch = _.get( preferredTypes, @@ -74,7 +74,7 @@ export default iterateJsdoc(({ ['[]', 'SQUARE_BRACKET'], ['.', 'ANGLE_BRACKET_WITH_DOT'], ['.<>', 'ANGLE_BRACKET_WITH_DOT'], - ['<>', 'ANGLE_BRACKET'] + ['<>', 'ANGLE_BRACKET'], ].some(([checkPostFix, syn]) => { isGenericMatch = _.get(preferredTypes, checkPostFix) !== undefined && syntax === syn; @@ -153,7 +153,7 @@ export default iterateJsdoc(({ invalidTypes.push([ nodeName, preferred, - _.get(preferredSetting, 'message') + _.get(preferredSetting, 'message'), ]); } else { utils.reportSettings( @@ -209,7 +209,7 @@ export default iterateJsdoc(({ jsdocTag, message ? { tagName, - tagValue + tagValue, } : null ); }); @@ -224,15 +224,15 @@ export default iterateJsdoc(({ additionalProperties: false, properties: { noDefaults: { - type: 'boolean' + type: 'boolean', }, unifyParentAndChildTypeChecks: { - type: 'boolean' - } + type: 'boolean', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/implementsOnClasses.js b/src/rules/implementsOnClasses.js index 2d41126df..917e0bd33 100644 --- a/src/rules/implementsOnClasses.js +++ b/src/rules/implementsOnClasses.js @@ -2,12 +2,12 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ report, - utils + utils, }) => { if ( utils.hasATag([ 'class', - 'constructor' + 'constructor', ]) || utils.isConstructor() ) { @@ -19,6 +19,6 @@ export default iterateJsdoc(({ }); }, { meta: { - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/matchDescription.js b/src/rules/matchDescription.js index 5d28e2002..78947efe6 100644 --- a/src/rules/matchDescription.js +++ b/src/rules/matchDescription.js @@ -15,7 +15,7 @@ export default iterateJsdoc(({ jsdoc, report, context, - utils + utils, }) => { const options = context.options[0] || {}; @@ -38,7 +38,7 @@ export default iterateJsdoc(({ if (!regex.test(description)) { report('JSDoc description does not satisfy the regex pattern.', null, tag || { // Add one as description would typically be into block - line: jsdoc.line + 1 + line: jsdoc.line + 1, }); } }; @@ -87,24 +87,24 @@ export default iterateJsdoc(({ properties: { contexts: { items: { - type: 'string' + type: 'string', }, - type: 'array' + type: 'array', }, mainDescription: { oneOf: [ { format: 'regex', - type: 'string' + type: 'string', }, { - type: 'boolean' - } - ] + type: 'boolean', + }, + ], }, matchDescription: { format: 'regex', - type: 'string' + type: 'string', }, tags: { patternProperties: { @@ -112,21 +112,21 @@ export default iterateJsdoc(({ oneOf: [ { format: 'regex', - type: 'string' + type: 'string', }, { enum: [true], - type: 'boolean' - } - ] - } + type: 'boolean', + }, + ], + }, }, - type: 'object' - } + type: 'object', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/newlineAfterDescription.js b/src/rules/newlineAfterDescription.js index e06471ea1..5aa4bdb4d 100644 --- a/src/rules/newlineAfterDescription.js +++ b/src/rules/newlineAfterDescription.js @@ -7,7 +7,7 @@ export default iterateJsdoc(({ context, jsdocNode, sourceCode, - indent + indent, }) => { let always; @@ -38,7 +38,7 @@ export default iterateJsdoc(({ return fixer.replaceText(jsdocNode, sourceLines.join('\n')); }, { - line: lastDescriptionLine + line: lastDescriptionLine, }); } } else if (descriptionEndsWithANewline) { @@ -52,7 +52,7 @@ export default iterateJsdoc(({ return fixer.replaceText(jsdocNode, sourceLines.join('\n')); }, { - line: lastDescriptionLine + 1 + line: lastDescriptionLine + 1, }); } }, { @@ -62,9 +62,9 @@ export default iterateJsdoc(({ schema: [ { enum: ['always', 'never'], - type: 'string' - } + type: 'string', + }, ], - type: 'layout' - } + type: 'layout', + }, }); diff --git a/src/rules/noTypes.js b/src/rules/noTypes.js index ed0cc1361..a46c13708 100644 --- a/src/rules/noTypes.js +++ b/src/rules/noTypes.js @@ -1,7 +1,7 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ - utils + utils, }) => { const tags = utils.getPresentTags(['param', 'arg', 'argument', 'returns', 'return']); @@ -15,6 +15,6 @@ export default iterateJsdoc(({ }, { meta: { fixable: true, - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/noUndefinedTypes.js b/src/rules/noUndefinedTypes.js index 860026915..f673d6d30 100644 --- a/src/rules/noUndefinedTypes.js +++ b/src/rules/noUndefinedTypes.js @@ -10,7 +10,7 @@ const extraTypes = [ 'function', 'number', 'NaN', 'Infinity', 'any', '*', - 'Array', 'Object', 'RegExp', 'Date', 'Function' + 'Array', 'Object', 'RegExp', 'Date', 'Function', ]; const stripPseudoTypes = (str) => { @@ -22,7 +22,7 @@ export default iterateJsdoc(({ report, settings, sourceCode: {scopeManager}, - utils + utils, }) => { const {globalScope} = scopeManager; @@ -140,14 +140,14 @@ export default iterateJsdoc(({ properties: { definedTypes: { items: { - type: 'string' + type: 'string', }, - type: 'array' - } + type: 'array', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireDescription.js b/src/rules/requireDescription.js index e60b77def..cb8fbf608 100644 --- a/src/rules/requireDescription.js +++ b/src/rules/requireDescription.js @@ -5,7 +5,7 @@ export default iterateJsdoc(({ jsdoc, report, utils, - context + context, }) => { if (utils.avoidDocs()) { return; @@ -18,7 +18,7 @@ export default iterateJsdoc(({ // even if the tag is present (and `check-tag-names` is the one to // normally report the fact that it is blocked but present) skipReportingBlockedTag: descriptionStyle !== 'tag', - tagName: 'description' + tagName: 'description', }); if (!targetTagName) { return; @@ -49,7 +49,7 @@ export default iterateJsdoc(({ const functionExamples = isBlocked ? [] : _.filter(jsdoc.tags, { - tag: targetTagName + tag: targetTagName, }); if (!functionExamples.length) { @@ -76,24 +76,24 @@ export default iterateJsdoc(({ properties: { contexts: { items: { - type: 'string' + type: 'string', }, - type: 'array' + type: 'array', }, descriptionStyle: { enum: ['body', 'tag', 'any'], - type: 'string' + type: 'string', }, exemptedBy: { items: { - type: 'string' + type: 'string', }, - type: 'array' - } + type: 'array', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireDescriptionCompleteSentence.js b/src/rules/requireDescriptionCompleteSentence.js index 770e9ea6e..3492e5721 100644 --- a/src/rules/requireDescriptionCompleteSentence.js +++ b/src/rules/requireDescriptionCompleteSentence.js @@ -125,11 +125,11 @@ export default iterateJsdoc(({ report, jsdocNode, context, - utils + utils, }) => { if (!jsdoc.tags || validateDescription(jsdoc.description, report, jsdocNode, sourceCode, { - line: jsdoc.line + 1 + line: jsdoc.line + 1, }) ) { return; @@ -153,7 +153,7 @@ export default iterateJsdoc(({ // sensitive text, and the latter may have just a link, they are not // included by default 'summary', 'file', 'fileoverview', 'overview', 'classdesc', 'todo', - 'deprecated', 'throws', 'exception', 'yields', 'yield' + 'deprecated', 'throws', 'exception', 'yields', 'yield', ].includes(tagName) || hasOptionTag(tagName) && !tagsWithNames.some(({tag}) => { // If user accidentally adds tags with names (or like `returns` @@ -183,14 +183,14 @@ export default iterateJsdoc(({ properties: { tags: { items: { - type: 'string' + type: 'string', }, - type: 'array' - } + type: 'array', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireExample.js b/src/rules/requireExample.js index a710d244d..84a5c64ed 100644 --- a/src/rules/requireExample.js +++ b/src/rules/requireExample.js @@ -6,7 +6,7 @@ export default iterateJsdoc(({ jsdoc, report, utils, - context + context, }) => { warnRemovedSettings(context, 'require-example'); @@ -19,13 +19,13 @@ export default iterateJsdoc(({ const targetTagName = 'example'; const functionExamples = _.filter(jsdoc.tags, { - tag: targetTagName + tag: targetTagName, }); if (avoidExampleOnConstructors && ( utils.hasATag([ 'class', - 'constructor' + 'constructor', ]) || utils.isConstructor() )) { @@ -44,7 +44,7 @@ export default iterateJsdoc(({ name: '', optional: false, tag: targetTagName, - type: '' + type: '', }); }); @@ -68,24 +68,24 @@ export default iterateJsdoc(({ properties: { avoidExampleOnConstructors: { default: false, - type: 'boolean' + type: 'boolean', }, contexts: { items: { - type: 'string' + type: 'string', }, - type: 'array' + type: 'array', }, exemptedBy: { items: { - type: 'string' + type: 'string', }, - type: 'array' - } + type: 'array', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireHyphenBeforeParamDescription.js b/src/rules/requireHyphenBeforeParamDescription.js index 751b2e645..f41247111 100644 --- a/src/rules/requireHyphenBeforeParamDescription.js +++ b/src/rules/requireHyphenBeforeParamDescription.js @@ -6,7 +6,7 @@ export default iterateJsdoc(({ utils, report, context, - jsdocNode + jsdocNode, }) => { let always; if (_.has(context.options, 0)) { @@ -57,9 +57,9 @@ export default iterateJsdoc(({ schema: [ { enum: ['always', 'never'], - type: 'string' - } + type: 'string', + }, ], - type: 'layout' - } + type: 'layout', + }, }); diff --git a/src/rules/requireJsdoc.js b/src/rules/requireJsdoc.js index bf7ab2d40..355b36b4c 100644 --- a/src/rules/requireJsdoc.js +++ b/src/rules/requireJsdoc.js @@ -10,40 +10,40 @@ const OPTIONS_SCHEMA = { properties: { contexts: { items: { - type: 'string' + type: 'string', }, - type: 'array' + type: 'array', }, exemptEmptyFunctions: { default: false, - type: 'boolean' + type: 'boolean', }, publicOnly: { oneOf: [ { default: false, - type: 'boolean' + type: 'boolean', }, { additionalProperties: false, default: {}, properties: { ancestorsOnly: { - type: 'boolean' + type: 'boolean', }, cjs: { - type: 'boolean' + type: 'boolean', }, esm: { - type: 'boolean' + type: 'boolean', }, window: { - type: 'boolean' - } + type: 'boolean', + }, }, - type: 'object' - } - ] + type: 'object', + }, + ], }, require: { additionalProperties: false, @@ -51,33 +51,33 @@ const OPTIONS_SCHEMA = { properties: { ArrowFunctionExpression: { default: false, - type: 'boolean' + type: 'boolean', }, ClassDeclaration: { default: false, - type: 'boolean' + type: 'boolean', }, ClassExpression: { default: false, - type: 'boolean' + type: 'boolean', }, FunctionDeclaration: { default: true, - type: 'boolean' + type: 'boolean', }, FunctionExpression: { default: false, - type: 'boolean' + type: 'boolean', }, MethodDefinition: { default: false, - type: 'boolean' - } + type: 'boolean', + }, }, - type: 'object' - } + type: 'object', + }, }, - type: 'object' + type: 'object', }; const getOption = (context, baseObject, option, key) => { @@ -111,7 +111,7 @@ const getOptions = (context) => { return obj; }, {}); - })(OPTIONS_SCHEMA.properties.require) + })(OPTIONS_SCHEMA.properties.require), }; }; @@ -122,20 +122,20 @@ export default { category: 'Stylistic Issues', description: 'Require JSDoc comments', recommended: 'true', - url: 'https://github.com/gajus/eslint-plugin-jsdoc' + url: 'https://github.com/gajus/eslint-plugin-jsdoc', }, fixable: 'code', messages: { - missingJsDoc: 'Missing JSDoc comment.' + missingJsDoc: 'Missing JSDoc comment.', }, schema: [ - OPTIONS_SCHEMA + OPTIONS_SCHEMA, ], - type: 'suggestion' + type: 'suggestion', }, create (context) { warnRemovedSettings(context, 'require-jsdoc'); @@ -166,7 +166,7 @@ export default { const indent = jsdocUtils.getIndent(sourceCode); const insertion = `/**\n${indent}*\n${indent}*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`; const baseNode = [ - 'ExportDefaultDeclaration', 'ExportNamedDeclaration' + 'ExportDefaultDeclaration', 'ExportNamedDeclaration', ].includes(node.parent && node.parent.type) ? node.parent : node; return fixer.insertTextBefore(baseNode, insertion); @@ -177,7 +177,7 @@ export default { ancestorsOnly: Boolean(_.get(publicOnly, 'ancestorsOnly', false)), esm: Boolean(_.get(publicOnly, 'esm', true)), initModuleExports: Boolean(_.get(publicOnly, 'cjs', true)), - initWindow: Boolean(_.get(publicOnly, 'window', false)) + initWindow: Boolean(_.get(publicOnly, 'window', false)), }; const parseResult = exportParser.parse(sourceCode.ast, node, opt); const exported = exportParser.isExported(node, parseResult, opt); @@ -186,14 +186,14 @@ export default { context.report({ fix, messageId: 'missingJsDoc', - node + node, }); } } else { context.report({ fix, messageId: 'missingJsDoc', - node + node, }); } }; @@ -254,8 +254,8 @@ export default { } else if (node.parent.type === 'Property' && node === node.parent.value) { checkJsDoc(node); } - } + }, } ); - } + }, }; diff --git a/src/rules/requireParam.js b/src/rules/requireParam.js index 4291ccf78..b5a73a5ac 100644 --- a/src/rules/requireParam.js +++ b/src/rules/requireParam.js @@ -3,7 +3,7 @@ import iterateJsdoc from '../iterateJsdoc'; // eslint-disable-next-line complexity export default iterateJsdoc(({ report, - utils + utils, }) => { const functionParameterNames = utils.getFunctionParameterNames(); const jsdocParameterNames = utils.getJsdocParameterNames(); @@ -36,14 +36,14 @@ export default iterateJsdoc(({ properties: { exemptedBy: { items: { - type: 'string' + type: 'string', }, - type: 'array' - } + type: 'array', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireParamDescription.js b/src/rules/requireParamDescription.js index 77fb8a5bb..03216d134 100644 --- a/src/rules/requireParamDescription.js +++ b/src/rules/requireParamDescription.js @@ -2,7 +2,7 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ report, - utils + utils, }) => { utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { if (!jsdocParameter.description) { @@ -15,6 +15,6 @@ export default iterateJsdoc(({ }); }, { meta: { - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireParamName.js b/src/rules/requireParamName.js index ba1af0638..ff2ce76e5 100644 --- a/src/rules/requireParamName.js +++ b/src/rules/requireParamName.js @@ -2,7 +2,7 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ report, - utils + utils, }) => { utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { if (jsdocParameter.tag && jsdocParameter.name === '') { @@ -15,6 +15,6 @@ export default iterateJsdoc(({ }); }, { meta: { - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireParamType.js b/src/rules/requireParamType.js index 93d1e9169..402afe181 100644 --- a/src/rules/requireParamType.js +++ b/src/rules/requireParamType.js @@ -2,7 +2,7 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ report, - utils + utils, }) => { utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => { if (!jsdocParameter.type) { @@ -15,6 +15,6 @@ export default iterateJsdoc(({ }); }, { meta: { - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireReturns.js b/src/rules/requireReturns.js index 10fde682c..265d70780 100644 --- a/src/rules/requireReturns.js +++ b/src/rules/requireReturns.js @@ -31,7 +31,7 @@ const canSkip = (utils) => { 'type', // This seems to imply a class as well - 'interface' + 'interface', ]) || utils.isConstructor() || @@ -44,7 +44,7 @@ const canSkip = (utils) => { export default iterateJsdoc(({ report, utils, - context + context, }) => { warnRemovedSettings(context, 'require-returns'); @@ -56,7 +56,7 @@ export default iterateJsdoc(({ const { forceRequireReturn = false, - forceReturnsWithAsync = false + forceReturnsWithAsync = false, } = context.options[0] || {}; const tagName = utils.getPreferredTagName({tagName: 'returns'}); @@ -100,22 +100,22 @@ export default iterateJsdoc(({ properties: { exemptedBy: { items: { - type: 'string' + type: 'string', }, - type: 'array' + type: 'array', }, forceRequireReturn: { default: false, - type: 'boolean' + type: 'boolean', }, forceReturnsWithAsync: { default: false, - type: 'boolean' - } + type: 'boolean', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireReturnsCheck.js b/src/rules/requireReturnsCheck.js index 410745324..da454eaab 100755 --- a/src/rules/requireReturnsCheck.js +++ b/src/rules/requireReturnsCheck.js @@ -14,13 +14,13 @@ const canSkip = (utils) => { // tag indicating this but no explicit return 'class', 'constructor', - 'interface' + 'interface', ]) || utils.isConstructor() || utils.classHasTag('interface'); }; export default iterateJsdoc(({ report, - utils + utils, }) => { if (canSkip(utils)) { return; @@ -52,6 +52,6 @@ export default iterateJsdoc(({ } }, { meta: { - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireReturnsDescription.js b/src/rules/requireReturnsDescription.js index 536a9c6cf..20306da8c 100644 --- a/src/rules/requireReturnsDescription.js +++ b/src/rules/requireReturnsDescription.js @@ -2,7 +2,7 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ report, - utils + utils, }) => { utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => { const type = jsdocTag.type && jsdocTag.type.trim(); @@ -17,6 +17,6 @@ export default iterateJsdoc(({ }); }, { meta: { - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/requireReturnsType.js b/src/rules/requireReturnsType.js index d6fda6a48..b3e064505 100644 --- a/src/rules/requireReturnsType.js +++ b/src/rules/requireReturnsType.js @@ -2,7 +2,7 @@ import iterateJsdoc from '../iterateJsdoc'; export default iterateJsdoc(({ report, - utils + utils, }) => { utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => { if (!jsdocTag.type) { @@ -11,6 +11,6 @@ export default iterateJsdoc(({ }); }, { meta: { - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index bb1869b11..de113654b 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -8,13 +8,13 @@ export default iterateJsdoc(({ jsdoc, report, utils, - context + context, }) => { warnRemovedSettings(context, 'valid-types'); const { allowEmptyNamepaths = true, - checkSeesForNamepaths = false + checkSeesForNamepaths = false, } = context.options[0] || {}; if (!jsdoc.tags) { @@ -114,16 +114,16 @@ export default iterateJsdoc(({ properties: { allowEmptyNamepaths: { default: true, - type: 'boolean' + type: 'boolean', }, checkSeesForNamepaths: { default: false, - type: 'boolean' - } + type: 'boolean', + }, }, - type: 'object' - } + type: 'object', + }, ], - type: 'suggestion' - } + type: 'suggestion', + }, }); diff --git a/src/tagNames.js b/src/tagNames.js index fa99c5a64..055819ac0 100644 --- a/src/tagNames.js +++ b/src/tagNames.js @@ -1,49 +1,49 @@ export default { abstract: [ - 'virtual' + 'virtual', ], access: [], alias: [], async: [], augments: [ - 'extends' + 'extends', ], author: [], borrows: [], callback: [], class: [ - 'constructor' + 'constructor', ], classdesc: [], constant: [ - 'const' + 'const', ], constructs: [], copyright: [], default: [ - 'defaultvalue' + 'defaultvalue', ], deprecated: [], description: [ - 'desc' + 'desc', ], enum: [], event: [], example: [], exports: [], external: [ - 'host' + 'host', ], file: [ 'fileoverview', - 'overview' + 'overview', ], fires: [ - 'emits' + 'emits', ], function: [ 'func', - 'method' + 'method', ], generator: [], global: [], @@ -59,7 +59,7 @@ export default { license: [], listens: [], member: [ - 'var' + 'var', ], memberof: [], 'memberof!': [], @@ -72,18 +72,18 @@ export default { package: [], param: [ 'arg', - 'argument' + 'argument', ], private: [], property: [ - 'prop' + 'prop', ], protected: [], public: [], readonly: [], requires: [], returns: [ - 'return' + 'return', ], see: [], since: [], @@ -99,7 +99,7 @@ export default { this: [], throws: [ - 'exception' + 'exception', ], todo: [], tutorial: [], @@ -108,6 +108,6 @@ export default { variation: [], version: [], yields: [ - 'yield' - ] + 'yield', + ], }; diff --git a/src/warnRemovedSettings.js b/src/warnRemovedSettings.js index 833cf98e1..a97333784 100644 --- a/src/warnRemovedSettings.js +++ b/src/warnRemovedSettings.js @@ -64,7 +64,7 @@ const getMovedSettings = (ruleName) => { 'configFile', 'eslintrcForExamples', 'baseConfig', - 'reportUnusedDisableDirectives' + 'reportUnusedDisableDirectives', ]; } @@ -92,11 +92,11 @@ export default function warnRemovedSettings (context, ruleName) { loc: { start: { column: 1, - line: 1 - } + line: 1, + }, }, message: `\`settings.jsdoc.${setting}\` has been removed, ` + - `use options in the rule \`${ruleName}\` instead.` + `use options in the rule \`${ruleName}\` instead.`, }); markSettingAsWarned(context, setting); } diff --git a/test/eslint/getJSDocComment.js b/test/eslint/getJSDocComment.js index 98df2d135..93ed74ffd 100644 --- a/test/eslint/getJSDocComment.js +++ b/test/eslint/getJSDocComment.js @@ -1,5 +1,5 @@ import { - RuleTester + RuleTester, } from 'eslint'; import getJSDocComment from '../../src/eslint/getJSDocComment'; import {getSettings} from '../../src/iterateJsdoc'; @@ -8,9 +8,9 @@ import {getSettings} from '../../src/iterateJsdoc'; const rule = { meta: { messages: { - missingJsDoc: 'Missing JSDoc comment.' + missingJsDoc: 'Missing JSDoc comment.', }, - type: 'layout' + type: 'layout', }, create (context) { const sourceCode = context.getSourceCode(); @@ -24,11 +24,11 @@ const rule = { } context.report({ messageId: 'missingJsDoc', - node + node, }); - } + }, }; - } + }, }; const ruleTester = new RuleTester(); @@ -36,12 +36,12 @@ const ruleTester = new RuleTester(); ruleTester.run('getJSDocComment', rule, { invalid: [{ code: 'var a = {};', - errors: [{messageId: 'missingJsDoc'}] + errors: [{messageId: 'missingJsDoc'}], }], valid: [{ code: ` /** Doc */ var a = {}; - ` - }] + `, + }], }); diff --git a/test/iterateJsdoc.js b/test/iterateJsdoc.js index 40124828b..4d3362f00 100644 --- a/test/iterateJsdoc.js +++ b/test/iterateJsdoc.js @@ -1,7 +1,7 @@ /* eslint-disable max-nested-callbacks */ import { - expect + expect, } from 'chai'; // eslint-disable-next-line import/no-named-default import {parseComment, default as iterateJsdoc} from '../src/iterateJsdoc'; @@ -73,9 +73,9 @@ describe('iterateJsdoc', () => { optional: false, source: '@param {MyType} name desc', tag: 'param', - type: 'MyType' - } - ] + type: 'MyType', + }, + ], }); }); }); diff --git a/test/jsdocUtils.js b/test/jsdocUtils.js index 30119f25c..dc3849ac2 100644 --- a/test/jsdocUtils.js +++ b/test/jsdocUtils.js @@ -1,7 +1,7 @@ /* eslint-disable max-nested-callbacks */ import { - expect + expect, } from 'chai'; import jsdocUtils from '../src/jsdocUtils'; @@ -51,8 +51,8 @@ describe('jsdocUtils', () => { expect(() => { jsdocUtils.getFunctionParameterNames({params: [ { - type: 'AssignmentPattern' - } + type: 'AssignmentPattern', + }, ]}); }).to.throw('Unsupported function signature format.'); }); diff --git a/test/rules/assertions/checkAlignment.js b/test/rules/assertions/checkAlignment.js index 73c22e145..e232a6758 100644 --- a/test/rules/assertions/checkAlignment.js +++ b/test/rules/assertions/checkAlignment.js @@ -12,8 +12,8 @@ export default { errors: [ { line: 3, - message: 'Expected JSDoc block to be aligned.' - } + message: 'Expected JSDoc block to be aligned.', + }, ], output: ` /** @@ -22,7 +22,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -36,8 +36,8 @@ export default { errors: [ { line: 4, - message: 'Expected JSDoc block to be aligned.' - } + message: 'Expected JSDoc block to be aligned.', + }, ], output: ` /** @@ -46,7 +46,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -60,8 +60,8 @@ export default { errors: [ { line: 3, - message: 'Expected JSDoc block to be aligned.' - } + message: 'Expected JSDoc block to be aligned.', + }, ], output: ` /** @@ -70,7 +70,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -84,8 +84,8 @@ export default { errors: [ { line: 4, - message: 'Expected JSDoc block to be aligned.' - } + message: 'Expected JSDoc block to be aligned.', + }, ], output: ` /** @@ -94,7 +94,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -108,8 +108,8 @@ export default { errors: [ { line: 3, - message: 'Expected JSDoc block to be aligned.' - } + message: 'Expected JSDoc block to be aligned.', + }, ], output: ` /** @@ -118,7 +118,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -129,9 +129,9 @@ export default { errors: [ { line: 3, - message: 'Expected JSDoc block to be aligned.' - } - ] + message: 'Expected JSDoc block to be aligned.', + }, + ], }, { code: ` @@ -146,10 +146,10 @@ export default { errors: [ { line: 5, - message: 'Expected JSDoc block to be aligned.' - } - ] - } + message: 'Expected JSDoc block to be aligned.', + }, + ], + }, ], valid: [ { @@ -162,7 +162,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -178,7 +178,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -186,7 +186,7 @@ export default { * So this is unchecked. */ function quux (foo) {} - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/checkExamples.js b/test/rules/assertions/checkExamples.js index b6bef81a0..def086362 100644 --- a/test/rules/assertions/checkExamples.js +++ b/test/rules/assertions/checkExamples.js @@ -13,21 +13,21 @@ export default { `, errors: [ { - message: '@example error (no-alert): Unexpected alert.' + message: '@example error (no-alert): Unexpected alert.', }, { - message: '@example error (semi): Missing semicolon.' - } + message: '@example error (semi): Missing semicolon.', + }, ], options: [{ baseConfig: { rules: { 'no-alert': 2, - semi: ['error', 'always'] - } + semi: ['error', 'always'], + }, }, - eslintrcForExamples: false - }] + eslintrcForExamples: false, + }], }, { code: ` @@ -40,21 +40,21 @@ export default { `, errors: [ { - message: '@example error (no-alert): Unexpected alert.' + message: '@example error (no-alert): Unexpected alert.', }, { - message: '@example error (semi): Missing semicolon.' - } + message: '@example error (semi): Missing semicolon.', + }, ], options: [{ baseConfig: { rules: { 'no-alert': 2, - semi: ['error', 'always'] - } + semi: ['error', 'always'], + }, }, - eslintrcForExamples: false - }] + eslintrcForExamples: false, + }], }, { code: ` @@ -69,18 +69,18 @@ export default { `, errors: [ { - message: '@example error (semi): Extra semicolon.' - } + message: '@example error (semi): Extra semicolon.', + }, ], options: [{ baseConfig: { rules: { - semi: ['error', 'never'] - } + semi: ['error', 'never'], + }, }, eslintrcForExamples: false, - exampleCodeRegex: '```js([\\s\\S]*)```' - }] + exampleCodeRegex: '```js([\\s\\S]*)```', + }], }, { code: ` @@ -95,18 +95,18 @@ export default { `, errors: [ { - message: '@example error (semi): Extra semicolon.' - } + message: '@example error (semi): Extra semicolon.', + }, ], options: [{ baseConfig: { rules: { - semi: ['error', 'never'] - } + semi: ['error', 'never'], + }, }, eslintrcForExamples: false, - exampleCodeRegex: '```js ([\\s\\S]*)```' - }] + exampleCodeRegex: '```js ([\\s\\S]*)```', + }], }, { code: ` @@ -120,18 +120,18 @@ export default { `, errors: [ { - message: '@example error (semi): Extra semicolon.' - } + message: '@example error (semi): Extra semicolon.', + }, ], options: [{ baseConfig: { rules: { - semi: ['error', 'never'] - } + semi: ['error', 'never'], + }, }, eslintrcForExamples: false, - exampleCodeRegex: '```js ([\\s\\S]*)```' - }] + exampleCodeRegex: '```js ([\\s\\S]*)```', + }], }, { code: ` @@ -145,18 +145,18 @@ export default { `, errors: [ { - message: '@example error (semi): Extra semicolon.' - } + message: '@example error (semi): Extra semicolon.', + }, ], options: [{ baseConfig: { rules: { - semi: ['error', 'never'] - } + semi: ['error', 'never'], + }, }, eslintrcForExamples: false, - exampleCodeRegex: '```\njs ([\\s\\S]*)```' - }] + exampleCodeRegex: '```\njs ([\\s\\S]*)```', + }], }, { code: ` @@ -175,18 +175,18 @@ export default { `, errors: [ { - message: '@example error (semi): Extra semicolon.' - } + message: '@example error (semi): Extra semicolon.', + }, ], options: [{ baseConfig: { rules: { - semi: ['error', 'never'] - } + semi: ['error', 'never'], + }, }, eslintrcForExamples: false, - rejectExampleCodeRegex: '^\\s*<.*>\\s*$' - }] + rejectExampleCodeRegex: '^\\s*<.*>\\s*$', + }], }, { code: ` @@ -200,18 +200,18 @@ export default { `, errors: [ { - message: '@example error (no-undef): \'quux\' is not defined.' - } + message: '@example error (no-undef): \'quux\' is not defined.', + }, ], options: [{ baseConfig: { rules: { - 'no-undef': ['error'] - } + 'no-undef': ['error'], + }, }, eslintrcForExamples: false, - noDefaultExampleRules: true - }] + noDefaultExampleRules: true, + }], }, { code: ` @@ -228,13 +228,13 @@ export default { `, errors: [ { - message: 'Caption is expected for examples.' - } + message: 'Caption is expected for examples.', + }, ], options: [{ captionRequired: true, - eslintrcForExamples: false - }] + eslintrcForExamples: false, + }], }, { code: ` @@ -247,18 +247,18 @@ export default { `, errors: [ { - message: '@example error (indent): Expected indentation of 0 spaces but found 1.' - } + message: '@example error (indent): Expected indentation of 0 spaces but found 1.', + }, ], options: [{ baseConfig: { rules: { - indent: ['error'] - } + indent: ['error'], + }, }, eslintrcForExamples: false, - noDefaultExampleRules: false - }] + noDefaultExampleRules: false, + }], }, { code: ` @@ -269,14 +269,14 @@ export default { `, errors: [ { - message: '@example error: Unused eslint-disable directive (no problems were reported from \'semi\').' - } + message: '@example error: Unused eslint-disable directive (no problems were reported from \'semi\').', + }, ], options: [{ eslintrcForExamples: false, noDefaultExampleRules: true, - reportUnusedDisableDirectives: true - }] + reportUnusedDisableDirectives: true, + }], }, { code: ` @@ -288,19 +288,19 @@ export default { `, errors: [ { - message: '@example error (semi): Missing semicolon.' - } + message: '@example error (semi): Missing semicolon.', + }, ], options: [{ allowInlineConfig: false, baseConfig: { rules: { - semi: ['error', 'always'] - } + semi: ['error', 'always'], + }, }, eslintrcForExamples: false, - noDefaultExampleRules: true - }] + noDefaultExampleRules: true, + }], }, { code: ` @@ -314,15 +314,15 @@ export default { `, errors: [ { - message: '@example warning (id-length): Identifier name \'i\' is too short (< 2).' + message: '@example warning (id-length): Identifier name \'i\' is too short (< 2).', }, { - message: '@example error (semi): Missing semicolon.' - } + message: '@example error (semi): Missing semicolon.', + }, ], options: [{ - matchingFileName: 'test/jsdocUtils.js' - }] + matchingFileName: 'test/jsdocUtils.js', + }], }, { code: ` @@ -336,17 +336,17 @@ export default { `, errors: [ { - message: '@example warning (id-length): Identifier name \'i\' is too short (< 2).' + message: '@example warning (id-length): Identifier name \'i\' is too short (< 2).', }, { - message: '@example error (semi): Missing semicolon.' - } + message: '@example error (semi): Missing semicolon.', + }, ], options: [ { - paddedIndent: 2 - } - ] + paddedIndent: 2, + }, + ], }, { code: ` @@ -361,12 +361,12 @@ export default { `, errors: [ { - message: '@example warning (id-length): Identifier name \'i\' is too short (< 2).' + message: '@example warning (id-length): Identifier name \'i\' is too short (< 2).', }, { - message: '@example error (semi): Missing semicolon.' - } - ] + message: '@example error (semi): Missing semicolon.', + }, + ], }, { code: ` @@ -380,12 +380,12 @@ export default { `, errors: [ { - message: '@example error (semi): Missing semicolon.' - } + message: '@example error (semi): Missing semicolon.', + }, ], options: [{ - matchingFileName: 'test/rules/data/dummy.js' - }] + matchingFileName: 'test/rules/data/dummy.js', + }], }, { code: ` @@ -400,19 +400,19 @@ export default { `, errors: [ { - message: '@example warning (semi): Missing semicolon.' - } + message: '@example warning (semi): Missing semicolon.', + }, ], options: [{ baseConfig: { rules: { - semi: ['warn', 'always'] - } + semi: ['warn', 'always'], + }, }, eslintrcForExamples: false, exampleCodeRegex: '// begin[\\s\\S]*// end', - noDefaultExampleRules: true - }] + noDefaultExampleRules: true, + }], }, { code: ` @@ -425,35 +425,35 @@ export default { `, errors: [ { - message: '`settings.jsdoc.captionRequired` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.captionRequired` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.exampleCodeRegex` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.exampleCodeRegex` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.rejectExampleCodeRegex` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.rejectExampleCodeRegex` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.allowInlineConfig` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.allowInlineConfig` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.noDefaultExampleRules` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.noDefaultExampleRules` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.matchingFileName` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.matchingFileName` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.configFile` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.configFile` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.eslintrcForExamples` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.eslintrcForExamples` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.baseConfig` has been removed, use options in the rule `check-examples` instead.' + message: '`settings.jsdoc.baseConfig` has been removed, use options in the rule `check-examples` instead.', }, { - message: '`settings.jsdoc.reportUnusedDisableDirectives` has been removed, use options in the rule `check-examples` instead.' - } + message: '`settings.jsdoc.reportUnusedDisableDirectives` has been removed, use options in the rule `check-examples` instead.', + }, ], settings: { jsdoc: { @@ -466,9 +466,9 @@ export default { matchingFileName: 'test.md', noDefaultExampleRules: false, rejectExampleCodeRegex: '\\W*', - reportUnusedDisableDirectives: true - } - } + reportUnusedDisableDirectives: true, + }, + }, }, { code: ` @@ -480,14 +480,14 @@ export default { `, errors: [ { - message: 'Caption is expected for examples.' - } + message: 'Caption is expected for examples.', + }, ], options: [{ captionRequired: true, - eslintrcForExamples: false - }] - } + eslintrcForExamples: false, + }], + }, ], valid: [ { @@ -504,12 +504,12 @@ export default { options: [{ baseConfig: { rules: { - semi: ['error', 'always'] - } + semi: ['error', 'always'], + }, }, eslintrcForExamples: false, - exampleCodeRegex: '```js([\\s\\S]*)```' - }] + exampleCodeRegex: '```js([\\s\\S]*)```', + }], }, { code: ` @@ -522,8 +522,8 @@ export default { } `, options: [{ - eslintrcForExamples: false - }] + eslintrcForExamples: false, + }], }, { code: ` @@ -538,12 +538,12 @@ export default { options: [{ baseConfig: { rules: { - 'no-undef': ['error'] - } + 'no-undef': ['error'], + }, }, eslintrcForExamples: false, - noDefaultExampleRules: false - }] + noDefaultExampleRules: false, + }], }, { code: ` @@ -557,12 +557,12 @@ export default { options: [{ baseConfig: { rules: { - indent: ['error'] - } + indent: ['error'], + }, }, eslintrcForExamples: false, - noDefaultExampleRules: false - }] + noDefaultExampleRules: false, + }], }, { code: ` @@ -579,8 +579,8 @@ export default { `, options: [{ captionRequired: true, - eslintrcForExamples: false - }] + eslintrcForExamples: false, + }], }, { code: ` @@ -592,8 +592,8 @@ export default { options: [{ eslintrcForExamples: false, noDefaultExampleRules: true, - reportUnusedDisableDirectives: false - }] + reportUnusedDisableDirectives: false, + }], }, { code: ` @@ -607,12 +607,12 @@ export default { allowInlineConfig: true, baseConfig: { rules: { - semi: ['error', 'always'] - } + semi: ['error', 'always'], + }, }, eslintrcForExamples: false, - noDefaultExampleRules: true - }] + noDefaultExampleRules: true, + }], }, { code: ` @@ -628,12 +628,12 @@ export default { options: [{ baseConfig: { rules: { - semi: ['error', 'never'] - } + semi: ['error', 'never'], + }, }, eslintrcForExamples: false, - exampleCodeRegex: '```js([\\s\\S]*)```' - }] + exampleCodeRegex: '```js([\\s\\S]*)```', + }], }, { code: ` @@ -648,12 +648,12 @@ export default { options: [{ baseConfig: { rules: { - indent: ['error'] - } + indent: ['error'], + }, }, eslintrcForExamples: false, - noDefaultExampleRules: false - }] - } - ] + noDefaultExampleRules: false, + }], + }, + ], }; diff --git a/test/rules/assertions/checkIndentation.js b/test/rules/assertions/checkIndentation.js index 6ab824361..8738f9c25 100644 --- a/test/rules/assertions/checkIndentation.js +++ b/test/rules/assertions/checkIndentation.js @@ -10,9 +10,9 @@ export default { errors: [ { line: 2, - message: 'There must be no indentation.' - } - ] + message: 'There must be no indentation.', + }, + ], }, { code: ` @@ -29,9 +29,9 @@ export default { errors: [ { line: 6, - message: 'There must be no indentation.' - } - ] + message: 'There must be no indentation.', + }, + ], }, { code: ` @@ -44,10 +44,10 @@ export default { errors: [ { line: 4, - message: 'There must be no indentation.' - } - ] - } + message: 'There must be no indentation.', + }, + ], + }, ], valid: [ { @@ -61,7 +61,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -69,7 +69,7 @@ export default { function quux () { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/checkParamNames.js b/test/rules/assertions/checkParamNames.js index dec6914a5..9c3ad07d0 100644 --- a/test/rules/assertions/checkParamNames.js +++ b/test/rules/assertions/checkParamNames.js @@ -18,9 +18,9 @@ export default { errors: [ { line: 3, - message: 'Expected @param names to be "foo". Got "Foo".' - } - ] + message: 'Expected @param names to be "foo". Got "Foo".', + }, + ], }, { code: ` @@ -34,16 +34,16 @@ export default { errors: [ { line: 3, - message: 'Expected @arg names to be "foo". Got "Foo".' - } + message: 'Expected @arg names to be "foo". Got "Foo".', + }, ], settings: { jsdoc: { tagNamePreference: { - param: 'arg' - } - } - } + param: 'arg', + }, + }, + }, }, { code: ` @@ -57,9 +57,9 @@ export default { errors: [ { line: 3, - message: 'Expected @param names to be "foo". Got "Foo".' - } - ] + message: 'Expected @param names to be "foo". Got "Foo".', + }, + ], }, { code: ` @@ -73,9 +73,9 @@ export default { errors: [ { line: 3, - message: '@param path declaration ("Foo.Bar") appears before any real parameter.' - } - ] + message: '@param path declaration ("Foo.Bar") appears before any real parameter.', + }, + ], }, { code: ` @@ -90,9 +90,9 @@ export default { errors: [ { line: 4, - message: '@param path declaration ("Foo.Bar") root node name ("Foo") does not match previous real parameter name ("foo").' - } - ] + message: '@param path declaration ("Foo.Bar") root node name ("Foo") does not match previous real parameter name ("foo").', + }, + ], }, { code: ` @@ -108,9 +108,9 @@ export default { errors: [ { line: 3, - message: 'Expected @param names to be "bar, foo". Got "foo, bar".' - } - ] + message: 'Expected @param names to be "bar, foo". Got "foo, bar".', + }, + ], }, { code: ` @@ -125,9 +125,9 @@ export default { errors: [ { line: 4, - message: '@param "bar" does not match an existing function parameter.' - } - ] + message: '@param "bar" does not match an existing function parameter.', + }, + ], }, { code: ` @@ -142,8 +142,8 @@ export default { errors: [ { line: 4, - message: 'Duplicate @param "foo"' - } + message: 'Duplicate @param "foo"', + }, ], output: ` /** @@ -152,7 +152,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -167,9 +167,9 @@ export default { errors: [ { line: 4, - message: 'Duplicate @param "foo"' - } - ] + message: 'Duplicate @param "foo"', + }, + ], }, { code: ` @@ -184,9 +184,9 @@ export default { errors: [ { line: 4, - message: 'Duplicate @param "foo"' - } - ] + message: 'Duplicate @param "foo"', + }, + ], }, { code: ` @@ -200,13 +200,13 @@ export default { errors: [ { line: 4, - message: 'Expected @param names to be "property". Got "prop".' - } + message: 'Expected @param names to be "property". Got "prop".', + }, ], parser: require.resolve('@typescript-eslint/parser'), parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -220,17 +220,17 @@ export default { errors: [ { line: 3, - message: 'Unexpected tag `@param`' - } + message: 'Unexpected tag `@param`', + }, ], settings: { jsdoc: { tagNamePreference: { - param: false - } - } - } - } + param: false, + }, + }, + }, + }, ], valid: [ { @@ -241,7 +241,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -251,7 +251,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -262,7 +262,7 @@ export default { function quux (foo, bar) { } - ` + `, }, { code: ` @@ -273,7 +273,7 @@ export default { function quux (foo, bar, baz) { } - ` + `, }, { code: ` @@ -285,7 +285,7 @@ export default { function quux (foo, bar) { } - ` + `, }, { code: ` @@ -295,7 +295,7 @@ export default { function quux (...args) { } - ` + `, }, { code: ` @@ -305,7 +305,7 @@ export default { function quux ({a, b}) { } - ` + `, }, { code: ` @@ -315,7 +315,7 @@ export default { function quux ({a, b} = {}) { } - ` + `, }, { code: ` @@ -325,7 +325,7 @@ export default { function quux ([a, b] = []) { } - ` + `, }, { code: ` @@ -338,7 +338,7 @@ export default { function assign (employees) { }; - ` + `, }, { code: ` @@ -351,8 +351,8 @@ export default { `, parser: require.resolve('@typescript-eslint/parser'), parserOptions: { - sourceType: 'module' - } - } - ] + sourceType: 'module', + }, + }, + ], }; diff --git a/test/rules/assertions/checkSyntax.js b/test/rules/assertions/checkSyntax.js index 87df4514e..9ce6719b8 100644 --- a/test/rules/assertions/checkSyntax.js +++ b/test/rules/assertions/checkSyntax.js @@ -12,10 +12,10 @@ export default { errors: [ { line: 3, - message: 'Syntax should not be Google Closure Compiler style.' - } - ] - } + message: 'Syntax should not be Google Closure Compiler style.', + }, + ], + }, ], valid: [ { @@ -26,7 +26,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -36,7 +36,7 @@ export default { function quux (foo) { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/checkTagNames.js b/test/rules/assertions/checkTagNames.js index fb09222e0..a4cac6ed9 100644 --- a/test/rules/assertions/checkTagNames.js +++ b/test/rules/assertions/checkTagNames.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 2, - message: 'Invalid JSDoc tag name "typoo".' - } - ] + message: 'Invalid JSDoc tag name "typoo".', + }, + ], }, { code: ` @@ -28,9 +28,9 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag name "Param".' - } - ] + message: 'Invalid JSDoc tag name "Param".', + }, + ], }, { code: ` @@ -44,9 +44,9 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag name "foo".' - } - ] + message: 'Invalid JSDoc tag name "foo".', + }, + ], }, { code: ` @@ -60,9 +60,9 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "param".' - } - ] + message: 'Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "param".', + }, + ], }, { code: ` @@ -76,16 +76,16 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "arg".' - } + message: 'Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "arg".', + }, ], settings: { jsdoc: { tagNamePreference: { - param: 'arg' - } - } - } + param: 'arg', + }, + }, + }, }, { code: ` @@ -99,16 +99,16 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "somethingDifferent".' - } + message: 'Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "somethingDifferent".', + }, ], settings: { jsdoc: { tagNamePreference: { - arg: 'somethingDifferent' - } - } - } + arg: 'somethingDifferent', + }, + }, + }, }, { code: ` @@ -122,16 +122,16 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "parameter".' - } + message: 'Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "parameter".', + }, ], settings: { jsdoc: { tagNamePreference: { - param: 'parameter' - } - } - } + param: 'parameter', + }, + }, + }, }, { code: ` @@ -145,9 +145,9 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag name "bar".' - } - ] + message: 'Invalid JSDoc tag name "bar".', + }, + ], }, { code: ` @@ -161,12 +161,12 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag name "baz".' - } + message: 'Invalid JSDoc tag name "baz".', + }, ], options: [{ - definedTags: ['bar'] - }] + definedTags: ['bar'], + }], }, { code: ` @@ -181,12 +181,12 @@ export default { errors: [ { line: 4, - message: 'Invalid JSDoc tag name "baz".' - } + message: 'Invalid JSDoc tag name "baz".', + }, ], options: [{ - definedTags: ['bar'] - }] + definedTags: ['bar'], + }], }, { code: ` @@ -199,16 +199,16 @@ export default { `, errors: [ { - message: 'Blacklisted tag found (`@todo`)' - } + message: 'Blacklisted tag found (`@todo`)', + }, ], settings: { jsdoc: { tagNamePreference: { - todo: false - } - } - } + todo: false, + }, + }, + }, }, { code: ` @@ -221,18 +221,18 @@ export default { `, errors: [ { - message: 'Please resolve to-dos or add to the tracker' - } + message: 'Please resolve to-dos or add to the tracker', + }, ], settings: { jsdoc: { tagNamePreference: { todo: { - message: 'Please resolve to-dos or add to the tracker' - } - } - } - } + message: 'Please resolve to-dos or add to the tracker', + }, + }, + }, + }, }, { code: ` @@ -245,19 +245,19 @@ export default { `, errors: [ { - message: 'Please use x-todo instead of todo' - } + message: 'Please use x-todo instead of todo', + }, ], settings: { jsdoc: { tagNamePreference: { todo: { message: 'Please use x-todo instead of todo', - replacement: 'x-todo' - } - } - } - } + replacement: 'x-todo', + }, + }, + }, + }, }, { code: ` @@ -270,19 +270,19 @@ export default { `, errors: [ { - message: 'Please use x-todo instead of todo' - } + message: 'Please use x-todo instead of todo', + }, ], settings: { jsdoc: { tagNamePreference: { todo: { message: 'Please use x-todo instead of todo', - replacement: 'x-todo' - } - } - } - } + replacement: 'x-todo', + }, + }, + }, + }, }, { code: ` @@ -296,19 +296,19 @@ export default { errors: [ { line: 1, - message: 'Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.' + message: 'Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.', }, { - message: 'Invalid JSDoc tag (preference). Replace "todo" JSDoc tag with "55".' - } + message: 'Invalid JSDoc tag (preference). Replace "todo" JSDoc tag with "55".', + }, ], settings: { jsdoc: { tagNamePreference: { - todo: 55 - } - } - } + todo: 55, + }, + }, + }, }, { code: ` @@ -323,8 +323,8 @@ export default { errors: [ { line: 4, - message: 'Invalid JSDoc tag (preference). Replace "prop" JSDoc tag with "property".' - } + message: 'Invalid JSDoc tag (preference). Replace "prop" JSDoc tag with "property".', + }, ], output: ` /** @@ -334,7 +334,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -349,13 +349,13 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".' - } + message: 'Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".', + }, ], options: [ { - definedTags: ['abcd'] - } + definedTags: ['abcd'], + }, ], output: ` /** @@ -369,10 +369,10 @@ export default { settings: { jsdoc: { tagNamePreference: { - abc: 'abcd' - } - } - } + abc: 'abcd', + }, + }, + }, }, { code: ` @@ -387,8 +387,8 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".' - } + message: 'Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".', + }, ], output: ` /** @@ -402,11 +402,11 @@ export default { settings: { jsdoc: { tagNamePreference: { - abc: 'abcd' - } - } - } - } + abc: 'abcd', + }, + }, + }, + }, ], valid: [ { @@ -417,7 +417,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -427,7 +427,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -441,10 +441,10 @@ export default { settings: { jsdoc: { tagNamePreference: { - param: 'arg' - } - } - } + param: 'arg', + }, + }, + }, }, { code: ` @@ -456,8 +456,8 @@ export default { } `, options: [{ - definedTags: ['bar'] - }] + definedTags: ['bar'], + }], }, { code: ` @@ -469,8 +469,8 @@ export default { } `, options: [{ - definedTags: ['baz', 'bar'] - }] + definedTags: ['baz', 'bar'], + }], }, { code: ` @@ -487,15 +487,15 @@ export default { param: 'baz', returns: { message: 'Prefer `bar`', - replacement: 'bar' + replacement: 'bar', }, - todo: false - } - } - } + todo: false, + }, + }, + }, }, { - code: `${ALL_JSDOC_TAGS_COMMENT}\nfunction quux (foo) {}` + code: `${ALL_JSDOC_TAGS_COMMENT}\nfunction quux (foo) {}`, }, { code: ` @@ -505,7 +505,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -515,7 +515,7 @@ export default { function quux () { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/checkTypes.js b/test/rules/assertions/checkTypes.js index a7836c575..3e91f4aa5 100644 --- a/test/rules/assertions/checkTypes.js +++ b/test/rules/assertions/checkTypes.js @@ -12,16 +12,16 @@ export default { errors: [ { line: 1, - message: 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.' - } + message: 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.', + }, ], settings: { jsdoc: { preferredTypes: { - abc: 100 - } - } - } + abc: 100, + }, + }, + }, }, { code: ` @@ -35,8 +35,8 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "Number"; prefer: "number".' - } + message: 'Invalid JSDoc @param "foo" type "Number"; prefer: "number".', + }, ], output: ` /** @@ -45,7 +45,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -59,8 +59,8 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @arg "foo" type "Number"; prefer: "number".' - } + message: 'Invalid JSDoc @arg "foo" type "Number"; prefer: "number".', + }, ], output: ` /** @@ -69,7 +69,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -84,13 +84,13 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @returns type "Number"; prefer: "number".' + message: 'Invalid JSDoc @returns type "Number"; prefer: "number".', }, { line: 4, - message: 'Invalid JSDoc @throws type "Number"; prefer: "number".' - } - ] + message: 'Invalid JSDoc @throws type "Number"; prefer: "number".', + }, + ], }, { code: ` @@ -104,12 +104,12 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "Number"; prefer: "number".' + message: 'Invalid JSDoc @param "foo" type "Number"; prefer: "number".', }, { line: 3, - message: 'Invalid JSDoc @param "foo" type "Boolean"; prefer: "boolean".' - } + message: 'Invalid JSDoc @param "foo" type "Boolean"; prefer: "boolean".', + }, ], output: ` /** @@ -118,7 +118,7 @@ export default { function quux (foo, bar, baz) { } - ` + `, }, { code: ` @@ -132,12 +132,12 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "Number"; prefer: "number".' + message: 'Invalid JSDoc @param "foo" type "Number"; prefer: "number".', }, { line: 3, - message: 'Invalid JSDoc @param "foo" type "String"; prefer: "string".' - } + message: 'Invalid JSDoc @param "foo" type "String"; prefer: "string".', + }, ], output: ` /** @@ -146,7 +146,7 @@ export default { function quux (foo, bar, baz) { } - ` + `, }, { code: ` @@ -160,12 +160,12 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "Number"; prefer: "number".' + message: 'Invalid JSDoc @param "foo" type "Number"; prefer: "number".', }, { line: 3, - message: 'Invalid JSDoc @param "foo" type "String"; prefer: "string".' - } + message: 'Invalid JSDoc @param "foo" type "String"; prefer: "string".', + }, ], output: ` /** @@ -174,7 +174,7 @@ export default { function quux (foo, bar, baz) { } - ` + `, }, { code: ` @@ -187,8 +187,8 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".' - } + message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".', + }, ], output: ` /** @@ -201,10 +201,10 @@ export default { jsdoc: { preferredTypes: { abc: 'Abc', - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -217,8 +217,8 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".' - } + message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".', + }, ], output: ` /** @@ -231,12 +231,12 @@ export default { jsdoc: { preferredTypes: { abc: { - replacement: 'Abc' + replacement: 'Abc', }, - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -249,8 +249,8 @@ export default { errors: [ { line: 3, - message: 'Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".' - } + message: 'Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".', + }, ], output: ` /** @@ -264,12 +264,12 @@ export default { preferredTypes: { abc: { message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc"; prefer: "Abc".', - replacement: 'Abc' + replacement: 'Abc', }, - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -284,32 +284,32 @@ export default { errors: [ { line: 3, - message: 'Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".' + message: 'Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".', }, { line: 4, - message: 'More messed up JSDoc @param "bar" type "cde"; prefer: "Cde".' + message: 'More messed up JSDoc @param "bar" type "cde"; prefer: "Cde".', }, { line: 5, - message: 'Invalid JSDoc @param "baz" type "object"; prefer: "Object".' - } + message: 'Invalid JSDoc @param "baz" type "object"; prefer: "Object".', + }, ], settings: { jsdoc: { preferredTypes: { abc: { message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc"; prefer: "Abc".', - replacement: 'Abc' + replacement: 'Abc', }, cde: { message: 'More messed up JSDoc @{{tagName}}{{tagValue}} type "cde"; prefer: "Cde".', - replacement: 'Cde' + replacement: 'Cde', }, - object: 'Object' - } - } - } + object: 'Object', + }, + }, + }, }, { code: ` @@ -322,20 +322,20 @@ export default { errors: [ { line: 3, - message: 'Messed up JSDoc @param "foo" type "abc".' - } + message: 'Messed up JSDoc @param "foo" type "abc".', + }, ], settings: { jsdoc: { preferredTypes: { abc: { message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc".', - replacement: false + replacement: false, }, - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -348,19 +348,19 @@ export default { errors: [ { line: 3, - message: 'Messed up JSDoc @param "foo" type "abc".' - } + message: 'Messed up JSDoc @param "foo" type "abc".', + }, ], settings: { jsdoc: { preferredTypes: { abc: { - message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc".' + message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc".', }, - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -374,11 +374,11 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".' - } + message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".', + }, ], options: [{ - noDefaults: true + noDefaults: true, }], output: ` /** @@ -392,10 +392,10 @@ export default { jsdoc: { preferredTypes: { abc: 'Abc', - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -409,21 +409,21 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".' + message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".', }, { line: 4, - message: 'Invalid JSDoc @param "bar" type "Number"; prefer: "number".' - } + message: 'Invalid JSDoc @param "bar" type "Number"; prefer: "number".', + }, ], settings: { jsdoc: { preferredTypes: { abc: 'Abc', - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -436,17 +436,17 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "abc".' - } + message: 'Invalid JSDoc @param "foo" type "abc".', + }, ], settings: { jsdoc: { preferredTypes: { abc: false, - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -459,16 +459,16 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "abc".' - } + message: 'Invalid JSDoc @param "foo" type "abc".', + }, ], settings: { jsdoc: { preferredTypes: { - abc: false - } - } - } + abc: false, + }, + }, + }, }, { code: ` @@ -481,8 +481,8 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "baz" type "*".' - } + message: 'Invalid JSDoc @param "baz" type "*".', + }, ], output: ` /** @@ -496,10 +496,10 @@ export default { preferredTypes: { '*': false, abc: 'Abc', - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -512,8 +512,8 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "baz" type "*"; prefer: "aaa".' - } + message: 'Invalid JSDoc @param "baz" type "*"; prefer: "aaa".', + }, ], output: ` /** @@ -527,10 +527,10 @@ export default { preferredTypes: { '*': 'aaa', abc: 'Abc', - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -544,12 +544,12 @@ export default { errors: [ { line: 3, - message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".' + message: 'Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".', }, { line: 4, - message: 'Invalid JSDoc @param "bar" type "Number"; prefer: "number".' - } + message: 'Invalid JSDoc @param "bar" type "Number"; prefer: "number".', + }, ], output: ` /** @@ -563,10 +563,10 @@ export default { jsdoc: { preferredTypes: { abc: 'Abc', - string: 'Str' - } - } - } + string: 'Str', + }, + }, + }, }, { code: ` @@ -579,8 +579,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".', + }, ], output: ` /** @@ -593,10 +593,10 @@ export default { settings: { jsdoc: { preferredTypes: { - Array: 'GenericArray' - } - } - } + Array: 'GenericArray', + }, + }, + }, }, { code: ` @@ -609,8 +609,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".', + }, ], output: ` /** @@ -624,10 +624,10 @@ export default { jsdoc: { preferredTypes: { Array: 'GenericArray', - 'Array.<>': 'GenericArray' - } - } - } + 'Array.<>': 'GenericArray', + }, + }, + }, }, { code: ` @@ -640,8 +640,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".', + }, ], output: ` /** @@ -654,10 +654,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'Array.<>': 'GenericArray' - } - } - } + 'Array.<>': 'GenericArray', + }, + }, + }, }, { code: ` @@ -670,8 +670,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".', + }, ], output: ` /** @@ -684,10 +684,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'Array<>': 'GenericArray' - } - } - } + 'Array<>': 'GenericArray', + }, + }, + }, }, { code: ` @@ -700,8 +700,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".' - } + message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".', + }, ], output: ` /** @@ -714,10 +714,10 @@ export default { settings: { jsdoc: { preferredTypes: { - '[]': 'SpecialTypeArray' - } - } - } + '[]': 'SpecialTypeArray', + }, + }, + }, }, { code: ` @@ -730,11 +730,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".' - } + message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], output: ` /** @@ -747,10 +747,10 @@ export default { settings: { jsdoc: { preferredTypes: { - '[]': 'SpecialTypeArray' - } - } - } + '[]': 'SpecialTypeArray', + }, + }, + }, }, { code: ` @@ -763,11 +763,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "SpecialTypeArray".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "SpecialTypeArray".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], output: ` /** @@ -780,10 +780,10 @@ export default { settings: { jsdoc: { preferredTypes: { - Array: 'SpecialTypeArray' - } - } - } + Array: 'SpecialTypeArray', + }, + }, + }, }, { code: ` @@ -796,8 +796,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], output: ` /** @@ -810,10 +810,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -826,8 +826,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], output: ` /** @@ -841,10 +841,10 @@ export default { jsdoc: { preferredTypes: { object: 'GenericObject', - 'object.<>': 'GenericObject' - } - } - } + 'object.<>': 'GenericObject', + }, + }, + }, }, { code: ` @@ -857,8 +857,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], output: ` /** @@ -872,10 +872,10 @@ export default { jsdoc: { preferredTypes: { object: 'GenericObject', - 'object<>': 'GenericObject' - } - } - } + 'object<>': 'GenericObject', + }, + }, + }, }, { code: ` @@ -888,8 +888,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], output: ` /** @@ -902,10 +902,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object.<>': 'GenericObject' - } - } - } + 'object.<>': 'GenericObject', + }, + }, + }, }, { code: ` @@ -918,8 +918,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], output: ` /** @@ -932,10 +932,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object<>': 'GenericObject' - } - } - } + 'object<>': 'GenericObject', + }, + }, + }, }, { code: ` @@ -948,8 +948,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], output: ` /** @@ -962,10 +962,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object.<>': 'GenericObject' - } - } - } + 'object.<>': 'GenericObject', + }, + }, + }, }, { code: ` @@ -978,8 +978,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], output: ` /** @@ -992,10 +992,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object<>': 'GenericObject' - } - } - } + 'object<>': 'GenericObject', + }, + }, + }, }, { code: ` @@ -1008,11 +1008,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], output: ` /** @@ -1025,10 +1025,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -1041,11 +1041,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], output: ` /** @@ -1058,10 +1058,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -1074,11 +1074,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], output: ` /** @@ -1091,10 +1091,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -1107,19 +1107,19 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object".' - } + message: 'Invalid JSDoc @param "foo" type "object".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], settings: { jsdoc: { preferredTypes: { - object: false - } - } - } + object: false, + }, + }, + }, }, { code: ` @@ -1132,16 +1132,16 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object".' - } + message: 'Invalid JSDoc @param "foo" type "object".', + }, ], settings: { jsdoc: { preferredTypes: { - object: false - } - } - } + object: false, + }, + }, + }, }, { code: ` @@ -1154,11 +1154,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], output: ` /** @@ -1171,10 +1171,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -1187,11 +1187,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], output: ` /** @@ -1204,10 +1204,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -1221,11 +1221,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.".' + message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.".', }, { - message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.".' - } + message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.".', + }, ], output: ` /** @@ -1239,10 +1239,10 @@ export default { settings: { jsdoc: { preferredTypes: { - '[]': 'Array.' - } - } - } + '[]': 'Array.', + }, + }, + }, }, { code: ` @@ -1256,11 +1256,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.<>".' + message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.<>".', }, { - message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.<>".' - } + message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array.<>".', + }, ], output: ` /** @@ -1274,10 +1274,10 @@ export default { settings: { jsdoc: { preferredTypes: { - '[]': 'Array.<>' - } - } - } + '[]': 'Array.<>', + }, + }, + }, }, { code: ` @@ -1291,11 +1291,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array<>".' + message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array<>".', }, { - message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array<>".' - } + message: 'Invalid JSDoc @param "foo" type "[]"; prefer: "Array<>".', + }, ], output: ` /** @@ -1309,10 +1309,10 @@ export default { settings: { jsdoc: { preferredTypes: { - '[]': 'Array<>' - } - } - } + '[]': 'Array<>', + }, + }, + }, }, { code: ` @@ -1326,11 +1326,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object".' + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object".', }, { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object".', + }, ], output: ` /** @@ -1344,10 +1344,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object.': 'Object' - } - } - } + 'object.': 'Object', + }, + }, + }, }, { code: ` @@ -1361,11 +1361,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".' + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".', }, { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".', + }, ], output: ` /** @@ -1379,10 +1379,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object.': 'Object<>' - } - } - } + 'object.': 'Object<>', + }, + }, + }, }, { code: ` @@ -1396,11 +1396,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object.".' + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object.".', }, { - message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object.".' - } + message: 'Invalid JSDoc @param "foo" type "object"; prefer: "Object.".', + }, ], output: ` /** @@ -1414,10 +1414,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object<>': 'Object.' - } - } - } + 'object<>': 'Object.', + }, + }, + }, }, { code: ` @@ -1431,11 +1431,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".' + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', }, { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', + }, ], output: ` /** @@ -1449,10 +1449,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'Array.': '[]' - } - } - } + 'Array.': '[]', + }, + }, + }, }, { code: ` @@ -1466,11 +1466,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array<>".' + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array<>".', }, { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array<>".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array<>".', + }, ], output: ` /** @@ -1484,10 +1484,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'Array.': 'Array<>' - } - } - } + 'Array.': 'Array<>', + }, + }, + }, }, { code: ` @@ -1501,11 +1501,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".' + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".', }, { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".', + }, ], output: ` /** @@ -1519,10 +1519,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'Array.': '<>' - } - } - } + 'Array.': '<>', + }, + }, + }, }, { code: ` @@ -1536,8 +1536,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "<>".', + }, ], output: ` /** @@ -1551,10 +1551,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'Array.': '<>' - } - } - } + 'Array.': '<>', + }, + }, + }, }, { code: ` @@ -1568,8 +1568,8 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "MyArray"; prefer: "<>".' - } + message: 'Invalid JSDoc @param "foo" type "MyArray"; prefer: "<>".', + }, ], output: ` /** @@ -1583,10 +1583,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'MyArray.': '<>' - } - } - } + 'MyArray.': '<>', + }, + }, + }, }, { code: ` @@ -1600,11 +1600,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".' + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".', }, { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".', + }, ], output: ` /** @@ -1618,10 +1618,10 @@ export default { settings: { jsdoc: { preferredTypes: { - '<>': 'Array.' - } - } - } + '<>': 'Array.', + }, + }, + }, }, { code: ` @@ -1635,14 +1635,14 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".' + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".', }, { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".', + }, ], options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], output: ` /** @@ -1656,10 +1656,10 @@ export default { settings: { jsdoc: { preferredTypes: { - Array: 'Array.' - } - } - } + Array: 'Array.', + }, + }, + }, }, { code: ` @@ -1673,11 +1673,11 @@ export default { `, errors: [ { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".' + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', }, { - message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".' - } + message: 'Invalid JSDoc @param "foo" type "Array"; prefer: "[]".', + }, ], output: ` /** @@ -1691,18 +1691,18 @@ export default { settings: { jsdoc: { preferredTypes: { - '<>': '[]' - } - } - } + '<>': '[]', + }, + }, + }, }, { code: '/** @typedef {String} foo */', errors: [ - {message: 'Invalid JSDoc @typedef "foo" type "String"; prefer: "string".'} + {message: 'Invalid JSDoc @typedef "foo" type "String"; prefer: "string".'}, ], - output: '/** @typedef {string} foo */' - } + output: '/** @typedef {string} foo */', + }, ], valid: [ { @@ -1715,7 +1715,7 @@ export default { function quux (foo, bar, baz) { } - ` + `, }, { code: ` @@ -1727,7 +1727,7 @@ export default { function quux (foo, bar, baz) { } - ` + `, }, { code: ` @@ -1737,7 +1737,7 @@ export default { function quux (foo, bar, baz) { } - ` + `, }, { code: ` @@ -1746,7 +1746,7 @@ export default { */ function qux(foo) { } - ` + `, }, { code: ` @@ -1755,7 +1755,7 @@ export default { */ function qux(foo) { } - ` + `, }, { code: ` @@ -1764,7 +1764,7 @@ export default { */ function qux(foo) { } - ` + `, }, { code: ` @@ -1773,7 +1773,7 @@ export default { */ function qux(foo) { } - ` + `, }, { code: ` @@ -1786,8 +1786,8 @@ export default { } `, options: [{ - noDefaults: true - }] + noDefaults: true, + }], }, { code: ` @@ -1801,10 +1801,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'Object' - } - } - } + object: 'Object', + }, + }, + }, }, { code: ` @@ -1814,7 +1814,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -1828,10 +1828,10 @@ export default { settings: { jsdoc: { preferredTypes: { - Array: 'GenericArray' - } - } - } + Array: 'GenericArray', + }, + }, + }, }, { code: ` @@ -1845,10 +1845,10 @@ export default { settings: { jsdoc: { preferredTypes: { - Array: 'GenericArray' - } - } - } + Array: 'GenericArray', + }, + }, + }, }, { code: ` @@ -1864,10 +1864,10 @@ export default { preferredTypes: { Array: 'SpecialTypeArray', 'Array.<>': 'SpecialTypeArray', - 'Array<>': 'SpecialTypeArray' - } - } - } + 'Array<>': 'SpecialTypeArray', + }, + }, + }, }, { code: ` @@ -1879,16 +1879,16 @@ export default { } `, options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], settings: { jsdoc: { preferredTypes: { 'Array.<>': 'SpecialTypeArray', - 'Array<>': 'SpecialTypeArray' - } - } - } + 'Array<>': 'SpecialTypeArray', + }, + }, + }, }, { code: ` @@ -1902,10 +1902,10 @@ export default { settings: { jsdoc: { preferredTypes: { - '[]': 'SpecialTypeArray' - } - } - } + '[]': 'SpecialTypeArray', + }, + }, + }, }, { code: ` @@ -1917,15 +1917,15 @@ export default { } `, options: [{ - unifyParentAndChildTypeChecks: true + unifyParentAndChildTypeChecks: true, }], settings: { jsdoc: { preferredTypes: { - '[]': 'SpecialTypeArray' - } - } - } + '[]': 'SpecialTypeArray', + }, + }, + }, }, { code: ` @@ -1939,10 +1939,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'Array.<>': 'GenericArray' - } - } - } + 'Array.<>': 'GenericArray', + }, + }, + }, }, { code: ` @@ -1956,10 +1956,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'Array<>': 'GenericArray' - } - } - } + 'Array<>': 'GenericArray', + }, + }, + }, }, { code: ` @@ -1969,7 +1969,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -1983,10 +1983,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -2000,10 +2000,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -2017,10 +2017,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -2034,10 +2034,10 @@ export default { settings: { jsdoc: { preferredTypes: { - object: 'GenericObject' - } - } - } + object: 'GenericObject', + }, + }, + }, }, { code: ` @@ -2051,10 +2051,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object.<>': 'GenericObject' - } - } - } + 'object.<>': 'GenericObject', + }, + }, + }, }, { code: ` @@ -2068,10 +2068,10 @@ export default { settings: { jsdoc: { preferredTypes: { - 'object<>': 'GenericObject' - } - } - } + 'object<>': 'GenericObject', + }, + }, + }, }, { code: ` @@ -2081,7 +2081,7 @@ export default { function quux (foo) { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/implementsOnClasses.js b/test/rules/assertions/implementsOnClasses.js index 1460f9026..082fd7741 100644 --- a/test/rules/assertions/implementsOnClasses.js +++ b/test/rules/assertions/implementsOnClasses.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 3, - message: '@implements used on a non-constructor function' - } - ] + message: '@implements used on a non-constructor function', + }, + ], }, { code: ` @@ -28,17 +28,17 @@ export default { errors: [ { line: 3, - message: 'Unexpected tag `@implements`' - } + message: 'Unexpected tag `@implements`', + }, ], settings: { jsdoc: { tagNamePreference: { - implements: false - } - } - } - } + implements: false, + }, + }, + }, + }, ], valid: [ { @@ -50,7 +50,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -61,7 +61,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -76,7 +76,7 @@ export default { } } - ` + `, }, { code: ` @@ -91,7 +91,7 @@ export default { } } - ` + `, }, { code: ` @@ -101,7 +101,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -115,10 +115,10 @@ export default { settings: { jsdoc: { tagNamePreference: { - implements: false - } - } - } - } - ] + implements: false, + }, + }, + }, + }, + ], }; diff --git a/test/rules/assertions/jsdoc3Tags.js b/test/rules/assertions/jsdoc3Tags.js index d65bb8e1e..f893b1984 100644 --- a/test/rules/assertions/jsdoc3Tags.js +++ b/test/rules/assertions/jsdoc3Tags.js @@ -61,5 +61,5 @@ export default [ 'type', 'typedef', 'variation', - 'version' + 'version', ]; diff --git a/test/rules/assertions/matchDescription.js b/test/rules/assertions/matchDescription.js index d8e09b479..7df36b7d9 100644 --- a/test/rules/assertions/matchDescription.js +++ b/test/rules/assertions/matchDescription.js @@ -12,16 +12,16 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { contexts: [ - 'ClassExpression' - ] - } - ] + 'ClassExpression', + ], + }, + ], }, { code: ` @@ -35,16 +35,16 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { contexts: [ - 'ObjectExpression' - ] - } - ] + 'ObjectExpression', + ], + }, + ], }, { code: ` @@ -58,9 +58,9 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } - ] + message: 'JSDoc description does not satisfy the regex pattern.', + }, + ], }, { code: ` @@ -74,9 +74,9 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } - ] + message: 'JSDoc description does not satisfy the regex pattern.', + }, + ], }, { code: ` @@ -90,12 +90,12 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [{ - matchDescription: '[\u0410-\u042F][\u0410-\u044F]+\\.' - }] + matchDescription: '[\u0410-\u042F][\u0410-\u044F]+\\.', + }], }, { code: ` @@ -109,15 +109,15 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [{ mainDescription: '[\u0410-\u042F][\u0410-\u044F]+\\.', tags: { - param: true - } - }] + param: true, + }, + }], }, { code: ` @@ -131,9 +131,9 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } - ] + message: 'JSDoc description does not satisfy the regex pattern.', + }, + ], }, { code: ` @@ -149,16 +149,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - param: true - } - } - ] + param: true, + }, + }, + ], }, { code: ` @@ -174,16 +174,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - prop: true - } - } - ] + prop: true, + }, + }, + ], }, { code: ` @@ -199,16 +199,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - summary: true - } - } - ] + summary: true, + }, + }, + ], }, { code: ` @@ -224,16 +224,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - author: '.+' - } - } - ] + author: '.+', + }, + }, + ], }, { code: ` @@ -249,16 +249,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - 'x-tag': '.+' - } - } - ] + 'x-tag': '.+', + }, + }, + ], }, { code: ` @@ -274,16 +274,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - description: true - } - } - ] + description: true, + }, + }, + ], }, { code: ` @@ -299,17 +299,17 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { mainDescription: '^[a-zA-Z]*$', tags: { - param: true - } - } - ] + param: true, + }, + }, + ], }, { code: ` @@ -325,17 +325,17 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { mainDescription: false, tags: { - param: true - } - } - ] + param: true, + }, + }, + ], }, { code: ` @@ -351,16 +351,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - param: true - } - } - ] + param: true, + }, + }, + ], }, { code: ` @@ -374,9 +374,9 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } - ] + message: 'JSDoc description does not satisfy the regex pattern.', + }, + ], }, { code: ` @@ -392,16 +392,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - returns: true - } - } - ] + returns: true, + }, + }, + ], }, { code: ` @@ -417,16 +417,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - returns: true - } - } - ] + returns: true, + }, + }, + ], }, { code: ` @@ -445,9 +445,9 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } - ] + message: 'JSDoc description does not satisfy the regex pattern.', + }, + ], }, { code: ` @@ -461,16 +461,16 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - arg: true - } - } - ] + arg: true, + }, + }, + ], }, { code: ` @@ -484,16 +484,16 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - argument: true - } - } - ] + argument: true, + }, + }, + ], }, { code: ` @@ -507,16 +507,16 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - return: true - } - } - ] + return: true, + }, + }, + ], }, { code: ` @@ -532,16 +532,16 @@ export default { errors: [ { line: 5, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { tags: { - return: true - } - } - ] + return: true, + }, + }, + ], }, { code: ` @@ -556,14 +556,14 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [{ tags: { - param: '[\u0410-\u042F][\u0410-\u044F]+\\.' - } - }] + param: '[\u0410-\u042F][\u0410-\u044F]+\\.', + }, + }], }, { code: ` @@ -578,14 +578,14 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [{ tags: { - description: '[\u0410-\u042F][\u0410-\u044F]+\\.' - } - }] + description: '[\u0410-\u042F][\u0410-\u044F]+\\.', + }, + }], }, { code: ` @@ -599,16 +599,16 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { contexts: [ - 'ClassDeclaration' - ] - } - ] + 'ClassDeclaration', + ], + }, + ], }, { code: ` @@ -622,17 +622,17 @@ export default { errors: [ { line: 4, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { contexts: [ - 'ClassProperty' - ] - } + 'ClassProperty', + ], + }, ], - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), }, { code: ` @@ -646,17 +646,17 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { contexts: [ - 'TSInterfaceDeclaration' - ] - } + 'TSInterfaceDeclaration', + ], + }, ], - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), }, { code: ` @@ -670,16 +670,16 @@ export default { errors: [ { line: 4, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [ { contexts: [ - 'Property' - ] - } - ] + 'Property', + ], + }, + ], }, { code: ` @@ -693,21 +693,21 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], options: [{ tags: { - param: true - } + param: true, + }, }], settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } + description: false, + }, + }, + }, }, { code: ` @@ -721,17 +721,17 @@ export default { errors: [ { line: 3, - message: 'JSDoc description does not satisfy the regex pattern.' - } + message: 'JSDoc description does not satisfy the regex pattern.', + }, ], settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } - } + description: false, + }, + }, + }, + }, ], valid: [ { @@ -746,10 +746,10 @@ export default { options: [ { tags: { - param: true - } - } - ] + param: true, + }, + }, + ], }, { code: ` @@ -759,7 +759,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -770,7 +770,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -782,7 +782,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -794,8 +794,8 @@ export default { } `, options: [{ - matchDescription: '[\u0410-\u042F][\u0410-\u044F]+\\.' - }] + matchDescription: '[\u0410-\u042F][\u0410-\u044F]+\\.', + }], }, { code: ` @@ -809,9 +809,9 @@ export default { `, options: [{ tags: { - returns: '[\u0410-\u042F][\u0410-\u044F]+\\.' - } - }] + returns: '[\u0410-\u042F][\u0410-\u044F]+\\.', + }, + }], }, { code: ` @@ -825,9 +825,9 @@ export default { `, options: [{ tags: { - description: '[\u0410-\u042F][\u0410-\u044F]+\\.' - } - }] + description: '[\u0410-\u042F][\u0410-\u044F]+\\.', + }, + }], }, { code: ` @@ -838,7 +838,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -852,10 +852,10 @@ export default { options: [ { tags: { - returns: true - } - } - ] + returns: true, + }, + }, + ], }, { code: ` @@ -869,10 +869,10 @@ export default { options: [ { tags: { - returns: true - } - } - ] + returns: true, + }, + }, + ], }, { code: ` @@ -886,10 +886,10 @@ export default { options: [ { tags: { - description: true - } - } - ] + description: true, + }, + }, + ], }, { code: ` @@ -899,7 +899,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -909,7 +909,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -925,7 +925,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -936,7 +936,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -946,7 +946,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -957,7 +957,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -969,7 +969,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -981,8 +981,8 @@ export default { } `, options: [ - {mainDescription: false} - ] + {mainDescription: false}, + ], }, { code: ` @@ -992,7 +992,7 @@ export default { class quux { } - ` + `, }, { code: ` @@ -1004,8 +1004,8 @@ export default { } `, options: [ - {mainDescription: true} - ] + {mainDescription: true}, + ], }, { code: ` @@ -1019,11 +1019,11 @@ export default { options: [ { contexts: [ - 'ClassProperty' - ] - } + 'ClassProperty', + ], + }, ], - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), }, { code: ` @@ -1037,11 +1037,11 @@ export default { options: [ { contexts: [ - 'TSInterfaceDeclaration' - ] - } + 'TSInterfaceDeclaration', + ], + }, ], - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), }, { code: ` @@ -1055,9 +1055,9 @@ export default { options: [ { contexts: [ - ] - } - ] + ], + }, + ], }, { code: ` @@ -1071,9 +1071,9 @@ export default { options: [ { contexts: [ - ] - } - ] + ], + }, + ], }, { code: ` @@ -1087,9 +1087,9 @@ export default { options: [ { contexts: [ - ] - } - ] + ], + }, + ], }, { code: ` @@ -1102,9 +1102,9 @@ export default { `, options: [ {tags: { - param: true - }} - ] + param: true, + }}, + ], }, { code: ` @@ -1120,10 +1120,10 @@ export default { options: [ { tags: { - summary: true - } - } - ] + summary: true, + }, + }, + ], }, { code: ` @@ -1139,10 +1139,10 @@ export default { options: [ { tags: { - author: '.+' - } - } - ] + author: '.+', + }, + }, + ], }, { code: ` @@ -1158,10 +1158,10 @@ export default { options: [ { tags: { - 'x-tag': '.+' - } - } - ] + 'x-tag': '.+', + }, + }, + ], }, { code: ` @@ -1177,10 +1177,10 @@ export default { options: [ { tags: { - prop: true - } - } - ] + prop: true, + }, + }, + ], }, { code: ` @@ -1194,10 +1194,10 @@ export default { settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } + description: false, + }, + }, + }, }, { code: ` @@ -1211,10 +1211,10 @@ export default { settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } - } - ] + description: false, + }, + }, + }, + }, + ], }; diff --git a/test/rules/assertions/newlineAfterDescription.js b/test/rules/assertions/newlineAfterDescription.js index fb2f99f96..d65856d3c 100644 --- a/test/rules/assertions/newlineAfterDescription.js +++ b/test/rules/assertions/newlineAfterDescription.js @@ -15,11 +15,11 @@ export default { errors: [ { line: 5, - message: 'There must be a newline after the description of the JSDoc block.' - } + message: 'There must be a newline after the description of the JSDoc block.', + }, ], options: [ - 'always' + 'always', ], output: ` /** @@ -32,7 +32,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -49,8 +49,8 @@ export default { errors: [ { line: 5, - message: 'There must be a newline after the description of the JSDoc block.' - } + message: 'There must be a newline after the description of the JSDoc block.', + }, ], output: ` /** @@ -63,7 +63,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -81,11 +81,11 @@ export default { errors: [ { line: 6, - message: 'There must be no newline after the description of the JSDoc block.' - } + message: 'There must be no newline after the description of the JSDoc block.', + }, ], options: [ - 'never' + 'never', ], output: ` /** @@ -97,7 +97,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -110,11 +110,11 @@ export default { `, errors: [ { - message: 'There must be no newline after the description of the JSDoc block.' - } + message: 'There must be no newline after the description of the JSDoc block.', + }, ], options: [ - 'never' + 'never', ], output: ` /** @@ -122,7 +122,7 @@ export default { * @typedef {Object} A * @prop {boolean} a A. */ - ` + `, }, { code: ` @@ -134,11 +134,11 @@ export default { `, errors: [ { - message: 'There must be a newline after the description of the JSDoc block.' - } + message: 'There must be a newline after the description of the JSDoc block.', + }, ], options: [ - 'always' + 'always', ], output: ` /** @@ -147,8 +147,8 @@ export default { * @typedef {Object} A * @prop {boolean} a A. */ - ` - } + `, + }, ], valid: [ { @@ -161,8 +161,8 @@ export default { } `, options: [ - 'always' - ] + 'always', + ], }, { code: ` @@ -174,8 +174,8 @@ export default { } `, options: [ - 'never' - ] + 'never', + ], }, { code: ` @@ -189,8 +189,8 @@ export default { } `, options: [ - 'always' - ] + 'always', + ], }, { code: ` @@ -203,8 +203,8 @@ export default { } `, options: [ - 'never' - ] - } - ] + 'never', + ], + }, + ], }; diff --git a/test/rules/assertions/noTypes.js b/test/rules/assertions/noTypes.js index 9ba1374d6..516840ce9 100644 --- a/test/rules/assertions/noTypes.js +++ b/test/rules/assertions/noTypes.js @@ -11,8 +11,8 @@ export default { `, errors: [ { - message: 'Types are not permitted on @param.' - } + message: 'Types are not permitted on @param.', + }, ], output: ` /** @@ -21,7 +21,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -34,8 +34,8 @@ export default { `, errors: [ { - message: 'Types are not permitted on @returns.' - } + message: 'Types are not permitted on @returns.', + }, ], output: ` /** @@ -44,8 +44,8 @@ export default { function quux () { } - ` - } + `, + }, ], valid: [ { @@ -56,7 +56,7 @@ export default { function quux (foo) { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/noUndefinedTypes.js b/test/rules/assertions/noUndefinedTypes.js index c5d87e54f..9f8dd3941 100644 --- a/test/rules/assertions/noUndefinedTypes.js +++ b/test/rules/assertions/noUndefinedTypes.js @@ -12,19 +12,19 @@ export default { errors: [ { line: 1, - message: 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.' + message: 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.', }, { - message: 'The type \'HerType\' is undefined.' - } + message: 'The type \'HerType\' is undefined.', + }, ], settings: { jsdoc: { preferredTypes: { - HerType: 1000 - } - } - } + HerType: 1000, + }, + }, + }, }, { code: ` @@ -37,16 +37,16 @@ export default { `, errors: [ { - message: 'The type \'HerType\' is undefined.' - } + message: 'The type \'HerType\' is undefined.', + }, ], settings: { jsdoc: { preferredTypes: { - HerType: false - } - } - } + HerType: false, + }, + }, + }, }, { code: ` @@ -60,12 +60,12 @@ export default { errors: [ { line: 3, - message: 'The type \'strnig\' is undefined.' - } + message: 'The type \'strnig\' is undefined.', + }, ], rules: { - 'no-undef': 'error' - } + 'no-undef': 'error', + }, }, { code: ` @@ -80,12 +80,12 @@ export default { errors: [ { line: 4, - message: 'The type \'HisType\' is undefined.' - } + message: 'The type \'HisType\' is undefined.', + }, ], options: [{ - definedTypes: ['MyType'] - }] + definedTypes: ['MyType'], + }], }, { code: ` @@ -101,21 +101,21 @@ export default { errors: [ { line: 4, - message: 'The type \'HisType\' is undefined.' - } + message: 'The type \'HisType\' is undefined.', + }, ], options: [{ - definedTypes: ['MyType'] + definedTypes: ['MyType'], }], settings: { jsdoc: { preferredTypes: { hertype: { - replacement: 'HerType' - } - } - } - } + replacement: 'HerType', + }, + }, + }, + }, }, { code: ` @@ -131,22 +131,22 @@ export default { errors: [ { line: 5, - message: 'The type \'HerType\' is undefined.' - } + message: 'The type \'HerType\' is undefined.', + }, ], options: [{ - definedTypes: ['MyType'] + definedTypes: ['MyType'], }], settings: { jsdoc: { preferredTypes: { hertype: { - replacement: false + replacement: false, }, - histype: 'HisType' - } - } - } + histype: 'HisType', + }, + }, + }, }, { code: ` @@ -160,9 +160,9 @@ export default { errors: [ { line: 4, - message: 'The type \'WRONG_TEMPLATE_TYPE\' is undefined.' - } - ] + message: 'The type \'WRONG_TEMPLATE_TYPE\' is undefined.', + }, + ], }, { code: ` @@ -177,9 +177,9 @@ export default { errors: [ { line: 4, - message: 'The type \'TEMPLATE_TYPE\' is undefined.' - } - ] + message: 'The type \'TEMPLATE_TYPE\' is undefined.', + }, + ], }, { code: ` @@ -205,9 +205,9 @@ export default { errors: [ { line: 4, - message: 'The type \'TEMPLATE_TYPE\' is undefined.' - } - ] + message: 'The type \'TEMPLATE_TYPE\' is undefined.', + }, + ], }, { code: ` @@ -221,13 +221,13 @@ export default { errors: [ { line: 3, - message: 'The type \'strnig\' is undefined.' - } + message: 'The type \'strnig\' is undefined.', + }, ], rules: { - 'no-undef': 'error' - } - } + 'no-undef': 'error', + }, + }, ], valid: [ { @@ -238,7 +238,7 @@ export default { function quux(foo) { } - ` + `, }, { code: ` @@ -250,8 +250,8 @@ export default { } `, env: { - es6: true - } + es6: true, + }, }, { code: ` @@ -267,8 +267,8 @@ export default { quux(0); `, rules: { - 'no-unused-vars': 'error' - } + 'no-unused-vars': 'error', + }, }, { code: ` @@ -282,8 +282,8 @@ export default { } `, env: { - node: true - } + node: true, + }, }, { code: ` @@ -297,8 +297,8 @@ export default { } `, env: { - node: false - } + node: false, + }, }, { code: ` @@ -314,8 +314,8 @@ export default { } `, parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -330,8 +330,8 @@ export default { } `, globals: { - HisType: true - } + HisType: true, + }, }, { code: ` @@ -346,7 +346,7 @@ export default { function quux(foo) { } - ` + `, }, { code: ` @@ -356,7 +356,7 @@ export default { function quux(foo) { } - ` + `, }, { code: ` @@ -374,7 +374,7 @@ export default { function testFunction(callback) { callback(); } - ` + `, }, { code: ` @@ -385,7 +385,7 @@ export default { function foo () { } - ` + `, }, { code: ` @@ -396,7 +396,7 @@ export default { function foo () { } - ` + `, }, { code: ` @@ -409,8 +409,8 @@ export default { } `, options: [{ - definedTypes: ['MyType', 'HisType'] - }] + definedTypes: ['MyType', 'HisType'], + }], }, { code: ` @@ -424,18 +424,18 @@ export default { } `, options: [{ - definedTypes: ['MyType'] + definedTypes: ['MyType'], }], settings: { jsdoc: { preferredTypes: { hertype: { - replacement: 'HerType' + replacement: 'HerType', }, - histype: 'HisType' - } - } - } + histype: 'HisType', + }, + }, + }, }, { code: ` @@ -449,18 +449,18 @@ export default { } `, options: [{ - definedTypes: ['MyType'] + definedTypes: ['MyType'], }], settings: { jsdoc: { preferredTypes: { hertype: { - replacement: 'HerType<>' + replacement: 'HerType<>', }, - histype: 'HisType.<>' - } - } - } + histype: 'HisType.<>', + }, + }, + }, }, { code: ` @@ -471,7 +471,7 @@ export default { */ function foo (bar) { }; - ` + `, }, { code: ` @@ -485,7 +485,7 @@ export default { bar () { } } - ` + `, }, { code: ` @@ -500,7 +500,7 @@ export default { bar (baz) { } } - ` + `, }, { code: ` @@ -512,7 +512,7 @@ export default { function quux () { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/requireDescription.js b/test/rules/assertions/requireDescription.js index 5e533be40..0e153e7f8 100644 --- a/test/rules/assertions/requireDescription.js +++ b/test/rules/assertions/requireDescription.js @@ -11,14 +11,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc @description declaration.' - } + message: 'Missing JSDoc @description declaration.', + }, ], options: [ { - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -31,14 +31,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc block description or @description declaration.' - } + message: 'Missing JSDoc block description or @description declaration.', + }, ], options: [ { - descriptionStyle: 'any' - } - ] + descriptionStyle: 'any', + }, + ], }, { code: ` @@ -51,14 +51,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc block description.' - } + message: 'Missing JSDoc block description.', + }, ], options: [ { - descriptionStyle: 'body' - } - ] + descriptionStyle: 'body', + }, + ], }, { code: ` @@ -71,15 +71,15 @@ export default { `, errors: [ { - message: 'Missing JSDoc @description declaration.' - } + message: 'Missing JSDoc @description declaration.', + }, ], options: [ { contexts: ['ClassDeclaration'], - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -92,15 +92,15 @@ export default { `, errors: [ { - message: 'Missing JSDoc @description declaration.' - } + message: 'Missing JSDoc @description declaration.', + }, ], options: [ { contexts: ['ClassDeclaration'], - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -113,15 +113,15 @@ export default { `, errors: [ { - message: 'Missing JSDoc @description declaration.' - } + message: 'Missing JSDoc @description declaration.', + }, ], options: [ { contexts: ['ClassDeclaration'], - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -134,14 +134,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc @description description.' - } + message: 'Missing JSDoc @description description.', + }, ], options: [ { - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -154,18 +154,18 @@ export default { `, errors: [ { - message: 'Missing JSDoc @description declaration.' - } + message: 'Missing JSDoc @description declaration.', + }, ], options: [ { contexts: [ - 'TSInterfaceDeclaration' + 'TSInterfaceDeclaration', ], - descriptionStyle: 'tag' - } + descriptionStyle: 'tag', + }, ], - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), }, { code: ` @@ -178,17 +178,17 @@ export default { `, errors: [ { - message: 'Missing JSDoc @description declaration.' - } + message: 'Missing JSDoc @description declaration.', + }, ], options: [ { contexts: [ - 'ClassExpression' + 'ClassExpression', ], - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -201,17 +201,17 @@ export default { `, errors: [ { - message: 'Missing JSDoc @description declaration.' - } + message: 'Missing JSDoc @description declaration.', + }, ], options: [ { contexts: [ - 'ObjectExpression' + 'ObjectExpression', ], - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -224,24 +224,24 @@ export default { `, errors: [ { - message: 'Missing JSDoc @someDesc description.' - } + message: 'Missing JSDoc @someDesc description.', + }, ], options: [ { - descriptionStyle: 'tag' - } + descriptionStyle: 'tag', + }, ], settings: { jsdoc: { tagNamePreference: { description: { message: 'Please avoid `{{tagName}}`; use `{{replacement}}` instead', - replacement: 'someDesc' - } - } - } - } + replacement: 'someDesc', + }, + }, + }, + }, }, { code: ` @@ -254,21 +254,21 @@ export default { `, errors: [ { - message: 'Unexpected tag `@description`' - } + message: 'Unexpected tag `@description`', + }, ], options: [ { - descriptionStyle: 'tag' - } + descriptionStyle: 'tag', + }, ], settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } + description: false, + }, + }, + }, }, { code: ` @@ -281,22 +281,22 @@ export default { `, errors: [ { - message: 'Missing JSDoc block description or @description declaration.' - } + message: 'Missing JSDoc block description or @description declaration.', + }, ], options: [ { - descriptionStyle: 'any' - } + descriptionStyle: 'any', + }, ], settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } - } + description: false, + }, + }, + }, + }, ], valid: [ { @@ -311,9 +311,9 @@ export default { `, options: [ { - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -327,9 +327,9 @@ export default { `, options: [ { - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -346,9 +346,9 @@ export default { `, options: [ { - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -361,9 +361,9 @@ export default { `, options: [ { - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -376,9 +376,9 @@ export default { `, options: [ { - contexts: ['ClassDeclaration'] - } - ] + contexts: ['ClassDeclaration'], + }, + ], }, { code: ` @@ -391,9 +391,9 @@ export default { `, options: [ { - exemptedBy: ['type'] - } - ] + exemptedBy: ['type'], + }, + ], }, { code: ` @@ -406,10 +406,10 @@ export default { `, options: [ { - descriptionStyle: 'tag' - } + descriptionStyle: 'tag', + }, ], - parser: require.resolve('@typescript-eslint/parser') + parser: require.resolve('@typescript-eslint/parser'), }, { code: ` @@ -422,9 +422,9 @@ export default { `, options: [ { - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -437,9 +437,9 @@ export default { `, options: [ { - descriptionStyle: 'tag' - } - ] + descriptionStyle: 'tag', + }, + ], }, { code: ` @@ -452,9 +452,9 @@ export default { `, options: [ { - descriptionStyle: 'body' - } - ] + descriptionStyle: 'body', + }, + ], }, { code: ` @@ -464,7 +464,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -477,9 +477,9 @@ export default { `, options: [ { - descriptionStyle: 'any' - } - ] + descriptionStyle: 'any', + }, + ], }, { code: ` @@ -492,9 +492,9 @@ export default { `, options: [ { - descriptionStyle: 'any' - } - ] + descriptionStyle: 'any', + }, + ], }, { code: ` @@ -508,10 +508,10 @@ export default { settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } - } - ] + description: false, + }, + }, + }, + }, + ], }; diff --git a/test/rules/assertions/requireDescriptionCompleteSentence.js b/test/rules/assertions/requireDescriptionCompleteSentence.js index e02d39d2e..dca512acd 100644 --- a/test/rules/assertions/requireDescriptionCompleteSentence.js +++ b/test/rules/assertions/requireDescriptionCompleteSentence.js @@ -12,8 +12,8 @@ export default { errors: [ { line: 3, - message: 'Sentence should start with an uppercase character.' - } + message: 'Sentence should start with an uppercase character.', + }, ], output: ` /** @@ -22,7 +22,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -35,8 +35,8 @@ export default { `, errors: [ { - message: 'Sentence should start with an uppercase character.' - } + message: 'Sentence should start with an uppercase character.', + }, ], output: ` /** @@ -45,7 +45,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -59,8 +59,8 @@ export default { errors: [ { line: 3, - message: 'Sentence should start with an uppercase character.' - } + message: 'Sentence should start with an uppercase character.', + }, ], output: ` /** @@ -69,7 +69,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -83,8 +83,8 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -93,7 +93,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -106,8 +106,8 @@ export default { `, errors: [ { - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -116,7 +116,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -132,8 +132,8 @@ export default { errors: [ { line: 5, - message: 'Sentence should start with an uppercase character.' - } + message: 'Sentence should start with an uppercase character.', + }, ], output: ` /** @@ -144,7 +144,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -158,8 +158,8 @@ export default { errors: [ { line: 3, - message: 'Sentence should start with an uppercase character.' - } + message: 'Sentence should start with an uppercase character.', + }, ], output: ` /** @@ -168,7 +168,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -182,8 +182,8 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -192,7 +192,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -207,9 +207,9 @@ export default { errors: [ { line: 3, - message: 'A line of text is started with an uppercase character, but preceding line does not end the sentence.' - } - ] + message: 'A line of text is started with an uppercase character, but preceding line does not end the sentence.', + }, + ], }, { code: ` @@ -225,8 +225,8 @@ export default { errors: [ { line: 5, - message: 'Sentence should start with an uppercase character.' - } + message: 'Sentence should start with an uppercase character.', + }, ], output: ` /** @@ -237,7 +237,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -253,12 +253,12 @@ export default { errors: [ { line: 5, - message: 'Sentence should start with an uppercase character.' + message: 'Sentence should start with an uppercase character.', }, { line: 5, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -269,7 +269,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -283,12 +283,12 @@ export default { errors: [ { line: 3, - message: 'Sentence should start with an uppercase character.' + message: 'Sentence should start with an uppercase character.', }, { line: 3, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -297,7 +297,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -313,12 +313,12 @@ export default { errors: [ { line: 5, - message: 'Sentence should start with an uppercase character.' + message: 'Sentence should start with an uppercase character.', }, { line: 5, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -329,7 +329,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -345,8 +345,8 @@ export default { errors: [ { line: 5, - message: 'Sentence should start with an uppercase character.' - } + message: 'Sentence should start with an uppercase character.', + }, ], output: ` /** @@ -357,7 +357,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -376,8 +376,8 @@ export default { errors: [ { line: 3, - message: 'Sentence should start with an uppercase character.' - } + message: 'Sentence should start with an uppercase character.', + }, ], output: ` /** @@ -391,7 +391,7 @@ export default { function longDescription (foo) { } - ` + `, }, { code: ` @@ -405,8 +405,8 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -415,7 +415,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -429,8 +429,8 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -439,7 +439,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -453,12 +453,12 @@ export default { errors: [ { line: 3, - message: 'Sentence should start with an uppercase character.' + message: 'Sentence should start with an uppercase character.', }, { line: 3, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -467,7 +467,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -483,12 +483,12 @@ export default { errors: [ { line: 5, - message: 'Sentence should start with an uppercase character.' + message: 'Sentence should start with an uppercase character.', }, { line: 5, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], output: ` /** @@ -499,7 +499,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -511,9 +511,9 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } - ] + message: 'Sentence must end with a period.', + }, + ], }, { code: ` @@ -527,9 +527,9 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } - ] + message: 'Sentence must end with a period.', + }, + ], }, { code: ` @@ -543,9 +543,9 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } - ] + message: 'Sentence must end with a period.', + }, + ], }, { code: ` @@ -559,14 +559,14 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], options: [ { - tags: ['see'] - } - ] + tags: ['see'], + }, + ], }, { code: ` @@ -580,20 +580,20 @@ export default { errors: [ { line: 3, - message: 'Sentence must end with a period.' - } + message: 'Sentence must end with a period.', + }, ], options: [{ - tags: ['param'] + tags: ['param'], }], settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } - } + description: false, + }, + }, + }, + }, ], valid: [ { @@ -604,7 +604,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -614,7 +614,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -625,7 +625,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -637,7 +637,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -647,7 +647,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -658,7 +658,7 @@ export default { function quux () { } - ` + `, }, { // @see https://github.com/gajus/eslint-plugin-jsdoc/issues/10 @@ -669,7 +669,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -679,7 +679,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -689,7 +689,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -705,7 +705,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -716,7 +716,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -726,7 +726,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -736,7 +736,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -746,7 +746,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -756,7 +756,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -768,7 +768,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -778,7 +778,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -788,7 +788,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -799,7 +799,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -809,7 +809,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -819,7 +819,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -831,7 +831,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -846,9 +846,9 @@ export default { `, options: [ { - tags: ['param'] - } - ] + tags: ['param'], + }, + ], }, { code: ` @@ -860,15 +860,15 @@ export default { } `, options: [{ - tags: ['param'] + tags: ['param'], }], settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } + description: false, + }, + }, + }, }, { code: ` @@ -882,10 +882,10 @@ export default { settings: { jsdoc: { tagNamePreference: { - description: false - } - } - } - } - ] + description: false, + }, + }, + }, + }, + ], }; diff --git a/test/rules/assertions/requireExample.js b/test/rules/assertions/requireExample.js index 5f9c85493..057368426 100644 --- a/test/rules/assertions/requireExample.js +++ b/test/rules/assertions/requireExample.js @@ -11,8 +11,8 @@ export default { `, errors: [ { - message: 'Missing JSDoc @example declaration.' - } + message: 'Missing JSDoc @example declaration.', + }, ], output: ` /** @@ -21,7 +21,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -34,9 +34,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @example description.' - } - ] + message: 'Missing JSDoc @example description.', + }, + ], }, { code: ` @@ -49,17 +49,17 @@ export default { `, errors: [ { - message: '`settings.jsdoc.avoidExampleOnConstructors` has been removed, use options in the rule `require-example` instead.' + message: '`settings.jsdoc.avoidExampleOnConstructors` has been removed, use options in the rule `require-example` instead.', }, { - message: 'Missing JSDoc @example declaration.' - } + message: 'Missing JSDoc @example declaration.', + }, ], settings: { jsdoc: { - avoidExampleOnConstructors: true - } - } + avoidExampleOnConstructors: true, + }, + }, }, { code: ` @@ -72,9 +72,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @example declaration.' - } - ] + message: 'Missing JSDoc @example declaration.', + }, + ], }, { code: ` @@ -88,9 +88,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @example description.' - } - ] + message: 'Missing JSDoc @example description.', + }, + ], }, { code: ` @@ -103,15 +103,15 @@ export default { `, errors: [ { - message: 'Missing JSDoc @example declaration.' - } + message: 'Missing JSDoc @example declaration.', + }, ], options: [ { - contexts: ['ClassDeclaration'] - } - ] - } + contexts: ['ClassDeclaration'], + }, + ], + }, ], valid: [ { @@ -123,7 +123,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -134,7 +134,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -148,7 +148,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -160,8 +160,8 @@ export default { } `, options: [ - {avoidExampleOnConstructors: true} - ] + {avoidExampleOnConstructors: true}, + ], }, { code: ` @@ -174,8 +174,8 @@ export default { } `, options: [ - {avoidExampleOnConstructors: true} - ] + {avoidExampleOnConstructors: true}, + ], }, { code: ` @@ -189,8 +189,8 @@ export default { } `, options: [ - {avoidExampleOnConstructors: true} - ] + {avoidExampleOnConstructors: true}, + ], }, { code: ` @@ -200,7 +200,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -213,9 +213,9 @@ export default { `, options: [ { - exemptedBy: ['type'] - } - ] + exemptedBy: ['type'], + }, + ], }, { code: ` @@ -228,9 +228,9 @@ export default { `, options: [ { - contexts: ['ClassDeclaration'] - } - ] + contexts: ['ClassDeclaration'], + }, + ], }, { code: ` @@ -243,9 +243,9 @@ export default { `, options: [ { - contexts: ['ClassDeclaration'] - } - ] - } - ] + contexts: ['ClassDeclaration'], + }, + ], + }, + ], }; diff --git a/test/rules/assertions/requireHyphenBeforeParamDescription.js b/test/rules/assertions/requireHyphenBeforeParamDescription.js index a307d5938..61978658c 100644 --- a/test/rules/assertions/requireHyphenBeforeParamDescription.js +++ b/test/rules/assertions/requireHyphenBeforeParamDescription.js @@ -12,11 +12,11 @@ export default { errors: [ { line: 3, - message: 'There must be a hyphen before @param description.' - } + message: 'There must be a hyphen before @param description.', + }, ], options: [ - 'always' + 'always', ], output: ` /** @@ -25,7 +25,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -39,8 +39,8 @@ export default { errors: [ { line: 3, - message: 'There must be a hyphen before @param description.' - } + message: 'There must be a hyphen before @param description.', + }, ], output: ` /** @@ -49,7 +49,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -63,11 +63,11 @@ export default { errors: [ { line: 3, - message: 'There must be no hyphen before @param description.' - } + message: 'There must be no hyphen before @param description.', + }, ], options: [ - 'never' + 'never', ], output: ` /** @@ -76,7 +76,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -91,11 +91,11 @@ export default { errors: [ { line: 4, - message: 'There must be a hyphen before @param description.' - } + message: 'There must be a hyphen before @param description.', + }, ], options: [ - 'always' + 'always', ], output: ` /** @@ -105,7 +105,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -121,11 +121,11 @@ export default { errors: [ { line: 3, - message: 'There must be a hyphen before @param description.' - } + message: 'There must be a hyphen before @param description.', + }, ], options: [ - 'always' + 'always', ], output: ` /** @@ -136,7 +136,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -149,17 +149,17 @@ export default { `, errors: [ { - message: 'Unexpected tag `@param`' - } + message: 'Unexpected tag `@param`', + }, ], settings: { jsdoc: { tagNamePreference: { - param: false - } - } - } - } + param: false, + }, + }, + }, + }, ], valid: [ { @@ -172,8 +172,8 @@ export default { } `, options: [ - 'always' - ] + 'always', + ], }, { code: ` @@ -185,8 +185,8 @@ export default { } `, options: [ - 'never' - ] + 'never', + ], }, { code: ` @@ -196,7 +196,7 @@ export default { function quux () { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/requireJsdoc.js b/test/rules/assertions/requireJsdoc.js index b10e0383a..3a8ca3608 100644 --- a/test/rules/assertions/requireJsdoc.js +++ b/test/rules/assertions/requireJsdoc.js @@ -15,15 +15,15 @@ export default { `, errors: [ { - message: 'Missing JSDoc comment.' - } + message: 'Missing JSDoc comment.', + }, ], settings: { jsdoc: { maxLines: 3, - minLines: 2 - } - } + minLines: 2, + }, + }, }, { code: ` @@ -38,14 +38,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc comment.' - } + message: 'Missing JSDoc comment.', + }, ], settings: { jsdoc: { - maxLines: 2 - } - } + maxLines: 2, + }, + }, }, { code: ` @@ -55,14 +55,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc comment.' - } + message: 'Missing JSDoc comment.', + }, ], settings: { jsdoc: { - minLines: 1 - } - } + minLines: 1, + }, + }, }, { code: ` @@ -73,18 +73,18 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'FunctionExpression' - } + type: 'FunctionExpression', + }, ], options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -96,18 +96,18 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' - } + type: 'FunctionDeclaration', + }, ], options: [{ publicOnly: true, require: { - FunctionDeclaration: true - } + FunctionDeclaration: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -118,18 +118,18 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'ArrowFunctionExpression' - } + type: 'ArrowFunctionExpression', + }, ], options: [{ publicOnly: true, require: { - ArrowFunctionExpression: true - } + ArrowFunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -140,18 +140,18 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'ClassExpression' - } + type: 'ClassExpression', + }, ], options: [{ publicOnly: true, require: { - ClassExpression: true - } + ClassExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -160,22 +160,22 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' - } + type: 'FunctionDeclaration', + }, ], options: [{ publicOnly: { cjs: false, esm: true, - window: false + window: false, }, require: { - FunctionDeclaration: true - } + FunctionDeclaration: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -184,22 +184,22 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'ArrowFunctionExpression' - } + type: 'ArrowFunctionExpression', + }, ], options: [{ publicOnly: { cjs: false, esm: true, - window: false + window: false, }, require: { - ArrowFunctionExpression: true - } + ArrowFunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -208,22 +208,22 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'FunctionExpression' - } + type: 'FunctionExpression', + }, ], options: [{ publicOnly: { cjs: false, esm: true, - window: false + window: false, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -232,18 +232,18 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'ClassDeclaration' - } + type: 'ClassDeclaration', + }, ], options: [{ publicOnly: { cjs: false, esm: true, - window: false + window: false, }, require: { - ClassDeclaration: true - } + ClassDeclaration: true, + }, }], output: ` /** @@ -252,8 +252,8 @@ export default { export default class {} `, parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: @@ -264,22 +264,22 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc comment.' - } - ] + message: 'Missing JSDoc comment.', + }, + ], }, { code: '', errors: [ { - message: '`settings.jsdoc.exemptEmptyFunctions` has been removed, use options in the rule `require-jsdoc` instead.' - } + message: '`settings.jsdoc.exemptEmptyFunctions` has been removed, use options in the rule `require-jsdoc` instead.', + }, ], settings: { jsdoc: { - exemptEmptyFunctions: true - } - } + exemptEmptyFunctions: true, + }, + }, }, { code: ` @@ -289,11 +289,11 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc comment.' - } + message: 'Missing JSDoc comment.', + }, ], options: [ - {exemptEmptyFunctions: true} + {exemptEmptyFunctions: true}, ], output: ` /** @@ -301,7 +301,7 @@ export default { */ function quux (foo) { - }` + }`, }, { code: ` @@ -311,11 +311,11 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc comment.' - } + message: 'Missing JSDoc comment.', + }, ], options: [ - {exemptEmptyFunctions: true} + {exemptEmptyFunctions: true}, ], output: ` /** @@ -327,16 +327,16 @@ export default { }`, settings: { jsdoc: { - minLines: 2 - } - } + minLines: 2, + }, + }, }, { code: 'function myFunction() {}', errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' - }] + type: 'FunctionDeclaration', + }], }, { code: @@ -350,17 +350,17 @@ export default { }`, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -375,17 +375,17 @@ export default { }`, errors: [{ message: 'Missing JSDoc comment.', - type: 'ClassDeclaration' + type: 'ClassDeclaration', }], options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -400,17 +400,17 @@ export default { }`, errors: [{ message: 'Missing JSDoc comment.', - type: 'ClassDeclaration' + type: 'ClassDeclaration', }], options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -425,17 +425,17 @@ export default { }`, errors: [{ message: 'Missing JSDoc comment.', - type: 'ClassDeclaration' + type: 'ClassDeclaration', }], options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: @@ -450,86 +450,86 @@ export default { }`, errors: [{ message: 'Missing JSDoc comment.', - type: 'ClassDeclaration' + type: 'ClassDeclaration', }], options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: 'var myFunction = () => {}', errors: [{ message: 'Missing JSDoc comment.', - type: 'ArrowFunctionExpression' + type: 'ArrowFunctionExpression', }], options: [{ require: { - ArrowFunctionExpression: true - } + ArrowFunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: 'var myFunction = () => () => {}', errors: [{ message: 'Missing JSDoc comment.', - type: 'ArrowFunctionExpression' + type: 'ArrowFunctionExpression', }], options: [{ require: { - ArrowFunctionExpression: true - } + ArrowFunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: 'var foo = function() {}', errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: 'const foo = {bar() {}}', errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: 'var foo = {bar: function() {}}', errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -537,11 +537,11 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [ - {exemptEmptyFunctions: false} - ] + {exemptEmptyFunctions: false}, + ], }, { code: ` @@ -551,11 +551,11 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [ - {exemptEmptyFunctions: false} - ] + {exemptEmptyFunctions: false}, + ], }, { code: ` @@ -564,18 +564,18 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -584,20 +584,20 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -608,18 +608,18 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -632,18 +632,18 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -656,20 +656,20 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -678,18 +678,18 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -703,18 +703,18 @@ export default { test.prototype.method = function() {} `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -726,18 +726,18 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -749,18 +749,18 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'ArrowFunctionExpression' + type: 'ArrowFunctionExpression', }], options: [{ publicOnly: true, require: { - ArrowFunctionExpression: true - } - }] + ArrowFunctionExpression: true, + }, + }], }, { code: ` @@ -772,18 +772,18 @@ export default { module.exports = Test; `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: true, require: { - MethodDefinition: true - } - }] + MethodDefinition: true, + }, + }], }, { code: ` @@ -793,17 +793,17 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -813,19 +813,19 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -836,17 +836,17 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -856,17 +856,17 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -876,19 +876,19 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -900,18 +900,18 @@ export default { `, errors: [ { - message: 'Missing JSDoc comment.' - } + message: 'Missing JSDoc comment.', + }, ], options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -922,17 +922,17 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -942,17 +942,17 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'ClassDeclaration' + type: 'ClassDeclaration', }], options: [{ publicOnly: true, require: { - ClassDeclaration: true - } + ClassDeclaration: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -962,19 +962,19 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'ClassDeclaration' + type: 'ClassDeclaration', }], options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - ClassDeclaration: true - } + ClassDeclaration: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -984,19 +984,19 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: { - window: true + window: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1006,19 +1006,19 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: { - window: true + window: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1028,16 +1028,16 @@ export default { `, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [{ publicOnly: { - window: true - } + window: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1046,22 +1046,22 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionExpression' + type: 'FunctionExpression', }], options: [{ publicOnly: { cjs: true, esm: false, - window: false + window: false, }, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1070,26 +1070,26 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [{ publicOnly: { cjs: false, esm: true, - window: false + window: false, }, require: { - FunctionDeclaration: true - } + FunctionDeclaration: true, + }, }], parserOptions: { ecmaVersion: 6, - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1098,26 +1098,26 @@ export default { } `, env: { - node: true + node: true, }, errors: [{ message: 'Missing JSDoc comment.', - type: 'FunctionDeclaration' + type: 'FunctionDeclaration', }], options: [{ publicOnly: { cjs: false, esm: true, - window: false + window: false, }, require: { - FunctionDeclaration: true - } + FunctionDeclaration: true, + }, }], parserOptions: { ecmaVersion: 6, - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1128,17 +1128,17 @@ export default { errors: [ { message: 'Missing JSDoc comment.', - type: 'Property' - } + type: 'Property', + }, ], options: [ { contexts: [ - 'Property' - ] - } - ] - } + 'Property', + ], + }, + ], + }, ], valid: [{ code: ` @@ -1229,7 +1229,7 @@ export default { Object.keys(this.options.rules || {}).forEach(function(name) {}.bind(this)); var object = { name: 'key'}; Object.keys(object).forEach(function() {}) - ` + `, }, { code: ` @@ -1244,9 +1244,9 @@ export default { settings: { jsdoc: { maxLines: 2, - minLines: 0 - } - } + minLines: 0, + }, + }, }, { code: ` @@ -1262,9 +1262,9 @@ export default { settings: { jsdoc: { maxLines: 3, - minLines: 0 - } - } + minLines: 0, + }, + }, }, { code: ` @@ -1275,9 +1275,9 @@ export default { settings: { jsdoc: { maxLines: 0, - minLines: 0 - } - } + minLines: 0, + }, + }, }, { code: ` @@ -1292,9 +1292,9 @@ export default { settings: { jsdoc: { maxLines: 3, - minLines: 2 - } - } + minLines: 2, + }, + }, }, { code: 'function myFunction() {}', @@ -1302,9 +1302,9 @@ export default { require: { ClassDeclaration: true, FunctionDeclaration: false, - MethodDefinition: true - } - }] + MethodDefinition: true, + }, + }], }, { code: 'var myFunction = function() {}', @@ -1312,9 +1312,9 @@ export default { require: { ClassDeclaration: true, FunctionDeclaration: false, - MethodDefinition: true - } - }] + MethodDefinition: true, + }, + }], }, { code: ` @@ -1333,12 +1333,12 @@ export default { options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -1357,12 +1357,12 @@ export default { options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -1381,13 +1381,13 @@ export default { options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { ecmaVersion: 6, - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: @@ -1406,13 +1406,13 @@ export default { options: [{ require: { ClassDeclaration: true, - MethodDefinition: true - } + MethodDefinition: true, + }, }], parserOptions: { ecmaVersion: 6, - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: @@ -1424,12 +1424,12 @@ export default { options: [{ require: { ClassDeclaration: false, - MethodDefinition: false - } + MethodDefinition: false, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -1439,12 +1439,12 @@ export default { var myFunction = () => {}`, options: [{ require: { - ArrowFunctionExpression: true - } + ArrowFunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -1454,12 +1454,12 @@ export default { var myFunction = function () {}`, options: [{ require: { - ArrowFunctionExpression: true - } + ArrowFunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -1469,12 +1469,12 @@ export default { var myFunction = () => {}`, options: [{ require: { - ArrowFunctionExpression: false - } + ArrowFunctionExpression: false, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -1484,23 +1484,23 @@ export default { var myFunction = () => () => {}`, options: [{ require: { - ArrowFunctionExpression: true - } + ArrowFunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: 'setTimeout(() => {}, 10);', options: [{ require: { - ArrowFunctionExpression: true - } + ArrowFunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -1510,9 +1510,9 @@ export default { var foo = function() {}`, options: [{ require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: @@ -1522,12 +1522,12 @@ export default { bar() {}}`, options: [{ require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: @@ -1537,28 +1537,28 @@ export default { bar: function() {}}`, options: [{ require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ' var foo = { [function() {}]: 1 };', options: [{ require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - ecmaVersion: 6 - } + ecmaVersion: 6, + }, }, { code: ` function foo () {} `, options: [ - {exemptEmptyFunctions: true} - ] + {exemptEmptyFunctions: true}, + ], }, { code: ` @@ -1567,8 +1567,8 @@ export default { } `, options: [ - {exemptEmptyFunctions: true} - ] + {exemptEmptyFunctions: true}, + ], }, { code: ` @@ -1584,14 +1584,14 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1607,14 +1607,14 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1630,18 +1630,18 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: { cjs: true, esm: false, - window: false + window: false, }, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1657,18 +1657,18 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: { cjs: false, esm: true, - window: false + window: false, }, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1684,14 +1684,14 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: true, require: { - ArrowFunctionExpression: true - } - }] + ArrowFunctionExpression: true, + }, + }], }, { code: ` @@ -1703,16 +1703,16 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - ArrowFunctionExpression: true - } - }] + ArrowFunctionExpression: true, + }, + }], }, { code: ` @@ -1728,14 +1728,14 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1755,14 +1755,14 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1777,14 +1777,14 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1807,14 +1807,14 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: true, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` @@ -1829,14 +1829,14 @@ export default { module.exports = Test; `, env: { - node: true + node: true, }, options: [{ publicOnly: true, require: { - MethodDefinition: true - } - }] + MethodDefinition: true, + }, + }], }, { code: ` @@ -1850,12 +1850,12 @@ export default { options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1868,15 +1868,15 @@ export default { `, options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1891,12 +1891,12 @@ export default { options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1907,15 +1907,15 @@ export default { `, options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1929,12 +1929,12 @@ export default { options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1947,15 +1947,15 @@ export default { `, options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1971,12 +1971,12 @@ export default { options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -1991,12 +1991,12 @@ export default { options: [{ publicOnly: true, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -2009,15 +2009,15 @@ export default { `, options: [{ publicOnly: { - ancestorsOnly: true + ancestorsOnly: true, }, require: { - ClassDeclaration: true - } + ClassDeclaration: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -2030,15 +2030,15 @@ export default { `, options: [{ publicOnly: { - window: true + window: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -2048,15 +2048,15 @@ export default { `, options: [{ publicOnly: { - window: true + window: true, }, require: { - FunctionExpression: true - } + FunctionExpression: true, + }, }], parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -2067,9 +2067,9 @@ export default { options: [{ publicOnly: true, require: { - ClassExpression: false - } - }] + ClassExpression: false, + }, + }], }, { code: ` @@ -2083,9 +2083,9 @@ export default { options: [{ publicOnly: true, require: { - ClassExpression: true - } - }] + ClassExpression: true, + }, + }], }, { code: ` @@ -2094,22 +2094,22 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: { cjs: true, esm: false, - window: false + window: false, }, require: { - FunctionDeclaration: true - } + FunctionDeclaration: true, + }, }], parserOptions: { ecmaVersion: 6, - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` export function someMethod() { @@ -2117,22 +2117,22 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: { cjs: true, esm: false, - window: false + window: false, }, require: { - FunctionDeclaration: true - } + FunctionDeclaration: true, + }, }], parserOptions: { ecmaVersion: 6, - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` exports.someMethod = function() { @@ -2140,18 +2140,18 @@ export default { } `, env: { - node: true + node: true, }, options: [{ publicOnly: { cjs: false, esm: true, - window: false + window: false, }, require: { - FunctionExpression: true - } - }] + FunctionExpression: true, + }, + }], }, { code: ` const myObject = { @@ -2160,8 +2160,8 @@ export default { `, options: [ { - contexts: [] - } - ] - }] + contexts: [], + }, + ], + }], }; diff --git a/test/rules/assertions/requireParam.js b/test/rules/assertions/requireParam.js index 2cb4b7d17..9b67308e1 100644 --- a/test/rules/assertions/requireParam.js +++ b/test/rules/assertions/requireParam.js @@ -17,9 +17,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } - ] + message: 'Missing JSDoc @param "foo" declaration.', + }, + ], }, { code: ` @@ -32,12 +32,12 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' + message: 'Missing JSDoc @param "foo" declaration.', }, { - message: 'Missing JSDoc @param "bar" declaration.' - } - ] + message: 'Missing JSDoc @param "bar" declaration.', + }, + ], }, { code: ` @@ -50,12 +50,12 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' + message: 'Missing JSDoc @param "foo" declaration.', }, { - message: 'Missing JSDoc @param "baz" declaration.' - } - ] + message: 'Missing JSDoc @param "baz" declaration.', + }, + ], }, { code: ` @@ -68,12 +68,12 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' + message: 'Missing JSDoc @param "foo" declaration.', }, { - message: 'Missing JSDoc @param "bar" declaration.' - } - ] + message: 'Missing JSDoc @param "bar" declaration.', + }, + ], }, { code: ` @@ -86,16 +86,16 @@ export default { `, errors: [ { - message: 'Missing JSDoc @arg "foo" declaration.' - } + message: 'Missing JSDoc @arg "foo" declaration.', + }, ], settings: { jsdoc: { tagNamePreference: { - param: 'arg' - } - } - } + param: 'arg', + }, + }, + }, }, { code: ` @@ -108,9 +108,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "bar" declaration.' - } - ] + message: 'Missing JSDoc @param "bar" declaration.', + }, + ], }, { code: ` @@ -123,14 +123,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } + message: 'Missing JSDoc @param "foo" declaration.', + }, ], settings: { jsdoc: { - overrideReplacesDocs: false - } - } + overrideReplacesDocs: false, + }, + }, }, { code: ` @@ -143,14 +143,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } + message: 'Missing JSDoc @param "foo" declaration.', + }, ], settings: { jsdoc: { - implementsReplacesDocs: false - } - } + implementsReplacesDocs: false, + }, + }, }, { code: ` @@ -163,9 +163,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } - ] + message: 'Missing JSDoc @param "foo" declaration.', + }, + ], }, { code: ` @@ -178,9 +178,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } - ] + message: 'Missing JSDoc @param "foo" declaration.', + }, + ], }, { code: ` @@ -198,14 +198,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } + message: 'Missing JSDoc @param "foo" declaration.', + }, ], settings: { jsdoc: { - overrideReplacesDocs: false - } - } + overrideReplacesDocs: false, + }, + }, }, { code: ` @@ -223,14 +223,14 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } + message: 'Missing JSDoc @param "foo" declaration.', + }, ], settings: { jsdoc: { - implementsReplacesDocs: false - } - } + implementsReplacesDocs: false, + }, + }, }, { code: ` @@ -248,9 +248,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } - ] + message: 'Missing JSDoc @param "foo" declaration.', + }, + ], }, { code: ` @@ -268,9 +268,9 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } - ] + message: 'Missing JSDoc @param "foo" declaration.', + }, + ], }, { code: ` @@ -283,13 +283,13 @@ export default { `, errors: [ { - message: 'Missing JSDoc @param "foo" declaration.' - } + message: 'Missing JSDoc @param "foo" declaration.', + }, ], parser: require.resolve('@typescript-eslint/parser'), parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -302,17 +302,17 @@ export default { `, errors: [ { - message: 'Unexpected tag `@param`' - } + message: 'Unexpected tag `@param`', + }, ], settings: { jsdoc: { tagNamePreference: { - param: false - } - } - } - } + param: false, + }, + }, + }, + }, ], valid: [ { @@ -323,7 +323,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -333,7 +333,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -347,10 +347,10 @@ export default { settings: { jsdoc: { tagNamePreference: { - param: 'arg' - } - } - } + param: 'arg', + }, + }, + }, }, { code: ` @@ -361,7 +361,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -371,7 +371,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -386,7 +386,7 @@ export default { } } - ` + `, }, { code: ` @@ -399,9 +399,9 @@ export default { `, settings: { jsdoc: { - overrideReplacesDocs: true - } - } + overrideReplacesDocs: true, + }, + }, }, { code: ` @@ -416,7 +416,7 @@ export default { } } - ` + `, }, { code: ` @@ -426,7 +426,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -439,9 +439,9 @@ export default { `, settings: { jsdoc: { - implementsReplacesDocs: true - } - } + implementsReplacesDocs: true, + }, + }, }, { code: ` @@ -452,7 +452,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -465,9 +465,9 @@ export default { `, settings: { jsdoc: { - augmentsExtendsReplacesDocs: true - } - } + augmentsExtendsReplacesDocs: true, + }, + }, }, { code: ` @@ -478,7 +478,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -491,9 +491,9 @@ export default { `, settings: { jsdoc: { - augmentsExtendsReplacesDocs: true - } - } + augmentsExtendsReplacesDocs: true, + }, + }, }, { code: ` @@ -504,7 +504,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -517,9 +517,9 @@ export default { `, settings: { jsdoc: { - augmentsExtendsReplacesDocs: true - } - } + augmentsExtendsReplacesDocs: true, + }, + }, }, { code: ` @@ -532,9 +532,9 @@ export default { `, settings: { jsdoc: { - augmentsExtendsReplacesDocs: true - } - } + augmentsExtendsReplacesDocs: true, + }, + }, }, { code: ` @@ -549,7 +549,7 @@ export default { } } - ` + `, }, { code: ` @@ -567,9 +567,9 @@ export default { `, settings: { jsdoc: { - overrideReplacesDocs: true - } - } + overrideReplacesDocs: true, + }, + }, }, { code: ` @@ -587,9 +587,9 @@ export default { `, settings: { jsdoc: { - implementsReplacesDocs: true - } - } + implementsReplacesDocs: true, + }, + }, }, { code: ` @@ -604,7 +604,7 @@ export default { } } - ` + `, }, { code: ` @@ -622,9 +622,9 @@ export default { `, settings: { jsdoc: { - augmentsExtendsReplacesDocs: true - } - } + augmentsExtendsReplacesDocs: true, + }, + }, }, { code: ` @@ -639,7 +639,7 @@ export default { } } - ` + `, }, { code: ` @@ -657,9 +657,9 @@ export default { `, settings: { jsdoc: { - augmentsExtendsReplacesDocs: true - } - } + augmentsExtendsReplacesDocs: true, + }, + }, }, { code: ` @@ -674,7 +674,7 @@ export default { } } - ` + `, }, { code: ` @@ -692,9 +692,9 @@ export default { `, settings: { jsdoc: { - augmentsExtendsReplacesDocs: true - } - } + augmentsExtendsReplacesDocs: true, + }, + }, }, { code: ` @@ -712,9 +712,9 @@ export default { `, settings: { jsdoc: { - augmentsExtendsReplacesDocs: true - } - } + augmentsExtendsReplacesDocs: true, + }, + }, }, { code: ` @@ -727,9 +727,9 @@ export default { `, settings: { jsdoc: { - ignorePrivate: true - } - } + ignorePrivate: true, + }, + }, }, { code: ` @@ -737,13 +737,13 @@ export default { /** @const {boolean} test */ const test = something?.find(_ => _) `, - parser: require.resolve('babel-eslint') + parser: require.resolve('babel-eslint'), }, { code: ` /** @type {RequestHandler} */ function foo(req, res, next) {} - ` + `, }, { code: ` @@ -756,9 +756,9 @@ export default { `, options: [ { - exemptedBy: ['type'] - } - ] + exemptedBy: ['type'], + }, + ], }, { code: ` @@ -773,7 +773,7 @@ export default { } } - ` + `, }, { code: ` @@ -786,8 +786,8 @@ export default { `, parser: require.resolve('@typescript-eslint/parser'), parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -801,7 +801,7 @@ export default { function assign({name, department}) { // ... } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/requireParamDescription.js b/test/rules/assertions/requireParamDescription.js index fc7fc32f4..8090049a4 100644 --- a/test/rules/assertions/requireParamDescription.js +++ b/test/rules/assertions/requireParamDescription.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @param "foo" description.' - } - ] + message: 'Missing JSDoc @param "foo" description.', + }, + ], }, { code: ` @@ -28,16 +28,16 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @arg "foo" description.' - } + message: 'Missing JSDoc @arg "foo" description.', + }, ], settings: { jsdoc: { tagNamePreference: { - param: 'arg' - } - } - } + param: 'arg', + }, + }, + }, }, { code: ` @@ -50,17 +50,17 @@ export default { `, errors: [ { - message: 'Unexpected tag `@param`' - } + message: 'Unexpected tag `@param`', + }, ], settings: { jsdoc: { tagNamePreference: { - param: false - } - } - } - } + param: false, + }, + }, + }, + }, ], valid: [ { @@ -71,7 +71,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -81,7 +81,7 @@ export default { function quux (foo) { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/requireParamName.js b/test/rules/assertions/requireParamName.js index 160018133..7bedfc197 100644 --- a/test/rules/assertions/requireParamName.js +++ b/test/rules/assertions/requireParamName.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 3, - message: 'There must be an identifier after @param type.' - } - ] + message: 'There must be an identifier after @param type.', + }, + ], }, { code: ` @@ -28,9 +28,9 @@ export default { errors: [ { line: 3, - message: 'There must be an identifier after @param tag.' - } - ] + message: 'There must be an identifier after @param tag.', + }, + ], }, { code: ` @@ -43,17 +43,17 @@ export default { `, errors: [ { - message: 'Unexpected tag `@param`' - } + message: 'Unexpected tag `@param`', + }, ], settings: { jsdoc: { tagNamePreference: { - param: false - } - } - } - } + param: false, + }, + }, + }, + }, ], valid: [ { @@ -64,7 +64,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -74,7 +74,7 @@ export default { function quux (foo) { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/requireParamType.js b/test/rules/assertions/requireParamType.js index a23a34e63..3685eafdc 100644 --- a/test/rules/assertions/requireParamType.js +++ b/test/rules/assertions/requireParamType.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @param "foo" type.' - } - ] + message: 'Missing JSDoc @param "foo" type.', + }, + ], }, { code: ` @@ -28,16 +28,16 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @arg "foo" type.' - } + message: 'Missing JSDoc @arg "foo" type.', + }, ], settings: { jsdoc: { tagNamePreference: { - param: 'arg' - } - } - } + param: 'arg', + }, + }, + }, }, { code: ` @@ -50,17 +50,17 @@ export default { `, errors: [ { - message: 'Unexpected tag `@param`' - } + message: 'Unexpected tag `@param`', + }, ], settings: { jsdoc: { tagNamePreference: { - param: false - } - } - } - } + param: false, + }, + }, + }, + }, ], valid: [ { @@ -71,7 +71,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -81,7 +81,7 @@ export default { function quux (foo) { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/requireReturns.js b/test/rules/assertions/requireReturns.js index abe174cef..a05a1d142 100644 --- a/test/rules/assertions/requireReturns.js +++ b/test/rules/assertions/requireReturns.js @@ -13,9 +13,9 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } - ] + message: 'Missing JSDoc @returns declaration.', + }, + ], }, { code: ` @@ -29,9 +29,9 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } - ] + message: 'Missing JSDoc @returns declaration.', + }, + ], }, { code: ` @@ -43,9 +43,9 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } - ] + message: 'Missing JSDoc @returns declaration.', + }, + ], }, { code: ` @@ -57,9 +57,9 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } - ] + message: 'Missing JSDoc @returns declaration.', + }, + ], }, { code: ` @@ -74,16 +74,16 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @return declaration.' - } + message: 'Missing JSDoc @return declaration.', + }, ], settings: { jsdoc: { tagNamePreference: { - returns: 'return' - } - } - } + returns: 'return', + }, + }, + }, }, { code: ` @@ -99,14 +99,14 @@ export default { `, errors: [ { - message: '`settings.jsdoc.forceRequireReturn` has been removed, use options in the rule `require-returns` instead.' - } + message: '`settings.jsdoc.forceRequireReturn` has been removed, use options in the rule `require-returns` instead.', + }, ], settings: { jsdoc: { - forceRequireReturn: true - } - } + forceRequireReturn: true, + }, + }, }, { code: ` @@ -119,15 +119,15 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } + message: 'Missing JSDoc @returns declaration.', + }, ], options: [{ - forceRequireReturn: true + forceRequireReturn: true, }], parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -139,15 +139,15 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } + message: 'Missing JSDoc @returns declaration.', + }, ], options: [{ - forceRequireReturn: true + forceRequireReturn: true, }], parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -159,15 +159,15 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } + message: 'Missing JSDoc @returns declaration.', + }, ], options: [{ - forceRequireReturn: true + forceRequireReturn: true, }], parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -179,15 +179,15 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } + message: 'Missing JSDoc @returns declaration.', + }, ], options: [{ - forceRequireReturn: true + forceRequireReturn: true, }], parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -200,12 +200,12 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } + message: 'Missing JSDoc @returns declaration.', + }, ], options: [{ - forceRequireReturn: true - }] + forceRequireReturn: true, + }], }, { code: ` @@ -221,9 +221,9 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @returns declaration.' - } - ] + message: 'Missing JSDoc @returns declaration.', + }, + ], }, { code: ` @@ -236,15 +236,15 @@ export default { errors: [ { line: 2, - message: 'Missing JSDoc @returns declaration.' - } + message: 'Missing JSDoc @returns declaration.', + }, ], options: [{ - forceReturnsWithAsync: true + forceReturnsWithAsync: true, }], parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -260,9 +260,9 @@ export default { errors: [ { line: 2, - message: 'Found more than one @returns declaration.' - } - ] + message: 'Found more than one @returns declaration.', + }, + ], }, { code: ` @@ -275,17 +275,17 @@ export default { `, errors: [ { - message: 'Unexpected tag `@returns`' - } + message: 'Unexpected tag `@returns`', + }, ], settings: { jsdoc: { tagNamePreference: { - returns: false - } - } - } - } + returns: false, + }, + }, + }, + }, ], valid: [ { @@ -297,7 +297,7 @@ export default { return foo; } - ` + `, }, { code: ` @@ -306,7 +306,7 @@ export default { */ function quux () { } - ` + `, }, { code: ` @@ -318,7 +318,7 @@ export default { return baz.corge(); }) } - ` + `, }, { code: ` @@ -330,7 +330,7 @@ export default { return baz.corge(); }) } - ` + `, }, { code: ` @@ -338,7 +338,7 @@ export default { * @returns Array */ const quux = (bar) => bar.filter(({ corge }) => corge()) - ` + `, }, { code: ` @@ -347,7 +347,7 @@ export default { */ function quux (foo) { } - ` + `, }, { code: ` @@ -356,7 +356,7 @@ export default { */ function quux (foo) { } - ` + `, }, { code: ` @@ -365,7 +365,7 @@ export default { */ function quux (foo) { } - ` + `, }, { code: ` @@ -374,7 +374,7 @@ export default { */ function quux (foo) { } - ` + `, }, { code: ` @@ -385,7 +385,7 @@ export default { return foo; } - ` + `, }, { code: ` @@ -395,7 +395,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -405,7 +405,7 @@ export default { function quux (foo) { } - ` + `, }, { code: ` @@ -416,7 +416,7 @@ export default { return {a: foo}; } - ` + `, }, { code: ` @@ -424,7 +424,7 @@ export default { * @returns {Object} */ const quux = () => ({a: foo}); - ` + `, }, { code: ` @@ -434,7 +434,7 @@ export default { const quux = () => { return {a: foo} }; - ` + `, }, { code: ` @@ -443,7 +443,7 @@ export default { */ function quux () { } - ` + `, }, { code: ` @@ -453,7 +453,7 @@ export default { const quux = () => { } - ` + `, }, { code: ` @@ -462,7 +462,7 @@ export default { */ function quux () { } - ` + `, }, { code: ` @@ -472,7 +472,7 @@ export default { const quux = () => { } - ` + `, }, { code: ` @@ -481,7 +481,7 @@ export default { */ function quux () { } - ` + `, }, { code: ` @@ -491,7 +491,7 @@ export default { const quux = () => { } - ` + `, }, { code: ` @@ -504,8 +504,8 @@ export default { } `, options: [{ - forceRequireReturn: true - }] + forceRequireReturn: true, + }], }, { code: ` @@ -517,7 +517,7 @@ export default { this._name = name; } } - ` + `, }, { code: ` @@ -528,8 +528,8 @@ export default { } `, options: [{ - forceRequireReturn: true - }] + forceRequireReturn: true, + }], }, { code: ` @@ -539,7 +539,7 @@ export default { function quux () { return undefined; } - ` + `, }, { code: ` @@ -551,8 +551,8 @@ export default { } `, options: [{ - forceRequireReturn: true - }] + forceRequireReturn: true, + }], }, { code: ` @@ -562,7 +562,7 @@ export default { function quux () { return; } - ` + `, }, { code: ` @@ -573,8 +573,8 @@ export default { } `, options: [{ - forceRequireReturn: true - }] + forceRequireReturn: true, + }], }, { code: ` @@ -586,8 +586,8 @@ export default { } `, options: [{ - forceRequireReturn: true - }] + forceRequireReturn: true, + }], }, { code: ` @@ -595,7 +595,7 @@ export default { function quux (req, res , next) { return; } - ` + `, }, { code: ` @@ -606,11 +606,11 @@ export default { } `, options: [{ - forceRequireReturn: true + forceRequireReturn: true, }], parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -621,11 +621,11 @@ export default { } `, options: [{ - forceReturnsWithAsync: true + forceReturnsWithAsync: true, }], parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -635,8 +635,8 @@ export default { async function quux () {} `, parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -646,8 +646,8 @@ export default { const quux = async function () {} `, parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -657,8 +657,8 @@ export default { const quux = async () => {} `, parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -674,8 +674,8 @@ export default { export default foo; `, parserOptions: { - sourceType: 'module' - } + sourceType: 'module', + }, }, { code: ` @@ -686,8 +686,8 @@ export default { } `, options: [{ - forceReturnsWithAsync: true - }] + forceReturnsWithAsync: true, + }], }, { code: ` @@ -700,9 +700,9 @@ export default { `, options: [ { - exemptedBy: ['type'] - } - ] - } - ] + exemptedBy: ['type'], + }, + ], + }, + ], }; diff --git a/test/rules/assertions/requireReturnsCheck.js b/test/rules/assertions/requireReturnsCheck.js index 0dcfa5a1a..299074187 100755 --- a/test/rules/assertions/requireReturnsCheck.js +++ b/test/rules/assertions/requireReturnsCheck.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 2, - message: 'JSDoc @returns declaration present but return expression not available in function.' - } - ] + message: 'JSDoc @returns declaration present but return expression not available in function.', + }, + ], }, { code: ` @@ -28,16 +28,16 @@ export default { errors: [ { line: 2, - message: 'JSDoc @return declaration present but return expression not available in function.' - } + message: 'JSDoc @return declaration present but return expression not available in function.', + }, ], settings: { jsdoc: { tagNamePreference: { - returns: 'return' - } - } - } + returns: 'return', + }, + }, + }, }, { code: ` @@ -49,9 +49,9 @@ export default { errors: [ { line: 2, - message: 'JSDoc @returns declaration present but return expression not available in function.' - } - ] + message: 'JSDoc @returns declaration present but return expression not available in function.', + }, + ], }, { code: ` @@ -67,9 +67,9 @@ export default { errors: [ { line: 2, - message: 'Found more than one @returns declaration.' - } - ] + message: 'Found more than one @returns declaration.', + }, + ], }, { code: ` @@ -86,9 +86,9 @@ export default { errors: [ { line: 3, - message: 'JSDoc @returns declaration present but return expression not available in function.' - } - ] + message: 'JSDoc @returns declaration present but return expression not available in function.', + }, + ], }, { code: ` @@ -103,9 +103,9 @@ export default { errors: [ { line: 3, - message: 'JSDoc @returns declaration present but return expression not available in function.' - } - ] + message: 'JSDoc @returns declaration present but return expression not available in function.', + }, + ], }, { code: ` @@ -118,16 +118,16 @@ export default { `, errors: [ { - message: 'Unexpected tag `@returns`' - } + message: 'Unexpected tag `@returns`', + }, ], settings: { jsdoc: { tagNamePreference: { - returns: false - } - } - } + returns: false, + }, + }, + }, }, { code: ` @@ -147,10 +147,10 @@ export default { errors: [ { line: 2, - message: 'JSDoc @returns declaration present but return expression not available in function.' - } - ] - } + message: 'JSDoc @returns declaration present but return expression not available in function.', + }, + ], + }, ], valid: [ { @@ -162,7 +162,7 @@ export default { return foo; } - ` + `, }, { code: ` @@ -173,7 +173,7 @@ export default { return foo; } - ` + `, }, { code: ` @@ -184,7 +184,7 @@ export default { return foo; } - ` + `, }, { code: ` @@ -193,7 +193,7 @@ export default { */ function quux () { } - ` + `, }, { code: ` @@ -201,7 +201,7 @@ export default { * @returns {*} Foo. */ const quux = () => foo; - ` + `, }, { code: ` @@ -209,7 +209,7 @@ export default { * @returns {undefined} Foo. */ function quux () {} - ` + `, }, { code: ` @@ -217,7 +217,7 @@ export default { * @returns { void } Foo. */ function quux () {} - ` + `, }, { code: ` @@ -227,8 +227,8 @@ export default { async function quux() {} `, parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -238,8 +238,8 @@ export default { const quux = async function () {} `, parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -249,8 +249,8 @@ export default { const quux = async () => {} `, parserOptions: { - ecmaVersion: 8 - } + ecmaVersion: 8, + }, }, { code: ` @@ -261,7 +261,7 @@ export default { function quux () { throw new Error('must be implemented by subclass!'); } - ` + `, }, { code: ` @@ -272,7 +272,7 @@ export default { function quux () { throw new Error('must be implemented by subclass!'); } - ` + `, }, { code: ` @@ -282,7 +282,7 @@ export default { */ function quux () { } - ` + `, }, { code: ` @@ -296,7 +296,7 @@ export default { bar () { } } - ` + `, }, { code: ` @@ -305,7 +305,7 @@ export default { */ function quux () { } - ` + `, }, { code: ` @@ -314,7 +314,7 @@ export default { */ function quux () { } - ` + `, }, { code: ` @@ -324,7 +324,7 @@ export default { function quux () { return undefined; } - ` + `, }, { code: ` @@ -334,7 +334,7 @@ export default { function quux () { return; } - ` + `, }, { code: ` @@ -344,7 +344,7 @@ export default { function quux () { return undefined; } - ` + `, }, { code: ` @@ -354,7 +354,7 @@ export default { function quux () { return; } - ` + `, }, { code: ` @@ -368,7 +368,7 @@ export default { } return; } - ` + `, }, { code: ` @@ -382,7 +382,7 @@ export default { } return; } - ` + `, }, { code: ` @@ -396,7 +396,7 @@ export default { } return true; } - ` + `, }, { code: ` @@ -411,7 +411,7 @@ export default { } return; } - ` + `, }, { code: ` @@ -425,7 +425,7 @@ export default { } return; } - ` + `, }, { code: ` @@ -439,7 +439,7 @@ export default { } return true; } - ` + `, }, { code: ` @@ -452,7 +452,7 @@ export default { } return; } - ` + `, }, { code: ` @@ -464,7 +464,7 @@ export default { return true; } } - ` + `, }, { code: ` @@ -476,7 +476,7 @@ export default { return true; } } - ` + `, }, { code: ` @@ -488,7 +488,7 @@ export default { return true } } - ` + `, }, { code: ` @@ -501,7 +501,7 @@ export default { } while(true) } - ` + `, }, { code: ` @@ -514,7 +514,7 @@ export default { } return true; } - ` + `, }, { code: ` @@ -526,7 +526,7 @@ export default { return true; } } - ` + `, }, { code: ` @@ -539,7 +539,7 @@ export default { return true; } } - ` + `, }, { code: ` @@ -554,7 +554,7 @@ export default { } return; } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/requireReturnsDescription.js b/test/rules/assertions/requireReturnsDescription.js index 80814dc96..df583c01f 100644 --- a/test/rules/assertions/requireReturnsDescription.js +++ b/test/rules/assertions/requireReturnsDescription.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @returns description.' - } - ] + message: 'Missing JSDoc @returns description.', + }, + ], }, { code: ` @@ -28,16 +28,16 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @return description.' - } + message: 'Missing JSDoc @return description.', + }, ], settings: { jsdoc: { tagNamePreference: { - returns: 'return' - } - } - } + returns: 'return', + }, + }, + }, }, { code: ` @@ -50,17 +50,17 @@ export default { `, errors: [ { - message: 'Unexpected tag `@returns`' - } + message: 'Unexpected tag `@returns`', + }, ], settings: { jsdoc: { tagNamePreference: { - returns: false - } - } - } - } + returns: false, + }, + }, + }, + }, ], valid: [ { @@ -71,7 +71,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -81,7 +81,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -91,7 +91,7 @@ export default { function quux () { } - ` + `, }, { code: ` @@ -101,7 +101,7 @@ export default { function quux () { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/requireReturnsType.js b/test/rules/assertions/requireReturnsType.js index eba849c6a..eb08f48b7 100644 --- a/test/rules/assertions/requireReturnsType.js +++ b/test/rules/assertions/requireReturnsType.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @returns type.' - } - ] + message: 'Missing JSDoc @returns type.', + }, + ], }, { code: ` @@ -28,9 +28,9 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @returns type.' - } - ] + message: 'Missing JSDoc @returns type.', + }, + ], }, { code: ` @@ -44,16 +44,16 @@ export default { errors: [ { line: 3, - message: 'Missing JSDoc @return type.' - } + message: 'Missing JSDoc @return type.', + }, ], settings: { jsdoc: { tagNamePreference: { - returns: 'return' - } - } - } + returns: 'return', + }, + }, + }, }, { code: ` @@ -66,17 +66,17 @@ export default { `, errors: [ { - message: 'Unexpected tag `@returns`' - } + message: 'Unexpected tag `@returns`', + }, ], settings: { jsdoc: { tagNamePreference: { - returns: false - } - } - } - } + returns: false, + }, + }, + }, + }, ], valid: [ { @@ -87,7 +87,7 @@ export default { function quux () { } - ` - } - ] + `, + }, + ], }; diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index 564859b30..531463ff5 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -12,9 +12,9 @@ export default { errors: [ { line: 3, - message: 'Syntax error in type: Array { const parserOptions = { - ecmaVersion: 6 + ecmaVersion: 6, }; // eslint-disable-next-line global-require, import/no-dynamic-require From 2bfe7d80ab9e4dd04d824526eff09bc3bcc8002d Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Thu, 8 Aug 2019 19:55:50 +0700 Subject: [PATCH 13/23] Cleanup after merging --- src/jsdocUtils.js | 6 ++-- src/rules/validTypes.js | 2 +- test/rules/assertions/validTypes.js | 46 ++++++++++++++--------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index 2b8662254..391f37f12 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -197,7 +197,7 @@ const potentiallyEmptyNamepathTags = [ 'see', // GCC syntax allows typedef to be named through variable declaration rather than jsdoc name - 'typedef' + 'typedef', ]; const isPotentiallyEmptyNamepathTag = (tag) => { @@ -249,7 +249,7 @@ const potentiallyEmptyTypeTags = [ 'return', 'returns', 'throws', 'exception', 'yields', 'yield', - 'package', 'private', 'protected', 'public', 'static' + 'package', 'private', 'protected', 'public', 'static', ]; const isPotentiallyEmptyTypeTag = (tag) => { @@ -263,7 +263,7 @@ const isTagWithType = (tagName) => { const tagsWithMandatoryNamepathOrType = [ 'augments', 'extends', 'param', 'arg', - 'typedef' + 'typedef', ]; const isTagWithMandatoryNamepathOrType = (tagName) => { return tagsWithMandatoryNamepathOrType.includes(tagName); diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index de113654b..7a9cd7405 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -64,7 +64,7 @@ export default iterateJsdoc(({ const hasType = Boolean(tag.type); const mustHaveType = utils.isTagWithType(tag.tag) && !utils.isPotentiallyEmptyTypeTag(tag.tag); - const hasNamePath = Boolean(tag.name); + const hasNamePath = Boolean(tag.name) && !(tag.tag === 'see' && !checkSeesForNamepaths); const mustHaveNamepath = utils.isNamepathTag(tag.tag, checkSeesForNamepaths) && !utils.passesEmptyNamepathCheck(tag, allowEmptyNamepaths); diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index 531463ff5..ea4214995 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -183,7 +183,7 @@ export default { message: 'Tag @callback must have a namepath', }], options: [{ - allowEmptyNamepaths: false + allowEmptyNamepaths: false, }], }, { @@ -196,9 +196,9 @@ export default { errors: [ { line: 3, - message: 'Syntax error in type: str%ng' - } - ] + message: 'Syntax error in type: str%ng', + }, + ], }, { code: ` @@ -209,9 +209,9 @@ export default { errors: [ { line: 3, - message: 'Syntax error in type: str%ng' - } - ] + message: 'Syntax error in type: str%ng', + }, + ], }, { code: ` @@ -222,9 +222,9 @@ export default { errors: [ { line: 3, - message: 'Syntax error in type: UserStr%ng' - } - ] + message: 'Syntax error in type: UserStr%ng', + }, + ], }, { code: ` @@ -236,9 +236,9 @@ export default { errors: [ { line: 3, - message: 'Tag @extends must have either a type or namepath' - } - ] + message: 'Tag @extends must have either a type or namepath', + }, + ], }, { code: ` @@ -250,10 +250,10 @@ export default { errors: [ { line: 3, - message: 'Tag @type must have a type' - } - ] - } + message: 'Tag @type must have a type', + }, + ], + }, ], valid: [ { @@ -403,7 +403,7 @@ export default { * @constant {string} */ const FOO = 'foo'; - ` + `, }, { code: ` @@ -411,7 +411,7 @@ export default { * @extends Foo */ class Bar {}; - ` + `, }, { code: ` @@ -419,14 +419,14 @@ export default { * @extends {Foo} */ class Bar {}; - ` + `, }, { code: ` /** * @typedef {number|string} UserDefinedType */ - ` + `, }, { code: ` @@ -434,7 +434,7 @@ export default { * @typedef {number|string} */ let UserDefinedGCCType; - ` - } + `, + }, ], }; From 44f98a4063de9cc88b5f09847205665a72c93f6e Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Thu, 8 Aug 2019 19:58:58 +0700 Subject: [PATCH 14/23] docs(valid-types) Update readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index ae54e3d89..49f84ab61 100644 --- a/README.md +++ b/README.md @@ -7493,6 +7493,13 @@ function quux() { } +/** + * @see foo% + */ +function quux() { + +} + /** * @alias module:namespace.SomeClass#event:ext_anevent */ From 5e0f9a5bca77a31808bbe4ed89d3ecb856fd35ee Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Thu, 8 Aug 2019 20:14:26 +0700 Subject: [PATCH 15/23] Completely ignore @see {@link ...} tag in parser --- src/iterateJsdoc.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index d2d12659f..b941fb190 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -11,29 +11,31 @@ import getJSDocComment from './eslint/getJSDocComment'; * @returns {object} */ const parseComment = (commentNode, indent, trim = true) => { + const skipSeeLink = (parser) => { + return (str, data) => { + if (data.tag === 'see' && str.match(/{@link.+?}/)) { + return null; + } + + return parser(str, data); + } + }; + // Preserve JSDoc block start/end indentation. return commentParser(`${indent}/*${commentNode.value}${indent}*/`, { // @see https://github.com/yavorskiy/comment-parser/issues/21 parsers: [ commentParser.PARSERS.parse_tag, - (str, data) => { - if (data.tag === 'see') { - // @see can't contain types, only names or links which might be confused with types - return null; - } - - return commentParser.PARSERS.parse_type(str, data); - }, - (str, data) => { - if (['example', 'return', 'returns', 'throws', 'exception'].includes(data.tag)) { - return null; - } - if (data.tag === 'see' && str.match(/{@link.+?}/)) { - return null; - } + skipSeeLink(commentParser.PARSERS.parse_type), + skipSeeLink( + (str, data) => { + if (['example', 'return', 'returns', 'throws', 'exception'].includes(data.tag)) { + return null; + } - return commentParser.PARSERS.parse_name(str, data); - }, + return commentParser.PARSERS.parse_name(str, data); + }, + ), trim ? commentParser.PARSERS.parse_description : From b89725086a801f3483670216818e48433f29664a Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Thu, 8 Aug 2019 21:14:51 +0700 Subject: [PATCH 16/23] Refactor utils naming --- src/iterateJsdoc.js | 33 ++++--- src/jsdocUtils.js | 181 ++++++++++++++-------------------- src/rules/checkTypes.js | 2 +- src/rules/noUndefinedTypes.js | 2 +- src/rules/validTypes.js | 7 +- 5 files changed, 100 insertions(+), 125 deletions(-) diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index b941fb190..d2cbafacb 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -18,7 +18,7 @@ const parseComment = (commentNode, indent, trim = true) => { } return parser(str, data); - } + }; }; // Preserve JSDoc block start/end indentation. @@ -193,27 +193,32 @@ const getUtils = ( return false; }; - utils.isNamepathDefiningTag = (tagName) => { - return jsdocUtils.isNamepathDefiningTag(tagName); + utils.tagMustHaveEitherTypeOrNamepath = (tagName) => { + return jsdocUtils.tagMustHaveEitherTypeOrNamepath(tagName); }; - utils.isNamepathTag = (tagName, checkSeesForNamepaths) => { - return jsdocUtils.isNamepathTag(tagName, checkSeesForNamepaths); + + utils.tagMightHaveEitherTypeOrNamepath = (tagName) => { + return jsdocUtils.tagMightHaveEitherTypeOrNamepath(tagName); }; - utils.isTagWithType = (tagName) => { - return jsdocUtils.isTagWithType(tagName); + utils.tagMustHaveNamepath = (tagName) => { + return jsdocUtils.tagMustHaveNamepath(tagName); }; - utils.isPotentiallyEmptyTypeTag = (tagName) => { - return jsdocUtils.isPotentiallyEmptyTypeTag(tagName); + + utils.tagMightHaveNamepath = (tagName) => { + return jsdocUtils.tagMightHaveNamepath(tagName); }; - utils.passesEmptyNamepathCheck = (tag, allowEmptyNamepaths) => { - return !tag.name && allowEmptyNamepaths && - jsdocUtils.isPotentiallyEmptyNamepathTag(tag.tag); + utils.tagMustHaveType = (tagName) => { + return jsdocUtils.tagMustHaveType(tagName); }; - utils.isTagWithMandatoryNamepathOrType = (tagName) => { - return jsdocUtils.isTagWithMandatoryNamepathOrType(tagName); + utils.tagMightHaveType = (tagName) => { + return jsdocUtils.tagMightHaveType(tagName); + }; + + utils.isNamepathDefiningTag = (tagName) => { + return jsdocUtils.isNamepathDefiningTag(tagName); }; utils.hasDefinedTypeReturnTag = (tag) => { diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index 391f37f12..5c863b2b0 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -126,17 +126,45 @@ const hasDefinedTypeReturnTag = (tag) => { return true; }; +const tagsWithOptionalType = [ + 'augments', 'extends', + 'class', 'constructor', + 'constant', 'const', + 'enum', + 'implements', + 'member', 'var', + 'module', + 'namespace', + 'param', 'arg', 'argument', + 'property', 'prop', + 'returns', 'return', + 'throws', 'exception', + 'type', + 'typedef', + 'yields', 'yield', + + // GCC specific + 'package', + 'private', + 'protected', + 'public', + 'static', +]; + +const tagsWithMandatoryType = [ + 'enum', + 'implements', + 'member', 'var', + 'module', + 'type', + 'typedef', +]; + const namepathDefiningTags = [ - // NOT USEFUL WITHOUT NAMEPATH 'external', 'host', 'name', 'typedef', - - // MAY BE USEFUL WITHOUT NAMEPATH 'event', - - // MAY BE USEFUL WITHOUT NAMEPATH (OR - // BLOCK CAN USE NAMEPATH FROM ELSEWHERE) 'class', 'constructor', 'constant', 'const', 'callback', @@ -147,126 +175,68 @@ const namepathDefiningTags = [ 'namespace', ]; -const namepathPointingTags = [ - // NOT USEFUL WITHOUT NAMEPATH +const tagsWithOptionalNamepath = [ + ...namepathDefiningTags, 'alias', 'augments', 'extends', // `borrows` has a different format, however, so needs special parsing 'borrows', + 'emits', 'fires', 'lends', - 'memberof', - 'memberof!', + 'listens', + 'memberof', 'memberof!', 'mixes', + 'see', 'this', - - // MAY BE USEFUL WITHOUT NAMEPATH - 'emits', - 'fires', - 'listens', ]; -const isNamepathDefiningTag = (tagName) => { - return namepathDefiningTags.includes(tagName); -}; - -const isNamepathPointingTag = (tagName, checkSeesForNamepaths) => { - return namepathPointingTags.includes(tagName) || - tagName === 'see' && checkSeesForNamepaths; -}; - -const isNamepathTag = (tagName, checkSeesForNamepaths) => { - return isNamepathDefiningTag(tagName) || - isNamepathPointingTag(tagName, checkSeesForNamepaths); -}; - -const potentiallyEmptyNamepathTags = [ - // These may serve some minor purpose when empty or - // their namepath can be expressed elsewhere on the block - 'event', +const tagsWithMandatoryNamepath = [ 'callback', - 'class', 'constructor', - 'extends', 'augments', - 'constant', 'const', - 'function', 'func', 'method', - 'interface', - 'member', 'var', - 'mixin', - 'namespace', - 'listens', 'fires', 'emits', - 'see', - - // GCC syntax allows typedef to be named through variable declaration rather than jsdoc name + 'external', 'host', + 'name', 'typedef', ]; -const isPotentiallyEmptyNamepathTag = (tag) => { - return potentiallyEmptyNamepathTags.includes(tag); -}; - -let tagsWithTypes = [ +const tagsWithMandatoryEitherTypeOrNamepath = [ + 'alias', 'augments', 'extends', - 'class', - 'constant', - 'enum', - 'implements', - 'member', - 'module', - 'namespace', - 'param', - 'property', - 'returns', - 'throws', - 'type', + 'borrows', + 'external', 'host', + 'lends', + 'memberof', 'memberof!', + 'mixes', + 'name', + 'this', 'typedef', - 'yields', ]; -const closureTagsWithTypes = [ - 'package', 'private', 'protected', 'public', 'static', -]; +const isNamepathDefiningTag = (tagName) => { + return namepathDefiningTags.includes(tagName); +}; -const tagsWithTypesAliases = [ - 'constructor', - 'const', - 'var', - 'arg', - 'argument', - 'prop', - 'return', - 'exception', - 'yield', -]; +const tagMightHaveType = (tag) => { + return tagsWithOptionalType.includes(tag); +}; -tagsWithTypes = tagsWithTypes.concat(tagsWithTypesAliases, closureTagsWithTypes); +const tagMustHaveType = (tag) => { + return tagsWithMandatoryType.includes(tag); +}; -const potentiallyEmptyTypeTags = [ - 'class', 'constructor', - 'constant', 'const', - 'extends', 'augments', - 'namespace', - 'param', 'arg', - 'return', 'returns', - 'throws', 'exception', - 'yields', 'yield', - 'package', 'private', 'protected', 'public', 'static', -]; +const tagMightHaveNamepath = (tag) => { + return tagsWithOptionalNamepath.includes(tag); +}; -const isPotentiallyEmptyTypeTag = (tag) => { - return potentiallyEmptyTypeTags.includes(tag); +const tagMustHaveNamepath = (tag) => { + return tagsWithMandatoryNamepath.includes(tag); }; -const isTagWithType = (tagName) => { - return tagsWithTypes.includes(tagName); +const tagMightHaveEitherTypeOrNamepath = (tag) => { + return tagMightHaveType(tag) || tagMightHaveNamepath(tag); }; -const tagsWithMandatoryNamepathOrType = [ - 'augments', 'extends', - 'param', 'arg', - 'typedef', -]; -const isTagWithMandatoryNamepathOrType = (tagName) => { - return tagsWithMandatoryNamepathOrType.includes(tagName); +const tagMustHaveEitherTypeOrNamepath = (tag) => { + return tagsWithMandatoryEitherTypeOrNamepath.includes(tag); }; /** @@ -451,11 +421,12 @@ export default { hasReturnValue, hasTag, isNamepathDefiningTag, - isNamepathTag, - isPotentiallyEmptyNamepathTag, - isPotentiallyEmptyTypeTag, - isTagWithMandatoryNamepathOrType, - isTagWithType, isValidTag, parseClosureTemplateTag, + tagMightHaveEitherTypeOrNamepath, + tagMightHaveNamepath, + tagMightHaveType, + tagMustHaveEitherTypeOrNamepath, + tagMustHaveNamepath, + tagMustHaveType, }; diff --git a/src/rules/checkTypes.js b/src/rules/checkTypes.js index 2f40654b5..c4af665fd 100644 --- a/src/rules/checkTypes.js +++ b/src/rules/checkTypes.js @@ -26,7 +26,7 @@ export default iterateJsdoc(({ context, }) => { const jsdocTags = utils.filterTags((tag) => { - return utils.isTagWithType(tag.tag); + return utils.tagMightHaveType(tag.tag); }); const {preferredTypes} = settings; diff --git a/src/rules/noUndefinedTypes.js b/src/rules/noUndefinedTypes.js index f673d6d30..f179d1134 100644 --- a/src/rules/noUndefinedTypes.js +++ b/src/rules/noUndefinedTypes.js @@ -108,7 +108,7 @@ export default iterateJsdoc(({ .concat(closureGenericTypes); const jsdocTags = utils.filterTags((tag) => { - return utils.isTagWithType(tag.tag); + return utils.tagMightHaveType(tag.tag); }); jsdocTags.forEach((tag) => { diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index 7a9cd7405..623b60d7e 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -62,14 +62,13 @@ export default iterateJsdoc(({ }; const hasType = Boolean(tag.type); - const mustHaveType = utils.isTagWithType(tag.tag) && !utils.isPotentiallyEmptyTypeTag(tag.tag); + const mustHaveType = utils.tagMustHaveType(tag.tag); const hasNamePath = Boolean(tag.name) && !(tag.tag === 'see' && !checkSeesForNamepaths); - const mustHaveNamepath = utils.isNamepathTag(tag.tag, checkSeesForNamepaths) && - !utils.passesEmptyNamepathCheck(tag, allowEmptyNamepaths); + const mustHaveNamepath = utils.tagMustHaveNamepath(tag.tag) && !allowEmptyNamepaths; const hasEither = hasType || hasNamePath; - const mustHaveEither = utils.isTagWithMandatoryNamepathOrType(tag.tag); + const mustHaveEither = utils.tagMustHaveEitherTypeOrNamepath(tag.tag); if (tag.tag === 'borrows') { const thisNamepath = tag.description.replace(asExpression, ''); From 668ea896888e60dece4dc1b5ddd0b9ed81e6f53f Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Thu, 8 Aug 2019 21:30:19 +0700 Subject: [PATCH 17/23] Add couple more tests and reuse some utilites to fix coverage --- README.md | 13 +++++++++++++ src/rules/validTypes.js | 6 +++--- test/rules/assertions/validTypes.js | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 49f84ab61..cac20248e 100644 --- a/README.md +++ b/README.md @@ -7514,6 +7514,14 @@ function quux() { } +/** + * @callback foo + */ +function quux() { + +} +// Options: [{"allowEmptyNamepaths":true}] + /** * @class */ @@ -7562,6 +7570,11 @@ function quux() { */ const FOO = 'foo'; +/** + * @constant {string} FOO + */ + const FOO = 'foo'; + /** * @extends Foo */ diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index 623b60d7e..11e329950 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -61,13 +61,13 @@ export default iterateJsdoc(({ return true; }; - const hasType = Boolean(tag.type); + const hasType = utils.tagMightHaveType(tag.tag) && Boolean(tag.type); const mustHaveType = utils.tagMustHaveType(tag.tag); - const hasNamePath = Boolean(tag.name) && !(tag.tag === 'see' && !checkSeesForNamepaths); + const hasNamePath = utils.tagMightHaveNamepath(tag.tag) && Boolean(tag.name) && !(tag.tag === 'see' && !checkSeesForNamepaths); const mustHaveNamepath = utils.tagMustHaveNamepath(tag.tag) && !allowEmptyNamepaths; - const hasEither = hasType || hasNamePath; + const hasEither = utils.tagMightHaveEitherTypeOrNamepath(tag.tag) && hasType || hasNamePath; const mustHaveEither = utils.tagMustHaveEitherTypeOrNamepath(tag.tag); if (tag.tag === 'borrows') { diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index ea4214995..3b2bc0d20 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -336,6 +336,19 @@ export default { } `, }, + { + code: ` + /** + * @callback foo + */ + function quux() { + + } + `, + options: [{ + allowEmptyNamepaths: true, + }], + }, { code: ` /** @@ -405,6 +418,14 @@ export default { const FOO = 'foo'; `, }, + { + code: ` + /** + * @constant {string} FOO + */ + const FOO = 'foo'; + `, + }, { code: ` /** From bccfebe6ae5b971fc53d02a7459d4e1228edece9 Mon Sep 17 00:00:00 2001 From: Ilya Kalashnikov <1044684+l1bbcsg@users.noreply.github.com> Date: Thu, 8 Aug 2019 21:56:32 +0700 Subject: [PATCH 18/23] Call namepaths namepath instead of types in error messages --- README.md | 18 ++++++------- src/rules/validTypes.js | 42 ++++++++++++++++++----------- test/rules/assertions/validTypes.js | 18 ++++++------- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index cac20248e..fda9e2f54 100644 --- a/README.md +++ b/README.md @@ -7345,7 +7345,7 @@ function quux() { function quux() { } -// Message: Syntax error in type: module:namespace.SomeClass<~ +// Message: Syntax error in namepath: module:namespace.SomeClass<~ /** * @memberof module:namespace.SomeClass~< @@ -7353,7 +7353,7 @@ function quux() { function quux() { } -// Message: Syntax error in type: module:namespace.SomeClass~< +// Message: Syntax error in namepath: module:namespace.SomeClass~< /** * @borrows foo% as bar @@ -7361,7 +7361,7 @@ function quux() { function quux() { } -// Message: Syntax error in type: foo% +// Message: Syntax error in namepath: foo% /** * @borrows #foo as bar @@ -7369,7 +7369,7 @@ function quux() { function quux() { } -// Message: Syntax error in type: #foo +// Message: Syntax error in namepath: #foo /** * @borrows foo as bar% @@ -7377,7 +7377,7 @@ function quux() { function quux() { } -// Message: Syntax error in type: bar% +// Message: Syntax error in namepath: bar% /** * @borrows foo @@ -7394,7 +7394,7 @@ function quux() { } // Options: [{"checkSeesForNamepaths":true}] -// Message: Syntax error in type: foo% +// Message: Syntax error in namepath: foo% /** */ function foo() {} @@ -7407,7 +7407,7 @@ function foo() {} function quux() { } -// Message: Syntax error in type: module:abc#event:foo-bar +// Message: Syntax error in namepath: module:abc#event:foo-bar /** * @mixes module:namespace.SomeClass~ @@ -7415,7 +7415,7 @@ function quux() { function quux() { } -// Message: Syntax error in type: module:namespace.SomeClass~ +// Message: Syntax error in namepath: module:namespace.SomeClass~ /** * @callback @@ -7440,7 +7440,7 @@ function quux() { /** * @typedef {string} UserStr%ng */ -// Message: Syntax error in type: UserStr%ng +// Message: Syntax error in namepath: UserStr%ng /** * @extends diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index 11e329950..0ddf21bd9 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -21,29 +21,29 @@ export default iterateJsdoc(({ return; } jsdoc.tags.forEach((tag) => { - const validTypeParsing = function (type, tagName) { + const validNamepathParsing = function (namepath, tagName) { try { - parse(type); - } catch (err) { - let error = err; + parse(namepath); + } catch (error) { + let handled = false; if (tagName) { if (['memberof', 'memberof!'].includes(tagName)) { - const endChar = type.slice(-1); + const endChar = namepath.slice(-1); if (['#', '.', '~'].includes(endChar)) { try { - parse(type.slice(0, -1)); - error = {}; + parse(namepath.slice(0, -1)); + handled = true; } catch (memberofError) { // Use the original error for including the whole type } } } else if (tagName === 'borrows') { - const startChar = type.charAt(); + const startChar = namepath.charAt(); if (['#', '.', '~'].includes(startChar)) { try { - parse(type.slice(1)); - error = {}; + parse(namepath.slice(1)); + handled = true; } catch (memberofError) { // Use the original error for including the whole type } @@ -51,8 +51,8 @@ export default iterateJsdoc(({ } } - if (error.name === 'SyntaxError') { - report(`Syntax error in type: ${type}`, null, tag); + if (!handled) { + report(`Syntax error in namepath: ${namepath}`, null, tag); return false; } @@ -61,6 +61,18 @@ export default iterateJsdoc(({ return true; }; + const validTypeParsing = function (type) { + try { + parse(type); + } catch (error) { + report(`Syntax error in type: ${type}`, null, tag); + + return false; + } + + return true; + }; + const hasType = utils.tagMightHaveType(tag.tag) && Boolean(tag.type); const mustHaveType = utils.tagMustHaveType(tag.tag); @@ -79,10 +91,10 @@ export default iterateJsdoc(({ return; } - if (validTypeParsing(thisNamepath, 'borrows')) { + if (validNamepathParsing(thisNamepath, 'borrows')) { const thatNamepath = tag.name; - validTypeParsing(thatNamepath); + validNamepathParsing(thatNamepath); } } else { if (mustHaveEither && !hasEither) { @@ -98,7 +110,7 @@ export default iterateJsdoc(({ } if (hasNamePath) { - validTypeParsing(tag.name, tag.tag); + validNamepathParsing(tag.name, tag.tag); } else if (mustHaveNamepath) { report(`Tag @${tag.tag} must have a namepath`, null, tag); } diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index 3b2bc0d20..0a94ca49a 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -28,7 +28,7 @@ export default { errors: [ { line: 3, - message: 'Syntax error in type: module:namespace.SomeClass<~', + message: 'Syntax error in namepath: module:namespace.SomeClass<~', }, ], }, @@ -44,7 +44,7 @@ export default { errors: [ { line: 3, - message: 'Syntax error in type: module:namespace.SomeClass~<', + message: 'Syntax error in namepath: module:namespace.SomeClass~<', }, ], }, @@ -59,7 +59,7 @@ export default { `, errors: [{ line: 3, - message: 'Syntax error in type: foo%', + message: 'Syntax error in namepath: foo%', }], }, { @@ -73,7 +73,7 @@ export default { `, errors: [{ line: 3, - message: 'Syntax error in type: #foo', + message: 'Syntax error in namepath: #foo', }], }, { @@ -87,7 +87,7 @@ export default { `, errors: [{ line: 3, - message: 'Syntax error in type: bar%', + message: 'Syntax error in namepath: bar%', }], }, { @@ -115,7 +115,7 @@ export default { `, errors: [{ line: 3, - message: 'Syntax error in type: foo%', + message: 'Syntax error in namepath: foo%', }], options: [{ checkSeesForNamepaths: true, @@ -152,7 +152,7 @@ export default { `, errors: [{ line: 3, - message: 'Syntax error in type: module:abc#event:foo-bar', + message: 'Syntax error in namepath: module:abc#event:foo-bar', }], }, { @@ -166,7 +166,7 @@ export default { `, errors: [{ line: 3, - message: 'Syntax error in type: module:namespace.SomeClass~', + message: 'Syntax error in namepath: module:namespace.SomeClass~', }], }, { @@ -222,7 +222,7 @@ export default { errors: [ { line: 3, - message: 'Syntax error in type: UserStr%ng', + message: 'Syntax error in namepath: UserStr%ng', }, ], }, From 6b7ab349c6bb8343a64d58e4637a3831751b36cd Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 1 Sep 2019 11:15:05 +0800 Subject: [PATCH 19/23] refactor: remove mandatory type items from optional type items list and query both --- src/jsdocUtils.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index 99295f196..c4abc4ec9 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -129,21 +129,24 @@ const hasDefinedTypeReturnTag = (tag) => { return true; }; -const tagsWithOptionalType = [ - 'augments', 'extends', - 'class', 'constructor', - 'constant', 'const', +const tagsWithMandatoryType = [ 'enum', 'implements', 'member', 'var', 'module', + 'type', + 'typedef', +]; + +const tagsWithOptionalType = [ + 'augments', 'extends', + 'class', 'constructor', + 'constant', 'const', 'namespace', 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', 'throws', 'exception', - 'type', - 'typedef', 'yields', 'yield', // GCC specific @@ -154,15 +157,6 @@ const tagsWithOptionalType = [ 'static', ]; -const tagsWithMandatoryType = [ - 'enum', - 'implements', - 'member', 'var', - 'module', - 'type', - 'typedef', -]; - const namepathDefiningTags = [ 'external', 'host', 'name', @@ -219,7 +213,7 @@ const isNamepathDefiningTag = (tagName) => { }; const tagMightHaveType = (tag) => { - return tagsWithOptionalType.includes(tag); + return tagsWithMandatoryType.includes(tag) || tagsWithOptionalType.includes(tag); }; const tagMustHaveType = (tag) => { From 24e8a57f6c4423477391e6aa126e6e7304b67bff Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 1 Sep 2019 11:16:53 +0800 Subject: [PATCH 20/23] docs: add todo comment to ensure handling gcc when mode added --- src/jsdocUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index c4abc4ec9..c3e591305 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -149,7 +149,7 @@ const tagsWithOptionalType = [ 'throws', 'exception', 'yields', 'yield', - // GCC specific + // Todo: Omit these GCC specific items when in non-GCC mode after landing https://github.com/gajus/eslint-plugin-jsdoc/issues/356 'package', 'private', 'protected', From 439fd99ab7551848593f3794bf10b3bcdd21c434 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 1 Sep 2019 11:22:05 +0800 Subject: [PATCH 21/23] refactor: rename variable without redundant "either" --- src/jsdocUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index c3e591305..cc62bfa46 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -195,7 +195,7 @@ const tagsWithMandatoryNamepath = [ 'typedef', ]; -const tagsWithMandatoryEitherTypeOrNamepath = [ +const tagsWithMandatoryTypeOrNamepath = [ 'alias', 'augments', 'extends', 'borrows', @@ -233,7 +233,7 @@ const tagMightHaveEitherTypeOrNamepath = (tag) => { }; const tagMustHaveEitherTypeOrNamepath = (tag) => { - return tagsWithMandatoryEitherTypeOrNamepath.includes(tag); + return tagsWithMandatoryTypeOrNamepath.includes(tag); }; /** From 6081ff25073e7d805465a0e04c4a208e5f576d6d Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 1 Sep 2019 12:27:46 +0800 Subject: [PATCH 22/23] testing: remove namepath in test checking for empty namepath --- README.md | 2 +- test/rules/assertions/validTypes.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a269a05d..5a55b6172 100644 --- a/README.md +++ b/README.md @@ -7532,7 +7532,7 @@ function quux() { } /** - * @callback foo + * @callback */ function quux() { diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index 0a94ca49a..b64628f52 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -339,7 +339,7 @@ export default { { code: ` /** - * @callback foo + * @callback */ function quux() { From 902fac0f75f5bb3d576312977d2ad4d9b2772fde Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 1 Sep 2019 12:40:30 +0800 Subject: [PATCH 23/23] testing: ensure we don't report `see` with `link` even with `checkSeesForNamepaths` option on --- README.md | 1 + test/rules/assertions/validTypes.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 5a55b6172..4bcd5692e 100644 --- a/README.md +++ b/README.md @@ -7552,6 +7552,7 @@ function quux() { function quux() { } +// Options: [{"checkSeesForNamepaths":true}] /** * diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index b64628f52..1790b43ef 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -368,6 +368,9 @@ export default { } `, + options: [{ + checkSeesForNamepaths: true, + }], }, { code: `