Skip to content

Commit c0535ab

Browse files
authored
[chore] Enable core's eslint rule: @ts-expect-error (#93086)
* [chore] Enable core's eslint rules * Change comment from platform-team to core-team
1 parent 03cc5cc commit c0535ab

13 files changed

Lines changed: 35 additions & 39 deletions

File tree

.eslintrc.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ module.exports = {
13161316

13171317
{
13181318
files: [
1319-
// platform-team owned code
1319+
// core-team owned code
13201320
'src/core/**',
13211321
'x-pack/plugins/features/**',
13221322
'x-pack/plugins/licensing/**',
@@ -1325,6 +1325,14 @@ module.exports = {
13251325
'packages/kbn-config-schema',
13261326
'src/plugins/status_page/**',
13271327
'src/plugins/saved_objects_management/**',
1328+
'packages/kbn-analytics/**',
1329+
'packages/kbn-telemetry-tools/**',
1330+
'src/plugins/kibana_usage_collection/**',
1331+
'src/plugins/usage_collection/**',
1332+
'src/plugins/telemetry/**',
1333+
'src/plugins/telemetry_collection_manager/**',
1334+
'src/plugins/telemetry_management_section/**',
1335+
'x-pack/plugins/telemetry_collection_xpack/**',
13281336
],
13291337
rules: {
13301338
'@typescript-eslint/prefer-ts-expect-error': 'error',

src/plugins/kibana_usage_collection/server/collectors/kibana/get_saved_object_counts.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { getSavedObjectsCounts } from './get_saved_object_counts';
1212
export function mockGetSavedObjectsCounts(params: any) {
1313
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
1414
esClient.search.mockResolvedValue(
15-
// @ts-ignore we only care about the response body
15+
// @ts-expect-error we only care about the response body
1616
{
1717
body: { ...params },
1818
}

src/plugins/telemetry/public/services/telemetry_sender.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ describe('TelemetrySender', () => {
126126
originalFetch = window.fetch;
127127
});
128128

129-
// @ts-ignore
130129
beforeEach(() => (window.fetch = mockFetch = jest.fn()));
131-
// @ts-ignore
132130
afterAll(() => (window.fetch = originalFetch));
133131

134132
it('does not send if already sending', async () => {
@@ -250,9 +248,7 @@ describe('TelemetrySender', () => {
250248
originalSetInterval = window.setInterval;
251249
});
252250

253-
// @ts-ignore
254251
beforeEach(() => (window.setInterval = mockSetInterval = jest.fn()));
255-
// @ts-ignore
256252
afterAll(() => (window.setInterval = originalSetInterval));
257253

258254
it('calls sendIfDue every 60000 ms', () => {

src/plugins/telemetry/public/services/telemetry_service.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ describe('TelemetryService', () => {
211211
originalFetch = window.fetch;
212212
});
213213

214-
// @ts-ignore
215214
beforeEach(() => (window.fetch = mockFetch = jest.fn()));
216-
// @ts-ignore
217215
afterAll(() => (window.fetch = originalFetch));
218216

219217
it('reports opt-in status to telemetry url', async () => {

src/plugins/telemetry/server/fetcher.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import { Observable, Subscription, timer } from 'rxjs';
1010
import { take } from 'rxjs/operators';
11-
// @ts-ignore
1211
import fetch from 'node-fetch';
1312
import {
1413
TelemetryCollectionManagerPluginStart,

src/plugins/telemetry/server/routes/telemetry_opt_in_stats.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
jest.mock('node-fetch');
10-
// @ts-ignore
1110
import fetch from 'node-fetch';
1211
import { sendTelemetryOptInStatus } from './telemetry_opt_in_stats';
1312
import { StatsGetterConfig } from 'src/plugins/telemetry_collection_manager/server';

src/plugins/telemetry/server/telemetry_collection/get_cluster_info.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ import { getClusterInfo } from './get_cluster_info';
1111

1212
export function mockGetClusterInfo(clusterInfo: any) {
1313
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
14-
esClient.info
15-
// @ts-ignore we only care about the response body
16-
.mockResolvedValue(
17-
// @ts-ignore we only care about the response body
18-
{
19-
body: { ...clusterInfo },
20-
}
21-
);
14+
esClient.info.mockResolvedValue(
15+
// @ts-expect-error we only care about the response body
16+
{
17+
body: { ...clusterInfo },
18+
}
19+
);
2220
return esClient;
2321
}
2422

src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('get_cluster_stats', () => {
2121
const response = Promise.resolve({ body: { cluster_uuid: '1234' } });
2222
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
2323
esClient.cluster.stats.mockImplementationOnce(
24-
// @ts-ignore the method only cares about the response body
24+
// @ts-expect-error the method only cares about the response body
2525
async (_params = { timeout: TIMEOUT }) => {
2626
return response;
2727
}

src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ function mockEsClient(
265265
indexStats: any = {}
266266
) {
267267
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
268-
// @ts-ignore
268+
// @ts-expect-error
269269
esClient.indices.getMapping.mockImplementationOnce(async () => {
270270
const body = Object.fromEntries(
271271
indicesMappings.map((index) => [
@@ -294,7 +294,7 @@ function mockEsClient(
294294
);
295295
return { body };
296296
});
297-
// @ts-ignore
297+
// @ts-expect-error
298298
esClient.indices.stats.mockImplementationOnce(async () => {
299299
return { body: indexStats };
300300
});

src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,17 @@ function mockUsageCollection(kibanaUsage = {}) {
2424
// set up successful call mocks for info, cluster stats, nodes usage and data telemetry
2525
function mockGetLocalStats(clusterInfo: any, clusterStats: any) {
2626
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
27-
esClient.info
28-
// @ts-ignore we only care about the response body
29-
.mockResolvedValue(
30-
// @ts-ignore we only care about the response body
31-
{
32-
body: { ...clusterInfo },
33-
}
34-
);
27+
esClient.info.mockResolvedValue(
28+
// @ts-expect-error we only care about the response body
29+
{
30+
body: { ...clusterInfo },
31+
}
32+
);
3533
esClient.cluster.stats
36-
// @ts-ignore we only care about the response body
34+
// @ts-expect-error we only care about the response body
3735
.mockResolvedValue({ body: { ...clusterStats } });
3836
esClient.nodes.usage.mockResolvedValue(
39-
// @ts-ignore we only care about the response body
37+
// @ts-expect-error we only care about the response body
4038
{
4139
body: {
4240
cluster_name: 'testCluster',
@@ -64,9 +62,9 @@ function mockGetLocalStats(clusterInfo: any, clusterStats: any) {
6462
},
6563
}
6664
);
67-
// @ts-ignore we only care about the response body
65+
// @ts-expect-error we only care about the response body
6866
esClient.indices.getMapping.mockResolvedValue({ body: { mappings: {} } });
69-
// @ts-ignore we only care about the response body
67+
// @ts-expect-error we only care about the response body
7068
esClient.indices.stats.mockResolvedValue({ body: { indices: {} } });
7169
return esClient;
7270
}

0 commit comments

Comments
 (0)