Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Enable core's eslint rule: @ts-expect-error #93086

Merged
merged 2 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,14 @@ module.exports = {
'packages/kbn-config-schema',
'src/plugins/status_page/**',
'src/plugins/saved_objects_management/**',
'packages/kbn-analytics/**',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'packages/kbn-telemetry-tools/**',
'src/plugins/kibana_usage_collection/**',
'src/plugins/usage_collection/**',
'src/plugins/telemetry/**',
'src/plugins/telemetry_collection_manager/**',
'src/plugins/telemetry_management_section/**',
'x-pack/plugins/telemetry_collection_xpack/**',
],
rules: {
'@typescript-eslint/prefer-ts-expect-error': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getSavedObjectsCounts } from './get_saved_object_counts';
export function mockGetSavedObjectsCounts(params: any) {
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
esClient.search.mockResolvedValue(
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
{
body: { ...params },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ describe('TelemetrySender', () => {
originalFetch = window.fetch;
});

// @ts-ignore
beforeEach(() => (window.fetch = mockFetch = jest.fn()));
// @ts-ignore
afterAll(() => (window.fetch = originalFetch));

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

// @ts-ignore
beforeEach(() => (window.setInterval = mockSetInterval = jest.fn()));
// @ts-ignore
afterAll(() => (window.setInterval = originalSetInterval));

it('calls sendIfDue every 60000 ms', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ describe('TelemetryService', () => {
originalFetch = window.fetch;
});

// @ts-ignore
beforeEach(() => (window.fetch = mockFetch = jest.fn()));
// @ts-ignore
afterAll(() => (window.fetch = originalFetch));

it('reports opt-in status to telemetry url', async () => {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/telemetry/server/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import { Observable, Subscription, timer } from 'rxjs';
import { take } from 'rxjs/operators';
// @ts-ignore
import fetch from 'node-fetch';
import {
TelemetryCollectionManagerPluginStart,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

jest.mock('node-fetch');
// @ts-ignore
import fetch from 'node-fetch';
import { sendTelemetryOptInStatus } from './telemetry_opt_in_stats';
import { StatsGetterConfig } from 'src/plugins/telemetry_collection_manager/server';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import { getClusterInfo } from './get_cluster_info';

export function mockGetClusterInfo(clusterInfo: any) {
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
esClient.info
// @ts-ignore we only care about the response body
.mockResolvedValue(
// @ts-ignore we only care about the response body
{
body: { ...clusterInfo },
}
);
esClient.info.mockResolvedValue(
// @ts-expect-error we only care about the response body
{
body: { ...clusterInfo },
}
);
return esClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('get_cluster_stats', () => {
const response = Promise.resolve({ body: { cluster_uuid: '1234' } });
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
esClient.cluster.stats.mockImplementationOnce(
// @ts-ignore the method only cares about the response body
// @ts-expect-error the method only cares about the response body
async (_params = { timeout: TIMEOUT }) => {
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function mockEsClient(
indexStats: any = {}
) {
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
// @ts-ignore
// @ts-expect-error
esClient.indices.getMapping.mockImplementationOnce(async () => {
const body = Object.fromEntries(
indicesMappings.map((index) => [
Expand Down Expand Up @@ -294,7 +294,7 @@ function mockEsClient(
);
return { body };
});
// @ts-ignore
// @ts-expect-error
esClient.indices.stats.mockImplementationOnce(async () => {
return { body: indexStats };
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ function mockUsageCollection(kibanaUsage = {}) {
// set up successful call mocks for info, cluster stats, nodes usage and data telemetry
function mockGetLocalStats(clusterInfo: any, clusterStats: any) {
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
esClient.info
// @ts-ignore we only care about the response body
.mockResolvedValue(
// @ts-ignore we only care about the response body
{
body: { ...clusterInfo },
}
);
esClient.info.mockResolvedValue(
// @ts-expect-error we only care about the response body
{
body: { ...clusterInfo },
}
);
esClient.cluster.stats
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
.mockResolvedValue({ body: { ...clusterStats } });
esClient.nodes.usage.mockResolvedValue(
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
{
body: {
cluster_name: 'testCluster',
Expand Down Expand Up @@ -64,9 +62,9 @@ function mockGetLocalStats(clusterInfo: any, clusterStats: any) {
},
}
);
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
esClient.indices.getMapping.mockResolvedValue({ body: { mappings: {} } });
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
esClient.indices.stats.mockResolvedValue({ body: { indices: {} } });
return esClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('get_nodes_usage', () => {
const response = Promise.resolve({ body: mockedNodesFetchResponse });
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
esClient.nodes.usage.mockImplementationOnce(
// @ts-ignore
// @ts-expect-error
async (_params = { timeout: TIMEOUT }) => {
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ function mockEsClient() {
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
// mock for license should return a basic license
esClient.license.get.mockResolvedValue(
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
{ body: { license: { type: 'basic' } } }
);
// mock for xpack usage should return an empty object
esClient.xpack.usage.mockResolvedValue(
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
{ body: {} }
);
// mock for nodes usage should resolve for this test
esClient.nodes.usage.mockResolvedValue(
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
{ body: { cluster_name: 'test cluster', nodes: nodesUsage } }
);
// mock for info should resolve for this test
esClient.info.mockResolvedValue(
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
{
body: {
cluster_uuid: 'test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('get_xpack', () => {
describe('getXPackUsage', () => {
it('uses esClient to get /_xpack/usage API', async () => {
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
// @ts-ignore we only care about the response body
// @ts-expect-error we only care about the response body
esClient.xpack.usage.mockResolvedValue({ body: {} });
const result = await getXPackUsage(esClient);
expect(result).toEqual({});
Expand Down