From f7c53b56908fe2d97223447608b22c1e1efc784d Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 24 Jan 2020 15:38:44 +0100 Subject: [PATCH] Disallow importing Joi client side (#55018) * Disallow importing Joi client side * Move elasticsearch lib into server folder * Add a comment about the 'joi' eslint rule Co-authored-by: Elastic Machine --- .eslintrc.js | 2 ++ src/legacy/core_plugins/elasticsearch/index.js | 8 ++++---- .../{ => server}/lib/__tests__/ensure_es_version.js | 0 .../{ => server}/lib/__tests__/handle_es_error.js | 0 .../{ => server}/lib/__tests__/health_check.js | 0 .../lib/__tests__/is_es_compatible_with_kibana.js | 0 .../{ => server}/lib/abortable_request_handler.js | 0 .../{ => server}/lib/abortable_request_handler.test.js | 0 .../elasticsearch/{ => server}/lib/cluster.ts | 0 .../elasticsearch/{ => server}/lib/create_proxy.js | 0 .../elasticsearch/{ => server}/lib/ensure_es_version.js | 0 .../elasticsearch/{ => server}/lib/handle_es_error.js | 0 .../elasticsearch/{ => server}/lib/health_check.js | 0 .../{ => server}/lib/is_es_compatible_with_kibana.js | 0 .../elasticsearch/{ => server}/lib/kibana_version.js | 2 +- 15 files changed, 7 insertions(+), 5 deletions(-) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/__tests__/ensure_es_version.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/__tests__/handle_es_error.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/__tests__/health_check.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/__tests__/is_es_compatible_with_kibana.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/abortable_request_handler.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/abortable_request_handler.test.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/cluster.ts (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/create_proxy.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/ensure_es_version.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/handle_es_error.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/health_check.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/is_es_compatible_with_kibana.js (100%) rename src/legacy/core_plugins/elasticsearch/{ => server}/lib/kibana_version.js (92%) diff --git a/.eslintrc.js b/.eslintrc.js index 2c5804da053a6..bbe2047271cad 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -262,6 +262,8 @@ module.exports = { 'src/core/server/**/*', '(src|x-pack)/plugins/*/server/**/*', 'examples/**/server/**/*', + // TODO: Remove the 'joi' eslint rule once IE11 support is dropped + 'joi', ], errorMessage: 'Server modules cannot be imported into client modules or shared modules.', diff --git a/src/legacy/core_plugins/elasticsearch/index.js b/src/legacy/core_plugins/elasticsearch/index.js index da7b557e7ea19..5872a33d8aa08 100644 --- a/src/legacy/core_plugins/elasticsearch/index.js +++ b/src/legacy/core_plugins/elasticsearch/index.js @@ -17,10 +17,10 @@ * under the License. */ import { first } from 'rxjs/operators'; -import healthCheck from './lib/health_check'; -import { Cluster } from './lib/cluster'; -import { createProxy } from './lib/create_proxy'; -import { handleESError } from './lib/handle_es_error'; +import healthCheck from './server/lib/health_check'; +import { Cluster } from './server/lib/cluster'; +import { createProxy } from './server/lib/create_proxy'; +import { handleESError } from './server/lib/handle_es_error'; export default function(kibana) { let defaultVars; diff --git a/src/legacy/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js b/src/legacy/core_plugins/elasticsearch/server/lib/__tests__/ensure_es_version.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js rename to src/legacy/core_plugins/elasticsearch/server/lib/__tests__/ensure_es_version.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/__tests__/handle_es_error.js b/src/legacy/core_plugins/elasticsearch/server/lib/__tests__/handle_es_error.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/__tests__/handle_es_error.js rename to src/legacy/core_plugins/elasticsearch/server/lib/__tests__/handle_es_error.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/__tests__/health_check.js b/src/legacy/core_plugins/elasticsearch/server/lib/__tests__/health_check.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/__tests__/health_check.js rename to src/legacy/core_plugins/elasticsearch/server/lib/__tests__/health_check.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js b/src/legacy/core_plugins/elasticsearch/server/lib/__tests__/is_es_compatible_with_kibana.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js rename to src/legacy/core_plugins/elasticsearch/server/lib/__tests__/is_es_compatible_with_kibana.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/abortable_request_handler.js b/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/abortable_request_handler.js rename to src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/abortable_request_handler.test.js b/src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.test.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/abortable_request_handler.test.js rename to src/legacy/core_plugins/elasticsearch/server/lib/abortable_request_handler.test.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/cluster.ts b/src/legacy/core_plugins/elasticsearch/server/lib/cluster.ts similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/cluster.ts rename to src/legacy/core_plugins/elasticsearch/server/lib/cluster.ts diff --git a/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js b/src/legacy/core_plugins/elasticsearch/server/lib/create_proxy.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/create_proxy.js rename to src/legacy/core_plugins/elasticsearch/server/lib/create_proxy.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/ensure_es_version.js b/src/legacy/core_plugins/elasticsearch/server/lib/ensure_es_version.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/ensure_es_version.js rename to src/legacy/core_plugins/elasticsearch/server/lib/ensure_es_version.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/handle_es_error.js b/src/legacy/core_plugins/elasticsearch/server/lib/handle_es_error.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/handle_es_error.js rename to src/legacy/core_plugins/elasticsearch/server/lib/handle_es_error.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/health_check.js b/src/legacy/core_plugins/elasticsearch/server/lib/health_check.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/health_check.js rename to src/legacy/core_plugins/elasticsearch/server/lib/health_check.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/is_es_compatible_with_kibana.js b/src/legacy/core_plugins/elasticsearch/server/lib/is_es_compatible_with_kibana.js similarity index 100% rename from src/legacy/core_plugins/elasticsearch/lib/is_es_compatible_with_kibana.js rename to src/legacy/core_plugins/elasticsearch/server/lib/is_es_compatible_with_kibana.js diff --git a/src/legacy/core_plugins/elasticsearch/lib/kibana_version.js b/src/legacy/core_plugins/elasticsearch/server/lib/kibana_version.js similarity index 92% rename from src/legacy/core_plugins/elasticsearch/lib/kibana_version.js rename to src/legacy/core_plugins/elasticsearch/server/lib/kibana_version.js index e00c12f8271b0..344dbbb5bdf69 100644 --- a/src/legacy/core_plugins/elasticsearch/lib/kibana_version.js +++ b/src/legacy/core_plugins/elasticsearch/server/lib/kibana_version.js @@ -17,7 +17,7 @@ * under the License. */ -import { version as kibanaVersion } from '../../../../../package.json'; +import { version as kibanaVersion } from '../../../../../../package.json'; export default { // Make the version stubbable to improve testability.