Skip to content

Commit

Permalink
Increase prettier line width to 100 (#20535) (#20596)
Browse files Browse the repository at this point in the history
* Increase prettier line width to 100

* Fix packages JS prettier

* Change style guide to 100 width

* Fix line-width in latest master changes
  • Loading branch information
timroes authored Jul 10, 2018
1 parent e5223de commit de3e5b5
Show file tree
Hide file tree
Showing 107 changed files with 325 additions and 1,061 deletions.
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 @@ -77,15 +74,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']);
});
});
});
19 changes: 3 additions & 16 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 Down Expand Up @@ -91,10 +84,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 @@ -122,10 +112,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 @@ -195,12 +193,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/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
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
4 changes: 1 addition & 3 deletions packages/kbn-es/src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ exports.Cluster = class Cluster {
lines.forEach(line => this._log.info(line.formattedMessage));
});

this._process.stderr.on('data', data =>
this._log.error(chalk.red(data.toString()))
);
this._process.stderr.on('data', data => this._log.error(chalk.red(data.toString())));

this._outcome = new Promise((resolve, reject) => {
this._process.once('exit', code => {
Expand Down
12 changes: 2 additions & 10 deletions packages/kbn-es/src/install/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ exports.installArchive = async function installArchive(archive, options = {}) {
log.info('extracted to %s', chalk.bold(installPath));

if (license !== 'oss') {
await appendToConfig(
installPath,
'xpack.license.self_generated.type',
license
);
await appendToConfig(installPath, 'xpack.license.self_generated.type', license);

await appendToConfig(installPath, 'xpack.security.enabled', 'true');
await configureKeystore(installPath, password, log);
Expand Down Expand Up @@ -94,11 +90,7 @@ function rmrfSync(path) {
* @param {String} value
*/
async function appendToConfig(installPath, key, value) {
fs.appendFileSync(
path.resolve(installPath, ES_CONFIG),
`${key}: ${value}\n`,
'utf8'
);
fs.appendFileSync(path.resolve(installPath, ES_CONFIG), `${key}: ${value}\n`, 'utf8');
}

/**
Expand Down
9 changes: 2 additions & 7 deletions packages/kbn-es/src/install/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ function downloadFile(url, dest, log) {
res =>
new Promise((resolve, reject) => {
if (res.status === 304) {
log.info(
'etags match, using cache from %s',
chalk.bold(cacheMeta.ts)
);
log.info('etags match, using cache from %s', chalk.bold(cacheMeta.ts));
return resolve();
}

Expand Down Expand Up @@ -118,9 +115,7 @@ function downloadFile(url, dest, log) {

function getFilename(license, version) {
const extension = os.platform().startsWith('win') ? 'zip' : 'tar.gz';
const basename = `elasticsearch${
license === 'oss' ? '-oss-' : '-'
}${version}`;
const basename = `elasticsearch${license === 'oss' ? '-oss-' : '-'}${version}`;

return `${basename}-SNAPSHOT.${extension}`;
}
Loading

0 comments on commit de3e5b5

Please sign in to comment.