From 8f7b96db522251ef22c91075dd5371eb4d8d2e62 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 28 Apr 2016 15:26:50 -0700 Subject: [PATCH] tools: enforce arrow function brace usage linting If braces are not required for an arrow function body, omit them. Refs: https://github.com/nodejs/node/pull/6390#discussion-diff-61484591 --- .eslintrc | 1 + lib/net.js | 5 ++--- lib/repl.js | 4 +--- test/parallel/test-fs-buffer.js | 4 +--- test/parallel/test-module-loading-error.js | 7 ++++--- tools/eslint-rules/align-function-arguments.js | 2 +- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.eslintrc b/.eslintrc index 542be9ceaa749d..4aea1e30c579da 100644 --- a/.eslintrc +++ b/.eslintrc @@ -73,6 +73,7 @@ rules: # ECMAScript 6 # http://eslint.org/docs/rules/#ecmascript-6 + arrow-body-style: 2 arrow-parens: [2, "always"] arrow-spacing: [2, {"before": true, "after": true}] constructor-super: 2 diff --git a/lib/net.js b/lib/net.js index 509112f58f2077..216809ebf82e7f 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1122,9 +1122,8 @@ function Server(options, connectionListener) { return this._connections; }, 'Server.connections property is deprecated. ' + 'Use Server.getConnections method instead.'), - set: internalUtil.deprecate((val) => { - return (this._connections = val); - }, 'Server.connections property is deprecated.'), + set: internalUtil.deprecate((val) => (this._connections = val), + 'Server.connections property is deprecated.'), configurable: true, enumerable: false }); diff --git a/lib/repl.js b/lib/repl.js index a7452b8ec731bd..72fc04bdc56686 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -566,9 +566,7 @@ REPLServer.prototype.createContext = function() { Object.defineProperty(context, '_', { configurable: true, - get: () => { - return this.last; - }, + get: () => this.last, set: (value) => { this.last = value; if (!this.underscoreAssigned) { diff --git a/test/parallel/test-fs-buffer.js b/test/parallel/test-fs-buffer.js index 6f142310f5e418..6a6bdfd3e472c8 100644 --- a/test/parallel/test-fs-buffer.js +++ b/test/parallel/test-fs-buffer.js @@ -31,9 +31,7 @@ assert.throws(() => { const dir = Buffer.from(common.fixturesDir); fs.readdir(dir, 'hex', common.mustCall((err, list) => { if (err) throw err; - list = list.map((i) => { - return Buffer.from(i, 'hex').toString(); - }); + list = list.map((i) => Buffer.from(i, 'hex').toString()); fs.readdir(dir, common.mustCall((err, list2) => { if (err) throw err; assert.deepStrictEqual(list, list2); diff --git a/test/parallel/test-module-loading-error.js b/test/parallel/test-module-loading-error.js index 072a6aadcb8c62..11818e71fd9a6d 100644 --- a/test/parallel/test-module-loading-error.js +++ b/test/parallel/test-module-loading-error.js @@ -20,9 +20,10 @@ if (!dlerror_msg) { try { require('../fixtures/module-loading-error.node'); } catch (e) { - assert.strictEqual(dlerror_msg.some((errMsgCase) => { - return e.toString().indexOf(errMsgCase) !== -1; - }), true); + assert.strictEqual( + dlerror_msg.some((errMsgCase) => e.toString().includes(errMsgCase)), + true + ); } try { diff --git a/tools/eslint-rules/align-function-arguments.js b/tools/eslint-rules/align-function-arguments.js index a8cd71660d7d60..1275a7ca058845 100644 --- a/tools/eslint-rules/align-function-arguments.js +++ b/tools/eslint-rules/align-function-arguments.js @@ -41,7 +41,7 @@ function checkArgumentAlignment(context, node) { // For now, don't bother trying to validate potentially complicating things // like closures. Different people will have very different ideas and it's // probably best to implement configuration options. - if (args.some((node) => { return ignoreTypes.indexOf(node.type) !== -1; })) { + if (args.some((node) => ignoreTypes.indexOf(node.type) !== -1)) { return; }