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

Increase prettier line width to 100 #20535

Merged
merged 5 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 7 additions & 13 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ const { readdirSync } = require('fs');
const dedent = require('dedent');

module.exports = {
extends: [
'@elastic/eslint-config-kibana',
'@elastic/eslint-config-kibana/jest',
],
extends: ['@elastic/eslint-config-kibana', '@elastic/eslint-config-kibana/jest'],

settings: {
'import/resolver': {
Expand Down Expand Up @@ -82,15 +79,12 @@ module.exports = {
forceNode: false,
rootPackageName: 'kibana',
kibanaPath: '.',
pluginMap: readdirSync(resolve(__dirname, 'x-pack/plugins')).reduce(
(acc, name) => {
if (!name.startsWith('_')) {
acc[name] = `x-pack/plugins/${name}`;
}
return acc;
},
{}
),
pluginMap: readdirSync(resolve(__dirname, 'x-pack/plugins')).reduce((acc, name) => {
if (!name.startsWith('_')) {
acc[name] = `x-pack/plugins/${name}`;
}
return acc;
}, {}),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "es5",
"printWidth": 100
}
5 changes: 1 addition & 4 deletions packages/kbn-datemath/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ const isValidDate = d => isDate(d) && !isNaN(d.valueOf());
* will be done using this (and its locale settings) instead of the one bundled
* with this library.
*/
function parse(
text,
{ roundUp = false, momentInstance = moment, forceNow } = {}
) {
function parse(text, { roundUp = false, momentInstance = moment, forceNow } = {}) {
if (!text) return undefined;
if (momentInstance.isMoment(text)) return text;
if (isDate(text)) return momentInstance(text);
Expand Down
80 changes: 22 additions & 58 deletions packages/kbn-datemath/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ describe('dateMath', function() {
expect(dateMath.parse('now&1d')).to.be(undefined);
});

it(
'should return undefined if I pass a unit besides' + spans.toString(),
function() {
expect(dateMath.parse('now+5f')).to.be(undefined);
}
);
it('should return undefined if I pass a unit besides' + spans.toString(), function() {
expect(dateMath.parse('now+5f')).to.be(undefined);
});

it('should return undefined if rounding unit is not 1', function() {
expect(dateMath.parse('now/2y')).to.be(undefined);
Expand All @@ -74,21 +71,16 @@ describe('dateMath', function() {

describe('forceNow', function() {
it('should throw an Error if passed a string', function() {
const fn = () =>
dateMath.parse('now', { forceNow: '2000-01-01T00:00:00.000Z' });
const fn = () => dateMath.parse('now', { forceNow: '2000-01-01T00:00:00.000Z' });
expect(fn).to.throwError();
});

it('should throw an Error if passed a moment', function() {
expect(() =>
dateMath.parse('now', { forceNow: moment() })
).to.throwError();
expect(() => dateMath.parse('now', { forceNow: moment() })).to.throwError();
});

it('should throw an Error if passed an invalid date', function() {
expect(() =>
dateMath.parse('now', { forceNow: new Date('foobar') })
).to.throwError();
expect(() => dateMath.parse('now', { forceNow: new Date('foobar') })).to.throwError();
});
});
});
Expand Down Expand Up @@ -128,9 +120,7 @@ describe('dateMath', function() {
});

it('should use the forceNow parameter when parsing now', function() {
expect(
dateMath.parse('now', { forceNow: anchoredDate }).valueOf()
).to.eql(unix);
expect(dateMath.parse('now', { forceNow: anchoredDate }).valueOf()).to.eql(unix);
});
});

Expand Down Expand Up @@ -164,9 +154,7 @@ describe('dateMath', function() {
});

it('should return ' + len + span + ' before forceNow', function() {
const parsed = dateMath
.parse(nowEx, { forceNow: anchoredDate })
.valueOf();
const parsed = dateMath.parse(nowEx, { forceNow: anchoredDate }).valueOf();
expect(parsed).to.eql(anchored.subtract(len, span).valueOf());
});
});
Expand All @@ -193,9 +181,7 @@ describe('dateMath', function() {
const thenEx = `${anchor}||+${len}${span}`;

it('should return ' + len + span + ' from now', function() {
expect(dateMath.parse(nowEx).format(format)).to.eql(
now.add(len, span).format(format)
);
expect(dateMath.parse(nowEx).format(format)).to.eql(now.add(len, span).format(format));
});

it('should return ' + len + span + ' after ' + anchor, function() {
Expand All @@ -205,9 +191,9 @@ describe('dateMath', function() {
});

it('should return ' + len + span + ' after forceNow', function() {
expect(
dateMath.parse(nowEx, { forceNow: anchoredDate }).valueOf()
).to.eql(anchored.add(len, span).valueOf());
expect(dateMath.parse(nowEx, { forceNow: anchoredDate }).valueOf()).to.eql(
anchored.add(len, span).valueOf()
);
});
});
});
Expand Down Expand Up @@ -235,22 +221,20 @@ describe('dateMath', function() {
});

it(`should round now to the beginning of forceNow's ${span}`, function() {
expect(
dateMath.parse('now/' + span, { forceNow: anchoredDate }).valueOf()
).to.eql(anchored.startOf(span).valueOf());
expect(dateMath.parse('now/' + span, { forceNow: anchoredDate }).valueOf()).to.eql(
anchored.startOf(span).valueOf()
);
});

it(`should round now to the end of the ${span}`, function() {
expect(
dateMath.parse('now/' + span, { roundUp: true }).format(format)
).to.eql(now.endOf(span).format(format));
expect(dateMath.parse('now/' + span, { roundUp: true }).format(format)).to.eql(
now.endOf(span).format(format)
);
});

it(`should round now to the end of forceNow's ${span}`, function() {
expect(
dateMath
.parse('now/' + span, { roundUp: true, forceNow: anchoredDate })
.valueOf()
dateMath.parse('now/' + span, { roundUp: true, forceNow: anchoredDate }).valueOf()
).to.eql(anchored.endOf(span).valueOf());
});
});
Expand Down Expand Up @@ -336,9 +320,7 @@ describe('dateMath', function() {
});

it('should round relative to forceNow', function() {
const val = dateMath
.parse('now-0s/s', { forceNow: anchoredDate })
.valueOf();
const val = dateMath.parse('now-0s/s', { forceNow: anchoredDate }).valueOf();
expect(val).to.eql(anchored.startOf('s').valueOf());
});

Expand Down Expand Up @@ -402,29 +384,11 @@ describe('dateMath', function() {

describe('units', function() {
it('should have units descending for unitsDesc', function() {
expect(dateMath.unitsDesc).to.eql([
'y',
'M',
'w',
'd',
'h',
'm',
's',
'ms',
]);
expect(dateMath.unitsDesc).to.eql(['y', 'M', 'w', 'd', 'h', 'm', 's', 'ms']);
});

it('should have units ascending for unitsAsc', function() {
expect(dateMath.unitsAsc).to.eql([
'ms',
's',
'm',
'h',
'd',
'w',
'M',
'y',
]);
expect(dateMath.unitsAsc).to.eql(['ms', 's', 'm', 'h', 'd', 'w', 'M', 'y']);
});
});
});
10 changes: 1 addition & 9 deletions packages/kbn-dev-utils/src/proc_runner/observe_lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@
*/

import * as Rx from 'rxjs';
import {
scan,
takeUntil,
share,
materialize,
mergeMap,
last,
catchError,
} from 'rxjs/operators';
import { scan, takeUntil, share, materialize, mergeMap, last, catchError } from 'rxjs/operators';

const SEP = /\r?\n/;

Expand Down
5 changes: 1 addition & 4 deletions packages/kbn-dev-utils/src/proc_runner/observe_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ export function observeReadable(readable) {
return Rx.race(
Rx.fromEvent(readable, 'end').pipe(first(), ignoreElements()),

Rx.fromEvent(readable, 'error').pipe(
first(),
map(err => Rx.throwError(err))
)
Rx.fromEvent(readable, 'error').pipe(first(), map(err => Rx.throwError(err)))
);
}
23 changes: 4 additions & 19 deletions packages/kbn-dev-utils/src/proc_runner/proc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ import execa from 'execa';
import { statSync } from 'fs';

import * as Rx from 'rxjs';
import {
tap,
share,
take,
mergeMap,
map,
ignoreElements,
} from 'rxjs/operators';
import { tap, share, take, mergeMap, map, ignoreElements } from 'rxjs/operators';
import { gray } from 'chalk';

import treeKill from 'tree-kill';
Expand All @@ -46,9 +39,7 @@ async function withTimeout(attempt, ms, onTimeout) {
try {
await Promise.race([
attempt(),
new Promise((resolve, reject) =>
setTimeout(() => reject(TIMEOUT), STOP_TIMEOUT)
),
new Promise((resolve, reject) => setTimeout(() => reject(TIMEOUT), STOP_TIMEOUT)),
]);
} catch (error) {
if (error === TIMEOUT) {
Expand Down Expand Up @@ -90,10 +81,7 @@ export function createProc(name, { cmd, args, cwd, env, stdin, log }) {
return new class Proc {
name = name;

lines$ = Rx.merge(
observeLines(childProcess.stdout),
observeLines(childProcess.stderr)
).pipe(
lines$ = Rx.merge(observeLines(childProcess.stdout), observeLines(childProcess.stderr)).pipe(
tap(line => log.write(` ${gray('proc')} [${gray(name)}] ${line}`)),
share()
);
Expand Down Expand Up @@ -121,10 +109,7 @@ export function createProc(name, { cmd, args, cwd, env, stdin, log }) {
return Rx.race(exit$, error$);
}).pipe(share());

_outcomePromise = Rx.merge(
this.lines$.pipe(ignoreElements()),
this.outcome$
).toPromise();
_outcomePromise = Rx.merge(this.lines$.pipe(ignoreElements()), this.outcome$).toPromise();

getOutcomePromise() {
return this._outcomePromise;
Expand Down
11 changes: 2 additions & 9 deletions packages/kbn-dev-utils/src/proc_runner/proc_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export class ProcRunner {
first(),
catchError(err => {
if (err.name !== 'EmptyError') {
throw createCliError(
`[${name}] exited without matching pattern: ${wait}`
);
throw createCliError(`[${name}] exited without matching pattern: ${wait}`);
} else {
throw err;
}
Expand Down Expand Up @@ -191,12 +189,7 @@ export class ProcRunner {
proc.outcome$.subscribe({
next: code => {
const duration = moment.duration(Date.now() - startMs);
this._log.info(
'[%s] exited with %s after %s',
name,
code,
duration.humanize()
);
this._log.info('[%s] exited with %s after %s', name, code, duration.humanize());
},
complete: () => {
remove();
Expand Down
5 changes: 1 addition & 4 deletions packages/kbn-dev-utils/src/streams/promise_from_streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ export async function createPromiseFromStreams(streams) {

// wait (and rethrow) the first error, or for the last stream
// to both finish writing and providing values to read
await Promise.race([
anyStreamFailure,
Promise.all([lastFinishedWriting, lastFinishedReading]),
]);
await Promise.race([anyStreamFailure, Promise.all([lastFinishedWriting, lastFinishedReading])]);

// return the final chunk read from the last stream
return await lastFinishedReading;
Expand Down
5 changes: 1 addition & 4 deletions packages/kbn-dev-utils/src/tooling_log/__tests__/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ describe('utils: createToolingLog(logLevel, output)', () => {
log.info('Baz');
log.end();

const output = await createPromiseFromStreams([
log,
createConcatStream(''),
]);
const output = await createPromiseFromStreams([log, createConcatStream('')]);

expect(output).to.contain('Foo');
expect(output).to.contain('Bar');
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-dev-utils/src/tooling_log/log_levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export function parseLogLevel(name) {
const i = LEVELS.indexOf(name);

if (i === -1) {
const msg =
`Invalid log level "${name}" ` + `(expected one of ${LEVELS.join(',')})`;
const msg = `Invalid log level "${name}" ` + `(expected one of ${LEVELS.join(',')})`;
throw new Error(msg);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-dev-utils/src/tooling_log/tooling_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ export function createToolingLog(initialLogLevelName = 'silent') {
const subLineIndent = i === 0 ? '' : ' ';
const indent = !indentString
? ''
: indentString.slice(0, -1) +
(i === 0 && line[0] === '-' ? '└' : '│');
: indentString.slice(0, -1) + (i === 0 && line[0] === '-' ? '└' : '│');
super.write(`${indent}${subLineIndent}${line}\n`);
});
}
Expand Down
4 changes: 1 addition & 3 deletions packages/kbn-es/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ exports.run = async (defaults = {}) => {
const command = commands[commandName];

if (command === undefined) {
log.error(
chalk.red(`[${commandName}] is not a valid command, see 'es --help'`)
);
log.error(chalk.red(`[${commandName}] is not a valid command, see 'es --help'`));
process.exitCode = 1;
return;
}
Expand Down
6 changes: 1 addition & 5 deletions packages/kbn-es/src/cli_commands/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ const { Cluster } = require('../cluster');
exports.description = 'Downloads and run from a nightly snapshot';

exports.help = (defaults = {}) => {
const {
license = 'basic',
password = 'changeme',
'base-path': basePath,
} = defaults;
const { license = 'basic', password = 'changeme', 'base-path': basePath } = defaults;

return dedent`
Options:
Expand Down
6 changes: 1 addition & 5 deletions packages/kbn-es/src/cli_commands/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ const { Cluster } = require('../cluster');
exports.description = 'Build and run from source';

exports.help = (defaults = {}) => {
const {
license = 'basic',
password = 'changeme',
'base-path': basePath,
} = defaults;
const { license = 'basic', password = 'changeme', 'base-path': basePath } = defaults;

return dedent`
Options:
Expand Down
Loading