Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDoc can bug the plugin #2

Closed
Shahor opened this issue Aug 18, 2017 · 4 comments
Closed

JSDoc can bug the plugin #2

Shahor opened this issue Aug 18, 2017 · 4 comments

Comments

@Shahor
Copy link

Shahor commented Aug 18, 2017

This code doesn't expose the marked as exposed function

'use strict'

// Using false will remove the entry from the object and will ease the roles retrieval
const Overrides = {
    zob : true,
}

/**
 * Filter rights according to their Boolean value
 * @param {Object} rights An object with rights to filter on
 * @return {Set} The list of rights available to this user
 */
// @test-export
function format(rights) {
    console.log('whatever')
}

module.exports = {}

But this one does

'use strict'

// Using false will remove the entry from the object and will ease the roles retrieval
const Overrides = {
    zob : true,
}

/**
 * Filter rights according to their Boolean value
 * @param {Object} rights An object with rights to filter on
 * @return {Set} The list of rights available to this user
 */
// @test-export
function format(rights) {
    console.log('whatever')
}

module.exports = {}

The diff between the two is the following:

diff --git a/toto.js b/Volumes/Work/euronews/api/src/utils/rights.js
index a7907b3..9901739 100644
--- a/toto.js
+++ b/Volumes/Work/euronews/api/src/utils/rights.js
@@ -2,7 +2,7 @@
 
 // Using false will remove the entry from the object and will ease the roles retrieval
 const Overrides = {
-//    zob : true,
+    zob : true,
 }
 
 /**
@@ -16,4 +16,3 @@ function format(rights) {
 }
 
 module.exports = {}

I tried looking at the src but I must admit I'm no good at reCAST 😆

@Shahor
Copy link
Author

Shahor commented Aug 18, 2017

I also don't know which versions you would need to check that soooo...

$> yarn list | grep babel
├─ babel-code-frame@6.26.0
├─ babel-core@6.26.0
│  ├─ babel-code-frame@^6.26.0
│  ├─ babel-generator@^6.26.0
│  ├─ babel-helpers@^6.24.1
│  ├─ babel-messages@^6.23.0
│  ├─ babel-register@^6.26.0
│  ├─ babel-runtime@^6.26.0
│  ├─ babel-template@^6.26.0
│  ├─ babel-traverse@^6.26.0
│  ├─ babel-types@^6.26.0
├─ babel-generator@6.26.0
│  ├─ babel-messages@^6.23.0
│  ├─ babel-runtime@^6.26.0
│  ├─ babel-types@^6.26.0
├─ babel-helpers@6.24.1
│  ├─ babel-runtime@^6.22.0
│  └─ babel-template@^6.24.1
├─ babel-jest@20.0.3
│  ├─ babel-core@^6.0.0
│  ├─ babel-plugin-istanbul@^4.0.0
│  └─ babel-preset-jest@^20.0.3
├─ babel-messages@6.23.0
│  └─ babel-runtime@^6.22.0
├─ babel-plugin-istanbul@4.1.4
├─ babel-plugin-jest-hoist@20.0.3
├─ babel-plugin-test-export@1.0.0-beta.0
├─ babel-preset-jest@20.0.3
│  └─ babel-plugin-jest-hoist@^20.0.3
├─ babel-register@6.26.0
│  ├─ babel-core@^6.26.0
│  ├─ babel-runtime@^6.26.0
├─ babel-runtime@6.26.0
├─ babel-template@6.26.0
│  ├─ babel-runtime@^6.26.0
│  ├─ babel-traverse@^6.26.0
│  ├─ babel-types@^6.26.0
├─ babel-traverse@6.26.0
│  ├─ babel-code-frame@^6.26.0
│  ├─ babel-messages@^6.23.0
│  ├─ babel-runtime@^6.26.0
│  ├─ babel-types@^6.26.0
├─ babel-types@6.26.0
│  ├─ babel-runtime@^6.26.0
│  └─ babel-runtime@^6.18.0
│  ├─ babel-code-frame@^6.22.0
│  ├─ babel-generator@^6.18.0
│  ├─ babel-template@^6.16.0
│  ├─ babel-traverse@^6.18.0
│  ├─ babel-types@^6.18.0
│  ├─ babel-core@^6.0.0
│  ├─ babel-jest@^20.0.3
│  ├─ babel-plugin-istanbul@^4.0.0
│  │  ├─ babel-code-frame@^6.16.0
│  ├─ babel-runtime@^6.23.0
│  │  ├─ babel-code-frame@^6.16.0
│  │  ├─ babel-code-frame@^6.16.0

@Shahor
Copy link
Author

Shahor commented Aug 18, 2017

Turns out, it relates to the JSDoc, this exports the function as expected:

'use strict'

// Using false will remove the entry from the object and will ease the roles retrieval
const Overrides = {
    zob : true,
}

/**
 * Filter rights according to their Boolean value
 * @param {Object} rights An object with rights to filter on
 * @return {Array} The list of rights available to this user
 */
// @test-export
function format(rights) {
    console.log('whatever')
}

module.exports = {}

The only thing I changed is the return type that is an Array instead of a Set

@Shahor Shahor changed the title Order of declarations seem to matter JSDoc can bug the plugin Aug 18, 2017
@BenoitZugmeyer
Copy link
Owner

BenoitZugmeyer commented Aug 18, 2017

Thanks for the report. I don't think it's a JSDoc issue. I managed to reproduce without the JSDoc comment. It seems that since babylon 6.17.2, comments are sometimes attached to the previous statement (as trailing comments), if it doesn't end with a semicolon. I published a new version, please try out :)

@Shahor
Copy link
Author

Shahor commented Aug 19, 2017

Will do on monday :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants