Skip to content

Commit

Permalink
[ML] File upload enable consistent-type-imports eslint rule (#212044)
Browse files Browse the repository at this point in the history
Enabling `consistent-type-imports` rule and running `node scripts/eslint
--no-cache --fix` to fix every type import.

Every other ML owned plugin has this rule enabled. Originally added in
#176921

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit b26d85b)

# Conflicts:
#	x-pack/platform/plugins/private/file_upload/common/types.ts
#	x-pack/platform/plugins/private/file_upload/server/get_time_field_range.ts
  • Loading branch information
jgowdyelastic committed Mar 4, 2025
1 parent 811a455 commit db8ae8d
Show file tree
Hide file tree
Showing 35 changed files with 78 additions and 69 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,7 @@ module.exports = {
'x-pack/platform/plugins/private/transform/**/*.{js,mjs,ts,tsx}',
'x-pack/platform/packages/shared/ml/**/*.{js,mjs,ts,tsx}',
'x-pack/platform/packages/private/ml/**/*.{js,mjs,ts,tsx}',
'x-pack/platform/plugins/private/file_upload/**/*.{js,mjs,ts,tsx}',
],
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
Expand Down
4 changes: 2 additions & 2 deletions x-pack/platform/plugins/private/file_upload/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/common';
import type { estypes } from '@elastic/elasticsearch';
import type { ES_FIELD_TYPES } from '@kbn/data-plugin/common';

