mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[eslint] Prevents importing of public code into server (#67149)
We should not be allowing importing of public into server. Any shared code should reside in a common directory. After #66506, this will not even be possible as we will no longer be transpiling public code into commonjs. Blocks #66506 Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
3b4fa6ade6
commit
8a5a7c3032
26 changed files with 88 additions and 54 deletions
|
@ -197,9 +197,12 @@ module.exports = {
|
|||
errorMessage: `Plugins may only import from src/core/server and src/core/public.`,
|
||||
},
|
||||
{
|
||||
target: ['(src|x-pack)/plugins/*/public/**/*'],
|
||||
from: ['(src|x-pack)/plugins/*/server/**/*'],
|
||||
errorMessage: `Public code can not import from server, use a common directory.`,
|
||||
target: [
|
||||
'(src|x-pack)/plugins/*/server/**/*',
|
||||
'!x-pack/plugins/apm/**/*', // https://github.com/elastic/kibana/issues/67210
|
||||
],
|
||||
from: ['(src|x-pack)/plugins/*/public/**/*'],
|
||||
errorMessage: `Server code can not import from public, use a common directory.`,
|
||||
},
|
||||
{
|
||||
target: ['(src|x-pack)/plugins/*/common/**/*'],
|
||||
|
|
|
@ -308,7 +308,7 @@ export function getCurrentMethodAndTokenPaths(
|
|||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
export default function({ coreEditor: editor, parser }: { coreEditor: CoreEditor; parser: any }) {
|
||||
export default function ({ coreEditor: editor, parser }: { coreEditor: CoreEditor; parser: any }) {
|
||||
function isUrlPathToken(token: Token | null) {
|
||||
switch ((token || ({} as any)).type) {
|
||||
case 'url.slash':
|
||||
|
|
20
src/plugins/es_ui_shared/common/index.ts
Normal file
20
src/plugins/es_ui_shared/common/index.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export { Privileges, MissingPrivileges } from '../__packages_do_not_import__/authorization';
|
|
@ -17,4 +17,14 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export * from '../../__packages_do_not_import__/authorization';
|
||||
export {
|
||||
AuthorizationContext,
|
||||
AuthorizationProvider,
|
||||
Error,
|
||||
MissingPrivileges,
|
||||
NotAuthorizedSection,
|
||||
Privileges,
|
||||
SectionError,
|
||||
useAuthorizationContext,
|
||||
WithPrivileges,
|
||||
} from '../../__packages_do_not_import__/authorization';
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import { savedObjectsRepositoryMock } from '../../../../core/server/mocks';
|
||||
import { storeReport } from './store_report';
|
||||
import { ReportSchemaType } from './schema';
|
||||
import { METRIC_TYPE } from '../../public';
|
||||
import { METRIC_TYPE } from '@kbn/analytics';
|
||||
|
||||
describe('store_report', () => {
|
||||
test('stores report for all types of data', async () => {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { taskManagerMock } from '../../task_manager/server/task_manager.mock';
|
|||
import { KibanaRequest } from '../../../../src/core/server';
|
||||
import { loggingServiceMock, savedObjectsClientMock } from '../../../../src/core/server/mocks';
|
||||
import { encryptedSavedObjectsMock } from '../../encrypted_saved_objects/server/mocks';
|
||||
import { AuthenticatedUser } from '../../security/public';
|
||||
import { AuthenticatedUser } from '../../../plugins/security/common/model';
|
||||
import { securityMock } from '../../security/server/mocks';
|
||||
import { actionsMock } from '../../actions/server/mocks';
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { SavedObjectsErrorHelpers } from '../../../../../../src/core/server';
|
||||
import { apmIndexPattern } from '../../../../../../src/plugins/apm_oss/server';
|
||||
import { APM_STATIC_INDEX_PATTERN_ID } from '../../../../../../src/plugins/apm_oss/server';
|
||||
import {
|
||||
apmIndexPattern,
|
||||
APM_STATIC_INDEX_PATTERN_ID,
|
||||
} from '../../../../../../src/plugins/apm_oss/server';
|
||||
import { hasHistoricalAgentData } from '../services/get_services/has_historical_agent_data';
|
||||
import { Setup } from '../helpers/setup_request';
|
||||
import { APMRequestHandlerContext } from '../../routes/typings';
|
||||
|
|
|
@ -127,17 +127,19 @@ export class EmbeddableEnhancedPlugin
|
|||
});
|
||||
|
||||
dynamicActions.start().catch((error) => {
|
||||
/* eslint-disable */
|
||||
console.log('Failed to start embeddable dynamic actions', embeddable);
|
||||
console.error(error);
|
||||
/* eslint-disable */
|
||||
|
||||
console.log('Failed to start embeddable dynamic actions', embeddable);
|
||||
console.error(error);
|
||||
/* eslint-enable */
|
||||
});
|
||||
|
||||
const stop = () => {
|
||||
dynamicActions.stop().catch((error) => {
|
||||
/* eslint-disable */
|
||||
console.log('Failed to stop embeddable dynamic actions', embeddable);
|
||||
console.error(error);
|
||||
/* eslint-disable */
|
||||
|
||||
console.log('Failed to stop embeddable dynamic actions', embeddable);
|
||||
console.error(error);
|
||||
/* eslint-enable */
|
||||
});
|
||||
};
|
||||
|
|
|
@ -7,11 +7,18 @@ import { useKibana as _useKibana } from '../../../../src/plugins/kibana_react/pu
|
|||
import { AppServices } from './application';
|
||||
|
||||
export {
|
||||
AuthorizationProvider,
|
||||
Error,
|
||||
NotAuthorizedSection,
|
||||
SectionError,
|
||||
SectionLoading,
|
||||
sendRequest,
|
||||
SendRequestConfig,
|
||||
SendRequestResponse,
|
||||
UseRequestConfig,
|
||||
sendRequest,
|
||||
useAuthorizationContext,
|
||||
useRequest,
|
||||
UseRequestConfig,
|
||||
WithPrivileges,
|
||||
} from '../../../../src/plugins/es_ui_shared/public/';
|
||||
|
||||
export {
|
||||
|
@ -41,14 +48,4 @@ export {
|
|||
isEmptyString,
|
||||
} from '../../../../src/plugins/es_ui_shared/static/validators/string';
|
||||
|
||||
export {
|
||||
SectionLoading,
|
||||
WithPrivileges,
|
||||
AuthorizationProvider,
|
||||
SectionError,
|
||||
Error,
|
||||
useAuthorizationContext,
|
||||
NotAuthorizedSection,
|
||||
} from '../../../../src/plugins/es_ui_shared/public';
|
||||
|
||||
export const useKibana = () => _useKibana<AppServices>();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { RouteDependencies } from '../../types';
|
||||
import { API_BASE_PATH, APP_CLUSTER_REQUIRED_PRIVILEGES } from '../../../common/constants';
|
||||
import { Privileges } from '../../../../../../src/plugins/es_ui_shared/public';
|
||||
import { Privileges } from '../../../../../../src/plugins/es_ui_shared/common';
|
||||
|
||||
const extractMissingPrivileges = (privilegesObject: { [key: string]: boolean } = {}): string[] =>
|
||||
Object.keys(privilegesObject).reduce((privileges: string[], privilegeName: string): string[] => {
|
||||
|
|
|
@ -45,7 +45,8 @@ export const startBasicLicense = (currentLicenseType, ack) => async (
|
|||
'xpack.licenseMgmt.replacingCurrentLicenseWithBasicLicenseWarningMessage',
|
||||
{
|
||||
//eslint-disable-next-line
|
||||
defaultMessage: 'Some functionality will be lost if you replace your {currentLicenseType} license with a BASIC license. Review the list of features below.',
|
||||
defaultMessage:
|
||||
'Some functionality will be lost if you replace your {currentLicenseType} license with a BASIC license. Review the list of features below.',
|
||||
values: {
|
||||
currentLicenseType: currentLicenseType.toUpperCase(),
|
||||
},
|
||||
|
|
|
@ -23,7 +23,8 @@ import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/s
|
|||
import { emsBoundariesSpecProvider } from './tutorials/ems';
|
||||
// @ts-ignore
|
||||
import { initRoutes } from './routes';
|
||||
import { ILicense, LicensingPluginSetup } from '../../licensing/public';
|
||||
import { ILicense } from '../../licensing/common/types';
|
||||
import { LicensingPluginSetup } from '../../licensing/server';
|
||||
import { HomeServerPluginSetup } from '../../../../src/plugins/home/server';
|
||||
|
||||
interface SetupDeps {
|
||||
|
|
|
@ -221,7 +221,7 @@ export const queryTimelineById = <TCache>({
|
|||
variables: { id: timelineId },
|
||||
})
|
||||
// eslint-disable-next-line
|
||||
.then(result => {
|
||||
.then((result) => {
|
||||
const timelineToOpen: TimelineResult = omitTypenameInTimeline(
|
||||
getOr({}, 'data.getOneTimeline', result)
|
||||
);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { SearchResponse } from 'elasticsearch';
|
||||
import { IScopedClusterClient } from 'kibana/server';
|
||||
import { AlertEvent } from '../../../../../common/endpoint/types';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';
|
||||
import { esQuery } from '../../../../../../../../src/plugins/data/server';
|
||||
import {
|
||||
AlertAPIOrdering,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { SearchResponse } from 'elasticsearch';
|
||||
import { IScopedClusterClient } from 'kibana/server';
|
||||
import { ResolverEvent } from '../../../../../common/endpoint/types';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';
|
||||
import { legacyEventIndexPattern } from './legacy_event_index_pattern';
|
||||
import { MSearchQuery } from './multi_searcher';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { SearchResponse } from 'elasticsearch';
|
|||
import { ResolverEvent } from '../../../../../common/endpoint/types';
|
||||
import { ResolverQuery } from './base';
|
||||
import { PaginationBuilder, PaginatedResults } from '../utils/pagination';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';
|
||||
|
||||
/**
|
||||
* Builds a query for retrieving descendants of a node.
|
||||
|
|
|
@ -7,7 +7,7 @@ import { SearchResponse } from 'elasticsearch';
|
|||
import { ResolverEvent } from '../../../../../common/endpoint/types';
|
||||
import { ResolverQuery } from './base';
|
||||
import { PaginationBuilder, PaginatedResults } from '../utils/pagination';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';
|
||||
|
||||
/**
|
||||
* Builds a query for retrieving related events for a node.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { SearchResponse } from 'elasticsearch';
|
||||
import { ResolverQuery } from './base';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';
|
||||
import { ResolverEvent } from '../../../../../common/endpoint/types';
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { IScopedClusterClient } from 'kibana/server';
|
||||
import { MSearchResponse } from 'elasticsearch';
|
||||
import { ResolverEvent } from '../../../../../common/endpoint/types';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';
|
||||
|
||||
/**
|
||||
* Contract for queries to be compatible with ES multi search api
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { SearchResponse } from 'elasticsearch';
|
||||
import { ResolverQuery } from './base';
|
||||
import { ResolverEvent, EventStats } from '../../../../../common/endpoint/types';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';
|
||||
import { AggBucket } from '../utils/pagination';
|
||||
|
||||
export interface StatsResult {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { ResolverEvent } from '../../../../../common/endpoint/types';
|
||||
import { eventId } from '../../../../../common/endpoint/models/event';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../../../../src/plugins/kibana_utils/common';
|
||||
|
||||
/**
|
||||
* Represents a single result bucket of an aggregation
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { AuthenticatedUser } from '../../../security/public';
|
||||
import { AuthenticatedUser } from '../../../security/common/model';
|
||||
import { RequestHandlerContext } from '../../../../../src/core/server';
|
||||
export { ConfigType as Configuration } from '../config';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { UserInputError } from 'apollo-server-errors';
|
||||
import { isEmpty, isPlainObject, isString } from 'lodash/fp';
|
||||
|
||||
import { JsonObject } from '../../../../../src/plugins/kibana_utils/public';
|
||||
import { JsonObject } from '../../../../../src/plugins/kibana_utils/common';
|
||||
|
||||
export const parseFilterQuery = (filterQuery: string): JsonObject => {
|
||||
try {
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
*/
|
||||
|
||||
export {
|
||||
SendRequestConfig,
|
||||
SendRequestResponse,
|
||||
UseRequestConfig,
|
||||
sendRequest,
|
||||
useRequest,
|
||||
AuthorizationProvider,
|
||||
CronEditor,
|
||||
DAY,
|
||||
SectionError,
|
||||
Error,
|
||||
WithPrivileges,
|
||||
useAuthorizationContext,
|
||||
NotAuthorizedSection,
|
||||
AuthorizationProvider,
|
||||
SectionError,
|
||||
sendRequest,
|
||||
SendRequestConfig,
|
||||
SendRequestResponse,
|
||||
useAuthorizationContext,
|
||||
useRequest,
|
||||
UseRequestConfig,
|
||||
WithPrivileges,
|
||||
} from '../../../../src/plugins/es_ui_shared/public';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { Privileges } from '../../../../../../src/plugins/es_ui_shared/public';
|
||||
import { Privileges } from '../../../../../../src/plugins/es_ui_shared/common';
|
||||
|
||||
import {
|
||||
APP_REQUIRED_CLUSTER_PRIVILEGES,
|
||||
|
|
|
@ -13,9 +13,7 @@ import { mount } from 'enzyme';
|
|||
import { TimeRangeEmbeddable, TimeRangeContainer, TIME_RANGE_EMBEDDABLE } from './test_helpers';
|
||||
import { CustomTimeRangeAction } from './custom_time_range_action';
|
||||
/* eslint-disable */
|
||||
import {
|
||||
HelloWorldContainer,
|
||||
} from '../../../../src/plugins/embeddable/public/lib/test_samples';
|
||||
import { HelloWorldContainer } from '../../../../src/plugins/embeddable/public/lib/test_samples';
|
||||
/* eslint-enable */
|
||||
|
||||
import {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue