jscs-dev / jscs-jsdoc

JsDoc validation rules for jscs
MIT License
99 stars 35 forks source link

enforceExistence is not working with ES2015 exports #159

Closed AlexanderZeilmann closed 8 years ago

AlexanderZeilmann commented 8 years ago

With "enforceExistence": true and the following function

/**
 * A square method
 *
 * @param  {number} n  - The numbe to be squared
 * @return {number} The square of the number
 */
export default function square (n) {
  return n * n;
}

I get the following error (using jscs 2.2.0, jscs-doc 1.2.0)

->jscs test.js --verbose
jsDoc: Expect valid jsdoc-block definition at test.js :
     5 | * @return {number} The square of the number
     6 | */
     7 |export default function square (n) {
-----------------------^
     8 |  return n * n;
     9 |}

1 code style error found.

The error does not occur when using jscs 2.2.0, jscs-doc 1.1.0.

With the following snippet everything is working

/**
 * A square method
 *
 * @param  {number} n  - The numbe to be squared
 * @return {number} The square of the number
 */
function square (n) {
  return n * n;
}
lovedota commented 8 years ago

@zxqfox When will we have a new release for it. i am using jscs 2.2.1, and i face a same problem too. Thanks !

AlexanderZeilmann commented 8 years ago

Wow, that was quick, thanks :-)

But this fix only considers ExportDefaultDeclarations and not ExportNamedDeclarations, right? So,

/**
 * A square method
 *
 * @param  {number} n  - The numbe to be squared
 * @return {number} The square of the number
 */
export function square (n) {
  return n * n;
}

will still fail.

I should have included that in my initial report :-|

lovedota commented 8 years ago

@alawatthe Thanks for you posting. I have the same problem ! Now i need to switch back to version 2.1.1 and it works !

qfox commented 8 years ago

Oh, right. Will add tests for these cases and fix them if needed. ;-) Thanks for reports!

@lovedota If you need to update jsdoc plugin — just install more freshy jscs-jsdoc version than bundled in jscs (e.g. npm i jscs-dev/jscs-jsdoc for master branch).

qfox commented 8 years ago

What about:

export default () => {
};

?

AlexanderZeilmann commented 8 years ago

LGTM, thank you :-)