diff --git a/.eslintrc.js b/.eslintrc.js index 9cfae664458dc..a96805932827e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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': { @@ -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; + }, {}), }, }, }, diff --git a/.prettierrc b/.prettierrc index c1a6f66713166..d440171380611 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,5 @@ { "singleQuote": true, - "trailingComma": "es5" + "trailingComma": "es5", + "printWidth": 100 } diff --git a/packages/kbn-datemath/src/index.js b/packages/kbn-datemath/src/index.js index 6389fa0470fec..17d91a530fdb3 100644 --- a/packages/kbn-datemath/src/index.js +++ b/packages/kbn-datemath/src/index.js @@ -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); diff --git a/packages/kbn-datemath/test/index.js b/packages/kbn-datemath/test/index.js index 2f534b095a8d0..2028c2c0cedce 100644 --- a/packages/kbn-datemath/test/index.js +++ b/packages/kbn-datemath/test/index.js @@ -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); @@ -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(); }); }); }); @@ -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); }); }); @@ -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()); }); }); @@ -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() { @@ -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() + ); }); }); }); @@ -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()); }); }); @@ -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()); }); @@ -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']); }); }); }); diff --git a/packages/kbn-dev-utils/src/proc_runner/proc.js b/packages/kbn-dev-utils/src/proc_runner/proc.js index b68777a1127e1..8479330143498 100644 --- a/packages/kbn-dev-utils/src/proc_runner/proc.js +++ b/packages/kbn-dev-utils/src/proc_runner/proc.js @@ -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'; @@ -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() ); @@ -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; diff --git a/packages/kbn-dev-utils/src/proc_runner/proc_runner.js b/packages/kbn-dev-utils/src/proc_runner/proc_runner.js index 76607dba527ac..da04763626e08 100644 --- a/packages/kbn-dev-utils/src/proc_runner/proc_runner.js +++ b/packages/kbn-dev-utils/src/proc_runner/proc_runner.js @@ -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; } @@ -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(); diff --git a/packages/kbn-dev-utils/src/tooling_log/__tests__/log.js b/packages/kbn-dev-utils/src/tooling_log/__tests__/log.js index fbbd23869c3ab..071b3c180d0c9 100644 --- a/packages/kbn-dev-utils/src/tooling_log/__tests__/log.js +++ b/packages/kbn-dev-utils/src/tooling_log/__tests__/log.js @@ -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'); diff --git a/packages/kbn-es/src/cli.js b/packages/kbn-es/src/cli.js index e9acd441aef16..ed81e01ccf8ab 100644 --- a/packages/kbn-es/src/cli.js +++ b/packages/kbn-es/src/cli.js @@ -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; } diff --git a/packages/kbn-es/src/cli_commands/snapshot.js b/packages/kbn-es/src/cli_commands/snapshot.js index a90ac9c6e10a3..0a585e92cfd74 100644 --- a/packages/kbn-es/src/cli_commands/snapshot.js +++ b/packages/kbn-es/src/cli_commands/snapshot.js @@ -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: diff --git a/packages/kbn-es/src/cli_commands/source.js b/packages/kbn-es/src/cli_commands/source.js index 77940a1f9e6ba..00b40ccd6a4db 100644 --- a/packages/kbn-es/src/cli_commands/source.js +++ b/packages/kbn-es/src/cli_commands/source.js @@ -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: diff --git a/packages/kbn-es/src/cluster.js b/packages/kbn-es/src/cluster.js index f9389ed1b2662..bd744a0e977b0 100644 --- a/packages/kbn-es/src/cluster.js +++ b/packages/kbn-es/src/cluster.js @@ -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 => { diff --git a/packages/kbn-es/src/install/archive.js b/packages/kbn-es/src/install/archive.js index 2851a3e8451f8..8c869118f0d65 100644 --- a/packages/kbn-es/src/install/archive.js +++ b/packages/kbn-es/src/install/archive.js @@ -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); @@ -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'); } /** diff --git a/packages/kbn-es/src/install/snapshot.js b/packages/kbn-es/src/install/snapshot.js index dac535acb5aa7..d61f6e58ba20d 100644 --- a/packages/kbn-es/src/install/snapshot.js +++ b/packages/kbn-es/src/install/snapshot.js @@ -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(); } @@ -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}`; } diff --git a/packages/kbn-es/src/install/source.js b/packages/kbn-es/src/install/source.js index 1fde1172734fa..32e5267129926 100644 --- a/packages/kbn-es/src/install/source.js +++ b/packages/kbn-es/src/install/source.js @@ -27,15 +27,9 @@ const simpleGit = require('simple-git/promise'); const { installArchive } = require('./archive'); const { createCliError } = require('../errors'); const { findMostRecentlyChanged, log: defaultLog, cache } = require('../utils'); -const { - GRADLE_BIN, - ES_ARCHIVE_PATTERN, - ES_OSS_ARCHIVE_PATTERN, - BASE_PATH, -} = require('../paths'); +const { GRADLE_BIN, ES_ARCHIVE_PATTERN, ES_OSS_ARCHIVE_PATTERN, BASE_PATH } = require('../paths'); -const onceEvent = (emitter, event) => - new Promise(resolve => emitter.once(event, resolve)); +const onceEvent = (emitter, event) => new Promise(resolve => emitter.once(event, resolve)); /** * Installs ES from source @@ -65,15 +59,10 @@ exports.installSource = async function installSource({ const cacheMeta = cache.readMeta(dest); const isCached = cacheMeta.exists && cacheMeta.etag === metadata.etag; - const archive = isCached - ? dest - : await createSnapshot({ sourcePath, log, license }); + const archive = isCached ? dest : await createSnapshot({ sourcePath, log, license }); if (isCached) { - log.info( - 'source path unchanged since %s, using cache', - chalk.bold(cacheMeta.ts) - ); + log.info('source path unchanged since %s, using cache', chalk.bold(cacheMeta.ts)); } else { cache.writeMeta(dest, metadata); fs.copyFileSync(archive, dest); @@ -168,11 +157,8 @@ async function createSnapshot({ license, sourcePath, log = defaultLog }) { throw createCliError('unable to build ES'); } - const archivePattern = - license === 'oss' ? ES_OSS_ARCHIVE_PATTERN : ES_ARCHIVE_PATTERN; - const esTarballPath = findMostRecentlyChanged( - path.resolve(sourcePath, archivePattern) - ); + const archivePattern = license === 'oss' ? ES_OSS_ARCHIVE_PATTERN : ES_ARCHIVE_PATTERN; + const esTarballPath = findMostRecentlyChanged(path.resolve(sourcePath, archivePattern)); if (!esTarballPath) { throw createCliError('could not locate ES distribution'); diff --git a/packages/kbn-es/src/integration_tests/cluster.test.js b/packages/kbn-es/src/integration_tests/cluster.test.js index d381019fa034a..f13bf1954175e 100644 --- a/packages/kbn-es/src/integration_tests/cluster.test.js +++ b/packages/kbn-es/src/integration_tests/cluster.test.js @@ -20,11 +20,7 @@ const { createToolingLog } = require('@kbn/dev-utils'); const execa = require('execa'); const { Cluster } = require('../cluster'); -const { - installSource, - installSnapshot, - installArchive, -} = require('../install'); +const { installSource, installSnapshot, installArchive } = require('../install'); jest.mock('../install', () => ({ installSource: jest.fn(), @@ -55,9 +51,7 @@ async function ensureResolve(promise) { return await Promise.race([ promise, sleep(100).then(() => { - throw new Error( - 'promise was supposed to resolve with installSource() resolution' - ); + throw new Error('promise was supposed to resolve with installSource() resolution'); }), ]); } @@ -203,33 +197,25 @@ describe('#start(installPath)', () => { it('rejects when bin/elasticsearch exists with 0 before starting', async () => { mockEsBin({ exitCode: 0, start: false }); - await expect(new Cluster(log).start()).rejects.toThrowError( - 'ES exited without starting' - ); + await expect(new Cluster(log).start()).rejects.toThrowError('ES exited without starting'); }); it('rejects when bin/elasticsearch exists with 143 before starting', async () => { mockEsBin({ exitCode: 143, start: false }); - await expect(new Cluster(log).start()).rejects.toThrowError( - 'ES exited without starting' - ); + await expect(new Cluster(log).start()).rejects.toThrowError('ES exited without starting'); }); it('rejects when bin/elasticsearch exists with 130 before starting', async () => { mockEsBin({ exitCode: 130, start: false }); - await expect(new Cluster(log).start()).rejects.toThrowError( - 'ES exited without starting' - ); + await expect(new Cluster(log).start()).rejects.toThrowError('ES exited without starting'); }); it('rejects when bin/elasticsearch exists with 1 before starting', async () => { mockEsBin({ exitCode: 1, start: false }); - await expect(new Cluster(log).start()).rejects.toThrowError( - 'ES exited with code 1' - ); + await expect(new Cluster(log).start()).rejects.toThrowError('ES exited with code 1'); }); it('resolves when bin/elasticsearch logs "started"', async () => { @@ -243,9 +229,7 @@ describe('#start(installPath)', () => { const cluster = new Cluster(log); await cluster.start(); - await expect(cluster.start()).rejects.toThrowError( - 'ES has already been started' - ); + await expect(cluster.start()).rejects.toThrowError('ES has already been started'); }); it('rejects if #run() was called previously', async () => { @@ -253,9 +237,7 @@ describe('#start(installPath)', () => { const cluster = new Cluster(log); await cluster.run(); - await expect(cluster.start()).rejects.toThrowError( - 'ES has already been started' - ); + await expect(cluster.start()).rejects.toThrowError('ES has already been started'); }); }); @@ -281,9 +263,7 @@ describe('#run()', () => { it('rejects when bin/elasticsearch exists with 1', async () => { mockEsBin({ exitCode: 1 }); - await expect(new Cluster(log).run()).rejects.toThrowError( - 'ES exited with code 1' - ); + await expect(new Cluster(log).run()).rejects.toThrowError('ES exited with code 1'); }); it('rejects if #start() was called previously', async () => { @@ -291,9 +271,7 @@ describe('#run()', () => { const cluster = new Cluster(log); await cluster.start(); - await expect(cluster.run()).rejects.toThrowError( - 'ES has already been started' - ); + await expect(cluster.run()).rejects.toThrowError('ES has already been started'); }); it('rejects if #run() was called previously', async () => { @@ -301,18 +279,14 @@ describe('#run()', () => { const cluster = new Cluster(log); await cluster.run(); - await expect(cluster.run()).rejects.toThrowError( - 'ES has already been started' - ); + await expect(cluster.run()).rejects.toThrowError('ES has already been started'); }); }); describe('#stop()', () => { it('rejects if #run() or #start() was not called', async () => { const cluster = new Cluster(log); - await expect(cluster.stop()).rejects.toThrowError( - 'ES has not been started' - ); + await expect(cluster.stop()).rejects.toThrowError('ES has not been started'); }); it('resolves when ES exits with 0', async () => { diff --git a/packages/kbn-es/src/utils/decompress.test.js b/packages/kbn-es/src/utils/decompress.test.js index fe5d802ccb668..870fa815db34c 100644 --- a/packages/kbn-es/src/utils/decompress.test.js +++ b/packages/kbn-es/src/utils/decompress.test.js @@ -25,12 +25,8 @@ const path = require('path'); beforeEach(() => { mockFs({ '/data': { - 'snapshot.zip': fs.readFileSync( - path.resolve(__dirname, '__fixtures__/snapshot.zip') - ), - 'snapshot.tar.gz': fs.readFileSync( - path.resolve(__dirname, '__fixtures__/snapshot.tar.gz') - ), + 'snapshot.zip': fs.readFileSync(path.resolve(__dirname, '__fixtures__/snapshot.zip')), + 'snapshot.tar.gz': fs.readFileSync(path.resolve(__dirname, '__fixtures__/snapshot.tar.gz')), }, '/.es': {}, }); diff --git a/packages/kbn-es/src/utils/extract_config_files.js b/packages/kbn-es/src/utils/extract_config_files.js index 428cd8ea0d4fc..1ee4ee887fd31 100644 --- a/packages/kbn-es/src/utils/extract_config_files.js +++ b/packages/kbn-es/src/utils/extract_config_files.js @@ -29,11 +29,7 @@ const mkdirp = require('mkdirp'); * @param {Array} config * @param {String} dest */ -exports.extractConfigFiles = function extractConfigFiles( - config, - dest, - options = {} -) { +exports.extractConfigFiles = function extractConfigFiles(config, dest, options = {}) { const originalConfig = typeof config === 'string' ? [config] : config; const localConfig = []; diff --git a/packages/kbn-es/src/utils/extract_config_files.test.js b/packages/kbn-es/src/utils/extract_config_files.test.js index 5f1cdda96045e..3bf461e11c861 100644 --- a/packages/kbn-es/src/utils/extract_config_files.test.js +++ b/packages/kbn-es/src/utils/extract_config_files.test.js @@ -54,10 +54,7 @@ test('ignores non-paths', () => { }); test('ignores directories', () => { - const config = extractConfigFiles( - ['path=/data/foo.yml', 'foo.bar=/data/bar'], - '/es' - ); + const config = extractConfigFiles(['path=/data/foo.yml', 'foo.bar=/data/bar'], '/es'); expect(config).toEqual(['path=foo.yml', 'foo.bar=/data/bar']); }); diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_path_type.js b/packages/kbn-eslint-import-resolver-kibana/lib/get_path_type.js index 5ffb678dcf0ca..3fb5b5dab7776 100644 --- a/packages/kbn-eslint-import-resolver-kibana/lib/get_path_type.js +++ b/packages/kbn-eslint-import-resolver-kibana/lib/get_path_type.js @@ -23,9 +23,7 @@ const LRU = require('lru-cache'); const DIR = Symbol('dir'); const FILE = Symbol('file'); -const cache = process.env.KIBANA_RESOLVER_HARD_CACHE - ? new Map() - : new LRU({ maxAge: 1000 }); +const cache = process.env.KIBANA_RESOLVER_HARD_CACHE ? new Map() : new LRU({ maxAge: 1000 }); function getPathType(path) { const cached = cache.get(path); diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_project_root.js b/packages/kbn-eslint-import-resolver-kibana/lib/get_project_root.js index 45b99b4961ee7..5c70d63bf147b 100755 --- a/packages/kbn-eslint-import-resolver-kibana/lib/get_project_root.js +++ b/packages/kbn-eslint-import-resolver-kibana/lib/get_project_root.js @@ -27,12 +27,8 @@ function getConfig(config) { projectRoot: true, }; - if (!config || !config['@elastic/eslint-import-resolver-kibana']) - return defaults; - return Object.assign( - defaults, - config['@elastic/eslint-import-resolver-kibana'] - ); + if (!config || !config['@elastic/eslint-import-resolver-kibana']) return defaults; + return Object.assign(defaults, config['@elastic/eslint-import-resolver-kibana']); } function getRootPackageDir(dirRoot, dir, rootPackageName) { @@ -54,8 +50,7 @@ function getRootPackageDir(dirRoot, dir, rootPackageName) { // recurse until a matching package.json is found return getRootPackageDir(dirRoot, dirname(dir), rootPackageName); } catch (e) { - if (e.code === 'ENOENT') - return getRootPackageDir(dirRoot, dirname(dir), rootPackageName); + if (e.code === 'ENOENT') return getRootPackageDir(dirRoot, dirname(dir), rootPackageName); throw e; } } diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js b/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js index 64bb3a08940af..f0425026d1fdb 100755 --- a/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js +++ b/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js @@ -36,9 +36,7 @@ exports.getWebpackConfig = function(kibanaPath, projectRoot, config) { // Dev defaults for test bundle https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/core_plugins/tests_bundle/index.js#L73-L78 ng_mock$: fromKibana('src/test_utils/public/ng_mock'), - 'angular-mocks$': fromKibana( - 'src/core_plugins/tests_bundle/webpackShims/angular-mocks.js' - ), + 'angular-mocks$': fromKibana('src/core_plugins/tests_bundle/webpackShims/angular-mocks.js'), fixtures: fromKibana('src/fixtures'), test_utils: fromKibana('src/test_utils/public'), }; diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/is_probably_webpack_shim.js b/packages/kbn-eslint-import-resolver-kibana/lib/is_probably_webpack_shim.js index 8734140598d6c..2af7d1c2f5349 100644 --- a/packages/kbn-eslint-import-resolver-kibana/lib/is_probably_webpack_shim.js +++ b/packages/kbn-eslint-import-resolver-kibana/lib/is_probably_webpack_shim.js @@ -24,9 +24,7 @@ const LRU = require('lru-cache'); const { isDirectory } = require('./get_path_type'); -const cache = process.env.KIBANA_RESOLVER_HARD_CACHE - ? new Map() - : new LRU({ max: 1000 }); +const cache = process.env.KIBANA_RESOLVER_HARD_CACHE ? new Map() : new LRU({ max: 1000 }); function readShimNames(shimDirectory) { if (!isDirectory(shimDirectory)) { @@ -47,12 +45,9 @@ function findRelativeWebpackShims(directory) { const ownShims = readShimNames(join(directory, 'webpackShims')); const parent = dirname(directory); - const parentShims = - parent !== directory ? findRelativeWebpackShims(parent) : []; + const parentShims = parent !== directory ? findRelativeWebpackShims(parent) : []; - const allShims = !ownShims.length - ? parentShims - : ownShims.concat(parentShims); + const allShims = !ownShims.length ? parentShims : ownShims.concat(parentShims); cache.set(directory, allShims); return allShims; diff --git a/packages/kbn-plugin-generator/sao_template/sao.js b/packages/kbn-plugin-generator/sao_template/sao.js index 2fb0f37bccc22..db2abadc595bc 100755 --- a/packages/kbn-plugin-generator/sao_template/sao.js +++ b/packages/kbn-plugin-generator/sao_template/sao.js @@ -101,10 +101,7 @@ module.exports = function({ name }) { cwd: KBN_DIR, stdio: 'inherit', }).then(() => { - const dir = relative( - process.cwd(), - resolve(KBN_DIR, `../kibana-extra`, snakeCase(name)) - ); + const dir = relative(process.cwd(), resolve(KBN_DIR, `../kibana-extra`, snakeCase(name))); log.success(chalk`🎉 diff --git a/packages/kbn-plugin-helpers/lib/utils.js b/packages/kbn-plugin-helpers/lib/utils.js index 43a15160d3573..c0dee49f2e355 100644 --- a/packages/kbn-plugin-helpers/lib/utils.js +++ b/packages/kbn-plugin-helpers/lib/utils.js @@ -57,4 +57,4 @@ module.exports = { resolveKibanaPath: resolveKibanaPath, createToolingLog: createToolingLog, readFtrConfigFile: readFtrConfigFile, -}; \ No newline at end of file +}; diff --git a/packages/kbn-plugin-helpers/tasks/build/create_build.js b/packages/kbn-plugin-helpers/tasks/build/create_build.js index a7726f4fa6fc7..930f49c845d17 100644 --- a/packages/kbn-plugin-helpers/tasks/build/create_build.js +++ b/packages/kbn-plugin-helpers/tasks/build/create_build.js @@ -65,13 +65,7 @@ function parseTsconfig(pluginSourcePath, configPath) { return config; } -module.exports = function createBuild( - plugin, - buildTarget, - buildVersion, - kibanaVersion, - files -) { +module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaVersion, files) { const buildSource = plugin.root; const buildRoot = path.join(buildTarget, 'kibana', plugin.id); @@ -104,13 +98,9 @@ module.exports = function createBuild( } // install packages in build - execa.sync( - winCmd('yarn'), - ['install', '--production', '--pure-lockfile'], - { - cwd: buildRoot, - } - ); + execa.sync(winCmd('yarn'), ['install', '--production', '--pure-lockfile'], { + cwd: buildRoot, + }); }) .then(function () { if (!plugin.styleSheetToCompile) { @@ -119,17 +109,11 @@ module.exports = function createBuild( const file = path.resolve(plugin.root, plugin.styleSheetToCompile); if (!existsSync(file)) { - throw new Error( - `Path provided for styleSheetToCompile does not exist: ${file}` - ); + throw new Error(`Path provided for styleSheetToCompile does not exist: ${file}`); } const outputFileName = path.basename(file, path.extname(file)) + '.css'; - const output = path.join( - buildRoot, - path.dirname(plugin.styleSheetToCompile), - outputFileName - ); + const output = path.join(buildRoot, path.dirname(plugin.styleSheetToCompile), outputFileName); const rendered = sass.renderSync({ file, output }); writeFileSync(output, rendered.css); @@ -153,10 +137,7 @@ module.exports = function createBuild( const buildConfig = parseTsconfig(buildSource, buildConfigPath); if (buildConfig.extends) { - buildConfig.extends = path.join( - relative(buildRoot, buildSource), - buildConfig.extends - ); + buildConfig.extends = path.join(relative(buildRoot, buildSource), buildConfig.extends); writeFileSync(buildConfigPath, JSON.stringify(buildConfig)); } diff --git a/packages/kbn-plugin-helpers/tasks/build/create_build.test.js b/packages/kbn-plugin-helpers/tasks/build/create_build.test.js index 61653b50a6f7f..0e560289796c8 100644 --- a/packages/kbn-plugin-helpers/tasks/build/create_build.test.js +++ b/packages/kbn-plugin-helpers/tasks/build/create_build.test.js @@ -99,13 +99,7 @@ describe('creating the build', () => { it('produces CSS', async () => { expect(PLUGIN.styleSheetToCompile).toBe(sassPath); - await createBuild( - PLUGIN, - buildTarget, - buildVersion, - kibanaVersion, - buildFiles - ); + await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles); expect(existsSync(cssPath)).toBe(true); }); diff --git a/packages/kbn-plugin-helpers/tasks/build/rewrite_package_json.js b/packages/kbn-plugin-helpers/tasks/build/rewrite_package_json.js index f22193af94c3d..8793a5af757a3 100644 --- a/packages/kbn-plugin-helpers/tasks/build/rewrite_package_json.js +++ b/packages/kbn-plugin-helpers/tasks/build/rewrite_package_json.js @@ -56,4 +56,4 @@ function toBuffer(string) { // of Buffer.from(string, encoding) return new Buffer(string, 'utf8'); } -} \ No newline at end of file +} diff --git a/packages/kbn-pm/src/cli.ts b/packages/kbn-pm/src/cli.ts index 35498ba637fea..07383f89b8165 100644 --- a/packages/kbn-pm/src/cli.ts +++ b/packages/kbn-pm/src/cli.ts @@ -55,11 +55,7 @@ export async function run(argv: string[]) { // starts forwarding the `--` directly to this script, see // https://github.com/yarnpkg/yarn/blob/b2d3e1a8fe45ef376b716d597cc79b38702a9320/src/cli/index.js#L174-L182 if (argv.includes('--')) { - log.write( - chalk.red( - `Using "--" is not allowed, as it doesn't work with 'yarn kbn'.` - ) - ); + log.write(chalk.red(`Using "--" is not allowed, as it doesn't work with 'yarn kbn'.`)); process.exit(1); } @@ -89,9 +85,7 @@ export async function run(argv: string[]) { const command = commands[commandName]; if (command === undefined) { - log.write( - chalk.red(`[${commandName}] is not a valid command, see 'kbn --help'`) - ); + log.write(chalk.red(`[${commandName}] is not a valid command, see 'kbn --help'`)); process.exit(1); } diff --git a/packages/kbn-pm/src/commands/bootstrap.test.ts b/packages/kbn-pm/src/commands/bootstrap.test.ts index 307917e77d1ce..92785ebc91d3d 100644 --- a/packages/kbn-pm/src/commands/bootstrap.test.ts +++ b/packages/kbn-pm/src/commands/bootstrap.test.ts @@ -22,10 +22,7 @@ jest.mock('../utils/link_project_executables'); import { resolve } from 'path'; -import { - absolutePathSnapshotSerializer, - stripAnsiSnapshotSerializer, -} from '../test_helpers'; +import { absolutePathSnapshotSerializer, stripAnsiSnapshotSerializer } from '../test_helpers'; import { linkProjectExecutables } from '../utils/link_project_executables'; import { IPackageJson } from '../utils/package_json'; import { Project } from '../utils/project'; @@ -88,12 +85,7 @@ test('handles dependencies of dependencies', async () => { }, 'packages/baz' ); - const projects = new Map([ - ['kibana', kibana], - ['foo', foo], - ['bar', bar], - ['baz', baz], - ]); + const projects = new Map([['kibana', kibana], ['foo', foo], ['bar', bar], ['baz', baz]]); const projectGraph = buildProjectGraph(projects); const logMock = jest.spyOn(console, 'log').mockImplementation(noop); diff --git a/packages/kbn-pm/src/commands/bootstrap.ts b/packages/kbn-pm/src/commands/bootstrap.ts index 33e029aa25650..2d2aa9b040a75 100644 --- a/packages/kbn-pm/src/commands/bootstrap.ts +++ b/packages/kbn-pm/src/commands/bootstrap.ts @@ -45,9 +45,7 @@ export const BootstrapCommand: ICommand = { } } - log.write( - chalk.bold('\nInstalls completed, linking package executables:\n') - ); + log.write(chalk.bold('\nInstalls completed, linking package executables:\n')); await linkProjectExecutables(projects, projectGraph); /** @@ -56,11 +54,7 @@ export const BootstrapCommand: ICommand = { * transpiled before they can be used. Ideally we shouldn't do this unless we * have to, as it will slow down the bootstrapping process. */ - log.write( - chalk.bold( - '\nLinking executables completed, running `kbn:bootstrap` scripts\n' - ) - ); + log.write(chalk.bold('\nLinking executables completed, running `kbn:bootstrap` scripts\n')); await parallelizeBatches(batchedProjects, async pkg => { if (pkg.hasScript('kbn:bootstrap')) { await pkg.runScriptStreaming('kbn:bootstrap'); diff --git a/packages/kbn-pm/src/commands/clean.ts b/packages/kbn-pm/src/commands/clean.ts index 8bbf781b576ed..edc45c04b39fe 100644 --- a/packages/kbn-pm/src/commands/clean.ts +++ b/packages/kbn-pm/src/commands/clean.ts @@ -27,8 +27,7 @@ import { log } from '../utils/log'; import { ICommand } from './'; export const CleanCommand: ICommand = { - description: - 'Remove the node_modules and target directories from all projects.', + description: 'Remove the node_modules and target directories from all projects.', name: 'clean', async run(projects, projectGraph, { rootPath }) { diff --git a/packages/kbn-pm/src/commands/index.ts b/packages/kbn-pm/src/commands/index.ts index bf8e328c2975f..21de92bcbf47c 100644 --- a/packages/kbn-pm/src/commands/index.ts +++ b/packages/kbn-pm/src/commands/index.ts @@ -29,11 +29,7 @@ export interface ICommand { name: string; description: string; - run: ( - projects: ProjectMap, - projectGraph: ProjectGraph, - config: ICommandConfig - ) => Promise; + run: (projects: ProjectMap, projectGraph: ProjectGraph, config: ICommandConfig) => Promise; } import { BootstrapCommand } from './bootstrap'; diff --git a/packages/kbn-pm/src/commands/run.ts b/packages/kbn-pm/src/commands/run.ts index 0d76aee602ec4..2f4d9e8453d09 100644 --- a/packages/kbn-pm/src/commands/run.ts +++ b/packages/kbn-pm/src/commands/run.ts @@ -25,8 +25,7 @@ import { topologicallyBatchProjects } from '../utils/projects'; import { ICommand } from './'; export const RunCommand: ICommand = { - description: - 'Run script defined in package.json in each package that contains that script.', + description: 'Run script defined in package.json in each package that contains that script.', name: 'run', async run(projects, projectGraph, { extraArgs }) { @@ -41,11 +40,7 @@ export const RunCommand: ICommand = { const scriptArgs = extraArgs.slice(1); log.write( - chalk.bold( - `\nRunning script [${chalk.green( - scriptName - )}] in batched topological order\n` - ) + chalk.bold(`\nRunning script [${chalk.green(scriptName)}] in batched topological order\n`) ); await parallelizeBatches(batchedProjects, async pkg => { diff --git a/packages/kbn-pm/src/commands/watch.ts b/packages/kbn-pm/src/commands/watch.ts index d7c2ab38b7191..b5c493372b04f 100644 --- a/packages/kbn-pm/src/commands/watch.ts +++ b/packages/kbn-pm/src/commands/watch.ts @@ -69,9 +69,7 @@ export const WatchCommand: ICommand = { const projectNames = Array.from(projectsToWatch.keys()); log.write( chalk.bold( - chalk.green( - `Running ${watchScriptName} scripts for [${projectNames.join(', ')}].` - ) + chalk.green(`Running ${watchScriptName} scripts for [${projectNames.join(', ')}].`) ) ); @@ -79,10 +77,7 @@ export const WatchCommand: ICommand = { // topological batching and push it to the last one-entry batch manually. const shouldWatchKibanaProject = projectsToWatch.delete(kibanaProjectName); - const batchedProjects = topologicallyBatchProjects( - projectsToWatch, - projectGraph - ); + const batchedProjects = topologicallyBatchProjects(projectsToWatch, projectGraph); if (shouldWatchKibanaProject) { batchedProjects.push([projects.get(kibanaProjectName)!]); @@ -94,11 +89,7 @@ export const WatchCommand: ICommand = { ); log.write( - chalk.bold( - `[${chalk.green( - pkg.name - )}] Initial build completed (${completionHint}).` - ) + chalk.bold(`[${chalk.green(pkg.name)}] Initial build completed (${completionHint}).`) ); }); }, diff --git a/packages/kbn-pm/src/config.ts b/packages/kbn-pm/src/config.ts index 3eb497033b378..bc88df7139ef4 100644 --- a/packages/kbn-pm/src/config.ts +++ b/packages/kbn-pm/src/config.ts @@ -27,10 +27,7 @@ export interface IProjectPathOptions { /** * Returns all the paths where plugins are located */ -export function getProjectPaths( - rootPath: string, - options: IProjectPathOptions -) { +export function getProjectPaths(rootPath: string, options: IProjectPathOptions) { const skipKibanaExtra = Boolean(options['skip-kibana-extra']); const ossOnly = Boolean(options.oss); diff --git a/packages/kbn-pm/src/index.ts b/packages/kbn-pm/src/index.ts index 390dd5e2f67cb..76979b31e90e2 100644 --- a/packages/kbn-pm/src/index.ts +++ b/packages/kbn-pm/src/index.ts @@ -18,8 +18,5 @@ */ export { run } from './cli'; -export { - buildProductionProjects, - prepareExternalProjectDependencies, -} from './production'; +export { buildProductionProjects, prepareExternalProjectDependencies } from './production'; export { transformDependencies } from './utils/package_json'; diff --git a/packages/kbn-pm/src/production/build_production_projects.ts b/packages/kbn-pm/src/production/build_production_projects.ts index 211aef62997c2..292020b22781f 100644 --- a/packages/kbn-pm/src/production/build_production_projects.ts +++ b/packages/kbn-pm/src/production/build_production_projects.ts @@ -70,11 +70,9 @@ async function getProductionProjects(rootPath: string) { const projectPaths = getProjectPaths(rootPath, {}); const projects = await getProjects(rootPath, projectPaths); - const productionProjects = includeTransitiveProjects( - [projects.get('kibana')!], - projects, - { onlyProductionDependencies: true } - ); + const productionProjects = includeTransitiveProjects([projects.get('kibana')!], projects, { + onlyProductionDependencies: true, + }); // We remove Kibana, as we're already building Kibana productionProjects.delete('kibana'); @@ -107,11 +105,7 @@ async function buildProject(project: Project) { * manage dependencies is that it will "dedupe" them, so we don't include * unnecessary copies of dependencies. */ -async function copyToBuild( - project: Project, - kibanaRoot: string, - buildRoot: string -) { +async function copyToBuild(project: Project, kibanaRoot: string, buildRoot: string) { // We want the package to have the same relative location within the build const relativeProjectPath = relative(kibanaRoot, project.path); const buildProjectPath = resolve(buildRoot, relativeProjectPath); diff --git a/packages/kbn-pm/src/production/index.ts b/packages/kbn-pm/src/production/index.ts index c25ee25dafe9f..493af2beb648d 100644 --- a/packages/kbn-pm/src/production/index.ts +++ b/packages/kbn-pm/src/production/index.ts @@ -18,6 +18,4 @@ */ export { buildProductionProjects } from './build_production_projects'; -export { - prepareExternalProjectDependencies, -} from './prepare_project_dependencies'; +export { prepareExternalProjectDependencies } from './prepare_project_dependencies'; diff --git a/packages/kbn-pm/src/production/integration_tests/build_production_projects.test.ts b/packages/kbn-pm/src/production/integration_tests/build_production_projects.test.ts index b17f28b74b157..d0f2f05bec1b1 100644 --- a/packages/kbn-pm/src/production/integration_tests/build_production_projects.test.ts +++ b/packages/kbn-pm/src/production/integration_tests/build_production_projects.test.ts @@ -61,9 +61,7 @@ describe('kbn-pm production', () => { for (const file of files) { if (file.endsWith('package.json')) { - expect(await readPackageJson(join(buildRoot, file))).toMatchSnapshot( - file - ); + expect(await readPackageJson(join(buildRoot, file))).toMatchSnapshot(file); } } }, diff --git a/packages/kbn-pm/src/production/prepare_project_dependencies.test.ts b/packages/kbn-pm/src/production/prepare_project_dependencies.test.ts index 694b412ee371f..13ab8d56e0190 100644 --- a/packages/kbn-pm/src/production/prepare_project_dependencies.test.ts +++ b/packages/kbn-pm/src/production/prepare_project_dependencies.test.ts @@ -28,9 +28,7 @@ test('does nothing when Kibana `link:` dependencies', async () => { // We're checking for undefined, but we don't really care about what's // returned, we only care about it resolving. - await expect( - prepareExternalProjectDependencies(projectPath) - ).resolves.toBeUndefined(); + await expect(prepareExternalProjectDependencies(projectPath)).resolves.toBeUndefined(); }); test('throws if non-Kibana `link` dependencies', async () => { diff --git a/packages/kbn-pm/src/production/prepare_project_dependencies.ts b/packages/kbn-pm/src/production/prepare_project_dependencies.ts index b894d0683ae46..1bc9435f9c05f 100644 --- a/packages/kbn-pm/src/production/prepare_project_dependencies.ts +++ b/packages/kbn-pm/src/production/prepare_project_dependencies.ts @@ -24,8 +24,7 @@ import { Project } from '../utils/project'; * All external projects are located within `../kibana-extra/{plugin}` relative * to Kibana itself. */ -const isKibanaDep = (depVersion: string) => - depVersion.includes('../../kibana/'); +const isKibanaDep = (depVersion: string) => depVersion.includes('../../kibana/'); /** * This prepares the dependencies for an _external_ project. @@ -49,9 +48,7 @@ export async function prepareExternalProjectDependencies(projectPath: string) { if (isLinkDependency(depVersion) && !isKibanaDep(depVersion)) { // For non-Kibana packages we need to set up symlinks during the // installation process, but this is not something we support yet. - throw new Error( - 'This plugin is using `link:` dependencies for non-Kibana packages' - ); + throw new Error('This plugin is using `link:` dependencies for non-Kibana packages'); } } } diff --git a/packages/kbn-pm/src/run.test.ts b/packages/kbn-pm/src/run.test.ts index 7827498daa7ea..9b3d7707ae7b1 100644 --- a/packages/kbn-pm/src/run.test.ts +++ b/packages/kbn-pm/src/run.test.ts @@ -25,21 +25,14 @@ import { Project } from './utils/project'; const rootPath = resolve(`${__dirname}/utils/__fixtures__/kibana`); function getExpectedProjectsAndGraph(runMock: any) { - const [fullProjects, fullProjectGraph] = (runMock as jest.Mock< - any - >).mock.calls[0]; + const [fullProjects, fullProjectGraph] = (runMock as jest.Mock).mock.calls[0]; const projects = [...fullProjects.keys()].sort(); - const graph = [...fullProjectGraph.entries()].reduce( - (expected, [projectName, dependencies]) => { - expected[projectName] = dependencies.map( - (project: Project) => project.name - ); - return expected; - }, - {} - ); + const graph = [...fullProjectGraph.entries()].reduce((expected, [projectName, dependencies]) => { + expected[projectName] = dependencies.map((project: Project) => project.name); + return expected; + }, {}); return { projects, graph }; } diff --git a/packages/kbn-pm/src/run.ts b/packages/kbn-pm/src/run.ts index d64dd3a9045a6..980997200a194 100644 --- a/packages/kbn-pm/src/run.ts +++ b/packages/kbn-pm/src/run.ts @@ -32,16 +32,11 @@ export async function runCommand(command: ICommand, config: ICommandConfig) { try { log.write( chalk.bold( - `Running [${chalk.green(command.name)}] command from [${chalk.yellow( - config.rootPath - )}]:\n` + `Running [${chalk.green(command.name)}] command from [${chalk.yellow(config.rootPath)}]:\n` ) ); - const projectPaths = getProjectPaths( - config.rootPath, - config.options as IProjectPathOptions - ); + const projectPaths = getProjectPaths(config.rootPath, config.options as IProjectPathOptions); const projects = await getProjects(config.rootPath, projectPaths, { exclude: toArray(config.options.exclude), @@ -59,9 +54,7 @@ export async function runCommand(command: ICommand, config: ICommandConfig) { const projectGraph = buildProjectGraph(projects); - log.write( - chalk.bold(`Found [${chalk.green(projects.size.toString())}] projects:\n`) - ); + log.write(chalk.bold(`Found [${chalk.green(projects.size.toString())}] projects:\n`)); log.write(renderProjectsTree(config.rootPath, projects)); await command.run(projects, projectGraph, config); diff --git a/packages/kbn-pm/src/test_helpers/index.ts b/packages/kbn-pm/src/test_helpers/index.ts index 3498705d0f770..7032a19093fc4 100644 --- a/packages/kbn-pm/src/test_helpers/index.ts +++ b/packages/kbn-pm/src/test_helpers/index.ts @@ -17,8 +17,6 @@ * under the License. */ -export { - absolutePathSnapshotSerializer, -} from './absolute_path_snapshot_serializer'; +export { absolutePathSnapshotSerializer } from './absolute_path_snapshot_serializer'; export { stripAnsiSnapshotSerializer } from './strip_ansi_snapshot_serializer'; diff --git a/packages/kbn-pm/src/utils/child_process.ts b/packages/kbn-pm/src/utils/child_process.ts index eeefe5a26e195..caf1e822ff96d 100644 --- a/packages/kbn-pm/src/utils/child_process.ts +++ b/packages/kbn-pm/src/utils/child_process.ts @@ -23,14 +23,7 @@ import logSymbols from 'log-symbols'; import logTransformer from 'strong-log-transformer'; function generateColors() { - const colorWheel = [ - chalk.cyan, - chalk.magenta, - chalk.blue, - chalk.yellow, - chalk.green, - chalk.red, - ]; + const colorWheel = [chalk.cyan, chalk.magenta, chalk.blue, chalk.yellow, chalk.green, chalk.red]; const count = colorWheel.length; let children = 0; diff --git a/packages/kbn-pm/src/utils/link_project_executables.test.ts b/packages/kbn-pm/src/utils/link_project_executables.test.ts index 1b8dc60ea44e5..b618a28e642d3 100644 --- a/packages/kbn-pm/src/utils/link_project_executables.test.ts +++ b/packages/kbn-pm/src/utils/link_project_executables.test.ts @@ -21,10 +21,7 @@ jest.mock('./fs'); import { resolve } from 'path'; -import { - absolutePathSnapshotSerializer, - stripAnsiSnapshotSerializer, -} from '../test_helpers'; +import { absolutePathSnapshotSerializer, stripAnsiSnapshotSerializer } from '../test_helpers'; import { linkProjectExecutables } from './link_project_executables'; import { Project } from './project'; import { buildProjectGraph } from './projects'; diff --git a/packages/kbn-pm/src/utils/link_project_executables.ts b/packages/kbn-pm/src/utils/link_project_executables.ts index e2b515f4056c5..25fb11f17f782 100644 --- a/packages/kbn-pm/src/utils/link_project_executables.ts +++ b/packages/kbn-pm/src/utils/link_project_executables.ts @@ -59,9 +59,7 @@ export async function linkProjectExecutables( .split(sep) .join('/'); - log.write( - chalk`{dim [${project.name}]} ${name} -> {dim ${projectRelativePath}}` - ); + log.write(chalk`{dim [${project.name}]} ${name} -> {dim ${projectRelativePath}}`); await mkdirp(dirname(dest)); await createSymlink(srcPath, dest, 'exec'); diff --git a/packages/kbn-pm/src/utils/package_json.ts b/packages/kbn-pm/src/utils/package_json.ts index cd62249eb54e4..132325149d824 100644 --- a/packages/kbn-pm/src/utils/package_json.ts +++ b/packages/kbn-pm/src/utils/package_json.ts @@ -43,8 +43,7 @@ export const createProductionPackageJson = (pkgJson: IPackageJson) => ({ dependencies: transformDependencies(pkgJson.dependencies), }); -export const isLinkDependency = (depVersion: string) => - depVersion.startsWith('link:'); +export const isLinkDependency = (depVersion: string) => depVersion.startsWith('link:'); /** * Replaces `link:` dependencies with `file:` dependencies. When installing diff --git a/packages/kbn-pm/src/utils/parallelize.ts b/packages/kbn-pm/src/utils/parallelize.ts index dc202b8b6b2d3..4e833d698f956 100644 --- a/packages/kbn-pm/src/utils/parallelize.ts +++ b/packages/kbn-pm/src/utils/parallelize.ts @@ -17,10 +17,7 @@ * under the License. */ -export async function parallelizeBatches( - batches: T[][], - fn: (item: T) => Promise -) { +export async function parallelizeBatches(batches: T[][], fn: (item: T) => Promise) { for (const batch of batches) { // We need to make sure the entire batch has completed before we can move on // to the next batch @@ -28,11 +25,7 @@ export async function parallelizeBatches( } } -export async function parallelize( - items: T[], - fn: (item: T) => Promise, - concurrency = 4 -) { +export async function parallelize(items: T[], fn: (item: T) => Promise, concurrency = 4) { if (items.length === 0) { return; } diff --git a/packages/kbn-pm/src/utils/project.test.ts b/packages/kbn-pm/src/utils/project.test.ts index 9512777a7ed89..ba7d44814f64c 100644 --- a/packages/kbn-pm/src/utils/project.test.ts +++ b/packages/kbn-pm/src/utils/project.test.ts @@ -96,9 +96,7 @@ describe('#ensureValidProjectDependency', () => { 'packages/foo' ); - expect(() => - root.ensureValidProjectDependency(foo) - ).toThrowErrorMatchingSnapshot(); + expect(() => root.ensureValidProjectDependency(foo)).toThrowErrorMatchingSnapshot(); }); test('using version instead of link:', () => { @@ -118,9 +116,7 @@ describe('#ensureValidProjectDependency', () => { 'packages/foo' ); - expect(() => - root.ensureValidProjectDependency(foo) - ).toThrowErrorMatchingSnapshot(); + expect(() => root.ensureValidProjectDependency(foo)).toThrowErrorMatchingSnapshot(); }); }); @@ -157,9 +153,7 @@ describe('#getExecutables()', () => { }); test('throws CliError when bin is something strange', () => { - expect(() => - createProjectWith({ bin: 1 }).getExecutables() - ).toThrowErrorMatchingSnapshot(); + expect(() => createProjectWith({ bin: 1 }).getExecutables()).toThrowErrorMatchingSnapshot(); }); }); diff --git a/packages/kbn-pm/src/utils/project.ts b/packages/kbn-pm/src/utils/project.ts index 9d855f2ff55c8..279a8fabaa1bd 100644 --- a/packages/kbn-pm/src/utils/project.ts +++ b/packages/kbn-pm/src/utils/project.ts @@ -30,11 +30,7 @@ import { isLinkDependency, readPackageJson, } from './package_json'; -import { - installInDir, - runScriptInPackage, - runScriptInPackageStreaming, -} from './scripts'; +import { installInDir, runScriptInPackage, runScriptInPackageStreaming } from './scripts'; interface IBuildConfig { skip?: boolean; @@ -80,9 +76,7 @@ export class Project { } public ensureValidProjectDependency(project: Project) { - const relativePathToProject = normalizePath( - relative(this.path, project.path) - ); + const relativePathToProject = normalizePath(relative(this.path, project.path)); const versionInPackageJson = this.allDependencies[project.name]; const expectedVersionInPackageJson = `link:${relativePathToProject}`; @@ -125,10 +119,7 @@ export class Project { * instead of everything located in the project directory. */ public getIntermediateBuildDirectory() { - return resolvePath( - this.path, - this.getBuildConfig().intermediateBuildDirectory || '.' - ); + return resolvePath(this.path, this.getBuildConfig().intermediateBuildDirectory || '.'); } public hasScript(name: string) { @@ -169,9 +160,7 @@ export class Project { public async runScript(scriptName: string, args: string[] = []) { log.write( chalk.bold( - `\n\nRunning script [${chalk.green(scriptName)}] in [${chalk.green( - this.name - )}]:\n` + `\n\nRunning script [${chalk.green(scriptName)}] in [${chalk.green(this.name)}]:\n` ) ); return runScriptInPackage(scriptName, args, this); @@ -186,11 +175,7 @@ export class Project { } public async installDependencies({ extraArgs }: { extraArgs: string[] }) { - log.write( - chalk.bold( - `\n\nInstalling dependencies in [${chalk.green(this.name)}]:\n` - ) - ); + log.write(chalk.bold(`\n\nInstalling dependencies in [${chalk.green(this.name)}]:\n`)); return installInDir(this.path, extraArgs); } } diff --git a/packages/kbn-pm/src/utils/projects.test.ts b/packages/kbn-pm/src/utils/projects.test.ts index f378319cfe1f5..e2b6f225472d1 100644 --- a/packages/kbn-pm/src/utils/projects.test.ts +++ b/packages/kbn-pm/src/utils/projects.test.ts @@ -39,9 +39,7 @@ describe('#getProjects', () => { const expectedProjects = ['bar', 'foo']; expect(projects.size).toBe(2); - expect([...projects.keys()]).toEqual( - expect.arrayContaining(expectedProjects) - ); + expect([...projects.keys()]).toEqual(expect.arrayContaining(expectedProjects)); }); test('can specify root as a separate project', async () => { @@ -57,36 +55,22 @@ describe('#getProjects', () => { const expectedProjects = ['baz', 'quux']; expect(projects.size).toBe(2); - expect([...projects.keys()]).toEqual( - expect.arrayContaining(expectedProjects) - ); + expect([...projects.keys()]).toEqual(expect.arrayContaining(expectedProjects)); }); test('throws if multiple projects has the same name', async () => { await expect( getProjects(rootPath, ['../plugins/*', '../other-plugins/*']) - ).rejects.toHaveProperty( - 'message', - 'There are multiple projects with the same name [baz]' - ); + ).rejects.toHaveProperty('message', 'There are multiple projects with the same name [baz]'); }); test('includes additional projects in package.json', async () => { const projectPaths = getProjectPaths(rootPath, {}); const projects = await getProjects(rootPath, projectPaths); - const expectedProjects = [ - 'kibana', - 'bar', - 'foo', - 'with-additional-projects', - 'quux', - 'baz', - ]; - - expect([...projects.keys()]).toEqual( - expect.arrayContaining(expectedProjects) - ); + const expectedProjects = ['kibana', 'bar', 'foo', 'with-additional-projects', 'quux', 'baz']; + + expect([...projects.keys()]).toEqual(expect.arrayContaining(expectedProjects)); expect(projects.size).toBe(expectedProjects.length); }); @@ -101,11 +85,7 @@ describe('#getProjects', () => { exclude: ['foo', 'bar', 'baz'], }); - expect([...projects.keys()].sort()).toEqual([ - 'kibana', - 'quux', - 'with-additional-projects', - ]); + expect([...projects.keys()].sort()).toEqual(['kibana', 'quux', 'with-additional-projects']); }); test('ignores unknown projects specified in `exclude` filter', async () => { @@ -157,14 +137,7 @@ describe('#getProjects', () => { test('does not return any project if `exclude` filter is specified for all projects', async () => { const projects = await getProjects(rootPath, projectPaths, { - exclude: [ - 'kibana', - 'bar', - 'foo', - 'with-additional-projects', - 'quux', - 'baz', - ], + exclude: ['kibana', 'bar', 'foo', 'with-additional-projects', 'quux', 'baz'], }); expect(projects.size).toBe(0); @@ -183,11 +156,7 @@ describe('#getProjects', () => { describe('#buildProjectGraph', () => { test('builds full project graph', async () => { - const allProjects = await getProjects(rootPath, [ - '.', - 'packages/*', - '../plugins/*', - ]); + const allProjects = await getProjects(rootPath, ['.', 'packages/*', '../plugins/*']); const graph = buildProjectGraph(allProjects); const expected: { [k: string]: string[] } = {}; @@ -210,9 +179,7 @@ describe('#topologicallyBatchProjects', () => { test('batches projects topologically based on their project dependencies', async () => { const batches = topologicallyBatchProjects(projects, graph); - const expectedBatches = batches.map(batch => - batch.map(project => project.name) - ); + const expectedBatches = batches.map(batch => batch.map(project => project.name)); expect(expectedBatches).toMatchSnapshot(); }); @@ -223,9 +190,7 @@ describe('#topologicallyBatchProjects', () => { const batches = topologicallyBatchProjects(projects, graph); - const expectedBatches = batches.map(batch => - batch.map(project => project.name) - ); + const expectedBatches = batches.map(batch => batch.map(project => project.name)); expect(expectedBatches).toMatchSnapshot(); }); @@ -261,11 +226,7 @@ describe('#includeTransitiveProjects', () => { }); test('includes dependencies of dependencies', async () => { - const projects = await getProjects(rootPath, [ - '.', - 'packages/*', - '../plugins/*', - ]); + const projects = await getProjects(rootPath, ['.', 'packages/*', '../plugins/*']); const quux = projects.get('quux')!; const withTransitive = includeTransitiveProjects([quux], projects); diff --git a/packages/kbn-pm/src/utils/projects.ts b/packages/kbn-pm/src/utils/projects.ts index 192c1be71350f..d46596a08694c 100644 --- a/packages/kbn-pm/src/utils/projects.ts +++ b/packages/kbn-pm/src/utils/projects.ts @@ -49,21 +49,17 @@ export async function getProjects( const project = await Project.fromPath(projectDir); const excludeProject = - exclude.includes(project.name) || - (include.length > 0 && !include.includes(project.name)); + exclude.includes(project.name) || (include.length > 0 && !include.includes(project.name)); if (excludeProject) { continue; } if (projects.has(project.name)) { - throw new CliError( - `There are multiple projects with the same name [${project.name}]`, - { - name: project.name, - paths: [project.path, projects.get(project.name)!.path], - } - ); + throw new CliError(`There are multiple projects with the same name [${project.name}]`, { + name: project.name, + paths: [project.path, projects.get(project.name)!.path], + }); } projects.set(project.name, project); @@ -73,13 +69,7 @@ export async function getProjects( return projects; } -function packagesFromGlobPattern({ - pattern, - rootPath, -}: { - pattern: string; - rootPath: string; -}) { +function packagesFromGlobPattern({ pattern, rootPath }: { pattern: string; rootPath: string }) { const globOptions = { cwd: rootPath, @@ -141,9 +131,7 @@ export function topologicallyBatchProjects( const batch = []; for (const projectName of projectToBatchNames) { const projectDeps = projectGraph.get(projectName)!; - const hasNotBatchedDependencies = projectDeps.some(dep => - projectToBatchNames.has(dep.name) - ); + const hasNotBatchedDependencies = projectDeps.some(dep => projectToBatchNames.has(dep.name)); if (!hasNotBatchedDependencies) { batch.push(projectsToBatch.get(projectName)!); diff --git a/packages/kbn-pm/src/utils/projects_tree.test.ts b/packages/kbn-pm/src/utils/projects_tree.test.ts index 27c4f1d328424..f8c99d22eaf22 100644 --- a/packages/kbn-pm/src/utils/projects_tree.test.ts +++ b/packages/kbn-pm/src/utils/projects_tree.test.ts @@ -36,11 +36,7 @@ test('handles projects with root folder', async () => { }); test('handles projects outside root folder', async () => { - const projects = await getProjects(rootPath, [ - '.', - 'packages/*', - '../plugins/*', - ]); + const projects = await getProjects(rootPath, ['.', 'packages/*', '../plugins/*']); const tree = await renderProjectsTree(rootPath, projects); expect(tree).toMatchSnapshot(); diff --git a/packages/kbn-pm/src/utils/projects_tree.ts b/packages/kbn-pm/src/utils/projects_tree.ts index c3b2064ee6e49..61e997d021a17 100644 --- a/packages/kbn-pm/src/utils/projects_tree.ts +++ b/packages/kbn-pm/src/utils/projects_tree.ts @@ -24,10 +24,7 @@ import { Project } from './project'; const projectKey = Symbol('__project'); -export function renderProjectsTree( - rootPath: string, - projects: Map -) { +export function renderProjectsTree(rootPath: string, projects: Map) { const projectsTree = buildProjectsTree(rootPath, projects); return treeToString(createTreeStructure(projectsTree)); } @@ -46,10 +43,7 @@ function treeToString(tree: ITree) { return [tree.name].concat(childrenToStrings(tree.children, '')).join('\n'); } -function childrenToStrings( - tree: ITreeChildren | undefined, - treePrefix: string -) { +function childrenToStrings(tree: ITreeChildren | undefined, treePrefix: string) { if (tree === undefined) { return []; } @@ -149,11 +143,7 @@ function buildProjectsTree(rootPath: string, projects: Map) { return tree; } -function addProjectToTree( - tree: IProjectsTree, - pathParts: string[], - project: Project -) { +function addProjectToTree(tree: IProjectsTree, pathParts: string[], project: Project) { if (pathParts.length === 0) { tree.set(projectKey, project.name); } else { diff --git a/packages/kbn-pm/src/utils/scripts.ts b/packages/kbn-pm/src/utils/scripts.ts index a0cbd01fc811a..044c84124311b 100644 --- a/packages/kbn-pm/src/utils/scripts.ts +++ b/packages/kbn-pm/src/utils/scripts.ts @@ -23,16 +23,8 @@ import { Project } from './project'; /** * Install all dependencies in the given directory */ -export async function installInDir( - directory: string, - extraArgs: string[] = [] -) { - const options = [ - 'install', - '--non-interactive', - '--mutex file', - ...extraArgs, - ]; +export async function installInDir(directory: string, extraArgs: string[] = []) { + const options = ['install', '--non-interactive', '--mutex file', ...extraArgs]; // We pass the mutex flag to ensure only one instance of yarn runs at any // given time (e.g. to avoid conflicts). @@ -44,11 +36,7 @@ export async function installInDir( /** * Run script in the given directory */ -export async function runScriptInPackage( - script: string, - args: string[], - pkg: Project -) { +export async function runScriptInPackage(script: string, args: string[], pkg: Project) { const execOpts = { cwd: pkg.path, }; @@ -59,11 +47,7 @@ export async function runScriptInPackage( /** * Run script in the given directory */ -export function runScriptInPackageStreaming( - script: string, - args: string[], - pkg: Project -) { +export function runScriptInPackageStreaming(script: string, args: string[], pkg: Project) { const execOpts = { cwd: pkg.path, }; diff --git a/packages/kbn-pm/src/utils/watch.ts b/packages/kbn-pm/src/utils/watch.ts index 7566d76674736..f8527692fcac7 100644 --- a/packages/kbn-pm/src/utils/watch.ts +++ b/packages/kbn-pm/src/utils/watch.ts @@ -18,16 +18,7 @@ */ import * as Rx from 'rxjs'; -import { - catchError, - delay, - finalize, - first, - map, - mapTo, - mergeMap, - timeout, -} from 'rxjs/operators'; +import { catchError, delay, finalize, first, map, mapTo, mergeMap, timeout } from 'rxjs/operators'; /** * Number of milliseconds we wait before we fall back to the default watch handler. @@ -67,43 +58,26 @@ function getWatchHandlers( const typescriptHandler = buildOutput$.pipe( first(data => data.includes('$ tsc')), map(() => - buildOutput$.pipe( - first(data => data.includes('Compilation complete.')), - mapTo('tsc') - ) + buildOutput$.pipe(first(data => data.includes('Compilation complete.')), mapTo('tsc')) ) ); const webpackHandler = buildOutput$.pipe( first(data => data.includes('$ webpack')), - map(() => - buildOutput$.pipe( - first(data => data.includes('Chunk Names')), - mapTo('webpack') - ) - ) + map(() => buildOutput$.pipe(first(data => data.includes('Chunk Names')), mapTo('webpack'))) ); const defaultHandler = Rx.of(undefined).pipe( delay(handlerReadinessTimeout), - map(() => - buildOutput$.pipe( - timeout(handlerDelay), - catchError(() => Rx.of('timeout')) - ) - ) + map(() => buildOutput$.pipe(timeout(handlerDelay), catchError(() => Rx.of('timeout')))) ); return [typescriptHandler, webpackHandler, defaultHandler]; } -export function waitUntilWatchIsReady( - stream: NodeJS.EventEmitter, - opts: IWatchOptions = {} -) { +export function waitUntilWatchIsReady(stream: NodeJS.EventEmitter, opts: IWatchOptions = {}) { const buildOutput$ = new Rx.Subject(); - const onDataListener = (data: Buffer) => - buildOutput$.next(data.toString('utf-8')); + const onDataListener = (data: Buffer) => buildOutput$.next(data.toString('utf-8')); const onEndListener = () => buildOutput$.complete(); const onErrorListener = (e: Error) => buildOutput$.error(e); diff --git a/packages/kbn-system-loader/src/sorted_systems.ts b/packages/kbn-system-loader/src/sorted_systems.ts index ab4ef397dd736..85dcc64ed9654 100644 --- a/packages/kbn-system-loader/src/sorted_systems.ts +++ b/packages/kbn-system-loader/src/sorted_systems.ts @@ -35,9 +35,7 @@ function toSortable(systems: Map>) { /** * Sorts systems in topological order based on dependencies */ -export function getSortedSystemNames( - systems: Map> -) { +export function getSortedSystemNames(systems: Map>) { const sorted = topologicalSort(toSortable(systems)); return [...sorted]; } diff --git a/packages/kbn-system-loader/src/system.ts b/packages/kbn-system-loader/src/system.ts index 5a8bb861b6a90..7f42c073a97de 100644 --- a/packages/kbn-system-loader/src/system.ts +++ b/packages/kbn-system-loader/src/system.ts @@ -26,9 +26,7 @@ import { } from './system_types'; function isPromise(obj: any) { - return ( - obj != null && typeof obj === 'object' && typeof obj.then === 'function' - ); + return obj != null && typeof obj === 'object' && typeof obj.then === 'function'; } export class System { @@ -56,19 +54,14 @@ export class System { public getExposedValues(): E { if (this.systemInstance === undefined) { - throw new Error( - 'trying to get the exposed value of a system that is NOT running' - ); + throw new Error('trying to get the exposed value of a system that is NOT running'); } return this.exposedValues!; } public start(kibanaValues: C, dependenciesValues: D) { - this.systemInstance = new this.systemClass( - kibanaValues, - dependenciesValues - ); + this.systemInstance = new this.systemClass(kibanaValues, dependenciesValues); const exposedValues = this.systemInstance.start(); if (isPromise(exposedValues)) { @@ -79,8 +72,7 @@ export class System { ); } - this.exposedValues = - exposedValues === undefined ? ({} as E) : exposedValues; + this.exposedValues = exposedValues === undefined ? ({} as E) : exposedValues; } public stop() { @@ -91,9 +83,7 @@ export class System { if (isPromise(stoppedResponse)) { throw new Error( - `A promise was returned when stopping [${ - this.name - }], but systems must stop synchronously.` + `A promise was returned when stopping [${this.name}], but systems must stop synchronously.` ); } } diff --git a/packages/kbn-system-loader/src/system_loader.test.ts b/packages/kbn-system-loader/src/system_loader.test.ts index 31552ae514d29..c6d2beff24f34 100644 --- a/packages/kbn-system-loader/src/system_loader.test.ts +++ b/packages/kbn-system-loader/src/system_loader.test.ts @@ -59,10 +59,7 @@ test('starts system with core api', () => { }, }); - const createSystemApi: KibanaSystemApiFactory = ( - name, - metadata - ) => { + const createSystemApi: KibanaSystemApiFactory = (name, metadata) => { return { fromCore: true, metadata, @@ -226,11 +223,7 @@ test('receives values from dependencies but not transitive dependencies', () => }; } - class GrandchildSystem extends KibanaSystem< - CoreType, - {}, - IGrandchild['grandchild'] - > { + class GrandchildSystem extends KibanaSystem { public start() { return { value: 'grandchild', @@ -238,11 +231,7 @@ test('receives values from dependencies but not transitive dependencies', () => } } - class ChildSystem extends KibanaSystem< - CoreType, - IGrandchild, - IChild['child'] - > { + class ChildSystem extends KibanaSystem { public start() { expect(this.deps.grandchild).toEqual({ value: 'grandchild' }); diff --git a/packages/kbn-system-loader/src/system_loader.ts b/packages/kbn-system-loader/src/system_loader.ts index a0190c1bf5d84..b3f724737be15 100644 --- a/packages/kbn-system-loader/src/system_loader.ts +++ b/packages/kbn-system-loader/src/system_loader.ts @@ -21,10 +21,7 @@ import { getSortedSystemNames } from './sorted_systems'; import { System } from './system'; import { SystemMetadata, SystemName, SystemsType } from './system_types'; -export type KibanaSystemApiFactory = ( - name: SystemName, - metadata?: M -) => C; +export type KibanaSystemApiFactory = (name: SystemName, metadata?: M) => C; export class SystemLoader { private readonly systems = new Map>(); @@ -45,9 +42,7 @@ export class SystemLoader { }); } - public addSystem( - system: System - ) { + public addSystem(system: System) { if (this.systems.has(system.name)) { throw new Error(`a system named [${system.name}] has already been added`); } @@ -92,21 +87,14 @@ export class SystemLoader { } } - private startSystem( - system: System - ) { + private startSystem(system: System) { const dependenciesValues = {} as D; for (const dependency of system.dependencies) { - dependenciesValues[dependency] = this.systems - .get(dependency)! - .getExposedValues(); + dependenciesValues[dependency] = this.systems.get(dependency)!.getExposedValues(); } - const kibanaSystemApi = this.kibanaSystemApiFactory( - system.name, - system.metadata - ); + const kibanaSystemApi = this.kibanaSystemApiFactory(system.name, system.metadata); system.start(kibanaSystemApi, dependenciesValues); this.startedSystems.push(system.name); diff --git a/packages/kbn-system-loader/src/topological_sort.test.ts b/packages/kbn-system-loader/src/topological_sort.test.ts index d3cf67388e507..8dcf8d55c8714 100644 --- a/packages/kbn-system-loader/src/topological_sort.test.ts +++ b/packages/kbn-system-loader/src/topological_sort.test.ts @@ -20,12 +20,7 @@ import { topologicalSort } from './topological_sort'; test('returns a topologically ordered sequence', () => { - const nodes = new Map([ - ['a', []], - ['b', ['a']], - ['c', ['a', 'b']], - ['d', ['a']], - ]); + const nodes = new Map([['a', []], ['b', ['a']], ['c', ['a', 'b']], ['d', ['a']]]); const sorted = topologicalSort(nodes); @@ -35,12 +30,7 @@ test('returns a topologically ordered sequence', () => { }); test('handles multiple "roots" with no deps', () => { - const nodes = new Map([ - ['a', []], - ['b', []], - ['c', ['a', 'b']], - ['d', ['a']], - ]); + const nodes = new Map([['a', []], ['b', []], ['c', ['a', 'b']], ['d', ['a']]]); const sorted = topologicalSort(nodes); diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/args.js b/packages/kbn-test/src/functional_tests/cli/run_tests/args.js index b6490171f5d16..55d4cfb27c680 100644 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/args.js +++ b/packages/kbn-test/src/functional_tests/cli/run_tests/args.js @@ -42,8 +42,7 @@ const options = { desc: 'Pattern to select which tests to run.', }, updateBaselines: { - desc: - 'Replace baseline screenshots with whatever is generated from the test.', + desc: 'Replace baseline screenshots with whatever is generated from the test.', }, verbose: { desc: 'Log everything.' }, debug: { desc: 'Run in debug mode.' }, @@ -125,9 +124,7 @@ function validateOptions(userOptions) { // Validate enum flags (options[key].choices && !options[key].choices.includes(val)) ) { - throw new Error( - `functional_tests: invalid argument [${val}] to option [${key}]` - ); + throw new Error(`functional_tests: invalid argument [${val}] to option [${key}]`); } }); } diff --git a/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js b/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js index 0cd119a2d8eb8..2e0c2fb44022d 100644 --- a/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js +++ b/packages/kbn-test/src/functional_tests/cli/run_tests/args.test.js @@ -57,9 +57,7 @@ describe('process options for run tests CLI', () => { it('rejects boolean value for kibana-install-dir', () => { expect(() => { processOptions({ 'kibana-install-dir': true }, ['foo']); - }).toThrow( - 'functional_tests: invalid argument [true] to option [kibana-install-dir]' - ); + }).toThrow('functional_tests: invalid argument [true] to option [kibana-install-dir]'); }); it('accepts boolean value for updateBaselines', () => { @@ -75,9 +73,7 @@ describe('process options for run tests CLI', () => { it('rejects non-enum value for esFrom', () => { expect(() => { processOptions({ esFrom: 'butter' }, ['foo']); - }).toThrow( - 'functional_tests: invalid argument [butter] to option [esFrom]' - ); + }).toThrow('functional_tests: invalid argument [butter] to option [esFrom]'); }); it('accepts value for grep', () => { diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/args.js b/packages/kbn-test/src/functional_tests/cli/start_servers/args.js index 467ab098918ed..55a69d0bd15bd 100644 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/args.js +++ b/packages/kbn-test/src/functional_tests/cli/start_servers/args.js @@ -111,9 +111,7 @@ function validateOptions(userOptions) { // Validate enum flags (options[key].choices && !options[key].choices.includes(val)) ) { - throw new Error( - `functional_tests_server: invalid argument [${val}] to option [${key}]` - ); + throw new Error(`functional_tests_server: invalid argument [${val}] to option [${key}]`); } }); } diff --git a/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js b/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js index e4785a26b21b9..b85113b26ab8b 100644 --- a/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js +++ b/packages/kbn-test/src/functional_tests/cli/start_servers/args.test.js @@ -29,9 +29,7 @@ describe('process options for start servers CLI', () => { it('rejects boolean config value', () => { expect(() => { processOptions({ config: true }); - }).toThrow( - 'functional_tests_server: invalid argument [true] to option [config]' - ); + }).toThrow('functional_tests_server: invalid argument [true] to option [config]'); }); it('rejects empty config value if no default passed', () => { @@ -59,9 +57,7 @@ describe('process options for start servers CLI', () => { it('rejects boolean value for kibana-install-dir', () => { expect(() => { processOptions({ 'kibana-install-dir': true }, ['foo']); - }).toThrow( - 'functional_tests_server: invalid argument [true] to option [kibana-install-dir]' - ); + }).toThrow('functional_tests_server: invalid argument [true] to option [kibana-install-dir]'); }); it('accepts source value for esFrom', () => { @@ -72,9 +68,7 @@ describe('process options for start servers CLI', () => { it('rejects non-enum value for esFrom', () => { expect(() => { processOptions({ esFrom: 'butter' }, ['foo']); - }).toThrow( - 'functional_tests_server: invalid argument [butter] to option [esFrom]' - ); + }).toThrow('functional_tests_server: invalid argument [butter] to option [esFrom]'); }); it('accepts debug option', () => { diff --git a/packages/kbn-test/src/functional_tests/lib/auth.js b/packages/kbn-test/src/functional_tests/lib/auth.js index 5005bd877f8f9..2bae4c91265ab 100644 --- a/packages/kbn-test/src/functional_tests/lib/auth.js +++ b/packages/kbn-test/src/functional_tests/lib/auth.js @@ -62,9 +62,7 @@ async function updateCredentials(port, auth, username, password, retries = 10) { return await updateCredentials(port, auth, username, password, retries - 1); } - throw new Error( - `${statusCode} response, expected 200 -- ${JSON.stringify(body)}` - ); + throw new Error(`${statusCode} response, expected 200 -- ${JSON.stringify(body)}`); } export async function setupUsers(log, config) { @@ -75,10 +73,7 @@ export async function setupUsers(log, config) { let auth = `elastic:${DEFAULT_SUPERUSER_PASS}`; // list of updates we need to apply - const updates = [ - config.get('servers.elasticsearch'), - config.get('servers.kibana'), - ]; + const updates = [config.get('servers.elasticsearch'), config.get('servers.kibana')]; for (const { username, password } of updates) { log.info('setting %j user password to %j', username, password); diff --git a/packages/kbn-test/src/functional_tests/lib/index.js b/packages/kbn-test/src/functional_tests/lib/index.js index 5116dc060f41f..e20a27cda832e 100644 --- a/packages/kbn-test/src/functional_tests/lib/index.js +++ b/packages/kbn-test/src/functional_tests/lib/index.js @@ -20,9 +20,4 @@ export { runKibanaServer } from './run_kibana_server'; export { runElasticsearch } from './run_elasticsearch'; export { runFtr } from './run_ftr'; -export { - KIBANA_ROOT, - KIBANA_FTR_SCRIPT, - FUNCTIONAL_CONFIG_PATH, - API_CONFIG_PATH, -} from './paths'; +export { KIBANA_ROOT, KIBANA_FTR_SCRIPT, FUNCTIONAL_CONFIG_PATH, API_CONFIG_PATH } from './paths'; diff --git a/packages/kbn-test/src/functional_tests/lib/paths.js b/packages/kbn-test/src/functional_tests/lib/paths.js index 0aae3c4628129..6584f78163851 100644 --- a/packages/kbn-test/src/functional_tests/lib/paths.js +++ b/packages/kbn-test/src/functional_tests/lib/paths.js @@ -28,17 +28,8 @@ function resolveRelative(path) { export const KIBANA_EXEC = 'node'; export const KIBANA_EXEC_PATH = resolveRelative('scripts/kibana'); export const KIBANA_ROOT = resolve(__dirname, '../../../../../'); -export const KIBANA_FTR_SCRIPT = resolve( - KIBANA_ROOT, - 'scripts/functional_test_runner' -); +export const KIBANA_FTR_SCRIPT = resolve(KIBANA_ROOT, 'scripts/functional_test_runner'); export const PROJECT_ROOT = resolve(__dirname, '../../../../../../'); -export const FUNCTIONAL_CONFIG_PATH = resolve( - KIBANA_ROOT, - 'test/functional/config' -); -export const API_CONFIG_PATH = resolve( - KIBANA_ROOT, - 'test/api_integration/config' -); +export const FUNCTIONAL_CONFIG_PATH = resolve(KIBANA_ROOT, 'test/functional/config'); +export const API_CONFIG_PATH = resolve(KIBANA_ROOT, 'test/api_integration/config'); export const OPTIMIZE_BUNDLE_DIR = resolve(KIBANA_ROOT, 'optimize/bundles'); diff --git a/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js b/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js index efcc464faf059..d0a3160018fea 100644 --- a/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js +++ b/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js @@ -29,9 +29,7 @@ export async function runElasticsearch({ config, options }) { const cluster = createEsTestCluster({ port: config.get('servers.elasticsearch.port'), - password: !isOss - ? DEFAULT_SUPERUSER_PASS - : config.get('servers.elasticsearch.password'), + password: !isOss ? DEFAULT_SUPERUSER_PASS : config.get('servers.elasticsearch.password'), license: config.get('esTestCluster.license'), log, basePath: resolve(KIBANA_ROOT, '.es'), diff --git a/packages/kbn-test/src/functional_tests/lib/run_kibana_server.js b/packages/kbn-test/src/functional_tests/lib/run_kibana_server.js index 730f816f9c727..a92924c967b6b 100644 --- a/packages/kbn-test/src/functional_tests/lib/run_kibana_server.js +++ b/packages/kbn-test/src/functional_tests/lib/run_kibana_server.js @@ -59,9 +59,7 @@ function collectCliArgs(config, { installDir, extraKbnOpts }) { serverArgs, args => (installDir ? args.filter(a => a !== '--oss') : args), args => { - return installDir - ? [...args, ...buildArgs] - : [KIBANA_EXEC_PATH, ...args, ...sourceArgs]; + return installDir ? [...args, ...buildArgs] : [KIBANA_EXEC_PATH, ...args, ...sourceArgs]; }, args => args.concat(extraKbnOpts || []) ); diff --git a/packages/kbn-test/src/functional_tests/tasks.js b/packages/kbn-test/src/functional_tests/tasks.js index 6f10dc7760c14..802d84d4b6a20 100644 --- a/packages/kbn-test/src/functional_tests/tasks.js +++ b/packages/kbn-test/src/functional_tests/tasks.js @@ -22,12 +22,7 @@ import * as Rx from 'rxjs'; import { startWith, switchMap, take } from 'rxjs/operators'; import { withProcRunner } from '@kbn/dev-utils'; -import { - runElasticsearch, - runKibanaServer, - runFtr, - KIBANA_FTR_SCRIPT, -} from './lib'; +import { runElasticsearch, runKibanaServer, runFtr, KIBANA_FTR_SCRIPT } from './lib'; import { readConfigFile } from '../../../../src/functional_test_runner/lib'; diff --git a/packages/kbn-test/src/index.js b/packages/kbn-test/src/index.js index 7cacee4e4dd71..90401da7eb606 100644 --- a/packages/kbn-test/src/index.js +++ b/packages/kbn-test/src/index.js @@ -25,9 +25,4 @@ export { OPTIMIZE_BUNDLE_DIR, KIBANA_ROOT } from './functional_tests/lib/paths'; export { esTestConfig, createEsTestCluster } from './es'; -export { - kbnTestConfig, - kibanaServerTestUser, - kibanaTestUser, - adminTestUser, -} from './kbn'; +export { kbnTestConfig, kibanaServerTestUser, kibanaTestUser, adminTestUser } from './kbn'; diff --git a/packages/kbn-test/src/kbn/kbn_test_config.js b/packages/kbn-test/src/kbn/kbn_test_config.js index 24e4edcbf9f08..920865fcfc6b1 100644 --- a/packages/kbn-test/src/kbn/kbn_test_config.js +++ b/packages/kbn-test/src/kbn/kbn_test_config.js @@ -39,10 +39,8 @@ export const kbnTestConfig = new class KbnTestConfig { }; } - const username = - process.env.TEST_KIBANA_USERNAME || kibanaTestUser.username; - const password = - process.env.TEST_KIBANA_PASSWORD || kibanaTestUser.password; + const username = process.env.TEST_KIBANA_USERNAME || kibanaTestUser.username; + const password = process.env.TEST_KIBANA_PASSWORD || kibanaTestUser.password; return { protocol: process.env.TEST_KIBANA_PROTOCOL || 'http', hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost', diff --git a/src/core_plugins/kibana/public/dashboard/actions/embeddables.test.ts b/src/core_plugins/kibana/public/dashboard/actions/embeddables.test.ts index 51fd81ccb6f6a..1a2f0bbbcd291 100644 --- a/src/core_plugins/kibana/public/dashboard/actions/embeddables.test.ts +++ b/src/core_plugins/kibana/public/dashboard/actions/embeddables.test.ts @@ -41,17 +41,13 @@ describe('staged filters', () => { }); test('can set a staged filter', () => { - store.dispatch( - setStagedFilter({ stagedFilter: ['imafilter'], panelId: 'foo1' }) - ); + store.dispatch(setStagedFilter({ stagedFilter: ['imafilter'], panelId: 'foo1' })); const stagedFilters = getStagedFilters(store.getState()); expect(stagedFilters.length).toBe(1); }); test('getStagedFilters returns filters for all embeddables', () => { - store.dispatch( - setStagedFilter({ stagedFilter: ['imafilter'], panelId: 'foo2' }) - ); + store.dispatch(setStagedFilter({ stagedFilter: ['imafilter'], panelId: 'foo2' })); const stagedFilters = getStagedFilters(store.getState()); expect(stagedFilters.length).toBe(2); }); diff --git a/src/core_plugins/kibana/public/dashboard/actions/embeddables.ts b/src/core_plugins/kibana/public/dashboard/actions/embeddables.ts index 65b52a2c235f4..f0b0388a01873 100644 --- a/src/core_plugins/kibana/public/dashboard/actions/embeddables.ts +++ b/src/core_plugins/kibana/public/dashboard/actions/embeddables.ts @@ -20,11 +20,7 @@ import _ from 'lodash'; import { Dispatch } from 'redux'; import { createAction } from 'redux-actions'; -import { - CoreKibanaState, - getEmbeddableCustomization, - getPanel, -} from '../../selectors'; +import { CoreKibanaState, getEmbeddableCustomization, getPanel } from '../../selectors'; import { PanelId, PanelState } from '../selectors'; import { updatePanel } from './panels'; @@ -40,10 +36,7 @@ export enum EmbeddableActionTypeKeys { } export interface EmbeddableIsInitializingAction - extends KibanaAction< - EmbeddableActionTypeKeys.EMBEDDABLE_IS_INITIALIZING, - PanelId - > {} + extends KibanaAction {} export interface EmbeddableIsInitializedActionPayload { panelId: PanelId; @@ -62,16 +55,10 @@ export interface SetStagedFilterActionPayload { } export interface SetStagedFilterAction - extends KibanaAction< - EmbeddableActionTypeKeys.SET_STAGED_FILTER, - SetStagedFilterActionPayload - > {} + extends KibanaAction {} export interface ClearStagedFiltersAction - extends KibanaAction< - EmbeddableActionTypeKeys.CLEAR_STAGED_FILTERS, - undefined - > {} + extends KibanaAction {} export interface EmbeddableErrorActionPayload { error: string | object; @@ -79,10 +66,7 @@ export interface EmbeddableErrorActionPayload { } export interface EmbeddableErrorAction - extends KibanaAction< - EmbeddableActionTypeKeys.EMBEDDABLE_ERROR, - EmbeddableErrorActionPayload - > {} + extends KibanaAction {} export type EmbeddableActions = | EmbeddableIsInitializingAction @@ -94,15 +78,13 @@ export type EmbeddableActions = export const embeddableIsInitializing = createAction( EmbeddableActionTypeKeys.EMBEDDABLE_IS_INITIALIZING ); -export const embeddableIsInitialized = createAction< - EmbeddableIsInitializedActionPayload ->(EmbeddableActionTypeKeys.EMBEDDABLE_IS_INITIALIZED); +export const embeddableIsInitialized = createAction( + EmbeddableActionTypeKeys.EMBEDDABLE_IS_INITIALIZED +); export const setStagedFilter = createAction( EmbeddableActionTypeKeys.SET_STAGED_FILTER ); -export const clearStagedFilters = createAction( - EmbeddableActionTypeKeys.CLEAR_STAGED_FILTERS -); +export const clearStagedFilters = createAction(EmbeddableActionTypeKeys.CLEAR_STAGED_FILTERS); export const embeddableError = createAction( EmbeddableActionTypeKeys.EMBEDDABLE_ERROR ); @@ -120,10 +102,7 @@ export function embeddableStateChanged(changeData: { embeddableState: EmbeddableState; }) { const { panelId, embeddableState } = changeData; - return ( - dispatch: Dispatch, - getState: () => CoreKibanaState - ) => { + return (dispatch: Dispatch, getState: () => CoreKibanaState) => { // Translate embeddableState to things redux cares about. const customization = getEmbeddableCustomization(getState(), panelId); if (!_.isEqual(embeddableState.customization, customization)) { @@ -136,9 +115,7 @@ export function embeddableStateChanged(changeData: { } if (embeddableState.stagedFilter) { - dispatch( - setStagedFilter({ stagedFilter: embeddableState.stagedFilter, panelId }) - ); + dispatch(setStagedFilter({ stagedFilter: embeddableState.stagedFilter, panelId })); } }; } diff --git a/src/core_plugins/kibana/public/dashboard/actions/metadata.ts b/src/core_plugins/kibana/public/dashboard/actions/metadata.ts index ead28e7a555a2..05466c9b8a081 100644 --- a/src/core_plugins/kibana/public/dashboard/actions/metadata.ts +++ b/src/core_plugins/kibana/public/dashboard/actions/metadata.ts @@ -28,24 +28,16 @@ export enum MetadataActionTypeKeys { export type UpdateTitleActionPayload = string; export interface UpdateTitleAction - extends KibanaAction< - MetadataActionTypeKeys.UPDATE_TITLE, - UpdateTitleActionPayload - > {} + extends KibanaAction {} export type UpdateDescriptionActionPayload = string; export interface UpdateDescriptionAction - extends KibanaAction< - MetadataActionTypeKeys.UPDATE_DESCRIPTION, - UpdateDescriptionActionPayload - > {} + extends KibanaAction {} export type MetadataActions = UpdateDescriptionAction | UpdateTitleAction; export const updateDescription = createAction( MetadataActionTypeKeys.UPDATE_DESCRIPTION ); -export const updateTitle = createAction( - MetadataActionTypeKeys.UPDATE_TITLE -); +export const updateTitle = createAction(MetadataActionTypeKeys.UPDATE_TITLE); diff --git a/src/core_plugins/kibana/public/dashboard/actions/panels.ts b/src/core_plugins/kibana/public/dashboard/actions/panels.ts index 314ae9c593622..2f45a2999d3a0 100644 --- a/src/core_plugins/kibana/public/dashboard/actions/panels.ts +++ b/src/core_plugins/kibana/public/dashboard/actions/panels.ts @@ -48,13 +48,9 @@ export interface SetPanelTitleActionPayload { } export interface SetPanelTitleAction - extends KibanaAction< - PanelActionTypeKeys.SET_PANEl_TITLE, - SetPanelTitleActionPayload - > {} + extends KibanaAction {} -export interface SetPanelsAction - extends KibanaAction {} +export interface SetPanelsAction extends KibanaAction {} export type PanelActions = | DeletePanelAction @@ -64,21 +60,11 @@ export type PanelActions = | SetPanelTitleAction | SetPanelsAction; -export const deletePanel = createAction( - PanelActionTypeKeys.DELETE_PANEL -); -export const updatePanel = createAction( - PanelActionTypeKeys.UPDATE_PANEL -); -export const resetPanelTitle = createAction( - PanelActionTypeKeys.RESET_PANEl_TITLE -); +export const deletePanel = createAction(PanelActionTypeKeys.DELETE_PANEL); +export const updatePanel = createAction(PanelActionTypeKeys.UPDATE_PANEL); +export const resetPanelTitle = createAction(PanelActionTypeKeys.RESET_PANEl_TITLE); export const setPanelTitle = createAction( PanelActionTypeKeys.SET_PANEl_TITLE ); -export const updatePanels = createAction( - PanelActionTypeKeys.UPDATE_PANELS -); -export const setPanels = createAction( - PanelActionTypeKeys.SET_PANELS -); +export const updatePanels = createAction(PanelActionTypeKeys.UPDATE_PANELS); +export const setPanels = createAction(PanelActionTypeKeys.SET_PANELS); diff --git a/src/core_plugins/kibana/public/dashboard/actions/view.ts b/src/core_plugins/kibana/public/dashboard/actions/view.ts index 81fcd9fd8a068..8313daa6e1462 100644 --- a/src/core_plugins/kibana/public/dashboard/actions/view.ts +++ b/src/core_plugins/kibana/public/dashboard/actions/view.ts @@ -37,16 +37,10 @@ export enum ViewActionTypeKeys { } export interface UpdateViewModeAction - extends KibanaAction< - ViewActionTypeKeys.UPDATE_VIEW_MODE, - DashboardViewMode - > {} + extends KibanaAction {} export interface SetVisibleContextMenuPanelIdAction - extends KibanaAction< - ViewActionTypeKeys.SET_VISIBLE_CONTEXT_MENU_PANEL_ID, - PanelId - > {} + extends KibanaAction {} export interface MaximizePanelAction extends KibanaAction {} @@ -55,10 +49,7 @@ export interface MinimizePanelAction extends KibanaAction {} export interface UpdateIsFullScreenModeAction - extends KibanaAction< - ViewActionTypeKeys.UPDATE_IS_FULL_SCREEN_MODE, - boolean - > {} + extends KibanaAction {} export interface UpdateUseMarginsAction extends KibanaAction {} @@ -72,8 +63,7 @@ export interface UpdateTimeRangeAction export interface UpdateFiltersAction extends KibanaAction {} -export interface UpdateQueryAction - extends KibanaAction {} +export interface UpdateQueryAction extends KibanaAction {} export type ViewActions = | UpdateViewModeAction @@ -87,29 +77,19 @@ export type ViewActions = | UpdateFiltersAction | UpdateQueryAction; -export const updateViewMode = createAction( - ViewActionTypeKeys.UPDATE_VIEW_MODE -); +export const updateViewMode = createAction(ViewActionTypeKeys.UPDATE_VIEW_MODE); export const setVisibleContextMenuPanelId = createAction( ViewActionTypeKeys.SET_VISIBLE_CONTEXT_MENU_PANEL_ID ); -export const maximizePanel = createAction( - ViewActionTypeKeys.MAXIMIZE_PANEl -); +export const maximizePanel = createAction(ViewActionTypeKeys.MAXIMIZE_PANEl); export const minimizePanel = createAction(ViewActionTypeKeys.MINIMIZE_PANEL); export const updateIsFullScreenMode = createAction( ViewActionTypeKeys.UPDATE_IS_FULL_SCREEN_MODE ); -export const updateUseMargins = createAction( - ViewActionTypeKeys.UPDATE_USE_MARGINS -); +export const updateUseMargins = createAction(ViewActionTypeKeys.UPDATE_USE_MARGINS); export const updateHidePanelTitles = createAction( ViewActionTypeKeys.UPDATE_HIDE_PANEL_TITLES ); -export const updateTimeRange = createAction( - ViewActionTypeKeys.UPDATE_TIME_RANGE -); -export const updateFilters = createAction( - ViewActionTypeKeys.UPDATE_FILTERS -); +export const updateTimeRange = createAction(ViewActionTypeKeys.UPDATE_TIME_RANGE); +export const updateFilters = createAction(ViewActionTypeKeys.UPDATE_FILTERS); export const updateQuery = createAction(ViewActionTypeKeys.UPDATE_QUERY); diff --git a/src/core_plugins/kibana/public/dashboard/reducers/embeddables.ts b/src/core_plugins/kibana/public/dashboard/reducers/embeddables.ts index 905fa0b6cd2c5..93237df607964 100644 --- a/src/core_plugins/kibana/public/dashboard/reducers/embeddables.ts +++ b/src/core_plugins/kibana/public/dashboard/reducers/embeddables.ts @@ -27,11 +27,7 @@ import { PanelActionTypeKeys, SetStagedFilterActionPayload, } from '../actions'; -import { - EmbeddableReduxState, - EmbeddablesMap, - PanelId, -} from '../selectors/types'; +import { EmbeddableReduxState, EmbeddablesMap, PanelId } from '../selectors/types'; const embeddableIsInitializing = ( embeddables: EmbeddablesMap, @@ -81,16 +77,12 @@ const embeddableError = ( }); const clearStagedFilters = (embeddables: EmbeddablesMap): EmbeddablesMap => { - const omitStagedFilters = ( - embeddable: EmbeddableReduxState - ): EmbeddablesMap => _.omit({ ...embeddable }, ['stagedFilter']); + const omitStagedFilters = (embeddable: EmbeddableReduxState): EmbeddablesMap => + _.omit({ ...embeddable }, ['stagedFilter']); return _.mapValues(embeddables, omitStagedFilters); }; -const deleteEmbeddable = ( - embeddables: EmbeddablesMap, - panelId: PanelId -): EmbeddablesMap => { +const deleteEmbeddable = (embeddables: EmbeddablesMap, panelId: PanelId): EmbeddablesMap => { const embeddablesCopy = { ...embeddables }; delete embeddablesCopy[panelId]; return embeddablesCopy; @@ -100,9 +92,7 @@ export const embeddablesReducer: Reducer = ( embeddables = {}, action ): EmbeddablesMap => { - switch ( - action.type as EmbeddableActionTypeKeys | PanelActionTypeKeys.DELETE_PANEL - ) { + switch (action.type as EmbeddableActionTypeKeys | PanelActionTypeKeys.DELETE_PANEL) { case EmbeddableActionTypeKeys.EMBEDDABLE_IS_INITIALIZING: return embeddableIsInitializing(embeddables, action.payload); case EmbeddableActionTypeKeys.EMBEDDABLE_IS_INITIALIZED: diff --git a/src/core_plugins/kibana/public/dashboard/reducers/metadata.ts b/src/core_plugins/kibana/public/dashboard/reducers/metadata.ts index d67b2c6d27346..3a2b9c8e1bae3 100644 --- a/src/core_plugins/kibana/public/dashboard/reducers/metadata.ts +++ b/src/core_plugins/kibana/public/dashboard/reducers/metadata.ts @@ -26,10 +26,7 @@ import { } from '../actions'; import { DashboardMetadata } from '../selectors'; -const updateTitle = ( - metadata: DashboardMetadata, - title: UpdateTitleActionPayload -) => ({ +const updateTitle = (metadata: DashboardMetadata, title: UpdateTitleActionPayload) => ({ ...metadata, title, }); diff --git a/src/core_plugins/kibana/public/dashboard/reducers/panels.ts b/src/core_plugins/kibana/public/dashboard/reducers/panels.ts index 92746743f8f6e..f2abfd0490341 100644 --- a/src/core_plugins/kibana/public/dashboard/reducers/panels.ts +++ b/src/core_plugins/kibana/public/dashboard/reducers/panels.ts @@ -19,11 +19,7 @@ import _ from 'lodash'; import { Reducer } from 'redux'; -import { - PanelActions, - PanelActionTypeKeys, - SetPanelTitleActionPayload, -} from '../actions'; +import { PanelActions, PanelActionTypeKeys, SetPanelTitleActionPayload } from '../actions'; import { PanelId, PanelsMap, PanelState } from '../selectors'; /** @@ -47,10 +43,7 @@ const updatePanel = (panels: PanelsMap, panelState: PanelState): PanelsMap => ({ [panelState.panelIndex]: mergePanelData(panelState, panels), }); -const updatePanels = ( - panels: PanelsMap, - updatedPanels: PanelsMap -): PanelsMap => { +const updatePanels = (panels: PanelsMap, updatedPanels: PanelsMap): PanelsMap => { const panelsCopy = { ...panels }; Object.values(updatedPanels).forEach(panel => { panelsCopy[panel.panelIndex] = mergePanelData(panel, panels); @@ -66,10 +59,7 @@ const resetPanelTitle = (panels: PanelsMap, panelId: PanelId) => ({ }, }); -const setPanelTitle = ( - panels: PanelsMap, - payload: SetPanelTitleActionPayload -) => ({ +const setPanelTitle = (panels: PanelsMap, payload: SetPanelTitleActionPayload) => ({ ...panels, [payload.panelId]: { ...panels[payload.panelId], @@ -77,13 +67,9 @@ const setPanelTitle = ( }, }); -const setPanels = (panels: PanelsMap, newPanels: PanelsMap) => - _.cloneDeep(newPanels); +const setPanels = (panels: PanelsMap, newPanels: PanelsMap) => _.cloneDeep(newPanels); -export const panelsReducer: Reducer = ( - panels = {}, - action -): PanelsMap => { +export const panelsReducer: Reducer = (panels = {}, action): PanelsMap => { switch ((action as PanelActions).type) { case PanelActionTypeKeys.DELETE_PANEL: return deletePanel(panels, action.payload); diff --git a/src/core_plugins/kibana/public/dashboard/reducers/view.test.ts b/src/core_plugins/kibana/public/dashboard/reducers/view.test.ts index 1337376a753ad..481e6c9a8555a 100644 --- a/src/core_plugins/kibana/public/dashboard/reducers/view.test.ts +++ b/src/core_plugins/kibana/public/dashboard/reducers/view.test.ts @@ -18,18 +18,9 @@ */ import { store } from '../../store'; -import { - maximizePanel, - minimizePanel, - updateIsFullScreenMode, - updateViewMode, -} from '../actions'; +import { maximizePanel, minimizePanel, updateIsFullScreenMode, updateViewMode } from '../actions'; -import { - getFullScreenMode, - getMaximizedPanelId, - getViewMode, -} from '../../selectors'; +import { getFullScreenMode, getMaximizedPanelId, getViewMode } from '../../selectors'; import { DashboardViewMode } from '../dashboard_view_mode'; diff --git a/src/core_plugins/kibana/public/dashboard/reducers/view.ts b/src/core_plugins/kibana/public/dashboard/reducers/view.ts index e382c3b30a60e..d3bded4b2611d 100644 --- a/src/core_plugins/kibana/public/dashboard/reducers/view.ts +++ b/src/core_plugins/kibana/public/dashboard/reducers/view.ts @@ -46,10 +46,7 @@ const maximizePanel = (view: ViewState, panelId: PanelId) => ({ maximizedPanelId: panelId, }); -const updateIsFullScreenMode = ( - view: ViewState, - isFullScreenMode: boolean -) => ({ +const updateIsFullScreenMode = (view: ViewState, isFullScreenMode: boolean) => ({ ...view, isFullScreenMode, }); diff --git a/src/core_plugins/kibana/public/dashboard/selectors/dashboard.ts b/src/core_plugins/kibana/public/dashboard/selectors/dashboard.ts index 3d77ce7864009..f0ab91d7910de 100644 --- a/src/core_plugins/kibana/public/dashboard/selectors/dashboard.ts +++ b/src/core_plugins/kibana/public/dashboard/selectors/dashboard.ts @@ -18,13 +18,7 @@ */ import _ from 'lodash'; -import { - ContainerState, - EmbeddableMetadata, - Filters, - Query, - TimeRange, -} from 'ui/embeddable'; +import { ContainerState, EmbeddableMetadata, Filters, Query, TimeRange } from 'ui/embeddable'; import { DashboardViewMode } from '../dashboard_view_mode'; import { DashboardMetadata, @@ -36,33 +30,23 @@ import { PanelState, } from './types'; -export const getPanels = (dashboard: DashboardState): PanelsMap => - dashboard.panels; +export const getPanels = (dashboard: DashboardState): PanelsMap => dashboard.panels; -export const getPanel = ( - dashboard: DashboardState, - panelId: PanelId -): PanelState => getPanels(dashboard)[panelId]; +export const getPanel = (dashboard: DashboardState, panelId: PanelId): PanelState => + getPanels(dashboard)[panelId]; -export const getPanelType = ( - dashboard: DashboardState, - panelId: PanelId -): string => getPanel(dashboard, panelId).type; +export const getPanelType = (dashboard: DashboardState, panelId: PanelId): string => + getPanel(dashboard, panelId).type; -export const getEmbeddables = (dashboard: DashboardState): EmbeddablesMap => - dashboard.embeddables; +export const getEmbeddables = (dashboard: DashboardState): EmbeddablesMap => dashboard.embeddables; // TODO: rename panel.embeddableConfig to embeddableCustomization. Because it's on the panel that's stored on a // dashboard, renaming this will require a migration step. -export const getEmbeddableCustomization = ( - dashboard: DashboardState, - panelId: PanelId -): object => getPanel(dashboard, panelId).embeddableConfig; +export const getEmbeddableCustomization = (dashboard: DashboardState, panelId: PanelId): object => + getPanel(dashboard, panelId).embeddableConfig; -export const getEmbeddable = ( - dashboard: DashboardState, - panelId: PanelId -): EmbeddableReduxState => dashboard.embeddables[panelId]; +export const getEmbeddable = (dashboard: DashboardState, panelId: PanelId): EmbeddableReduxState => + dashboard.embeddables[panelId]; export const getEmbeddableError = ( dashboard: DashboardState, @@ -79,10 +63,8 @@ export const getEmbeddableTitle = ( : ''; }; -export const getEmbeddableInitialized = ( - dashboard: DashboardState, - panelId: PanelId -): boolean => getEmbeddable(dashboard, panelId).initialized; +export const getEmbeddableInitialized = (dashboard: DashboardState, panelId: PanelId): boolean => + getEmbeddable(dashboard, panelId).initialized; export const getEmbeddableStagedFilter = ( dashboard: DashboardState, @@ -104,12 +86,10 @@ export const getEmbeddableEditUrl = ( : ''; }; -export const getVisibleContextMenuPanelId = ( - dashboard: DashboardState -): PanelId | undefined => dashboard.view.visibleContextMenuPanelId; +export const getVisibleContextMenuPanelId = (dashboard: DashboardState): PanelId | undefined => + dashboard.view.visibleContextMenuPanelId; -export const getUseMargins = (dashboard: DashboardState): boolean => - dashboard.view.useMargins; +export const getUseMargins = (dashboard: DashboardState): boolean => dashboard.view.useMargins; export const getViewMode = (dashboard: DashboardState): DashboardViewMode => dashboard.view.viewMode; @@ -120,38 +100,27 @@ export const getFullScreenMode = (dashboard: DashboardState): boolean => export const getHidePanelTitles = (dashboard: DashboardState): boolean => dashboard.view.hidePanelTitles; -export const getMaximizedPanelId = ( - dashboard: DashboardState -): PanelId | undefined => dashboard.view.maximizedPanelId; +export const getMaximizedPanelId = (dashboard: DashboardState): PanelId | undefined => + dashboard.view.maximizedPanelId; -export const getTimeRange = (dashboard: DashboardState): TimeRange => - dashboard.view.timeRange; +export const getTimeRange = (dashboard: DashboardState): TimeRange => dashboard.view.timeRange; -export const getFilters = (dashboard: DashboardState): Filters => - dashboard.view.filters; +export const getFilters = (dashboard: DashboardState): Filters => dashboard.view.filters; -export const getQuery = (dashboard: DashboardState): Query => - dashboard.view.query; +export const getQuery = (dashboard: DashboardState): Query => dashboard.view.query; -export const getMetadata = (dashboard: DashboardState): DashboardMetadata => - dashboard.metadata; +export const getMetadata = (dashboard: DashboardState): DashboardMetadata => dashboard.metadata; -export const getTitle = (dashboard: DashboardState): string => - dashboard.metadata.title; +export const getTitle = (dashboard: DashboardState): string => dashboard.metadata.title; export const getDescription = (dashboard: DashboardState): string | undefined => dashboard.metadata.description; -export const getContainerState = ( - dashboard: DashboardState, - panelId: PanelId -): ContainerState => { +export const getContainerState = (dashboard: DashboardState, panelId: PanelId): ContainerState => { const time = getTimeRange(dashboard); return { customTitle: getPanel(dashboard, panelId).title, - embeddableCustomization: _.cloneDeep( - getEmbeddableCustomization(dashboard, panelId) || {} - ), + embeddableCustomization: _.cloneDeep(getEmbeddableCustomization(dashboard, panelId) || {}), filters: getFilters(dashboard), hidePanelTitles: getHidePanelTitles(dashboard), isPanelExpanded: getMaximizedPanelId(dashboard) === panelId, diff --git a/src/core_plugins/kibana/public/selectors/dashboard_selectors.ts b/src/core_plugins/kibana/public/selectors/dashboard_selectors.ts index 9bed7357d36fa..d4e1d436c6cab 100644 --- a/src/core_plugins/kibana/public/selectors/dashboard_selectors.ts +++ b/src/core_plugins/kibana/public/selectors/dashboard_selectors.ts @@ -23,9 +23,8 @@ import * as DashboardSelectors from '../dashboard/selectors'; import { PanelId } from '../dashboard/selectors/types'; import { CoreKibanaState } from './types'; -export const getDashboard = ( - state: CoreKibanaState -): DashboardSelectors.DashboardState => state.dashboard; +export const getDashboard = (state: CoreKibanaState): DashboardSelectors.DashboardState => + state.dashboard; export const getPanels = (state: CoreKibanaState) => DashboardSelectors.getPanels(getDashboard(state)); @@ -38,23 +37,14 @@ export const getEmbeddables = (state: CoreKibanaState) => DashboardSelectors.getEmbeddables(getDashboard(state)); export const getEmbeddableError = (state: CoreKibanaState, panelId: PanelId) => DashboardSelectors.getEmbeddableError(getDashboard(state), panelId); -export const getEmbeddableInitialized = ( - state: CoreKibanaState, - panelId: PanelId -) => DashboardSelectors.getEmbeddableInitialized(getDashboard(state), panelId); -export const getEmbeddableCustomization = ( - state: CoreKibanaState, - panelId: PanelId -) => +export const getEmbeddableInitialized = (state: CoreKibanaState, panelId: PanelId) => + DashboardSelectors.getEmbeddableInitialized(getDashboard(state), panelId); +export const getEmbeddableCustomization = (state: CoreKibanaState, panelId: PanelId) => DashboardSelectors.getEmbeddableCustomization(getDashboard(state), panelId); -export const getEmbeddableStagedFilter = ( - state: CoreKibanaState, - panelId: PanelId -) => DashboardSelectors.getEmbeddableStagedFilter(getDashboard(state), panelId); -export const getEmbeddableMetadata = ( - state: CoreKibanaState, - panelId: PanelId -) => DashboardSelectors.getEmbeddableMetadata(getDashboard(state), panelId); +export const getEmbeddableStagedFilter = (state: CoreKibanaState, panelId: PanelId) => + DashboardSelectors.getEmbeddableStagedFilter(getDashboard(state), panelId); +export const getEmbeddableMetadata = (state: CoreKibanaState, panelId: PanelId) => + DashboardSelectors.getEmbeddableMetadata(getDashboard(state), panelId); export const getStagedFilters = (state: CoreKibanaState): Filters => DashboardSelectors.getStagedFilters(getDashboard(state)); @@ -62,9 +52,7 @@ export const getViewMode = (state: CoreKibanaState): DashboardViewMode => DashboardSelectors.getViewMode(getDashboard(state)); export const getFullScreenMode = (state: CoreKibanaState): boolean => DashboardSelectors.getFullScreenMode(getDashboard(state)); -export const getMaximizedPanelId = ( - state: CoreKibanaState -): PanelId | undefined => +export const getMaximizedPanelId = (state: CoreKibanaState): PanelId | undefined => DashboardSelectors.getMaximizedPanelId(getDashboard(state)); export const getUseMargins = (state: CoreKibanaState): boolean => DashboardSelectors.getUseMargins(getDashboard(state)); diff --git a/src/dev/tslint/lint_files.ts b/src/dev/tslint/lint_files.ts index f90c822618bdb..f77dc02624f1b 100644 --- a/src/dev/tslint/lint_files.ts +++ b/src/dev/tslint/lint_files.ts @@ -72,11 +72,7 @@ export async function lintFiles(log: ToolingLog, files: File[]) { if (exitCode > 0) { throw createFailError(`[tslint] failure`, 1); } else { - log.success( - '[tslint/%s] %d files linted successfully', - project.name, - filesInProject.length - ); + log.success('[tslint/%s] %d files linted successfully', project.name, filesInProject.length); } } } diff --git a/src/dev/tslint/run_tslint_cli.ts b/src/dev/tslint/run_tslint_cli.ts index 07d8b9c556a38..c873ff99932ee 100644 --- a/src/dev/tslint/run_tslint_cli.ts +++ b/src/dev/tslint/run_tslint_cli.ts @@ -50,15 +50,11 @@ export function runTslintCli() { return resolve(opts.project) === project.tsConfigPath; }).map(project => ({ task: () => - execa( - 'tslint', - [...process.argv.slice(2), '--project', project.tsConfigPath], - { - cwd: project.directory, - env: chalk.enabled ? { FORCE_COLOR: 'true' } : {}, - stdio: ['ignore', 'pipe', 'pipe'], - } - ).catch(error => { + execa('tslint', [...process.argv.slice(2), '--project', project.tsConfigPath], { + cwd: project.directory, + env: chalk.enabled ? { FORCE_COLOR: 'true' } : {}, + stdio: ['ignore', 'pipe', 'pipe'], + }).catch(error => { throw new LintFailure(project, error); }), title: project.name, diff --git a/src/dev/typescript/get_ts_project_for_absolute_path.ts b/src/dev/typescript/get_ts_project_for_absolute_path.ts index 1c0777321b851..409d18bed6f5e 100644 --- a/src/dev/typescript/get_ts_project_for_absolute_path.ts +++ b/src/dev/typescript/get_ts_project_for_absolute_path.ts @@ -42,9 +42,7 @@ export function getTsProjectForAbsolutePath(path: string) { } if (projects.length !== 1) { - const configPaths = projects.map( - p => `"${relative(REPO_ROOT, p.tsConfigPath)}"` - ); + const configPaths = projects.map(p => `"${relative(REPO_ROOT, p.tsConfigPath)}"`); const pathsMsg = `${configPaths.slice(0, -1).join(', ')} or ${ configPaths[configPaths.length - 1] diff --git a/src/dev/typescript/index.ts b/src/dev/typescript/index.ts index 15c7a5f70af5b..ff7b9413dd221 100644 --- a/src/dev/typescript/index.ts +++ b/src/dev/typescript/index.ts @@ -19,6 +19,4 @@ export { Project } from './project'; export { PROJECTS } from './projects'; -export { - getTsProjectForAbsolutePath, -} from './get_ts_project_for_absolute_path'; +export { getTsProjectForAbsolutePath } from './get_ts_project_for_absolute_path'; diff --git a/src/dev/typescript/project.ts b/src/dev/typescript/project.ts index bfdaa917580ca..4e24e01484f9c 100644 --- a/src/dev/typescript/project.ts +++ b/src/dev/typescript/project.ts @@ -35,10 +35,7 @@ function makeMatchers(directory: string, patterns: string[]) { } function parseTsConfig(path: string) { - const { error, config } = parseConfigFileTextToJson( - path, - readFileSync(path, 'utf8') - ); + const { error, config } = parseConfigFileTextToJson(path, readFileSync(path, 'utf8')); if (error) { throw error; @@ -76,8 +73,6 @@ export class Project { } public isAbsolutePathSelected(path: string) { - return testMatchers(this.exclude, path) - ? false - : testMatchers(this.include, path); + return testMatchers(this.exclude, path) ? false : testMatchers(this.include, path); } } diff --git a/src/ui/public/agg_types/filter/agg_type_filters.ts b/src/ui/public/agg_types/filter/agg_type_filters.ts index 959387c55a092..cb5bf41e0d8aa 100644 --- a/src/ui/public/agg_types/filter/agg_type_filters.ts +++ b/src/ui/public/agg_types/filter/agg_type_filters.ts @@ -50,16 +50,10 @@ class AggTypeFilters { * @param aggConfig The aggConfig for which the returning list will be used. * @return A filtered list of the passed aggTypes. */ - public filter( - aggTypes: AggType[], - indexPattern: IndexPattern, - aggConfig: AggConfig - ) { + public filter(aggTypes: AggType[], indexPattern: IndexPattern, aggConfig: AggConfig) { const allFilters = Array.from(this.filters); const allowedAggTypes = aggTypes.filter(aggType => { - const isAggTypeAllowed = allFilters.every(filter => - filter(aggType, indexPattern, aggConfig) - ); + const isAggTypeAllowed = allFilters.every(filter => filter(aggType, indexPattern, aggConfig)); return isAggTypeAllowed; }); return allowedAggTypes; diff --git a/src/ui/public/dashboard_panel_actions/index.ts b/src/ui/public/dashboard_panel_actions/index.ts index a11538441a434..ec931eb48b5ae 100644 --- a/src/ui/public/dashboard_panel_actions/index.ts +++ b/src/ui/public/dashboard_panel_actions/index.ts @@ -19,6 +19,4 @@ export { DashboardContextMenuPanel } from './dashboard_context_menu_panel'; export { DashboardPanelAction } from './dashboard_panel_action'; -export { - DashboardPanelActionsRegistryProvider, -} from './dashboard_panel_actions_registry'; +export { DashboardPanelActionsRegistryProvider } from './dashboard_panel_actions_registry'; diff --git a/src/ui/public/embeddable/embeddable.ts b/src/ui/public/embeddable/embeddable.ts index df538caf50a3d..7689c0c298995 100644 --- a/src/ui/public/embeddable/embeddable.ts +++ b/src/ui/public/embeddable/embeddable.ts @@ -85,10 +85,7 @@ export abstract class Embeddable { /** * Embeddable should render itself at the given domNode. */ - public abstract render( - domNode: HTMLElement, - containerState: ContainerState - ): void; + public abstract render(domNode: HTMLElement, containerState: ContainerState): void; /** * An embeddable can return inspector adapters if it want the inspector to be diff --git a/src/ui/public/embeddable/index.ts b/src/ui/public/embeddable/index.ts index ca51c6d799cdb..9e5b64b02c2d8 100644 --- a/src/ui/public/embeddable/index.ts +++ b/src/ui/public/embeddable/index.ts @@ -19,13 +19,5 @@ export { EmbeddableFactory } from './embeddable_factory'; export * from './embeddable'; -export { - EmbeddableFactoriesRegistryProvider, -} from './embeddable_factories_registry'; -export { - ContainerState, - EmbeddableState, - Query, - Filters, - TimeRange, -} from './types'; +export { EmbeddableFactoriesRegistryProvider } from './embeddable_factories_registry'; +export { ContainerState, EmbeddableState, Query, Filters, TimeRange } from './types'; diff --git a/src/ui/public/inspector/adapters/data/data_adapter.ts b/src/ui/public/inspector/adapters/data/data_adapter.ts index a4b204f9f3f9d..8de2838915c63 100644 --- a/src/ui/public/inspector/adapters/data/data_adapter.ts +++ b/src/ui/public/inspector/adapters/data/data_adapter.ts @@ -36,10 +36,7 @@ class DataAdapter extends EventEmitter { private tabular?: TabularCallback; private tabularOptions?: TabularLoaderOptions; - public setTabularLoader( - callback: TabularCallback, - options: TabularLoaderOptions = {} - ): void { + public setTabularLoader(callback: TabularCallback, options: TabularLoaderOptions = {}): void { this.tabular = callback; this.tabularOptions = options; this.emit('change', 'tabular'); diff --git a/src/ui/public/inspector/inspector.tsx b/src/ui/public/inspector/inspector.tsx index 2ff00efeb23fe..d463cba47468c 100644 --- a/src/ui/public/inspector/inspector.tsx +++ b/src/ui/public/inspector/inspector.tsx @@ -109,10 +109,7 @@ interface InspectorOptions { * @param {InspectorOptions} options - Options that configure the inspector. See InspectorOptions type. * @return {InspectorSession} The session instance for the opened inspector. */ -function open( - adapters: Adapters, - options: InspectorOptions = {} -): InspectorSession { +function open(adapters: Adapters, options: InspectorOptions = {}): InspectorSession { // If there is an active inspector session close it before opening a new one. if (activeSession) { activeSession.close(); diff --git a/src/ui/public/inspector/ui/inspector_view.tsx b/src/ui/public/inspector/ui/inspector_view.tsx index 4a961a23b7a64..f13ea363b46ac 100644 --- a/src/ui/public/inspector/ui/inspector_view.tsx +++ b/src/ui/public/inspector/ui/inspector_view.tsx @@ -33,10 +33,7 @@ import { EuiFlyoutBody } from '@elastic/eui'; * inspector view. It makes sure, that the appropriate stylings are applied to the * view. */ -const InspectorView: React.SFC<{ useFlex?: boolean }> = ({ - useFlex, - children, -}) => { +const InspectorView: React.SFC<{ useFlex?: boolean }> = ({ useFlex, children }) => { const classes = classNames({ 'inspector-view__flex': Boolean(useFlex), }); diff --git a/src/ui/public/inspector/view_registry.test.ts b/src/ui/public/inspector/view_registry.test.ts index 40e65254a1f05..e073c6431892f 100644 --- a/src/ui/public/inspector/view_registry.test.ts +++ b/src/ui/public/inspector/view_registry.test.ts @@ -17,10 +17,7 @@ * under the License. */ -import { - InspectorViewDescription, - InspectorViewRegistry, -} from './view_registry'; +import { InspectorViewDescription, InspectorViewRegistry } from './view_registry'; import { Adapters } from './types'; diff --git a/src/ui/public/inspector/view_registry.ts b/src/ui/public/inspector/view_registry.ts index 2f0757d2ce5e7..a4be902fc8ee1 100644 --- a/src/ui/public/inspector/view_registry.ts +++ b/src/ui/public/inspector/view_registry.ts @@ -46,9 +46,7 @@ class InspectorViewRegistry extends EventEmitter { } this.views.push(view); // Keep registry sorted by the order property - this.views.sort( - (a, b) => (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE) - ); + this.views.sort((a, b) => (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE)); this.emit('change'); } @@ -71,9 +69,7 @@ class InspectorViewRegistry extends EventEmitter { if (!adapters) { return []; } - return this.views.filter( - view => !view.shouldShow || view.shouldShow(adapters) - ); + return this.views.filter(view => !view.shouldShow || view.shouldShow(adapters)); } } diff --git a/src/ui/public/resize_checker/resize_checker.ts b/src/ui/public/resize_checker/resize_checker.ts index 3f476aa0c6464..c00603c3b11d6 100644 --- a/src/ui/public/resize_checker/resize_checker.ts +++ b/src/ui/public/resize_checker/resize_checker.ts @@ -28,9 +28,7 @@ function validateElArg(el: HTMLElement) { const $el = $(el); if ($el.length !== 1) { - throw new TypeError( - 'ResizeChecker must be constructed with a single DOM element.' - ); + throw new TypeError('ResizeChecker must be constructed with a single DOM element.'); } return $el.get(0); diff --git a/src/ui/public/vis/editors/default/vis_type_agg_filter.ts b/src/ui/public/vis/editors/default/vis_type_agg_filter.ts index c0369a90eeb5f..02949c847badf 100644 --- a/src/ui/public/vis/editors/default/vis_type_agg_filter.ts +++ b/src/ui/public/vis/editors/default/vis_type_agg_filter.ts @@ -29,10 +29,7 @@ const filterByName = propFilter('name'); * This filter checks the defined aggFilter in the schemas of that visualization * and limits available aggregations based on that. */ -aggTypeFilters.addFilter( - (aggType: AggType, indexPatterns: IndexPattern, aggConfig: AggConfig) => { - const doesSchemaAllowAggType = - filterByName([aggType], aggConfig.schema.aggFilter).length !== 0; - return doesSchemaAllowAggType; - } -); +aggTypeFilters.addFilter((aggType: AggType, indexPatterns: IndexPattern, aggConfig: AggConfig) => { + const doesSchemaAllowAggType = filterByName([aggType], aggConfig.schema.aggFilter).length !== 0; + return doesSchemaAllowAggType; +}); diff --git a/style_guides/js_style_guide.md b/style_guides/js_style_guide.md index 7059bc0f4798d..1354f67009235 100644 --- a/style_guides/js_style_guide.md +++ b/style_guides/js_style_guide.md @@ -41,9 +41,9 @@ cheap syntactic pleasures. [the opposition]: http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding [hnsemicolons]: http://news.ycombinator.com/item?id=1547647 -## 120 characters per line +## 100 characters per line -Try to limit your lines to 80 characters. If it feels right, you can go up to 120 characters. +You should limit your lines to 100 chars. Prettier will check for that line width where enabled. ## Use `const` for variables diff --git a/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/combine.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/combine.ts index 3e7454a3bd14a..02a147ab16338 100644 --- a/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/combine.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/combine.ts @@ -69,11 +69,11 @@ export function $combine( png.width !== screenshot.rectangle.width || png.height !== screenshot.rectangle.height ) { - const errorMessage = `Screenshot captured with width:${ - png.width - } and height: ${png.height}) is not of expected width: ${ - screenshot.rectangle.width - } and height: ${screenshot.rectangle.height}`; + const errorMessage = `Screenshot captured with width:${png.width} and height: ${ + png.height + }) is not of expected width: ${screenshot.rectangle.width} and height: ${ + screenshot.rectangle.height + }`; logger.error(errorMessage); throw new Error(errorMessage); @@ -90,19 +90,9 @@ export function $combine( // fixed, this should probably get pared down. logger.debug(`Output dimensions is ${JSON.stringify(outputSize)}`); logger.debug(`Input png w: ${png.width} and h: ${png.height}`); - logger.debug( - `Creating output png with ${JSON.stringify(screenshot.rectangle)}` - ); + logger.debug(`Creating output png with ${JSON.stringify(screenshot.rectangle)}`); const { rectangle } = screenshot; - png.bitblt( - output, - 0, - 0, - rectangle.width, - rectangle.height, - rectangle.x, - rectangle.y - ); + png.bitblt(output, 0, 0, rectangle.width, rectangle.height, rectangle.x, rectangle.y); return output; }, new PNG({ width: outputSize.width, height: outputSize.height })) ); diff --git a/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/get_clips.test.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/get_clips.test.ts index aeccb99b5279b..89d688b43822e 100644 --- a/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/get_clips.test.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/get_clips.test.ts @@ -64,10 +64,7 @@ getClipsTest( rectangle: { x: 0, y: 0, height: 100, width: 150 }, }, { - clips: [ - { x: 0, y: 0, height: 100, width: 100 }, - { x: 100, y: 0, height: 100, width: 50 }, - ], + clips: [{ x: 0, y: 0, height: 100, width: 100 }, { x: 100, y: 0, height: 100, width: 50 }], } ); @@ -78,10 +75,7 @@ getClipsTest( rectangle: { x: 0, y: 0, height: 150, width: 100 }, }, { - clips: [ - { x: 0, y: 0, height: 100, width: 100 }, - { x: 0, y: 100, height: 50, width: 100 }, - ], + clips: [{ x: 0, y: 0, height: 100, width: 100 }, { x: 0, y: 100, height: 50, width: 100 }], } ); diff --git a/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/get_clips.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/get_clips.ts index 090cd6cdb0880..905690ac14eeb 100644 --- a/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/get_clips.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/get_clips.ts @@ -13,10 +13,7 @@ import { Rectangle } from './types'; * @param largeRectangle - A big rectangle that might be broken down into smaller rectangles * @param max - Maximum width or height any single clip should have */ -export function $getClips( - largeRectangle: Rectangle, - max: number -): Rx.Observable { +export function $getClips(largeRectangle: Rectangle, max: number): Rx.Observable { const rectanglesGenerator = function*(): IterableIterator { const columns = Math.ceil(largeRectangle.width / max) || 1; const rows = Math.ceil(largeRectangle.height / max) || 1; @@ -25,8 +22,7 @@ export function $getClips( for (let column = 0; column < columns; ++column) { yield { height: row === rows - 1 ? largeRectangle.height - row * max : max, - width: - column === columns - 1 ? largeRectangle.width - column * max : max, + width: column === columns - 1 ? largeRectangle.width - column * max : max, x: column * max + largeRectangle.x, y: row * max + largeRectangle.y, }; diff --git a/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/index.ts index dae6af27c1f0c..09c0d9e3bbf4d 100644 --- a/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/index.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/driver/screenshot_stitcher/index.ts @@ -43,11 +43,7 @@ export async function screenshotStitcher( const screenshotClips$ = $getClips(outputClip, maxDimensionBeforeZoom); const screenshots$ = screenshotClips$.pipe( - mergeMap( - clip => captureScreenshotFn(clip), - (clip, data) => ({ clip, data }), - 1 - ) + mergeMap(clip => captureScreenshotFn(clip), (clip, data) => ({ clip, data }), 1) ); // when we take the screenshots we don't have to scale the rects