Skip to content

Commit

Permalink
ESLint rules for Spaces and Security (elastic#93644)
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner authored and kibanamachine committed Mar 4, 2021
1 parent f48a962 commit c6c5430
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 40 deletions.
49 changes: 49 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,55 @@ module.exports = {
},
},

/**
* Platform Security Team overrides
*/
{
files: [
'src/plugins/security_oss/**/*.{js,mjs,ts,tsx}',
'src/plugins/spaces_oss/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/encrypted_saved_objects/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/security/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/spaces/**/*.{js,mjs,ts,tsx}',
],
rules: {
'@typescript-eslint/consistent-type-imports': 1,
'import/order': [
// This rule sorts import declarations
'error',
{
groups: [
'unknown',
['builtin', 'external'],
'internal',
['parent', 'sibling', 'index'],
],
pathGroups: [
{
pattern: '{@kbn/**,src/**,kibana{,/**}}',
group: 'internal',
},
],
pathGroupsExcludedImportTypes: [],
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
'newlines-between': 'always',
},
],
'import/no-duplicates': ['error'],
'sort-imports': [
// This rule sorts imports of multiple members (destructured imports)
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
},
},

{
files: [
// core-team owned code
Expand Down
5 changes: 0 additions & 5 deletions src/plugins/security_oss/.eslintrc.json

This file was deleted.

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

import { nextTick } from '@kbn/test/jest';

import { coreMock } from 'src/core/public/mocks';

import { mockAppStateService } from '../app_state/app_state_service.mock';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { distinctUntilChanged, map } from 'rxjs/operators';

import type { CoreSetup, CoreStart, MountPoint, Toast } from 'src/core/public';

import type { ConfigType } from '../config';
import type { AppStateServiceStart } from '../app_state';
import type { ConfigType } from '../config';
import { defaultAlertText, defaultAlertTitle } from './components';

interface SetupDeps {
Expand Down
5 changes: 0 additions & 5 deletions src/plugins/spaces_oss/.eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/plugins/spaces_oss/public/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Side Public License, v 1.
*/

import type { Observable } from 'rxjs';
import type { ReactElement } from 'react';
import type { Observable } from 'rxjs';

import type { Space } from '../common';

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/spaces_oss/public/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
* Side Public License, v 1.
*/

import { spacesApiMock } from '../api.mock';

import type { SpacesOssPluginSetup, SpacesOssPluginStart } from '../';
import { spacesApiMock } from '../api.mock';

const createSetupContract = (): jest.Mocked<SpacesOssPluginSetup> => ({
registerSpacesApi: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/spaces_oss/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import type { Plugin } from 'src/core/public';

import type { SpacesOssPluginSetup, SpacesOssPluginStart } from './types';
import type { SpacesApi } from './api';
import type { SpacesOssPluginSetup, SpacesOssPluginStart } from './types';

export class SpacesOssPlugin implements Plugin<SpacesOssPluginSetup, SpacesOssPluginStart, {}, {}> {
private api?: SpacesApi;
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/encrypted_saved_objects/.eslintrc.json

This file was deleted.

5 changes: 0 additions & 5 deletions x-pack/plugins/security/.eslintrc.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ import type {
RoleIndexPrivilege,
} from '../../../../common/model';
import {
copyRole,
getExtendedRoleDeprecationNotice,
isRoleDeprecated as checkIfRoleDeprecated,
isRoleReadOnly as checkIfRoleReadOnly,
isRoleReserved as checkIfRoleReserved,
copyRole,
getExtendedRoleDeprecationNotice,
prepareRoleClone,
} from '../../../../common/model';
import type { UserAPIClient } from '../../users';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { nextTick } from '@kbn/test/jest';
import { coreMock, elasticsearchServiceMock, loggingSystemMock } from 'src/core/server/mocks';

// Note: this import must be before other relative imports for the mocks to work as intended.
// eslint-disable-next-line import/order
import {
mockAuthorizationModeFactory,
mockCheckPrivilegesDynamicallyWithRequestFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import { uniq } from 'lodash';

import type {
KibanaFeature,
PluginSetupContract as FeaturesPluginSetup,
KibanaFeature,
} from '../../../../features/server';
import type { SecurityLicense } from '../../../common/licensing';
import type { RawKibanaPrivileges } from '../../../common/model';
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/spaces/.eslintrc.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import type { ProcessedImportResponse } from 'src/plugins/saved_objects_manageme
import type { Space } from 'src/plugins/spaces_oss/common';

import { processImportResponse } from '../../../../../../src/plugins/saved_objects_management/public';
import { useSpaces } from '../../spaces_context';
import type { CopyOptions, ImportRetry, SavedObjectTarget } from '../types';
import { CopyToSpaceFlyoutFooter } from './copy_to_space_flyout_footer';
import { CopyToSpaceForm } from './copy_to_space_form';
import { ProcessingCopyToSpace } from './processing_copy_to_space';
import { useSpaces } from '../../spaces_context';

export interface CopyToSpaceFlyoutProps {
onClose: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type {
SavedObjectsManagementRecord,
} from 'src/plugins/saved_objects_management/public';

import { summarizeCopyResult } from './summarize_copy_result';
import type { SavedObjectTarget } from '../types';
import { summarizeCopyResult } from './summarize_copy_result';

// Sample data references:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { i18n } from '@kbn/i18n';

import type { FeatureCatalogueEntry } from 'src/plugins/home/public';

import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useMemo } from 'react';

import { i18n } from '@kbn/i18n';
import type { SavedObjectsManagementRecord } from 'src/plugins/saved_objects_management/public';
import type { SpacesApiUi, ShareToSpaceFlyoutProps } from 'src/plugins/spaces_oss/public';
import type { ShareToSpaceFlyoutProps, SpacesApiUi } from 'src/plugins/spaces_oss/public';

import { SavedObjectsManagementAction } from '../../../../../src/plugins/saved_objects_management/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useMemo } from 'react';

import { i18n } from '@kbn/i18n';
import type { SavedObjectsManagementColumn } from 'src/plugins/saved_objects_management/public';
import type { SpacesApiUi, SpaceListProps } from 'src/plugins/spaces_oss/public';
import type { SpaceListProps, SpacesApiUi } from 'src/plugins/spaces_oss/public';

interface WrapperProps {
spacesApiUi: SpacesApiUi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { SpacesContextProps } from 'src/plugins/spaces_oss/public';
import type { SpacesManager } from '../spaces_manager';
import type { ShareToSpacesData, ShareToSpaceTarget } from '../types';
import { createSpacesReactContext } from './context';
import type { SpacesReactContext, InternalProps } from './types';
import type { InternalProps, SpacesReactContext } from './types';

interface Services {
application: ApplicationStart;
Expand Down

0 comments on commit c6c5430

Please sign in to comment.