Skip to content

Commit

Permalink
Add eslint rule to enforce/autofix import group order
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz committed Mar 2, 2021
1 parent cce6861 commit f9be98d
Show file tree
Hide file tree
Showing 99 changed files with 196 additions and 179 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,21 @@ module.exports = {
},
},

/**
* Fleet overrides
*/
{
files: ['x-pack/plugins/fleet/**/*.{js,mjs,ts,tsx}'],
rules: {
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', 'parent'],
},
],
},
},

/**
* Security Solution overrides
*/
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/constants/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { defaultPackages } from './epm';
import { AgentPolicy } from '../types';
import { defaultPackages } from './epm';
export const AGENT_POLICY_SAVED_OBJECT_TYPE = 'ingest-agent-policies';
export const AGENT_POLICY_INDEX = '.fleet-policies';
export const agentPolicyStatuses = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { isAgentUpgradeable } from './is_agent_upgradeable';
import { Agent } from '../types/models/agent';
import { isAgentUpgradeable } from './is_agent_upgradeable';

const getAgent = ({
version,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { FullAgentPolicy } from './agent_policy';
import { AGENT_TYPE_EPHEMERAL, AGENT_TYPE_PERMANENT, AGENT_TYPE_TEMPORARY } from '../../constants';
import { FullAgentPolicy } from './agent_policy';

export type AgentType =
| typeof AGENT_TYPE_EPHEMERAL
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/fleet/public/applications/fleet/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import styled from 'styled-components';
import useObservable from 'react-use/lib/useObservable';
import { FleetConfigType, FleetStartServices } from '../../plugin';
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
import { EuiThemeProvider } from '../../../../../../src/plugins/kibana_react/common';
import {
ConfigContext,
FleetStatusProvider,
Expand All @@ -34,10 +37,7 @@ import { DataStreamApp } from './sections/data_stream';
import { FleetApp } from './sections/agents';
import { IngestManagerOverview } from './sections/overview';
import { ProtectedRoute } from './index';
import { FleetConfigType, FleetStartServices } from '../../plugin';
import { UIExtensionsStorage } from './types';
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
import { EuiThemeProvider } from '../../../../../../src/plugins/kibana_react/common';
import { UIExtensionsContext } from './hooks/use_ui_extension';

const ErrorLayout = ({ children }: { children: JSX.Element }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import React, { useState, useContext, useEffect } from 'react';
import { GetFleetStatusResponse } from '../types';
import { useConfig } from './use_config';
import { sendGetFleetStatus } from './use_request';
import { GetFleetStatusResponse } from '../types';

interface FleetStatusState {
enabled: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
* 2.0.
*/

import {
useRequest,
sendRequest,
useConditionalRequest,
SendConditionalRequestConfig,
} from './use_request';
import { agentPolicyRouteService } from '../../services';
import {
GetAgentPoliciesRequest,
Expand All @@ -26,6 +20,12 @@ import {
DeleteAgentPolicyRequest,
DeleteAgentPolicyResponse,
} from '../../types';
import {
useRequest,
sendRequest,
useConditionalRequest,
SendConditionalRequestConfig,
} from './use_request';

export const useGetAgentPolicies = (query?: GetAgentPoliciesRequest['query']) => {
return useRequest<GetAgentPoliciesResponse>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import { useRequest, UseRequestConfig, sendRequest } from './use_request';
import { agentRouteService } from '../../services';
import {
GetOneAgentResponse,
Expand All @@ -30,6 +29,7 @@ import {
PostNewAgentActionRequest,
PostNewAgentActionResponse,
} from '../../types';
import { useRequest, UseRequestConfig, sendRequest } from './use_request';

type RequestOptions = Pick<Partial<UseRequestConfig>, 'pollIntervalMs'>;

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

import { sendRequest } from './use_request';
import { appRoutesService } from '../../services';
import { CheckPermissionsResponse } from '../../types';
import { sendRequest } from './use_request';

export const sendGetPermissionsCheck = () => {
return sendRequest<CheckPermissionsResponse>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { useRequest } from './use_request';
import { dataStreamRouteService } from '../../services';
import { GetDataStreamsResponse } from '../../types';
import { useRequest } from './use_request';

export const useGetDataStreams = () => {
return useRequest<GetDataStreamsResponse>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
* 2.0.
*/

import { enrollmentAPIKeyRouteService } from '../../services';
import {
GetOneEnrollmentAPIKeyResponse,
GetEnrollmentAPIKeysResponse,
GetEnrollmentAPIKeysRequest,
} from '../../types';
import {
useRequest,
UseRequestConfig,
sendRequest,
useConditionalRequest,
SendConditionalRequestConfig,
} from './use_request';
import { enrollmentAPIKeyRouteService } from '../../services';
import {
GetOneEnrollmentAPIKeyResponse,
GetEnrollmentAPIKeysResponse,
GetEnrollmentAPIKeysRequest,
} from '../../types';

type RequestOptions = Pick<Partial<UseRequestConfig>, 'pollIntervalMs'>;

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

import { useRequest, sendRequest } from './use_request';
import { epmRouteService } from '../../services';
import {
GetCategoriesRequest,
Expand All @@ -18,6 +17,7 @@ import {
DeletePackageResponse,
} from '../../types';
import { GetStatsResponse } from '../../../../../common';
import { useRequest, sendRequest } from './use_request';

export const useGetCategories = (query: GetCategoriesRequest['query'] = {}) => {
return useRequest<GetCategoriesResponse>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { sendRequest, useRequest } from './use_request';
import { outputRoutesService } from '../../services';
import { PutOutputRequest, GetOutputsResponse } from '../../types';
import { sendRequest, useRequest } from './use_request';

export function useGetOutputs() {
return useRequest<GetOutputsResponse>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import { sendRequest, useRequest } from './use_request';
import { packagePolicyRouteService } from '../../services';
import {
CreatePackagePolicyRequest,
Expand All @@ -20,6 +19,7 @@ import {
GetPackagePoliciesResponse,
GetOnePackagePolicyResponse,
} from '../../../../../common/types/rest_spec';
import { sendRequest, useRequest } from './use_request';

export const sendCreatePackagePolicy = (body: CreatePackagePolicyRequest['body']) => {
return sendRequest<CreatePackagePolicyResponse>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { sendRequest, useRequest } from './use_request';
import { settingsRoutesService } from '../../services';
import { PutSettingsResponse, PutSettingsRequest, GetSettingsResponse } from '../../types';
import { sendRequest, useRequest } from './use_request';

export function useGetSettings() {
return useRequest<GetSettingsResponse>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { sendRequest } from './use_request';
import { setupRouteService, fleetSetupRouteService } from '../../services';
import { GetFleetStatusResponse } from '../../types';
import { sendRequest } from './use_request';

export const sendSetup = () => {
return sendRequest({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { render as reactRender, RenderOptions, RenderResult, act } from '@testin
import { ScopedHistory } from '../../../../../../../src/core/public';
import { FleetAppContext } from '../app';
import { FleetConfigType } from '../../../plugin';
import { createConfigurationMock } from './plugin_configuration';
import { UIExtensionsStorage } from '../types';
import { createConfigurationMock } from './plugin_configuration';
import { createStartMock } from './plugin_interfaces';
import { createStartServices } from './fleet_start_services';
import { MockedFleetStart, MockedFleetStartServices } from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import React from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { MockedKeys } from '@kbn/utility-types/jest';
import { coreMock } from '../../../../../../../src/core/public/mocks';
import { createStartDepsMock } from './plugin_dependencies';
import { IStorage, Storage } from '../../../../../../../src/plugins/kibana_utils/public';
import { setHttpClient } from '../hooks/use_request';
import { createStartDepsMock } from './plugin_dependencies';
import { MockedFleetStartServices } from './types';

// Taken from core. See: src/plugins/kibana_utils/public/storage/storage.test.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* 2.0.
*/

import { createTestRendererMock, MockedFleetStartServices, TestRenderer } from '../../../mock';
import { PAGE_ROUTING_PATHS, pagePathGetters, PLUGIN_ID } from '../../../constants';
import { Route } from 'react-router-dom';
import { CreatePackagePolicyPage } from './index';
import React from 'react';
import { CreatePackagePolicyRouteState } from '../../../types';
import { act } from 'react-test-renderer';
import { createTestRendererMock, MockedFleetStartServices, TestRenderer } from '../../../mock';
import { PAGE_ROUTING_PATHS, pagePathGetters, PLUGIN_ID } from '../../../constants';
import { CreatePackagePolicyRouteState } from '../../../types';
import { CreatePackagePolicyPage } from './index';

describe('when on the package policy create page', () => {
const createPageUrlPath = pagePathGetters.add_integration_to_policy({ pkgkey: 'nginx-0.3.7' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ import {
} from '../../../hooks';
import { Loading } from '../../../components';
import { ConfirmDeployAgentPolicyModal } from '../components';
import { useIntraAppState } from '../../../hooks/use_intra_app_state';
import { useUIExtension } from '../../../hooks/use_ui_extension';
import { ExtensionWrapper } from '../../../components/extension_wrapper';
import { PackagePolicyEditExtensionComponentProps } from '../../../types';
import { PLUGIN_ID } from '../../../../../../common/constants';
import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info';
import { CreatePackagePolicyPageLayout } from './components';
import { CreatePackagePolicyFrom, PackagePolicyFormState } from './types';
import {
Expand All @@ -48,12 +54,6 @@ import { StepSelectPackage } from './step_select_package';
import { StepSelectAgentPolicy } from './step_select_agent_policy';
import { StepConfigurePackagePolicy } from './step_configure_package';
import { StepDefinePackagePolicy } from './step_define_package_policy';
import { useIntraAppState } from '../../../hooks/use_intra_app_state';
import { useUIExtension } from '../../../hooks/use_ui_extension';
import { ExtensionWrapper } from '../../../components/extension_wrapper';
import { PackagePolicyEditExtensionComponentProps } from '../../../types';
import { PLUGIN_ID } from '../../../../../../common/constants';
import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info';

const StepsWithLessPadding = styled(EuiSteps)`
.euiStep__content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
import { AgentPolicy, PackageInfo, PackagePolicy, NewPackagePolicy } from '../../../types';
import { packageToPackagePolicyInputs } from '../../../services';
import { Loading } from '../../../components';
import { PackagePolicyValidationResults } from './services';
import { pkgKeyFromPackageInfo } from '../../../services/pkg_key_from_package_info';
import { PackagePolicyValidationResults } from './services';

export const StepDefinePackagePolicy: React.FunctionComponent<{
agentPolicy: AgentPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import {
} from '../../../hooks';
import { Loading, Error } from '../../../components';
import { WithHeaderLayout } from '../../../layouts';
import { AgentPolicyRefreshContext, useGetAgentStatus, AgentStatusRefreshContext } from './hooks';
import { LinkedAgentCount, AgentPolicyActionMenu } from '../components';
import { PackagePoliciesView, SettingsView } from './components';
import { useIntraAppState } from '../../../hooks/use_intra_app_state';
import { AgentPolicyRefreshContext, useGetAgentStatus, AgentStatusRefreshContext } from './hooks';
import { PackagePoliciesView, SettingsView } from './components';

const Divider = styled.div`
width: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import url from 'url';
import React, { memo, useMemo, useState, useCallback, useEffect } from 'react';
import styled from 'styled-components';
import url from 'url';
import { encode } from 'rison-node';
import { stringify } from 'query-string';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import React, { memo, useState, useEffect } from 'react';
import { EuiPopover, EuiFilterButton, EuiFilterSelectItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { ORDERED_FILTER_LOG_LEVELS, AGENT_LOG_INDEX_PATTERN, LOG_LEVEL_FIELD } from './constants';
import { useStartServices } from '../../../../../hooks';
import { ORDERED_FILTER_LOG_LEVELS, AGENT_LOG_INDEX_PATTERN, LOG_LEVEL_FIELD } from './constants';

function sortLogLevels(levels: string[]): string[] {
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import {
} from '../../../hooks';
import { WithHeaderLayout } from '../../../layouts';
import { AgentHealth } from '../components';
import { AgentRefreshContext } from './hooks';
import { AgentLogs, AgentDetailsActionMenu, AgentDetailsContent } from './components';
import { useIntraAppState } from '../../../hooks/use_intra_app_state';
import { isAgentUpgradeable } from '../../../services';
import { AgentRefreshContext } from './hooks';
import { AgentLogs, AgentDetailsActionMenu, AgentDetailsContent } from './components';

export const AgentDetailsPage: React.FunctionComponent = () => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { AgentPolicy } from '../../../../types';
import { useStartServices, useLink, sendGetOneAgentPolicyFull } from '../../../../hooks';
import { DownloadStep, AgentPolicySelectionStep } from './steps';
import { fullAgentPolicyToYaml, agentPolicyRouteService } from '../../../../services';
import { DownloadStep, AgentPolicySelectionStep } from './steps';

interface Props {
agentPolicies?: AgentPolicy[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import React from 'react';
import { EuiText, EuiButton, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { EnrollmentStepAgentPolicy } from './agent_policy_selection';
import { AgentPolicy } from '../../../../types';
import { EnrollmentStepAgentPolicy } from './agent_policy_selection';

export const DownloadStep = () => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
import { PAGE_ROUTING_PATHS } from '../../constants';
import { Loading, Error } from '../../components';
import { useConfig, useFleetStatus, useBreadcrumbs, useCapabilities } from '../../hooks';
import { WithoutHeaderLayout } from '../../layouts';
import { AgentListPage } from './agent_list_page';
import { SetupPage } from './setup_page';
import { AgentDetailsPage } from './agent_details_page';
import { NoAccessPage } from './error_pages/no_access';
import { EnrollmentTokenListPage } from './enrollment_token_list_page';
import { ListLayout } from './components/list_layout';
import { WithoutHeaderLayout } from '../../layouts';

export const FleetApp: React.FunctionComponent = () => {
useBreadcrumbs('fleet');
Expand Down
Loading

0 comments on commit f9be98d

Please sign in to comment.