export interface InputOverrides {
[key: string]: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import React from 'react';
import { EuiSkeletonText } from '@elastic/eui';
import { FileUploadComponentProps, lazyLoadModules } from '../lazy_load_bundle';
import type { FileUploadComponentProps } from '../lazy_load_bundle';
import { lazyLoadModules } from '../lazy_load_bundle';

interface State {
GeoUploadWizard: React.ComponentType<FileUploadComponentProps> | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React from 'react';
import { EuiSkeletonText } from '@elastic/eui';
import { lazyLoadModules } from '../lazy_load_bundle';
import { IndexNameFormProps } from '..';
import type { IndexNameFormProps } from '..';

interface State {
IndexNameForm: React.ComponentType<IndexNameFormProps> | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@
* 2.0.
*/

import React, { ChangeEvent, Component } from 'react';
import {
EuiForm,
EuiFormRow,
EuiSpacer,
EuiSelect,
EuiSwitch,
EuiSwitchEvent,
EuiToolTip,
} from '@elastic/eui';
import type { ChangeEvent } from 'react';
import React, { Component } from 'react';
import type { EuiSwitchEvent } from '@elastic/eui';
import { EuiForm, EuiFormRow, EuiSpacer, EuiSelect, EuiSwitch, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { GeoFilePicker, OnFileSelectParameters } from './geo_file_picker';
import type { OnFileSelectParameters } from './geo_file_picker';
import { GeoFilePicker } from './geo_file_picker';
import { IndexNameForm } from './index_name_form';
import { validateIndexName } from '../../validate_index_name';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

import _ from 'lodash';
import React, { ChangeEvent, Component } from 'react';
import type { ChangeEvent } from 'react';
import React, { Component } from 'react';
import { EuiFormRow, EuiFieldText, EuiCallOut, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { validateIndexName } from '../../validate_index_name';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { i18n } from '@kbn/i18n';
import { EuiProgress, EuiText } from '@elastic/eui';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { getDataViewsService } from '../kibana_services';
import { GeoUploadForm, OnFileSelectParameters } from './geo_upload_form';
import type { OnFileSelectParameters } from './geo_upload_form';
import { GeoUploadForm } from './geo_upload_form';
import { ImportCompleteView } from './import_complete_view';
import type { FileUploadComponentProps, FileUploadGeoResults } from '../lazy_load_bundle';
import { ImportResults } from '../importer';
import { GeoFileImporter } from '../importer/geo';
import type { ImportResults } from '../importer';
import type { GeoFileImporter } from '../importer/geo';
import { hasImportPermission } from '../api';
import { getPartialImportMessage } from './utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { CodeEditor } from '@kbn/code-editor';
import { getDocLinks, getHttp, getUiSettings, getSettings, getTheme } from '../kibana_services';
import { ImportResults } from '../importer';
import type { ImportResults } from '../importer';
import { getPartialImportMessage } from './utils';

const services = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* 2.0.
*/

import { ReactNode } from 'react';
import { Feature } from 'geojson';
import type { ReactNode } from 'react';
import type { Feature } from 'geojson';
import { i18n } from '@kbn/i18n';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { GeoFileImporter, GeoFilePreview } from './types';
import { CreateDocsResponse, ImportResults } from '../types';
import type { GeoFileImporter, GeoFilePreview } from './types';
import type { CreateDocsResponse, ImportResults } from '../types';
import { Importer, IMPORT_RETRIES, MAX_CHUNK_CHAR_COUNT } from '../importer';
import { MB } from '../../../common/constants';
import type { ImportDoc, ImportFailure, ImportResponse } from '../../../common/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { Feature } from 'geojson';
import type { Feature } from 'geojson';
import { createChunks, toEsDoc } from './create_chunks';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { Feature, Point } from 'geojson';
import type { Feature, Point } from 'geojson';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import type { ImportDoc } from '../../../common/types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { Feature } from 'geojson';
import type { Feature } from 'geojson';
import { i18n } from '@kbn/i18n';
import type { Batch } from '@loaders.gl/schema';
import { JSONLoader, type JSONLoaderOptions } from '@loaders.gl/json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { Feature } from 'geojson';
import type { Feature } from 'geojson';
import { _BrowserFileSystem as BrowserFileSystem, loadInBatches } from '@loaders.gl/core';
import { DBFLoader, ShapefileLoader } from '@loaders.gl/shapefile';
import type { ImportFailure } from '../../../../common/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* 2.0.
*/

import { Feature } from 'geojson';
import { ReactNode } from 'react';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { IImporter } from '../types';
import type { Feature } from 'geojson';
import type { ReactNode } from 'react';
import type { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import type { IImporter } from '../types';
import type { ImportFailure } from '../../../common/types';

export interface GeoFilePreview {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type {
IngestPipeline,
IngestPipelineWrapper,
} from '../../common/types';
import { CreateDocsResponse, IImporter, ImportResults } from './types';
import type { CreateDocsResponse, IImporter, ImportResults } from './types';
import { callImportRoute, callInitializeImportRoute } from './routes';

const CHUNK_SIZE = 5000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { MessageImporter } from './message_importer';
import { NdjsonImporter } from './ndjson_importer';
import { TikaImporter } from './tika_importer';
import { ImportFactoryOptions } from './types';
import type { ImportFactoryOptions } from './types';
import { FILE_FORMATS } from '../../common/constants';

export function importerFactory(format: string, options: ImportFactoryOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { Importer } from './importer';
import { CreateDocsResponse } from './types';
import type { CreateDocsResponse } from './types';

export class NdjsonImporter extends Importer {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import { fromByteArray } from 'base64-js';
import { ImportDocTika } from '../../common/types';
import type { ImportDocTika } from '../../common/types';
import { Importer } from './importer';
import { CreateDocsResponse } from './types';
import type { CreateDocsResponse } from './types';

export class TikaImporter extends Importer {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { CoreStart } from '@kbn/core/public';
import { FileUploadStartDependencies } from './plugin';
import type { CoreStart } from '@kbn/core/public';
import type { FileUploadStartDependencies } from './plugin';

let coreStart: CoreStart;
let pluginsStart: FileUploadStartDependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* 2.0.
*/

import React from 'react';
import { FeatureCollection } from 'geojson';
import { HttpStart } from '@kbn/core/public';
import { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import { IImporter, ImportFactoryOptions } from '../importer';
import type React from 'react';
import type { FeatureCollection } from 'geojson';
import type { HttpStart } from '@kbn/core/public';
import type { ES_FIELD_TYPES } from '@kbn/data-plugin/public';
import type { IImporter, ImportFactoryOptions } from '../importer';
import { getHttp } from '../kibana_services';
import { IndexNameFormProps } from '..';
import type { IndexNameFormProps } from '..';

export interface FileUploadGeoResults {
indexPatternId: string;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/platform/plugins/private/file_upload/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* 2.0.
*/

import { CoreStart, Plugin } from '@kbn/core/public';
import type { CoreStart, Plugin } from '@kbn/core/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { FileUploadStartApi } from './api';
import {
FileUploadStartApi,
FileUploadComponent,
importerFactory,
hasImportPermission,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { IScopedClusterClient } from '@kbn/core/server';
import type { IScopedClusterClient } from '@kbn/core/server';
import type {
AnalysisResult,
FormattedOverrides,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { setupCapabilities } from './capabilities';
import { coreMock, httpServerMock } from '@kbn/core/server/mocks';
import { Capabilities, CoreStart } from '@kbn/core/server';
import type { Capabilities, CoreStart } from '@kbn/core/server';
import { securityMock } from '@kbn/security-plugin/server/mocks';

describe('setupCapabilities', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { CoreSetup } from '@kbn/core/server';
import type { CoreSetup } from '@kbn/core/server';
import { checkFileUploadPrivileges } from './check_privileges';
import { StartDeps } from './types';
import type { StartDeps } from './types';

export const setupCapabilities = (
core: Pick<CoreSetup<StartDeps>, 'capabilities' | 'getStartServices'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
* 2.0.
*/

import { KibanaRequest } from '@kbn/core/server';
import { AuthorizationServiceSetup, CheckPrivilegesPayload } from '@kbn/security-plugin/server';
import type { KibanaRequest } from '@kbn/core/server';
import type {
AuthorizationServiceSetup,
CheckPrivilegesPayload,
} from '@kbn/security-plugin/server';

interface Deps {
request: KibanaRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { boomify, isBoom } from '@hapi/boom';
import { ResponseError, CustomHttpResponseOptions } from '@kbn/core/server';
import type { ResponseError, CustomHttpResponseOptions } from '@kbn/core/server';

export function wrapError(error: any): CustomHttpResponseOptions<ResponseError> {
const boom = isBoom(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { IScopedClusterClient } from '@kbn/core/server';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import type { IScopedClusterClient } from '@kbn/core/server';
import type { estypes } from '@elastic/elasticsearch';
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import { isPopulatedObject } from '@kbn/ml-is-populated-object';

export async function getTimeFieldRange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { PluginInitializerContext } from '@kbn/core/server';
import type { PluginInitializerContext } from '@kbn/core/server';

export const plugin = async (initializerContext: PluginInitializerContext) => {
const { FileUploadPlugin } = await import('./plugin');
Expand Down
10 changes: 8 additions & 2 deletions x-pack/platform/plugins/private/file_upload/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
*/

import { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from '@kbn/core/server';
import type {
CoreSetup,
CoreStart,
Logger,
Plugin,
PluginInitializerContext,
} from '@kbn/core/server';
import { schema } from '@kbn/config-schema';
import { fileUploadRoutes } from './routes';
import { initFileUploadTelemetry } from './telemetry';
import { MAX_FILE_SIZE, UI_SETTING_MAX_FILE_SIZE } from '../common/constants';
import { setupCapabilities } from './capabilities';
import { StartDeps, SetupDeps } from './types';
import type { StartDeps, SetupDeps } from './types';

export class FileUploadPlugin implements Plugin {
private readonly _logger: Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type { StartDeps } from './types';
import { checkFileUploadPrivileges } from './check_privileges';
import { previewIndexTimeRange } from './preview_index_time_range';
import { previewTikaContents } from './preview_tika_contents';
import { IngestPipelineWrapper } from '../common/types';
import type { IngestPipelineWrapper } from '../common/types';

/**
* Routes for the file upload.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SavedObjectsServiceStart, ISavedObjectsRepository } from '@kbn/core/server';
import type { SavedObjectsServiceStart, ISavedObjectsRepository } from '@kbn/core/server';

let internalRepository: ISavedObjectsRepository | null = null;
export const setInternalRepository = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { SavedObjectsType } from '@kbn/core/server';
import type { SavedObjectsType } from '@kbn/core/server';
import { TELEMETRY_DOC_ID } from './telemetry';

export const telemetryMappingsType: SavedObjectsType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { isEmpty } from 'lodash';
import { ISavedObjectsRepository } from '@kbn/core/server';
import type { ISavedObjectsRepository } from '@kbn/core/server';

import { getInternalRepository } from './internal_repository';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* 2.0.
*/

import { CoreSetup } from '@kbn/core/server';
import type { CoreSetup } from '@kbn/core/server';

import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server';
import { getTelemetry, initTelemetry, Telemetry } from './telemetry';
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/server';
import type { Telemetry } from './telemetry';
import { getTelemetry, initTelemetry } from './telemetry';
import { telemetryMappingsType } from './mappings';
import { getInternalRepository, setInternalRepository } from './internal_repository';

Expand Down
Loading

0 comments on commit db8ae8d

Please sign in to comment.