Repository: websockets/ws
Pull request #1295 (2018-02-05 10:03:13)

Update eslint-plugin-node to the latest version 🚀

## Version **6.0.0** of [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node) was just published.

<table>
  <tr>
    <th align=left>
      Dependency
    </td>
    <td>
      eslint-plugin-node
    </td>
  </tr>
  <tr>
    <th align=left>
      Current Version
    </td>
    <td>
      5.2.1
    </td>
  </tr>
  <tr>
    <th align=left>
      Type
    </td>
    <td>
      devDependency
    </td>
  </tr>
</table>

The version **6.0.0** is **not covered** by your **current version range**.

If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.

It might be worth looking into these changes and trying to get this project onto the latest version of eslint-plugin-node.

If you have a solid test suite and good coverage, a passing build is a strong indicator that you can take advantage of these changes directly by merging the proposed change into your project. If the build fails or you don’t have such unconditional trust in your tests, this branch is a great starting point for you to work on the update.


---


<details>
<summary>Commits</summary>
<p>The new version differs by 9 commits.</p>
<ul>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/bbf4b6032705d446cd3532c92649fdc2894da9d1"><code>bbf4b60</code></a> <code>6.0.0</code></li>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/e8d757b97ac571d456085e9103dc7b9cbd9500c7"><code>e8d757b</code></a> <code>Breaking: update node/recommended preset</code></li>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/400e20a00a1620f986eb91317d6d26e1b049f8dd"><code>400e20a</code></a> <code>Breaking: update no-deprecated-api rule</code></li>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/49c060a7f7fcb5c33712914ce75bd499cf7e1340"><code>49c060a</code></a> <code>Breaking: no-unsupported-features supports ES2018 (fixes #94, fixes #103)</code></li>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/2e2d464d9afe0ce1e1e2ad8899c6f744d182b4bb"><code>2e2d464</code></a> <code>Chore: upgrade dependencies</code></li>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/dc32ab57cedf8566597dd7a9718084d4ed875542"><code>dc32ab5</code></a> <code>Docs: Use link to tagged version for rule docs (#104)</code></li>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/27ac4a834769cb2e26ac4a69aab823098366157f"><code>27ac4a8</code></a> <code>Docs: Add URL to rule documentation to the metadata (#102)</code></li>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/846e677789dc290c1f7a9fff658fbdc1c5bf5171"><code>846e677</code></a> <code>Chore: use semver public API's. (#99)</code></li>
<li><a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/commit/d5a8985c0cdf8329d2e16013f0070bc437190a64"><code>d5a8985</code></a> <code>Docs: fix comma JSON error on the first example (#98)</code></li>
</ul>
<p>See the <a href="https://urls.greenkeeper.io/mysticatea/eslint-plugin-node/compare/ad1f15a02940f4f6eae73b8ffc832742796e515b...bbf4b6032705d446cd3532c92649fdc2894da9d1">full diff</a></p>
</details>

<details>
  <summary>FAQ and help</summary>

  There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new).
</details>


---


Your [Greenkeeper](https://greenkeeper.io) bot :palm_tree:




Patch:
diff --git a/doc/ws.md b/doc/ws.md
index 44f1bd8e..62de3f84 100644
--- a/doc/ws.md
+++ b/doc/ws.md
@@ -124,6 +124,14 @@ Emitted when the underlying server has been bound.
 A set that stores all connected clients. Please note that this property is only
 added when the `clientTracking` is truthy.
 
+### server.address()
+
+Returns an object with `port`, `family`, and `address` properties specifying
+the bound address, the address family name, and port of the server as reported
+by the operating system if listening on an IP socket.
+If the server is listening on a pipe or UNIX domain socket, the name is
+returned as a string.
+
 ### server.close([callback])
 
 Close the server and terminate all clients, calls callback when done.
diff --git a/lib/websocket-server.js b/lib/websocket-server.js
index 7c1438e7..ee0913fb 100644
--- a/lib/websocket-server.js
+++ b/lib/websocket-server.js
@@ -90,6 +90,24 @@ class WebSocketServer extends EventEmitter {
     this.options = options;
   }
 
+  /**
+   * Returns the bound address, the address family name, and port of the server
+   * as reported by the operating system if listening on an IP socket.
+   * If the server is listening on a pipe or UNIX domain socket, the name is
+   * returned as a string.
+   *
+   * @return {(Object|String|null)} The address of the server
+   * @public
+   */
+  address () {
+    if (this.options.noServer) {
+      throw new Error('The server is operating in "noServer" mode');
+    }
+
+    if (!this._server) return null;
+    return this._server.address();
+  }
+
   /**
    * Close the server.
    *
diff --git a/package.json b/package.json
index e2530737..db9da5ce 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
     "eslint": "~4.17.0",
     "eslint-config-standard": "~10.2.0",
     "eslint-plugin-import": "~2.8.0",
-    "eslint-plugin-node": "~5.2.0",
+    "eslint-plugin-node": "~6.0.0",
     "eslint-plugin-promise": "~3.6.0",
     "eslint-plugin-standard": "~3.0.0",
     "mocha": "~5.0.0",


Test patch:
diff --git a/test/websocket-server.test.js b/test/websocket-server.test.js
index 14ea76c4..21f2c3ec 100644
--- a/test/websocket-server.test.js
+++ b/test/websocket-server.test.js
@@ -137,6 +137,34 @@ describe('WebSocketServer', function () {
     });
   });
 
+  describe('#address', function () {
+    it('returns the address of the server', function (done) {
+      const wss = new WebSocket.Server({ port: 0 }, () => {
+        const addr = wss.address();
+
+        assert.deepStrictEqual(addr, wss._server.address());
+        wss.close(done);
+      });
+    });
+
+    it('throws an error when operating in "noServer" mode', function () {
+      const wss = new WebSocket.Server({ noServer: true });
+
+      assert.throws(() => {
+        wss.address();
+      }, /^Error: The server is operating in "noServer" mode$/);
+    });
+
+    it('returns `null` if called after close', function (done) {
+      const wss = new WebSocket.Server({ port: 0 }, () => {
+        wss.close(() => {
+          assert.strictEqual(wss.address(), null);
+          done();
+        });
+      });
+    });
+  });
+
   describe('#close', function () {
     it('does not thrown when called twice', function (done) {
       const wss = new WebSocket.Server({ port: 0 }, () => {