[ML] Enable consistent-type-imports eslint rule (#176921)

Enabling `consistent-type-imports` rule and running `node scripts/eslint
--no-cache --fix` to fix every type import.

Affects x-pack plugins: `ml`, `transform`, `aiops`, `data_visualizer`
and `x-pack/packages/ml`

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
James Gowdy 2024-03-07 10:29:20 +00:00 committed by GitHub
parent 5ef169f0f0
commit 3670b4fa5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
1341 changed files with 3873 additions and 3187 deletions

View file

@ -9,9 +9,10 @@ import getAnnotationsRequestMock from './__mocks__/get_annotations_request.json'
import getAnnotationsResponseMock from './__mocks__/get_annotations_response.json';
import { ANNOTATION_TYPE } from '../../../common/constants/annotations';
import { Annotation, isAnnotations } from '../../../common/types/annotations';
import type { Annotation } from '../../../common/types/annotations';
import { isAnnotations } from '../../../common/types/annotations';
import { DeleteParams, GetResponse, IndexAnnotationArgs } from './annotation';
import type { DeleteParams, GetResponse, IndexAnnotationArgs } from './annotation';
import { annotationServiceProvider } from '.';
const acknowledgedResponseMock = { acknowledged: true };

View file

@ -7,7 +7,7 @@
import Boom from '@hapi/boom';
import { each, get } from 'lodash';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ML_PARTITION_FIELDS } from '@kbn/ml-anomaly-utils';
@ -17,15 +17,14 @@ import {
ML_ANNOTATIONS_INDEX_ALIAS_WRITE,
} from '../../../common/constants/index_patterns';
import type { Annotation, Annotations } from '../../../common/types/annotations';
import {
Annotation,
Annotations,
isAnnotation,
isAnnotations,
getAnnotationFieldName,
getAnnotationFieldValue,
} from '../../../common/types/annotations';
import { JobId } from '../../../common/types/anomaly_detection_jobs';
import type { JobId } from '../../../common/types/anomaly_detection_jobs';
// TODO All of the following interface/type definitions should
// eventually be replaced by the proper upstream definitions

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { annotationProvider } from './annotation';
export function annotationServiceProvider(client: IScopedClusterClient) {

View file

@ -5,8 +5,8 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import { BucketSpanEstimatorData } from '../../../common/types/job_service';
import type { IScopedClusterClient } from '@kbn/core/server';
import type { BucketSpanEstimatorData } from '../../../common/types/job_service';
export function estimateBucketSpanFactory({
asCurrentUser,

View file

@ -5,10 +5,10 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { ES_AGGREGATION } from '@kbn/ml-anomaly-utils';
import { BucketSpanEstimatorData } from '../../../common/types/job_service';
import type { BucketSpanEstimatorData } from '../../../common/types/job_service';
import { estimateBucketSpanFactory } from './bucket_span_estimator';

View file

@ -6,9 +6,9 @@
*/
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import numeral from '@elastic/numeral';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { MLCATEGORY } from '@kbn/ml-anomaly-utils';
import { AnalysisConfig, Datafeed } from '../../../common/types/anomaly_detection_jobs';
import type { AnalysisConfig, Datafeed } from '../../../common/types/anomaly_detection_jobs';
import { fieldsServiceProvider } from '../fields_service';
import type { MlClient } from '../../lib/ml_client';

View file

@ -5,9 +5,9 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { ML_NOTIFICATION_INDEX_PATTERN } from '../../../common/constants/index_patterns';
import { JobMessage } from '../../../common/types/audit_message';
import type { JobMessage } from '../../../common/types/audit_message';
const SIZE = 50;

View file

@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { extractErrorMessage } from '@kbn/ml-error-utils';
import {
getAnalysisType,

View file

@ -7,7 +7,7 @@
import { get, each, last, find } from 'lodash';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import {
buildSamplerAggregation,
fetchHistogramsForFields,
@ -19,7 +19,7 @@ import { buildBaseFilterCriteria, getSafeAggregationName } from '@kbn/ml-query-u
import { ML_JOB_FIELD_TYPES } from '@kbn/ml-anomaly-utils';
import type { RuntimeMappings } from '@kbn/ml-runtime-field-utils';
import { getDatafeedAggregations } from '../../../common/util/datafeed_utils';
import { Datafeed } from '../../../common/types/anomaly_detection_jobs';
import type { Datafeed } from '../../../common/types/anomaly_detection_jobs';
const SAMPLER_TOP_TERMS_THRESHOLD = 100000;
const SAMPLER_TOP_TERMS_SHARD_SIZE = 5000;

View file

@ -7,7 +7,7 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import Boom from '@hapi/boom';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { duration } from 'moment';
import type { AggCardinality } from '@kbn/ml-agg-utils';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
@ -16,7 +16,7 @@ import { parseInterval } from '../../../common/util/parse_interval';
import { initCardinalityFieldsCache } from './fields_aggs_cache';
import { isValidAggregationField } from '../../../common/util/validation_utils';
import { getDatafeedAggregations } from '../../../common/util/datafeed_utils';
import { Datafeed, IndicesOptions } from '../../../common/types/anomaly_detection_jobs';
import type { Datafeed, IndicesOptions } from '../../../common/types/anomaly_detection_jobs';
/**
* Service for carrying out queries to obtain data

View file

@ -14,7 +14,7 @@ import { MESSAGE_LEVEL } from '../../../common/constants/message_levels';
import type { MLSavedObjectService } from '../../saved_objects';
import type { MlClient } from '../../lib/ml_client';
import type { JobMessage } from '../../../common/types/audit_message';
import { AuditMessage } from '../../../common/types/anomaly_detection_jobs';
import type { AuditMessage } from '../../../common/types/anomaly_detection_jobs';
const SIZE = 1000;
const LEVEL = { system_info: -1, info: 0, warning: 1, error: 2 } as const;

View file

@ -7,10 +7,10 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { i18n } from '@kbn/i18n';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { JOB_STATE, DATAFEED_STATE } from '../../../common/constants/states';
import { fillResultsWithTimeouts, isRequestTimeout } from './error_utils';
import { Datafeed, DatafeedStats } from '../../../common/types/anomaly_detection_jobs';
import type { Datafeed, DatafeedStats } from '../../../common/types/anomaly_detection_jobs';
import type { MlClient } from '../../lib/ml_client';
export interface MlDatafeedsResponse {

View file

@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import { JOB_STATE, DATAFEED_STATE } from '../../../common/constants/states';
import { JobAction } from '../../../common/constants/job_actions';
import type { JobAction } from '../../../common/constants/job_actions';
const REQUEST_TIMEOUT_NAME = 'RequestTimeout';
type ACTION_STATE = DATAFEED_STATE | JOB_STATE | JobAction;

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import type { RulesClient } from '@kbn/alerting-plugin/server';
import { datafeedsProvider } from './datafeeds';
import { jobsProvider } from './jobs';

View file

@ -7,7 +7,7 @@
import { uniq } from 'lodash';
import Boom from '@hapi/boom';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import type { RulesClient } from '@kbn/alerting-plugin/server';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import {
@ -16,14 +16,14 @@ import {
isJobWithGeoData,
} from '../../../common/util/job_utils';
import { JOB_STATE, DATAFEED_STATE } from '../../../common/constants/states';
import type { JobAction } from '../../../common/constants/job_actions';
import {
getJobActionString,
JOB_ACTION_TASK,
JOB_ACTION_TASKS,
JOB_ACTION,
JobAction,
} from '../../../common/constants/job_actions';
import {
import type {
MlSummaryJob,
AuditMessage,
DatafeedWithStats,
@ -31,7 +31,7 @@ import {
Datafeed,
Job,
} from '../../../common/types/anomaly_detection_jobs';
import {
import type {
JobsExistResponse,
BulkCreateResults,
ResetJobsResponse,
@ -49,7 +49,7 @@ import {
import { groupsProvider } from './groups';
import type { MlClient } from '../../lib/ml_client';
import { ML_ALERT_TYPES } from '../../../common/constants/alerts';
import { MlAnomalyDetectionAlertParams } from '../../routes/schemas/alerting_schema';
import type { MlAnomalyDetectionAlertParams } from '../../routes/schemas/alerting_schema';
import type { AuthorizationHeader } from '../../lib/request_authorization';
import { parseInterval } from '../../../common/util/parse_interval';

View file

@ -7,10 +7,11 @@
import Boom from '@hapi/boom';
import { i18n } from '@kbn/i18n';
import { IScopedClusterClient } from '@kbn/core/server';
import { ModelSnapshot } from '../../../common/types/anomaly_detection_jobs';
import type { IScopedClusterClient } from '@kbn/core/server';
import type { ModelSnapshot } from '../../../common/types/anomaly_detection_jobs';
import { datafeedsProvider } from './datafeeds';
import { FormCalendar, CalendarManager } from '../calendar';
import type { FormCalendar } from '../calendar';
import { CalendarManager } from '../calendar';
import type { MlClient } from '../../lib/ml_client';
export interface ModelSnapshotsResponse {

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { newJobLineChartProvider } from './line_chart';
import { newJobPopulationChartProvider } from './population_chart';

View file

@ -6,10 +6,10 @@
*/
import { get } from 'lodash';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { type AggFieldNamePair, EVENT_RATE_FIELD_ID } from '@kbn/ml-anomaly-utils';
import type { RuntimeMappings } from '@kbn/ml-runtime-field-utils';
import { IndicesOptions } from '../../../../common/types/anomaly_detection_jobs';
import type { IndicesOptions } from '../../../../common/types/anomaly_detection_jobs';
import { ML_MEDIAN_PERCENTS } from '../../../../common/util/job_utils';
type DtrIndex = number;

View file

@ -6,10 +6,10 @@
*/
import { get } from 'lodash';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { type AggFieldNamePair, EVENT_RATE_FIELD_ID } from '@kbn/ml-anomaly-utils';
import type { RuntimeMappings } from '@kbn/ml-runtime-field-utils';
import { IndicesOptions } from '../../../../common/types/anomaly_detection_jobs';
import type { IndicesOptions } from '../../../../common/types/anomaly_detection_jobs';
import { ML_MEDIAN_PERCENTS } from '../../../../common/util/job_utils';
const OVER_FIELD_EXAMPLES_COUNT = 40;

View file

@ -5,14 +5,15 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { elasticsearchServiceMock } from '@kbn/core/server/mocks';
import { ES_CLIENT_TOTAL_HITS_RELATION } from '@kbn/ml-query-utils';
import type { MlClient } from '../../lib/ml_client';
import type { AuthorizationHeader } from '../../lib/request_authorization';
import { validateJob, ValidateJobPayload } from './job_validation';
import type { ValidateJobPayload } from './job_validation';
import { validateJob } from './job_validation';
const callAs = elasticsearchServiceMock.createElasticsearchClient();
// @ts-expect-error incorrect types

View file

@ -7,9 +7,10 @@
import Boom from '@hapi/boom';
import type { IScopedClusterClient } from '@kbn/core/server';
import { TypeOf } from '@kbn/config-schema';
import type { TypeOf } from '@kbn/config-schema';
import { fieldsServiceProvider } from '../fields_service';
import { getMessages, MessageId, JobValidationMessage } from '../../../common/constants/messages';
import type { MessageId, JobValidationMessage } from '../../../common/constants/messages';
import { getMessages } from '../../../common/constants/messages';
import { VALIDATION_STATUS } from '../../../common/constants/validation';
import { basicJobValidation, uniqWithIsEqual } from '../../../common/util/job_utils';
@ -19,7 +20,7 @@ import { validateInfluencers } from './validate_influencers';
import { validateDatafeedPreviewWithMessages } from './validate_datafeed_preview';
import { validateModelMemoryLimit } from './validate_model_memory_limit';
import { validateTimeRange, isValidTimeField } from './validate_time_range';
import { validateJobSchema } from '../../routes/schemas/job_validation_schema';
import type { validateJobSchema } from '../../routes/schemas/job_validation_schema';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { MlClient } from '../../lib/ml_client';
import { getDatafeedAggregations } from '../../../common/util/datafeed_utils';

View file

@ -7,7 +7,7 @@
import { SKIP_BUCKET_SPAN_ESTIMATION } from '../../../common/constants/validation';
import { JobValidationMessage } from '../../../common/constants/messages';
import type { JobValidationMessage } from '../../../common/constants/messages';
// @ts-ignore
import { validateBucketSpan } from './validate_bucket_span';

View file

@ -7,9 +7,9 @@
import { cloneDeep } from 'lodash';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import mockFareQuoteCardinality from './__mocks__/mock_farequote_cardinality.json';
import mockFieldCaps from './__mocks__/mock_field_caps.json';

View file

@ -5,13 +5,13 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { DataVisualizer } from '../data_visualizer';
import { validateJobObject } from './validate_job_object';
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import { Detector } from '../../../common/types/anomaly_detection_jobs';
import { MessageId, JobValidationMessage } from '../../../common/constants/messages';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { Detector } from '../../../common/types/anomaly_detection_jobs';
import type { MessageId, JobValidationMessage } from '../../../common/constants/messages';
import { isValidAggregationField } from '../../../common/util/validation_utils';
import { getDatafeedAggregations } from '../../../common/util/datafeed_utils';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import { validateInfluencers } from './validate_influencers';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import { validateJobObject } from './validate_job_object';

View file

@ -6,7 +6,7 @@
*/
import { i18n } from '@kbn/i18n';
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
export function validateJobObject(job: CombinedJob | null | undefined): job is CombinedJob | never {
if (job === null || typeof job !== 'object') {

View file

@ -5,9 +5,9 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import { CombinedJob, Detector } from '../../../common/types/anomaly_detection_jobs';
import { ModelMemoryEstimateResponse } from '../calculate_model_memory_limit/calculate_model_memory_limit';
import type { IScopedClusterClient } from '@kbn/core/server';
import type { CombinedJob, Detector } from '../../../common/types/anomaly_detection_jobs';
import type { ModelMemoryEstimateResponse } from '../calculate_model_memory_limit/calculate_model_memory_limit';
import { validateModelMemoryLimit } from './validate_model_memory_limit';
import type { MlClient } from '../../lib/ml_client';

View file

@ -6,8 +6,8 @@
*/
import numeral from '@elastic/numeral';
import { IScopedClusterClient } from '@kbn/core/server';
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { IScopedClusterClient } from '@kbn/core/server';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import { validateJobObject } from './validate_job_object';
import { calculateModelMemoryLimitProvider } from '../calculate_model_memory_limit';
import { ALLOWED_DATA_UNITS } from '../../../common/constants/validation';

View file

@ -7,9 +7,9 @@
import { cloneDeep } from 'lodash';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import { isValidTimeField, validateTimeRange } from './validate_time_range';

View file

@ -5,10 +5,10 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import { ES_FIELD_TYPES } from '@kbn/field-types';
import { parseInterval } from '../../../common/util/parse_interval';
import { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import type { CombinedJob } from '../../../common/types/anomaly_detection_jobs';
import { validateJobObject } from './validate_job_object';
interface ValidateTimeRangeMessage {

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { MlFeatures } from '../../../common/constants/app';
import type { MLSavedObjectService } from '../../saved_objects';

View file

@ -46,15 +46,16 @@ import {
ML_MEDIAN_PERCENTS,
mlFunctionToESAggregation,
} from '../../../common/util/job_utils';
import { CriteriaField } from './results_service';
import type { CriteriaField } from './results_service';
import type { CombinedJob, Datafeed } from '../../shared';
import { parseInterval } from '../../../common/util/parse_interval';
import { getDatafeedAggregations } from '../../../common/util/datafeed_utils';
import { findAggField } from '../../../common/util/validation_utils';
import { CHART_TYPE, ChartType } from '../../../common/constants/charts';
import type { ChartType } from '../../../common/constants/charts';
import { CHART_TYPE } from '../../../common/constants/charts';
import { getChartType } from '../../../common/util/chart_utils';
import { MlJob } from '../..';
import type { MlJob } from '../..';
export function chartLimits(data: ChartPoint[] = []) {
const domain = extent(data, (d) => {

View file

@ -8,8 +8,8 @@
import Boom from '@hapi/boom';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { type MlPartitionFieldsType, ML_PARTITION_FIELDS } from '@kbn/ml-anomaly-utils';
import { CriteriaField } from './results_service';
import { FieldConfig, FieldsConfig } from '../../routes/schemas/results_service_schema';
import type { CriteriaField } from './results_service';
import type { FieldConfig, FieldsConfig } from '../../routes/schemas/results_service_schema';
import type { MlClient } from '../../lib/ml_client';
type SearchTerm =

View file

@ -9,7 +9,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { sortBy, slice, get, cloneDeep } from 'lodash';
import moment from 'moment';
import Boom from '@hapi/boom';
import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import {
showActualForFunction,
showTypicalForFunction,
@ -22,12 +22,12 @@ import {
import { buildAnomalyTableItems } from './build_anomaly_table_items';
import { ANOMALIES_TABLE_DEFAULT_QUERY_SIZE } from '../../../common/constants/search';
import { getPartitionFieldsValuesFactory } from './get_partition_fields_values';
import {
import type {
GetStoppedPartitionResult,
GetDatafeedResultsChartDataResult,
defaultSearchQuery,
DatafeedResultsChartDataParams,
} from '../../../common/types/results';
import { defaultSearchQuery } from '../../../common/types/results';
import type { MlClient } from '../../lib/ml_client';
import { datafeedsProvider } from '../job_service/datafeeds';
import { annotationServiceProvider } from '../annotation_service';