Commit 9048c3b7 authored by Wiktor Walasek's avatar Wiktor Walasek

Do not add TODO for undefined|null|void return types

parent bc9d692a
......@@ -98,16 +98,19 @@ function jsdocParser(text, parsers, options) {
if (tag.type) {
// Figure out tag.type.name
if (!tag.type.name) {
const typeNameMap = {
'UndefinedLiteral': 'undefined',
'NullLiteral': 'null',
}
if (Object.keys(typeNameMap).includes(tag.type.type)) {
tag.type.name = typeNameMap[tag.type.type]
}
if (tag.type.expression) {
tag.type.name = tag.type.expression.name
tag.type.elements = tag.type.expression.elements
}
if (tag.type.elements) {
tag.type.name = tag.type.elements.map(e => {
const typeNameMap = {
'UndefinedLiteral': 'undefined',
'NullLiteral': 'null',
}
return typeNameMap[e.type] || e.name || 'undefined'
}).join('|')
}
......@@ -127,7 +130,8 @@ function jsdocParser(text, parsers, options) {
if (['description', 'param', 'return', 'todo'].includes(tag.title))
tag.description = formatDescription(tag.description, options.jsdocAddDotToDescription)
if (!tag.description && ['description', 'param', 'return', 'todo', 'memberof'].includes(tag.title))
if (!tag.description && ['description', 'param', 'return', 'todo', 'memberof'].includes(tag.title) &&
(!tag.type || !['Undefined', 'undefined', 'Null', 'null', 'Void', 'void'].includes(tag.type.name)))
tag.description = formatDescription('TODO', options.jsdocAddDotToDescription)
return tag
......
......@@ -127,4 +127,34 @@ test('Should add empty line after @description and @example description if neces
expect(Result3).toEqual(Expected3)
})
test('Should add TODO for return desc if it has undefined|null|void type', () => {
const Result1 = subject(`/**
* @returns {undefined}
*/`)
const Expected1 = `/**
* @return {undefined}
*/
`
const Result2 = subject(`/**
* @returns {null}
*/`)
const Expected2 = `/**
* @return {null}
*/
`
const Result3 = subject(`/**
* @returns {void}
*/`)
const Expected3 = `/**
* @return {void}
*/
`
// expect(Result1).toEqual(Expected1)
expect(Result2).toEqual(Expected2)
expect(Result3).toEqual(Expected3)
})
test.todo('spaces option')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment