Repository: eslint/doctrine
Pull request #189 (2017-03-25 11:10:16)

[BugFix] Incorrect behavior when arrow functions are used as default values
When arrow functions are used as default values in arguments, the output is currently incorrect. 

Example:

````
/**
* @param {String} [x=()=>{}]
*/
function hello() {}
````

Expected default value in generated documentation: `() => {}`
Current default value in generated documentation: `()`

jsf-clabot: [![CLA assistant check](https://cla.js.foundation/pull/badge/not_signed)](https://cla.js.foundation/eslint/doctrine?pullRequest=189) <br/>Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla.js.foundation/eslint/doctrine?pullRequest=189) before we can accept your contribution.<br/><hr/>**Gaurab Paul** seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please [add the email address used for this commit to your account](https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user/#commits-are-not-linked-to-any-user).
lorefnon: Can this be reviewed by someone ? 

Patch:
diff --git a/lib/doctrine.js b/lib/doctrine.js
index 095eeeb..bd6d38c 100644
--- a/lib/doctrine.js
+++ b/lib/doctrine.js
@@ -10,13 +10,11 @@
 
     var typed,
         utility,
-        isArray,
         jsdoc,
         esutils,
         hasOwnProperty;
 
     esutils = require('esutils');
-    isArray = require('isarray');
     typed = require('./typed');
     utility = require('./utility');
 
@@ -525,8 +523,8 @@
                         // extract the default value if there is one
                         // example: @param {string} [somebody=John Doe] description
                         assign = name.substring(1, name.length - 1).split('=');
-                        if (assign[1]) {
-                            this._tag['default'] = assign[1];
+                        if (assign.length > 1) {
+                            this._tag['default'] = assign.slice(1).join('=');
                         }
                         this._tag.name = assign[0];
 
@@ -839,7 +837,7 @@
 
             // array of relevant tags
             if (options.tags) {
-                if (isArray(options.tags)) {
+                if (Array.isArray(options.tags)) {
                     interestingTags = { };
                     for (i = 0, iz = options.tags.length; i < iz; i++) {
                         if (typeof options.tags[i] === 'string') {
diff --git a/package.json b/package.json
index 4616b44..71eec5c 100644
--- a/package.json
+++ b/package.json
@@ -54,7 +54,6 @@
     "betarelease": "eslint-prerelease beta"
   },
   "dependencies": {
-    "esutils": "^2.0.2",
-    "isarray": "^1.0.0"
+    "esutils": "^2.0.2"
   }
 }


Test patch:
diff --git a/test/parse.js b/test/parse.js
index abcde95..18421dd 100644
--- a/test/parse.js
+++ b/test/parse.js
@@ -2271,6 +2271,28 @@ describe('optional params', function() {
         });
     });
 
+    it('default arrow functions', function() {
+        doctrine.parse(
+            ["/**", " * @param {Function} [fn=()=>{}] some description", " */"].join('\n'),
+            {unwrap: true, sloppy: true}
+        ).should.eql({
+            description: "",
+            tags: [{
+                "title": "param",
+                "description": "some description",
+                "type": {
+                    "type": "OptionalType",
+                    "expression": {
+                        "type": "NameExpression",
+                        "name": "Function"
+                    }
+                },
+                "name": "fn",
+                "default": "()=>{}"
+            }]
+        });
+    });
+
     it('line numbers', function() {
         var res = doctrine.parse(
             [