Skip to content

Commit

Permalink
feat(javascript): use @returns instead of @return
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Oct 8, 2021
1 parent f1a08b4 commit 79e6247
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 73 deletions.
2 changes: 1 addition & 1 deletion ftplugin/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ call doge#buffer#register_doc_standard('jsdoc', [
\ '%(typeParameters| * {typeParameters})%',
\ '%(parameters| * {parameters})%',
\ '%(exceptions| * {exceptions})%',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ '%(returnType| * @returns {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down
40 changes: 20 additions & 20 deletions test/filetypes/javascript/es6.vader
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Expect javascript (no generated comment):
/**
* [TODO:description]
*
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
() => {}

Expand All @@ -26,12 +26,12 @@ Given javascript (fat-arrow function with a single parameter without return type
Do (trigger doge):
\<C-d>

Expect javascript (generated comment with @param and @return tags):
Expect javascript (generated comment with @param and @returns tags):
/**
* [TODO:description]
*
* @param {[TODO:type]} bar - [TODO:description]
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
export const foo = bar => {
return bar
Expand All @@ -50,15 +50,15 @@ Do (trigger doge):
:13\<CR>
\<C-d>

Expect javascript (generated comment with @param and @return tags):
Expect javascript (generated comment with @param and @returns tags):
/**
* [TODO:description]
*
* @param {[TODO:type]} [$p1] - [TODO:description]
* @param {[TODO:type]} [p2] - [TODO:description]
* @param {[TODO:type]} p3 - [TODO:description]
* @param {[TODO:type]} p4 - [TODO:description]
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
const myFunc = ($p1 = 'value', p2 = [], p3, p4) => {}

Expand All @@ -69,7 +69,7 @@ Expect javascript (generated comment with @param and @return tags):
* @param {[TODO:type]} [p2] - [TODO:description]
* @param {[TODO:type]} p3 - [TODO:description]
* @param {[TODO:type]} p4 - [TODO:description]
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
let myFunc = ($p1 = 'value', p2 = [], p3, p4) => {}

Expand All @@ -82,15 +82,15 @@ Given javascript (fat-arrow function with parameters with type hints):
Do (trigger doge):
\<C-d>

Expect javascript (generated comment with @param and @return tags):
Expect javascript (generated comment with @param and @returns tags):
/**
* [TODO:description]
*
* @param {string} [$p1] - [TODO:description]
* @param {string[]} [p2] - [TODO:description]
* @param {number} p3 - [TODO:description]
* @param {float} p4 - [TODO:description]
* @return {string[]} [TODO:description]
* @returns {string[]} [TODO:description]
*/
const myFunc = ($p1: string = 'value', p2: string[] = [], p3: number, p4: float): string[] => {}

Expand All @@ -114,14 +114,14 @@ Do (trigger doge):
:13\<CR>
\<C-d>

