mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[chore] Enable core's eslint rule: @ts-expect-error
(#93086)
* [chore] Enable core's eslint rules * Change comment from platform-team to core-team
This commit is contained in:
parent
03cc5cc0c2
commit
c0535abc06
13 changed files with 35 additions and 39 deletions
10
.eslintrc.js
10
.eslintrc.js
|
@ -1316,7 +1316,7 @@ module.exports = {
|
|||
|
||||
{
|
||||
files: [
|
||||
// platform-team owned code
|
||||
// core-team owned code
|
||||
'src/core/**',
|
||||
'x-pack/plugins/features/**',
|
||||
'x-pack/plugins/licensing/**',
|
||||
|
@ -1325,6 +1325,14 @@ module.exports = {
|
|||
'packages/kbn-config-schema',
|
||||
'src/plugins/status_page/**',
|
||||
'src/plugins/saved_objects_management/**',
|
||||
'packages/kbn-analytics/**',
|
||||
'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',
|
||||
|
|
|
@ -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 },
|
||||
}
|
||||
|
|
|
@ -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 () => {
|
||||
|
@ -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', () => {
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
import { Observable, Subscription, timer } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
// @ts-ignore
|
||||
import fetch from 'node-fetch';
|
||||
import {
|
||||
TelemetryCollectionManagerPluginStart,
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) => [
|
||||
|
@ -294,7 +294,7 @@ function mockEsClient(
|
|||
);
|
||||
return { body };
|
||||
});
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
esClient.indices.stats.mockImplementationOnce(async () => {
|
||||
return { body: indexStats };
|
||||
});
|
||||
|
|
|
@ -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',
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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({});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue