Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lint rule to prevent server code being imported into client #52447

Merged
merged 6 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ module.exports = {
'src/legacy/**/*',
'x-pack/**/*',
'!x-pack/**/*.test.*',
'src/plugins/**/(public|server)/**/*',
'!x-pack/test/**/*',
'(src|x-pack)/plugins/**/(public|server)/**/*',
'src/core/(public|server)/**/*',
],
from: [
Expand All @@ -317,13 +318,32 @@ module.exports = {
'!src/core/server/types',
'!src/core/server/*.test.mocks.ts',

'src/plugins/**/public/**/*',
'!src/plugins/**/public/index.{js,ts,tsx}',

'src/plugins/**/server/**/*',
'!src/plugins/**/server/index.{js,ts,tsx}',
'(src|x-pack)/plugins/**/(public|server)/**/*',
'!(src|x-pack)/plugins/**/(public|server)/(index|mocks).{js,ts,tsx}',
],
allowSameFolder: true,
errorMessage: 'Plugins may only import from top-level public and server modules.',
},
{
target: [
'(src|x-pack)/plugins/**/*',
'!(src|x-pack)/plugins/*/server/**/*',

'src/legacy/core_plugins/**/*',
'!src/legacy/core_plugins/*/server/**/*',
'!src/legacy/core_plugins/*/index.{js,ts,tsx}',

'x-pack/legacy/plugins/**/*',
'!x-pack/legacy/plugins/*/server/**/*',
'!x-pack/legacy/plugins/*/index.{js,ts,tsx}',
],
from: [
'src/core/server',
'src/core/server/**/*',
'(src|x-pack)/plugins/*/server/**/*',
],
errorMessage:
'Server modules cannot be imported into client modules or shared modules.',
},
{
target: ['src/core/**/*'],
Expand All @@ -340,6 +360,11 @@ module.exports = {
],
errorMessage: 'The core cannot depend on any plugins.',
},
{
target: ['(src|x-pack)/plugins/*/public/**/*'],
from: ['ui/**/*', 'uiExports/**/*'],
errorMessage: 'Plugins cannot import legacy UI code.',
},
{
from: ['src/legacy/ui/**/*', 'ui/**/*'],
target: [
Expand Down
7 changes: 7 additions & 0 deletions docs/development/core/public/kibana-plugin-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectsCreateOptions](./kibana-plugin-public.savedobjectscreateoptions.md) | |
| [SavedObjectsFindOptions](./kibana-plugin-public.savedobjectsfindoptions.md) | |
| [SavedObjectsFindResponsePublic](./kibana-plugin-public.savedobjectsfindresponsepublic.md) | Return type of the Saved Objects <code>find()</code> method.<!-- -->\*Note\*: this type is different between the Public and Server Saved Objects clients. |
| [SavedObjectsImportConflictError](./kibana-plugin-public.savedobjectsimportconflicterror.md) | Represents a failure to import due to a conflict. |
| [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) | Represents a failure to import. |
| [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md) | Represents a failure to import due to missing references. |
| [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md) | The response describing the result of an import. |
| [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) | Describes a retry operation for importing a saved object. |
| [SavedObjectsImportUnknownError](./kibana-plugin-public.savedobjectsimportunknownerror.md) | Represents a failure to import due to an unknown reason. |
| [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-public.savedobjectsimportunsupportedtypeerror.md) | Represents a failure to import due to having an unsupported saved object type. |
| [SavedObjectsMigrationVersion](./kibana-plugin-public.savedobjectsmigrationversion.md) | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
| [SavedObjectsStart](./kibana-plugin-public.savedobjectsstart.md) | |
| [SavedObjectsUpdateOptions](./kibana-plugin-public.savedobjectsupdateoptions.md) | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportConflictError](./kibana-plugin-public.savedobjectsimportconflicterror.md)

## SavedObjectsImportConflictError interface

Represents a failure to import due to a conflict.

<b>Signature:</b>

```typescript
export interface SavedObjectsImportConflictError
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [type](./kibana-plugin-public.savedobjectsimportconflicterror.type.md) | <code>'conflict'</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportConflictError](./kibana-plugin-public.savedobjectsimportconflicterror.md) &gt; [type](./kibana-plugin-public.savedobjectsimportconflicterror.type.md)

## SavedObjectsImportConflictError.type property

<b>Signature:</b>

```typescript
type: 'conflict';
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) &gt; [error](./kibana-plugin-public.savedobjectsimporterror.error.md)

## SavedObjectsImportError.error property

<b>Signature:</b>

```typescript
error: SavedObjectsImportConflictError | SavedObjectsImportUnsupportedTypeError | SavedObjectsImportMissingReferencesError | SavedObjectsImportUnknownError;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) &gt; [id](./kibana-plugin-public.savedobjectsimporterror.id.md)

## SavedObjectsImportError.id property

<b>Signature:</b>

```typescript
id: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md)

## SavedObjectsImportError interface

Represents a failure to import.

<b>Signature:</b>

