Skip to content

Commit 95861a0

Browse files
authored
[DX] Prettier v2.2 (#83899)
* update prettier with ts version support * mute type-error * run prettier on codebase * fix examples * fix errors after master merged
1 parent df4f475 commit 95861a0

File tree

172 files changed

+896
-953
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+896
-953
lines changed

examples/embeddable_examples/public/book/book_embeddable_factory.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ export class BookEmbeddableFactoryDefinition
127127

128128
private async unwrapMethod(savedObjectId: string): Promise<BookSavedObjectAttributes> {
129129
const { savedObjectsClient } = await this.getStartServices();
130-
const savedObject: SimpleSavedObject<BookSavedObjectAttributes> = await savedObjectsClient.get<
131-
BookSavedObjectAttributes
132-
>(this.type, savedObjectId);
130+
const savedObject: SimpleSavedObject<BookSavedObjectAttributes> = await savedObjectsClient.get<BookSavedObjectAttributes>(
131+
this.type,
132+
savedObjectId
133+
);
133134
return { ...savedObject.attributes };
134135
}
135136

@@ -163,9 +164,9 @@ export class BookEmbeddableFactoryDefinition
163164

164165
private async getAttributeService() {
165166
if (!this.attributeService) {
166-
this.attributeService = (await this.getStartServices()).getAttributeService<
167-
BookSavedObjectAttributes
168-
>(this.type, {
167+
this.attributeService = (
168+
await this.getStartServices()
169+
).getAttributeService<BookSavedObjectAttributes>(this.type, {
169170
saveMethod: this.saveMethod.bind(this),
170171
unwrapMethod: this.unwrapMethod.bind(this),
171172
checkForDuplicateTitle: this.checkForDuplicateTitleMethod.bind(this),

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@
510510
"@types/pdfmake": "^0.1.15",
511511
"@types/pegjs": "^0.10.1",
512512
"@types/pngjs": "^3.4.0",
513-
"@types/prettier": "^2.0.2",
513+
"@types/prettier": "^2.1.5",
514514
"@types/pretty-ms": "^5.0.0",
515515
"@types/prop-types": "^15.7.3",
516516
"@types/proper-lockfile": "^3.0.1",
@@ -626,7 +626,7 @@
626626
"enzyme-adapter-utils": "^1.13.0",
627627
"enzyme-to-json": "^3.4.4",
628628
"eslint": "^6.8.0",
629-
"eslint-config-prettier": "^6.11.0",
629+
"eslint-config-prettier": "^6.15.0",
630630
"eslint-import-resolver-node": "0.3.2",
631631
"eslint-import-resolver-webpack": "0.11.1",
632632
"eslint-module-utils": "2.5.0",
@@ -762,7 +762,7 @@
762762
"postcss": "^7.0.32",
763763
"postcss-loader": "^3.0.0",
764764
"postcss-prefix-selector": "^1.7.2",
765-
"prettier": "^2.1.1",
765+
"prettier": "^2.2.0",
766766
"pretty-ms": "5.0.0",
767767
"proxyquire": "1.8.0",
768768
"querystring": "^0.2.0",

packages/kbn-test/src/functional_test_runner/lib/snapshots/decorate_snapshot_ui.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ function getSnapshotState(file: string, test: Test, updateSnapshots: boolean) {
196196
path.join(dirname + `/__snapshots__/` + filename.replace(path.extname(filename), '.snap')),
197197
{
198198
updateSnapshot: updateSnapshots ? 'all' : 'new',
199+
// @ts-expect-error
199200
getPrettier: () => prettier,
200201
getBabelTraverse: () => babelTraverse,
201202
}

src/core/server/elasticsearch/elasticsearch_service.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ let coreContext: CoreContext;
5757
const logger = loggingSystemMock.create();
5858

5959
let mockClusterClientInstance: ReturnType<typeof elasticsearchClientMock.createCustomClusterClient>;
60-
let mockLegacyClusterClientInstance: ReturnType<typeof elasticsearchServiceMock.createLegacyCustomClusterClient>;
60+
let mockLegacyClusterClientInstance: ReturnType<
61+
typeof elasticsearchServiceMock.createLegacyCustomClusterClient
62+
>;
6163

6264
beforeEach(() => {
6365
env = Env.createDefault(REPO_ROOT, getEnvOptions());

src/core/server/saved_objects/migrations/mocks.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
import { SavedObjectMigrationContext } from './types';
2121
import { SavedObjectsMigrationLogger } from './core';
2222

23-
export const createSavedObjectsMigrationLoggerMock = (): jest.Mocked<
24-
SavedObjectsMigrationLogger
25-
> => {
23+
export const createSavedObjectsMigrationLoggerMock = (): jest.Mocked<SavedObjectsMigrationLogger> => {
2624
const mock = {
2725
debug: jest.fn(),
2826
info: jest.fn(),

src/core/server/saved_objects/saved_objects_service.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,8 @@ describe('SavedObjectsService', () => {
217217
await soService.setup(setupDeps);
218218
soService.start(createStartDeps());
219219
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(0);
220-
((setupDeps.elasticsearch.esNodesCompatibility$ as any) as BehaviorSubject<
221-
NodesVersionCompatibility
222-
>).next({
220+
((setupDeps.elasticsearch
221+
.esNodesCompatibility$ as any) as BehaviorSubject<NodesVersionCompatibility>).next({
223222
isCompatible: true,
224223
incompatibleNodes: [],
225224
warningNodes: [],

src/core/server/saved_objects/service/lib/repository_create_repository.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ describe('SavedObjectsRepository#createRepository', () => {
6666
});
6767

6868
const migrator = mockKibanaMigrator.create({ types: typeRegistry.getAllTypes() });
69-
const RepositoryConstructor = (SavedObjectsRepository as unknown) as jest.Mock<
70-
SavedObjectsRepository
71-
>;
69+
const RepositoryConstructor = (SavedObjectsRepository as unknown) as jest.Mock<SavedObjectsRepository>;
7270

7371
beforeEach(() => {
7472
RepositoryConstructor.mockClear();

src/plugins/console/public/application/models/legacy_core_editor/legacy_core_editor.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,20 +368,21 @@ export class LegacyCoreEditor implements CoreEditor {
368368

369369
// disable standard context based autocompletion.
370370
// @ts-ignore
371-
ace.define('ace/autocomplete/text_completer', ['require', 'exports', 'module'], function (
372-
require: any,
373-
exports: any
374-
) {
375-
exports.getCompletions = function (
376-
innerEditor: any,
377-
session: any,
378-
pos: any,
379-
prefix: any,
380-
callback: any
381-
) {
382-
callback(null, []);
383-
};
384-
});
371+
ace.define(
372+
'ace/autocomplete/text_completer',
373+
['require', 'exports', 'module'],
374+
function (require: any, exports: any) {
375+
exports.getCompletions = function (
376+
innerEditor: any,
377+
session: any,
378+
pos: any,
379+
prefix: any,
380+
callback: any
381+
) {
382+
callback(null, []);
383+
};
384+
}
385+
);
385386

386387
const langTools = ace.acequire('ace/ext/language_tools');
387388

src/plugins/console/public/application/models/sense_editor/__tests__/integration.test.js

Lines changed: 74 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -84,90 +84,93 @@ describe('Integration', () => {
8484
changeListener: function () {},
8585
}; // mimic auto complete
8686

87-
senseEditor.autocomplete._test.getCompletions(senseEditor, null, cursor, '', function (
88-
err,
89-
terms
90-
) {
91-
if (testToRun.assertThrows) {
92-
done();
93-
return;
94-
}
87+
senseEditor.autocomplete._test.getCompletions(
88+
senseEditor,
89+
null,
90+
cursor,
91+
'',
92+
function (err, terms) {
93+
if (testToRun.assertThrows) {
94+
done();
95+
return;
96+
}
9597

96-
if (err) {
97-
throw err;
98-
}
98+
if (err) {
99+
throw err;
100+
}
99101

100-
if (testToRun.no_context) {
101-
expect(!terms || terms.length === 0).toBeTruthy();
102-
} else {
103-
expect(terms).not.toBeNull();
104-
expect(terms.length).toBeGreaterThan(0);
105-
}
102+
if (testToRun.no_context) {
103+
expect(!terms || terms.length === 0).toBeTruthy();
104+
} else {
105+
expect(terms).not.toBeNull();
106+
expect(terms.length).toBeGreaterThan(0);
107+
}
106108

107-
if (!terms || terms.length === 0) {
108-
done();
109-
return;
110-
}
109+
if (!terms || terms.length === 0) {
110+
done();
111+
return;
112+
}
111113

112-
if (testToRun.autoCompleteSet) {
113-
const expectedTerms = _.map(testToRun.autoCompleteSet, function (t) {
114-
if (typeof t !== 'object') {
115-
t = { name: t };
116-
}
117-
return t;
118-
});
119-
if (terms.length !== expectedTerms.length) {
120-
expect(_.map(terms, 'name')).toEqual(_.map(expectedTerms, 'name'));
121-
} else {
122-
const filteredActualTerms = _.map(terms, function (actualTerm, i) {
123-
const expectedTerm = expectedTerms[i];
124-
const filteredTerm = {};
125-
_.each(expectedTerm, function (v, p) {
126-
filteredTerm[p] = actualTerm[p];
127-
});
128-
return filteredTerm;
114+
if (testToRun.autoCompleteSet) {
115+
const expectedTerms = _.map(testToRun.autoCompleteSet, function (t) {
116+
if (typeof t !== 'object') {
117+
t = { name: t };
118+
}
119+
return t;
129120
});
130-
expect(filteredActualTerms).toEqual(expectedTerms);
121+
if (terms.length !== expectedTerms.length) {
122+
expect(_.map(terms, 'name')).toEqual(_.map(expectedTerms, 'name'));
123+
} else {
124+
const filteredActualTerms = _.map(terms, function (actualTerm, i) {
125+
const expectedTerm = expectedTerms[i];
126+
const filteredTerm = {};
127+
_.each(expectedTerm, function (v, p) {
128+
filteredTerm[p] = actualTerm[p];
129+
});
130+
return filteredTerm;
131+
});
132+
expect(filteredActualTerms).toEqual(expectedTerms);
133+
}
131134
}
132-
}
133135

134-
const context = terms[0].context;
135-
const {
136-
cursor: { lineNumber, column },
137-
} = testToRun;
138-
senseEditor.autocomplete._test.addReplacementInfoToContext(
139-
context,
140-
{ lineNumber, column },
141-
terms[0].value
142-
);
136+
const context = terms[0].context;
137+
const {
138+
cursor: { lineNumber, column },
139+
} = testToRun;
140+
senseEditor.autocomplete._test.addReplacementInfoToContext(
141+
context,
142+
{ lineNumber, column },
143+
terms[0].value
144+
);
143145

144-
function ac(prop, propTest) {
145-
if (typeof testToRun[prop] !== 'undefined') {
146-
if (propTest) {
147-
propTest(context[prop], testToRun[prop], prop);
148-
} else {
149-
expect(context[prop]).toEqual(testToRun[prop]);
146+
function ac(prop, propTest) {
147+
if (typeof testToRun[prop] !== 'undefined') {
148+
if (propTest) {
149+
propTest(context[prop], testToRun[prop], prop);
150+
} else {
151+
expect(context[prop]).toEqual(testToRun[prop]);
152+
}
150153
}
151154
}
152-
}
153155

154-
function posCompare(actual, expected) {
155-
expect(actual.lineNumber).toEqual(expected.lineNumber + lineOffset);
156-
expect(actual.column).toEqual(expected.column);
157-
}
156+
function posCompare(actual, expected) {
157+
expect(actual.lineNumber).toEqual(expected.lineNumber + lineOffset);
158+
expect(actual.column).toEqual(expected.column);
159+
}
158160

159-
function rangeCompare(actual, expected, name) {
160-
posCompare(actual.start, expected.start, name + '.start');
161-
posCompare(actual.end, expected.end, name + '.end');
162-
}
161+
function rangeCompare(actual, expected, name) {
162+
posCompare(actual.start, expected.start, name + '.start');
163+
posCompare(actual.end, expected.end, name + '.end');
164+
}
163165

164-
ac('prefixToAdd');
165-
ac('suffixToAdd');
166-
ac('addTemplate');
167-
ac('textBoxPosition', posCompare);
168-
ac('rangeToReplace', rangeCompare);
169-
done();
170-
});
166+
ac('prefixToAdd');
167+
ac('suffixToAdd');
168+
ac('addTemplate');
169+
ac('textBoxPosition', posCompare);
170+
ac('rangeToReplace', rangeCompare);
171+
done();
172+
}
173+
);
171174
});
172175
}
173176

src/plugins/dashboard/public/plugin.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ export class DashboardPlugin
179179
core: CoreSetup<StartDependencies, DashboardStart>,
180180
{ share, uiActions, embeddable, home, urlForwarding, data, usageCollection }: SetupDependencies
181181
): DashboardSetup {
182-
this.dashboardFeatureFlagConfig = this.initializerContext.config.get<
183-
DashboardFeatureFlagConfig
184-
>();
182+
this.dashboardFeatureFlagConfig = this.initializerContext.config.get<DashboardFeatureFlagConfig>();
185183
const expandPanelAction = new ExpandPanelAction();
186184
uiActions.registerAction(expandPanelAction);
187185
uiActions.attachAction(CONTEXT_MENU_TRIGGER, expandPanelAction.id);

0 commit comments

Comments
 (0)