Skip to content

Commit

Permalink
tools: enforce arrow function brace usage linting
Browse files Browse the repository at this point in the history
If braces are not required for an arrow function body, omit them.

Refs: nodejs#6390 (diff)
  • Loading branch information
Trott committed Apr 28, 2016
1 parent ded3aea commit 8f7b96d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down
4 changes: 1 addition & 3 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-fs-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions test/parallel/test-module-loading-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint-rules/align-function-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8f7b96d

Please sign in to comment.