```typescript
export interface SavedObjectsImportError
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [error](./kibana-plugin-public.savedobjectsimporterror.error.md) | <code>SavedObjectsImportConflictError &#124; SavedObjectsImportUnsupportedTypeError &#124; SavedObjectsImportMissingReferencesError &#124; SavedObjectsImportUnknownError</code> | |
| [id](./kibana-plugin-public.savedobjectsimporterror.id.md) | <code>string</code> | |
| [title](./kibana-plugin-public.savedobjectsimporterror.title.md) | <code>string</code> | |
| [type](./kibana-plugin-public.savedobjectsimporterror.type.md) | <code>string</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) &gt; [title](./kibana-plugin-public.savedobjectsimporterror.title.md)

## SavedObjectsImportError.title property

<b>Signature:</b>

```typescript
title?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportError](./kibana-plugin-public.savedobjectsimporterror.md) &gt; [type](./kibana-plugin-public.savedobjectsimporterror.type.md)

## SavedObjectsImportError.type property

<b>Signature:</b>

```typescript
type: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md) &gt; [blocking](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.blocking.md)

## SavedObjectsImportMissingReferencesError.blocking property

<b>Signature:</b>

```typescript
blocking: Array<{
type: string;
id: string;
}>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md)

## SavedObjectsImportMissingReferencesError interface

Represents a failure to import due to missing references.

<b>Signature:</b>

```typescript
export interface SavedObjectsImportMissingReferencesError
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [blocking](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.blocking.md) | <code>Array&lt;{</code><br/><code> type: string;</code><br/><code> id: string;</code><br/><code> }&gt;</code> | |
| [references](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.references.md) | <code>Array&lt;{</code><br/><code> type: string;</code><br/><code> id: string;</code><br/><code> }&gt;</code> | |
| [type](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.type.md) | <code>'missing_references'</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md) &gt; [references](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.references.md)

## SavedObjectsImportMissingReferencesError.references property

<b>Signature:</b>

```typescript
references: Array<{
type: string;
id: string;
}>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportMissingReferencesError](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.md) &gt; [type](./kibana-plugin-public.savedobjectsimportmissingreferenceserror.type.md)

## SavedObjectsImportMissingReferencesError.type property

<b>Signature:</b>

```typescript
type: 'missing_references';
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md) &gt; [errors](./kibana-plugin-public.savedobjectsimportresponse.errors.md)

## SavedObjectsImportResponse.errors property

<b>Signature:</b>

```typescript
errors?: SavedObjectsImportError[];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md)

## SavedObjectsImportResponse interface

The response describing the result of an import.

<b>Signature:</b>

```typescript
export interface SavedObjectsImportResponse
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [errors](./kibana-plugin-public.savedobjectsimportresponse.errors.md) | <code>SavedObjectsImportError[]</code> | |
| [success](./kibana-plugin-public.savedobjectsimportresponse.success.md) | <code>boolean</code> | |
| [successCount](./kibana-plugin-public.savedobjectsimportresponse.successcount.md) | <code>number</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md) &gt; [success](./kibana-plugin-public.savedobjectsimportresponse.success.md)

## SavedObjectsImportResponse.success property

<b>Signature:</b>

```typescript
success: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportResponse](./kibana-plugin-public.savedobjectsimportresponse.md) &gt; [successCount](./kibana-plugin-public.savedobjectsimportresponse.successcount.md)

## SavedObjectsImportResponse.successCount property

<b>Signature:</b>

```typescript
successCount: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) &gt; [id](./kibana-plugin-public.savedobjectsimportretry.id.md)

## SavedObjectsImportRetry.id property

<b>Signature:</b>

```typescript
id: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md)

## SavedObjectsImportRetry interface

Describes a retry operation for importing a saved object.

<b>Signature:</b>

```typescript
export interface SavedObjectsImportRetry
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [id](./kibana-plugin-public.savedobjectsimportretry.id.md) | <code>string</code> | |
| [overwrite](./kibana-plugin-public.savedobjectsimportretry.overwrite.md) | <code>boolean</code> | |
| [replaceReferences](./kibana-plugin-public.savedobjectsimportretry.replacereferences.md) | <code>Array&lt;{</code><br/><code> type: string;</code><br/><code> from: string;</code><br/><code> to: string;</code><br/><code> }&gt;</code> | |
| [type](./kibana-plugin-public.savedobjectsimportretry.type.md) | <code>string</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) &gt; [overwrite](./kibana-plugin-public.savedobjectsimportretry.overwrite.md)

## SavedObjectsImportRetry.overwrite property

<b>Signature:</b>

```typescript
overwrite: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) &gt; [replaceReferences](./kibana-plugin-public.savedobjectsimportretry.replacereferences.md)

## SavedObjectsImportRetry.replaceReferences property

<b>Signature:</b>

```typescript
replaceReferences: Array<{
type: string;
from: string;
to: string;
}>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsImportRetry](./kibana-plugin-public.savedobjectsimportretry.md) &gt; [type](./kibana-plugin-public.savedobjectsimportretry.type.md)

## SavedObjectsImportRetry.type property

<b>Signature:</b>

```typescript
type: string;
```
Loading