Skip to content

Commit 966e5cf

Browse files
targosjasnell
authored andcommittedDec 23, 2016
tools: enforce linebreak after ternary operators
This is to be consistent with the other operators and helps understanding the context when the code is grepped. PR-URL: nodejs#10213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 9fd79c9 commit 966e5cf

12 files changed

+42
-43
lines changed
 

‎.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ rules:
9494
no-multiple-empty-lines: [2, {max: 2, maxEOF: 0, maxBOF: 0}]
9595
no-tabs: 2
9696
no-trailing-spaces: 2
97-
operator-linebreak: [2, after, {overrides: {'?': ignore, ':': ignore}}]
97+
operator-linebreak: [2, after]
9898
quotes: [2, single, avoid-escape]
9999
semi: 2
100100
semi-spacing: 2

‎benchmark/_http-benchmarkers.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ exports.PORT = process.env.PORT || 12346;
77

88
function AutocannonBenchmarker() {
99
this.name = 'autocannon';
10-
this.autocannon_exe = process.platform === 'win32'
11-
? 'autocannon.cmd'
12-
: 'autocannon';
10+
this.autocannon_exe = process.platform === 'win32' ?
11+
'autocannon.cmd' :
12+
'autocannon';
1313
const result = child_process.spawnSync(this.autocannon_exe, ['-h']);
1414
this.present = !(result.error && result.error.code === 'ENOENT');
1515
}

‎lib/_stream_readable.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,9 @@ function fromListPartial(n, list, hasStrings) {
876876
ret = list.shift();
877877
} else {
878878
// result spans more than one buffer
879-
ret = (hasStrings
880-
? copyFromBufferString(n, list)
881-
: copyFromBuffer(n, list));
879+
ret = (hasStrings ?
880+
copyFromBufferString(n, list) :
881+
copyFromBuffer(n, list));
882882
}
883883
return ret;
884884
}

‎lib/repl.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,12 @@ function REPLServer(prompt,
426426
self.lines.level = [];
427427

428428
// Figure out which "complete" function to use.
429-
self.completer = (typeof options.completer === 'function')
430-
? options.completer
431-
: completer;
429+
self.completer = (typeof options.completer === 'function') ?
430+
options.completer : completer;
432431

433432
function completer(text, cb) {
434-
complete.call(self, text, self.editorMode
435-
? self.completeOnEditorMode(cb) : cb);
433+
complete.call(self, text, self.editorMode ?
434+
self.completeOnEditorMode(cb) : cb);
436435
}
437436

438437
Interface.call(this, {

‎lib/url.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
381381
}
382382

383383
var firstIdx = (questionIdx !== -1 &&
384-
(hashIdx === -1 || questionIdx < hashIdx)
385-
? questionIdx
386-
: hashIdx);
384+
(hashIdx === -1 || questionIdx < hashIdx) ?
385+
questionIdx :
386+
hashIdx);
387387
if (firstIdx === -1) {
388388
if (rest.length > 0)
389389
this.pathname = rest;

‎test/parallel/test-buffer-alloc.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,9 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
777777
assert.strictEqual(string, '{"type":"Buffer","data":[116,101,115,116]}');
778778

779779
assert.deepStrictEqual(buffer, JSON.parse(string, (key, value) => {
780-
return value && value.type === 'Buffer'
781-
? Buffer.from(value.data)
782-
: value;
780+
return value && value.type === 'Buffer' ?
781+
Buffer.from(value.data) :
782+
value;
783783
}));
784784
}
785785

‎test/parallel/test-buffer-concat.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ function assertWrongList(value) {
4040
});
4141
}
4242

43-
const random10 = common.hasCrypto
44-
? require('crypto').randomBytes(10)
45-
: Buffer.alloc(10, 1);
43+
const random10 = common.hasCrypto ?
44+
require('crypto').randomBytes(10) :
45+
Buffer.alloc(10, 1);
4646
const empty = Buffer.alloc(0);
4747

4848
assert.notDeepStrictEqual(random10, empty);

‎test/parallel/test-https-strict.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ function makeReq(path, port, error, host, ca) {
127127
}
128128
var req = https.get(options);
129129
expectResponseCount++;
130-
var server = port === server1.address().port ? server1
131-
: port === server2.address().port ? server2
132-
: port === server3.address().port ? server3
133-
: null;
130+
var server = port === server1.address().port ? server1 :
131+
port === server2.address().port ? server2 :
132+
port === server3.address().port ? server3 :
133+
null;
134134

135135
if (!server) throw new Error('invalid port: ' + port);
136136
server.expectCount++;

‎test/parallel/test-promises-unhandled-rejections.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ var asyncTest = (function() {
1111
var currentTest = null;
1212

1313
function fail(error) {
14-
var stack = currentTest
15-
? error.stack + '\nFrom previous event:\n' + currentTest.stack
16-
: error.stack;
14+
var stack = currentTest ?
15+
error.stack + '\nFrom previous event:\n' + currentTest.stack :
16+
error.stack;
1717

1818
if (currentTest)
1919
process.stderr.write('\'' + currentTest.description + '\' failed\n\n');

‎test/parallel/test-punycode.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,19 @@ const testBattery = {
182182
),
183183
toASCII: (test) => assert.strictEqual(
184184
punycode.toASCII(test.decoded),
185-
regexNonASCII.test(test.decoded)
186-
? `xn--${test.encoded}`
187-
: test.decoded
185+
regexNonASCII.test(test.decoded) ?
186+
`xn--${test.encoded}` :
187+
test.decoded
188188
),
189189
toUnicode: (test) => assert.strictEqual(
190190
punycode.toUnicode(
191-
regexNonASCII.test(test.decoded)
192-
? `xn--${test.encoded}`
193-
: test.decoded
191+
regexNonASCII.test(test.decoded) ?
192+
`xn--${test.encoded}` :
193+
test.decoded
194194
),
195-
regexNonASCII.test(test.decoded)
196-
? test.decoded.toLowerCase()
197-
: test.decoded
195+
regexNonASCII.test(test.decoded) ?
196+
test.decoded.toLowerCase() :
197+
test.decoded
198198
)
199199
};
200200

‎test/parallel/test-readline-interface.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,9 @@ function isWarned(emitter) {
463463
});
464464

465465
{
466-
const expected = terminal
467-
? ['\u001b[1G', '\u001b[0J', '$ ', '\u001b[3G']
468-
: ['$ '];
466+
const expected = terminal ?
467+
['\u001b[1G', '\u001b[0J', '$ ', '\u001b[3G'] :
468+
['$ '];
469469

470470
let counter = 0;
471471
const output = new Writable({

‎tools/eslint-rules/no-useless-regex-char-class-escape.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ module.exports = {
108108
},
109109

110110
create(context) {
111-
const overrideSet = new Set(context.options.length
112-
? context.options[0].override || []
113-
: []);
111+
const overrideSet = new Set(context.options.length ?
112+
context.options[0].override || [] :
113+
[]);
114114

115115
/**
116116
* Reports a node

0 commit comments

Comments
 (0)
Please sign in to comment.