Expect javascript (generated comments with @static, @param and @return tags):
Expect javascript (generated comments with @static, @param and @returns tags):
class Test {
/**
* [TODO:description]
*
* @param {[TODO:type]} [TODO:name] - [TODO:description]
* @param {number} [TODO:name].b - [TODO:description]
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
myMethod = ({ b: number }) => {
return this.add(b);
Expand All @@ -133,7 +133,7 @@ Expect javascript (generated comments with @static, @param and @return tags):
* @static
* @param {[TODO:type]} [TODO:name] - [TODO:description]
* @param {number} [TODO:name].b - [TODO:description]
* @return {number} [TODO:description]
* @returns {number} [TODO:description]
*/
static myMethod({ b: number }): number {
return this.add(b);
Expand All @@ -154,13 +154,13 @@ Do (trigger doge):
:2\<CR>
\<C-d>

Expect javascript (generated comment with a description, @param and @return tags):
Expect javascript (generated comment with a description, @param and @returns tags):
class Test {
/**
* [TODO:description]
*
* @param {number} b - [TODO:description]
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
myMethod(public b: number) {
return this.add(b);
Expand All @@ -176,14 +176,14 @@ Given javascript (prototype fat-arrow function with parameters with type hints):
Do (trigger doge):
\<C-d>

Expect javascript (generated comment with @function, @param and @return tags):
Expect javascript (generated comment with @function, @param and @returns tags):
/**
* [TODO:description]
*
* @function Person#greet
* @param {string} [p1] - [TODO:description]
* @param {Immutable.List} [p2] - [TODO:description]
* @return {string[]} [TODO:description]
* @returns {string[]} [TODO:description]
*/
Person.prototype.greet = (p1: string = 'default', p2: Immutable.List = Immutable.List()): string[] => {};

Expand All @@ -199,7 +199,7 @@ Do (trigger doge):
/**
* [TODO:description]
*
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
Person.prototype.greet = () => {};

Expand All @@ -212,13 +212,13 @@ Given javascript (fat-arrow function with parameters with multiple type hints):
Do (trigger doge):
\<C-d>

Expect javascript (generated comment with @function, @param and @return tags):
Expect javascript (generated comment with @function, @param and @returns tags):
/**
* [TODO:description]
*
* @param {string} $p1 - [TODO:description]
* @param {Foo | Bar | Baz} p2 - [TODO:description]
* @return {(Foo | Bar)} [TODO:description]
* @returns {(Foo | Bar)} [TODO:description]
*/
const myFunc = ($p1: string, p2: Foo | Bar | Baz): (Foo | Bar) => {};

Expand All @@ -231,13 +231,13 @@ Given javascript (async fat-arrow function with parameters with multiple type hi
Do (trigger doge):
\<C-d>

Expect javascript (generated comment with @async, @function, @param and @return tags):
Expect javascript (generated comment with @async, @function, @param and @returns tags):
/**
* [TODO:description]
*
* @async
* @param {string} $p1 - [TODO:description]
* @param {Foo | Bar | Baz} p2 - [TODO:description]
* @return {(Foo | Bar)} [TODO:description]
* @returns {(Foo | Bar)} [TODO:description]
*/
const myFunc = async ($p1: string, p2: Foo | Bar | Baz): (Foo | Bar) => {};
4 changes: 2 additions & 2 deletions test/filetypes/javascript/es7.vader
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Do (trigger doge):
:8\<CR>
\<C-d>

Expect javascript (generated comment with @async, @param and @return tags):
Expect javascript (generated comment with @async, @param and @returns tags):
class Test {
/**
* [TODO:description]
Expand All @@ -28,7 +28,7 @@ Expect javascript (generated comment with @async, @param and @return tags):
* @param {User} [TODO:name] - [TODO:description]
* @param {[TODO:type]} [TODO:name].id - [TODO:description]
* @param {Request} req - [TODO:description]
* @return {Promise<User>} [TODO:description]
* @returns {Promise<User>} [TODO:description]
*/
@Get()
@UseGuards(LocalAuthGuard([
Expand Down
10 changes: 5 additions & 5 deletions test/filetypes/javascript/functions-inside-objects.vader
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Do (trigger doge):
/**
* [TODO:description]
*
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
myFunc: function(/* inline comment */) {
//
},
/**
* [TODO:description]
*
* @return {[TODO:type]} [TODO:description]
* @returns {[TODO:type]} [TODO:description]
*/
myArrowFunc: (/* inline comment */) => {
//
Expand All @@ -56,7 +56,7 @@ Do (trigger doge):
:15\<CR>
\<C-d>

Expect javascript (generated comment with @async, @param and @return tags):
Expect javascript (generated comment with @async, @param and @returns tags):
var myObj = {
/**
* [TODO:description]
Expand All @@ -66,7 +66,7 @@ Expect javascript (generated comment with @async, @param and @return tags):
* @param {array} [p2] - [TODO:description]
* @param {[TODO:type]} p3 - [TODO:description]
* @param {[TODO:type]} p4 - [TODO:description]
* @return {Promise<[TODO:type]>} [TODO:description]
* @returns {Promise<[TODO:type]>} [TODO:description]
*/
'my-func': async function test($p1: string = 'value', p2: array = [], p3, p4 /* inline comment */) {
//
Expand All @@ -79,7 +79,7 @@ Expect javascript (generated comment with @async, @param and @return tags):
* @param {array} [p2] - [TODO:description]
* @param {[TODO:type]} p3 - [TODO:description]
* @param {[TODO:type]} p4 - [TODO:description]
* @return {( 1 | 2 | 3 )} [TODO:description]
* @returns {( 1 | 2 | 3 )} [TODO:description]
*/
'my-arrow-func': async ($p1: string = 'value', p2: array = [], p3, p4 /* inline comment */): ( 1 | 2 | 3 ) => {
//
Expand Down
Loading

0 comments on commit 79e6247

Please sign in to comment.