Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: enforce linebreak after ternary operators #10213

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ rules:
no-multiple-empty-lines: [2, {max: 2, maxEOF: 0, maxBOF: 0}]
no-tabs: 2
no-trailing-spaces: 2
operator-linebreak: [2, after, {overrides: {'?': ignore, ':': ignore}}]
operator-linebreak: [2, after]
quotes: [2, single, avoid-escape]
semi: 2
semi-spacing: 2
6 changes: 3 additions & 3 deletions benchmark/_http-benchmarkers.js
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ exports.PORT = process.env.PORT || 12346;

function AutocannonBenchmarker() {
this.name = 'autocannon';
this.autocannon_exe = process.platform === 'win32'
? 'autocannon.cmd'
: 'autocannon';
this.autocannon_exe = process.platform === 'win32' ?
'autocannon.cmd' :
'autocannon';
const result = child_process.spawnSync(this.autocannon_exe, ['-h']);
this.present = !(result.error && result.error.code === 'ENOENT');
}
6 changes: 3 additions & 3 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
@@ -876,9 +876,9 @@ function fromListPartial(n, list, hasStrings) {
ret = list.shift();
} else {
// result spans more than one buffer
ret = (hasStrings
? copyFromBufferString(n, list)
: copyFromBuffer(n, list));
ret = (hasStrings ?
copyFromBufferString(n, list) :
copyFromBuffer(n, list));
}
return ret;
}
9 changes: 4 additions & 5 deletions lib/repl.js
Original file line number Diff line number Diff line change
@@ -426,13 +426,12 @@ function REPLServer(prompt,
self.lines.level = [];

// Figure out which "complete" function to use.
self.completer = (typeof options.completer === 'function')
? options.completer
: completer;
self.completer = (typeof options.completer === 'function') ?
options.completer : completer;

function completer(text, cb) {
complete.call(self, text, self.editorMode
? self.completeOnEditorMode(cb) : cb);
complete.call(self, text, self.editorMode ?
self.completeOnEditorMode(cb) : cb);
}

Interface.call(this, {
6 changes: 3 additions & 3 deletions lib/url.js
Original file line number Diff line number Diff line change
@@ -381,9 +381,9 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
}

var firstIdx = (questionIdx !== -1 &&
(hashIdx === -1 || questionIdx < hashIdx)
? questionIdx
: hashIdx);
(hashIdx === -1 || questionIdx < hashIdx) ?
questionIdx :
hashIdx);
if (firstIdx === -1) {
if (rest.length > 0)
this.pathname = rest;
6 changes: 3 additions & 3 deletions test/parallel/test-buffer-alloc.js
Original file line number Diff line number Diff line change
@@ -775,9 +775,9 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
assert.strictEqual(string, '{"type":"Buffer","data":[116,101,115,116]}');

assert.deepStrictEqual(buffer, JSON.parse(string, (key, value) => {
return value && value.type === 'Buffer'
? Buffer.from(value.data)
: value;
return value && value.type === 'Buffer' ?
Buffer.from(value.data) :
value;
}));
}

6 changes: 3 additions & 3 deletions test/parallel/test-buffer-concat.js
Original file line number Diff line number Diff line change
@@ -39,9 +39,9 @@ function assertWrongList(value) {
});
}

const random10 = common.hasCrypto
? require('crypto').randomBytes(10)
: Buffer.alloc(10, 1);
const random10 = common.hasCrypto ?
require('crypto').randomBytes(10) :
Buffer.alloc(10, 1);
const empty = Buffer.alloc(0);

assert.notDeepStrictEqual(random10, empty);
8 changes: 4 additions & 4 deletions test/parallel/test-https-strict.js
Original file line number Diff line number Diff line change
@@ -127,10 +127,10 @@ function makeReq(path, port, error, host, ca) {
}
var req = https.get(options);
expectResponseCount++;
var server = port === server1.address().port ? server1
: port === server2.address().port ? server2
: port === server3.address().port ? server3
: null;
var server = port === server1.address().port ? server1 :
port === server2.address().port ? server2 :
port === server3.address().port ? server3 :
null;

if (!server) throw new Error('invalid port: ' + port);
server.expectCount++;
6 changes: 3 additions & 3 deletions test/parallel/test-promises-unhandled-rejections.js
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ var asyncTest = (function() {
var currentTest = null;

function fail(error) {
var stack = currentTest
? error.stack + '\nFrom previous event:\n' + currentTest.stack
: error.stack;
var stack = currentTest ?
error.stack + '\nFrom previous event:\n' + currentTest.stack :
error.stack;

if (currentTest)
process.stderr.write('\'' + currentTest.description + '\' failed\n\n');
18 changes: 9 additions & 9 deletions test/parallel/test-punycode.js
Original file line number Diff line number Diff line change
@@ -182,19 +182,19 @@ const testBattery = {
),
toASCII: (test) => assert.strictEqual(
punycode.toASCII(test.decoded),
regexNonASCII.test(test.decoded)
? `xn--${test.encoded}`
: test.decoded
regexNonASCII.test(test.decoded) ?
`xn--${test.encoded}` :
test.decoded
),
toUnicode: (test) => assert.strictEqual(
punycode.toUnicode(
regexNonASCII.test(test.decoded)
? `xn--${test.encoded}`
: test.decoded
regexNonASCII.test(test.decoded) ?
`xn--${test.encoded}` :
test.decoded
),
regexNonASCII.test(test.decoded)
? test.decoded.toLowerCase()
: test.decoded
regexNonASCII.test(test.decoded) ?
test.decoded.toLowerCase() :
test.decoded
)
};

6 changes: 3 additions & 3 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
@@ -463,9 +463,9 @@ function isWarned(emitter) {
});

{
const expected = terminal
? ['\u001b[1G', '\u001b[0J', '$ ', '\u001b[3G']
: ['$ '];
const expected = terminal ?
['\u001b[1G', '\u001b[0J', '$ ', '\u001b[3G'] :
['$ '];

let counter = 0;
const output = new Writable({
6 changes: 3 additions & 3 deletions tools/eslint-rules/no-useless-regex-char-class-escape.js
Original file line number Diff line number Diff line change
@@ -108,9 +108,9 @@ module.exports = {
},

create(context) {
const overrideSet = new Set(context.options.length
? context.options[0].override || []
: []);
const overrideSet = new Set(context.options.length ?
context.options[0].override || [] :
[]);

/**
* Reports a node