Skip to content

Commit

Permalink
[7.x] Upgrade Prettier 1.19 (#50506)
Browse files Browse the repository at this point in the history
* Upgrade Prettier to 1.19

* Fix all prettier issues
  • Loading branch information
Tim Roes authored Nov 13, 2019
1 parent b601b69 commit b08dc0c
Show file tree
Hide file tree
Showing 279 changed files with 1,864 additions and 2,005 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@
"pngjs": "^3.4.0",
"postcss": "^7.0.5",
"postcss-url": "^8.0.0",
"prettier": "^1.18.2",
"prettier": "^1.19.1",
"proxyquire": "1.8.0",
"regenerate": "^1.4.0",
"sass-lint": "^1.12.1",
Expand Down
5 changes: 1 addition & 4 deletions packages/kbn-dev-utils/src/proc_runner/observe_readable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ import { first, ignoreElements, mergeMap } from 'rxjs/operators';
*/
export function observeReadable(readable: Readable): Rx.Observable<never> {
return Rx.race(
Rx.fromEvent(readable, 'end').pipe(
first(),
ignoreElements()
),
Rx.fromEvent(readable, 'end').pipe(first(), ignoreElements()),

Rx.fromEvent(readable, 'error').pipe(
first(),
Expand Down
5 changes: 1 addition & 4 deletions packages/kbn-dev-utils/src/tooling_log/tooling_log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ describe('#getWritten$()', () => {
const done$ = new Rx.Subject();
const promise = log
.getWritten$()
.pipe(
takeUntil(done$),
toArray()
)
.pipe(takeUntil(done$), toArray())
.toPromise();

log.debug('foo');
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"log-symbols": "^2.2.0",
"ncp": "^2.0.0",
"ora": "^1.4.0",
"prettier": "^1.18.2",
"prettier": "^1.19.1",
"read-pkg": "^5.2.0",
"rxjs": "^6.5.3",
"spawn-sync": "^1.0.15",
Expand Down
17 changes: 14 additions & 3 deletions packages/kbn-pm/src/commands/bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ 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);
Expand Down Expand Up @@ -133,7 +138,10 @@ test('does not run installer if no deps in package', async () => {
'packages/bar'
);

const projects = new Map([['kibana', kibana], ['bar', bar]]);
const projects = new Map([
['kibana', kibana],
['bar', bar],
]);
const projectGraph = buildProjectGraph(projects);

const logMock = jest.spyOn(console, 'log').mockImplementation(noop);
Expand Down Expand Up @@ -193,7 +201,10 @@ test('calls "kbn:bootstrap" scripts and links executables after installing deps'
'packages/bar'
);

const projects = new Map([['kibana', kibana], ['bar', bar]]);
const projects = new Map([
['kibana', kibana],
['bar', bar],
]);
const projectGraph = buildProjectGraph(projects);

jest.spyOn(console, 'log').mockImplementation(noop);
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-spec-to-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"homepage": "https://github.com/jbudz/spec-to-console#readme",
"devDependencies": {
"jest": "^24.9.0",
"prettier": "^1.18.2"
"prettier": "^1.19.1"
},
"dependencies": {
"commander": "^2.11.0",
Expand Down
10 changes: 5 additions & 5 deletions src/core/public/chrome/nav_links/nav_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ export class NavLinksService {

return {
getNavLinks$: () => {
return navLinks$.pipe(
map(sortNavLinks),
takeUntil(this.stop$)
);
return navLinks$.pipe(map(sortNavLinks), takeUntil(this.stop$));
},

get(id: string) {
Expand Down Expand Up @@ -192,7 +189,10 @@ export class NavLinksService {
}

function sortNavLinks(navLinks: ReadonlyMap<string, NavLinkWrapper>) {
return sortBy([...navLinks.values()].map(link => link.properties), 'order');
return sortBy(
[...navLinks.values()].map(link => link.properties),
'order'
);
}

function relativeToAbsolute(url: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ describe('RecentlyAccessed#start()', () => {
const stop$ = new Subject();
const observedValues$ = recentlyAccessed
.get$()
.pipe(
bufferCount(3),
takeUntil(stop$)
)
.pipe(bufferCount(3), takeUntil(stop$))
.toPromise();
recentlyAccessed.add('/app/item1', 'Item 1', 'item1');
recentlyAccessed.add('/app/item2', 'Item 2', 'item2');
Expand Down
5 changes: 4 additions & 1 deletion src/core/public/core_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ describe('#setup()', () => {
it('injects legacy dependency to context#setup()', async () => {
const pluginA = Symbol();
const pluginB = Symbol();
const pluginDependencies = new Map<symbol, symbol[]>([[pluginA, []], [pluginB, [pluginA]]]);
const pluginDependencies = new Map<symbol, symbol[]>([
[pluginA, []],
[pluginB, [pluginA]],
]);
MockPluginsService.getOpaqueIds.mockReturnValue(pluginDependencies);
await setupCore();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,27 @@ describe('setup.getPlugins()', () => {
it('returns injectedMetadata.uiPlugins', () => {
const injectedMetadata = new InjectedMetadataService({
injectedMetadata: {
uiPlugins: [{ id: 'plugin-1', plugin: {} }, { id: 'plugin-2', plugin: {} }],
uiPlugins: [
{ id: 'plugin-1', plugin: {} },
{ id: 'plugin-2', plugin: {} },
],
},
} as any);

const plugins = injectedMetadata.setup().getPlugins();
expect(plugins).toEqual([{ id: 'plugin-1', plugin: {} }, { id: 'plugin-2', plugin: {} }]);
expect(plugins).toEqual([
{ id: 'plugin-1', plugin: {} },
{ id: 'plugin-2', plugin: {} },
]);
});

it('returns frozen version of uiPlugins', () => {
const injectedMetadata = new InjectedMetadataService({
injectedMetadata: {
uiPlugins: [{ id: 'plugin-1', plugin: {} }, { id: 'plugin-2', plugin: {} }],
uiPlugins: [
{ id: 'plugin-1', plugin: {} },
{ id: 'plugin-2', plugin: {} },
],
},
} as any);

Expand Down
5 changes: 4 additions & 1 deletion src/core/public/overlays/banners/priority_map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ describe('PriorityMap', () => {
map = map.add('b', { priority: 3 });
map = map.add('c', { priority: 2 });
map = map.remove('c');
expect([...map]).toEqual([['b', { priority: 3 }], ['a', { priority: 1 }]]);
expect([...map]).toEqual([
['b', { priority: 3 }],
['a', { priority: 1 }],
]);
});

it('adds duplicate priorities to end', () => {
Expand Down
22 changes: 14 additions & 8 deletions src/core/public/plugins/plugins_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,13 @@ test('`PluginsService.setup` exposes dependent setup contracts to plugins', asyn

test('`PluginsService.setup` does not set missing dependent setup contracts', async () => {
plugins = [{ id: 'pluginD', plugin: createManifest('pluginD', { optional: ['missing'] }) }];
mockPluginInitializers.set('pluginD', jest.fn(() => ({
setup: jest.fn(),
start: jest.fn(),
})) as any);
mockPluginInitializers.set(
'pluginD',
jest.fn(() => ({
setup: jest.fn(),
start: jest.fn(),
})) as any
);

const pluginsService = new PluginsService(mockCoreContext, plugins);
await pluginsService.setup(mockSetupDeps);
Expand Down Expand Up @@ -268,10 +271,13 @@ test('`PluginsService.start` exposes dependent start contracts to plugins', asyn

test('`PluginsService.start` does not set missing dependent start contracts', async () => {
plugins = [{ id: 'pluginD', plugin: createManifest('pluginD', { optional: ['missing'] }) }];
mockPluginInitializers.set('pluginD', jest.fn(() => ({
setup: jest.fn(),
start: jest.fn(),
})) as any);
mockPluginInitializers.set(
'pluginD',
jest.fn(() => ({
setup: jest.fn(),
start: jest.fn(),
})) as any
);

const pluginsService = new PluginsService(mockCoreContext, plugins);
await pluginsService.setup(mockSetupDeps);
Expand Down
15 changes: 6 additions & 9 deletions src/core/public/ui_settings/ui_settings_api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,7 @@ describe('#getLoadingCount$()', () => {
const done$ = new Rx.Subject();
const promise = uiSettingsApi
.getLoadingCount$()
.pipe(
takeUntil(done$),
toArray()
)
.pipe(takeUntil(done$), toArray())
.toPromise();

await uiSettingsApi.batchSet('foo', 'bar');
Expand Down Expand Up @@ -214,10 +211,7 @@ describe('#getLoadingCount$()', () => {
const done$ = new Rx.Subject();
const promise = uiSettingsApi
.getLoadingCount$()
.pipe(
takeUntil(done$),
toArray()
)
.pipe(takeUntil(done$), toArray())
.toPromise();

await uiSettingsApi.batchSet('foo', 'bar');
Expand Down Expand Up @@ -250,7 +244,10 @@ describe('#stop', () => {
uiSettingsApi.stop();

// both observables should emit the same values, and complete before the request is done loading
await expect(promise).resolves.toEqual([[0, 1], [0, 1]]);
await expect(promise).resolves.toEqual([
[0, 1],
[0, 1],
]);
await batchSetPromise;
});
});
15 changes: 3 additions & 12 deletions src/core/public/ui_settings/ui_settings_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ describe('#get$', () => {
const { config } = setup();
const values = await config
.get$('dateFormat')
.pipe(
take(1),
toArray()
)
.pipe(take(1), toArray())
.toPromise();

expect(values).toEqual(['Browser']);
Expand Down Expand Up @@ -122,10 +119,7 @@ You can use \`config.get("unknown key", defaultValue)\`, which will just return

const values = await config
.get$('dateFormat')
.pipe(
take(2),
toArray()
)
.pipe(take(2), toArray())
.toPromise();

expect(values).toEqual(['Browser', 'new format']);
Expand All @@ -144,10 +138,7 @@ You can use \`config.get("unknown key", defaultValue)\`, which will just return

const values = await config
.get$('dateFormat', 'my default')
.pipe(
take(3),
toArray()
)
.pipe(take(3), toArray())
.toPromise();

expect(values).toEqual(['my default', 'new format', 'my default']);
Expand Down
10 changes: 2 additions & 8 deletions src/core/public/utils/share_weak_replay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,7 @@ Array [
});

it('resubscribes if parent completes', async () => {
const shared = counter().pipe(
take(4),
shareWeakReplay(4)
);
const shared = counter().pipe(take(4), shareWeakReplay(4));

await expect(Promise.all([record(shared.pipe(take(1))), record(shared)])).resolves
.toMatchInlineSnapshot(`
Expand Down Expand Up @@ -199,10 +196,7 @@ Array [
it('supports parents that complete synchronously', async () => {
const next = jest.fn();
const complete = jest.fn();
const shared = counter({ async: false }).pipe(
take(3),
shareWeakReplay(1)
);
const shared = counter({ async: false }).pipe(take(3), shareWeakReplay(1));

shared.subscribe({ next, complete });
expect(next.mock.calls).toMatchInlineSnapshot(`
Expand Down
23 changes: 10 additions & 13 deletions src/core/server/config/ensure_deep_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@ export function ensureDeepObject(obj: any): any {
return obj.map(item => ensureDeepObject(item));
}

return Object.keys(obj).reduce(
(fullObject, propertyKey) => {
const propertyValue = obj[propertyKey];
if (!propertyKey.includes(separator)) {
fullObject[propertyKey] = ensureDeepObject(propertyValue);
} else {
walk(fullObject, propertyKey.split(separator), propertyValue);
}

return fullObject;
},
{} as any
);
return Object.keys(obj).reduce((fullObject, propertyKey) => {
const propertyValue = obj[propertyKey];
if (!propertyKey.includes(separator)) {
fullObject[propertyKey] = ensureDeepObject(propertyValue);
} else {
walk(fullObject, propertyKey.split(separator), propertyValue);
}

return fullObject;
}, {} as any);
}

function walk(obj: any, keys: string[], value: any) {
Expand Down
42 changes: 18 additions & 24 deletions src/core/server/plugins/plugins_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,15 @@ export class PluginsSystem {

this.log.debug(`Setting up plugin "${pluginName}"...`);
const pluginDeps = new Set([...plugin.requiredPlugins, ...plugin.optionalPlugins]);
const pluginDepContracts = Array.from(pluginDeps).reduce(
(depContracts, dependencyName) => {
// Only set if present. Could be absent if plugin does not have server-side code or is a
// missing optional dependency.
if (contracts.has(dependencyName)) {
depContracts[dependencyName] = contracts.get(dependencyName);
}

return depContracts;
},
{} as Record<PluginName, unknown>
);
const pluginDepContracts = Array.from(pluginDeps).reduce((depContracts, dependencyName) => {
// Only set if present. Could be absent if plugin does not have server-side code or is a
// missing optional dependency.
if (contracts.has(dependencyName)) {
depContracts[dependencyName] = contracts.get(dependencyName);
}

return depContracts;
}, {} as Record<PluginName, unknown>);

contracts.set(
pluginName,
Expand Down Expand Up @@ -116,18 +113,15 @@ export class PluginsSystem {
this.log.debug(`Starting plugin "${pluginName}"...`);
const plugin = this.plugins.get(pluginName)!;
const pluginDeps = new Set([...plugin.requiredPlugins, ...plugin.optionalPlugins]);
const pluginDepContracts = Array.from(pluginDeps).reduce(
(depContracts, dependencyName) => {
// Only set if present. Could be absent if plugin does not have server-side code or is a
// missing optional dependency.
if (contracts.has(dependencyName)) {
depContracts[dependencyName] = contracts.get(dependencyName);
}

return depContracts;
},
{} as Record<PluginName, unknown>
);
const pluginDepContracts = Array.from(pluginDeps).reduce((depContracts, dependencyName) => {
// Only set if present. Could be absent if plugin does not have server-side code or is a
// missing optional dependency.
if (contracts.has(dependencyName)) {
depContracts[dependencyName] = contracts.get(dependencyName);
}

return depContracts;
}, {} as Record<PluginName, unknown>);

contracts.set(
pluginName,
Expand Down
Loading

0 comments on commit b08dc0c

Please sign in to comment.