Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
P
prettier-plugin-jsdoc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gumen
prettier-plugin-jsdoc
Commits
9048c3b7
Commit
9048c3b7
authored
Jan 23, 2020
by
Wiktor Walasek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not add TODO for undefined|null|void return types
parent
bc9d692a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
5 deletions
+39
-5
jsdoc_parser.js
jsdoc_parser.js
+9
-5
tests/main.js
tests/main.js
+30
-0
No files found.
jsdoc_parser.js
View file @
9048c3b7
...
...
@@ -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
...
...
tests/main.js
View file @
9048c3b7
...
...
@@ -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
'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment