2019-10-22 01:32:31 +02:00
|
|
|
/*
|
2021-01-20 02:52:56 +01:00
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
2021-02-04 03:12:39 +01:00
|
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
|
|
* Side Public License, v 1.
|
2019-10-22 01:32:31 +02:00
|
|
|
*/
|
|
|
|
|
2018-11-28 01:49:17 +01:00
|
|
|
const APACHE_2_0_LICENSE_HEADER = `
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
2021-02-04 03:12:39 +01:00
|
|
|
const OLD_DUAL_LICENSE_HEADER = `
|
2021-01-20 02:52:56 +01:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
|
|
* and the Server Side Public License, v 1; you may not use this file except in
|
|
|
|
* compliance with, at your election, the Elastic License or the Server Side
|
|
|
|
* Public License, v 1.
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
2021-02-04 03:12:39 +01:00
|
|
|
const DUAL_LICENSE_HEADER = `
|
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
|
|
* Side Public License, v 1.
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
|
|
|
const OLD_ELASTIC_LICENSE_HEADER = `
|
2018-11-28 01:49:17 +01:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
2021-02-04 03:12:39 +01:00
|
|
|
const ELASTIC_LICENSE_HEADER = `
|
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
|
|
* 2.0.
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
2020-07-15 10:29:57 +02:00
|
|
|
const SAFER_LODASH_SET_HEADER = `
|
|
|
|
/*
|
|
|
|
* Elasticsearch B.V licenses this file to you under the MIT License.
|
|
|
|
* See \`packages/elastic-safer-lodash-set/LICENSE\` for more information.
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
|
|
|
const SAFER_LODASH_SET_LODASH_HEADER = `
|
|
|
|
/*
|
|
|
|
* This file is forked from the lodash project (https://lodash.com/),
|
|
|
|
* and may include modifications made by Elasticsearch B.V.
|
|
|
|
* Elasticsearch B.V. licenses this file to you under the MIT License.
|
|
|
|
* See \`packages/elastic-safer-lodash-set/LICENSE\` for more information.
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
|
|
|
const SAFER_LODASH_SET_DEFINITELYTYPED_HEADER = `
|
|
|
|
/*
|
|
|
|
* This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped),
|
|
|
|
* and may include modifications made by Elasticsearch B.V.
|
|
|
|
* Elasticsearch B.V. licenses this file to you under the MIT License.
|
|
|
|
* See \`packages/elastic-safer-lodash-set/LICENSE\` for more information.
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
2018-02-05 18:18:43 +01:00
|
|
|
module.exports = {
|
2019-09-03 22:57:09 +02:00
|
|
|
root: true,
|
|
|
|
|
2019-08-16 17:29:46 +02:00
|
|
|
extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'],
|
2018-09-07 18:43:17 +02:00
|
|
|
|
2018-02-05 18:18:43 +01:00
|
|
|
overrides: [
|
2019-10-29 14:15:33 +01:00
|
|
|
/**
|
|
|
|
* Temporarily disable some react rules for specific plugins, remove in separate PRs
|
|
|
|
*/
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['src/plugins/kibana_react/**/*.{js,mjs,ts,tsx}'],
|
2019-10-29 14:15:33 +01:00
|
|
|
rules: {
|
|
|
|
'react-hooks/rules-of-hooks': 'off',
|
|
|
|
'react-hooks/exhaustive-deps': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['src/plugins/kibana_utils/**/*.{js,mjs,ts,tsx}'],
|
2019-10-29 14:15:33 +01:00
|
|
|
rules: {
|
|
|
|
'react-hooks/exhaustive-deps': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['x-pack/plugins/canvas/**/*.{js,mjs,ts,tsx}'],
|
2019-10-29 14:15:33 +01:00
|
|
|
rules: {
|
|
|
|
'jsx-a11y/click-events-have-key-events': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['x-pack/plugins/cross_cluster_replication/**/*.{js,mjs,ts,tsx}'],
|
2019-10-29 14:15:33 +01:00
|
|
|
rules: {
|
|
|
|
'jsx-a11y/click-events-have-key-events': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['x-pack/plugins/ml/**/*.{js,mjs,ts,tsx}'],
|
2019-10-29 14:15:33 +01:00
|
|
|
rules: {
|
|
|
|
'react-hooks/exhaustive-deps': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-04-05 18:45:23 +02:00
|
|
|
/**
|
2021-01-20 02:52:56 +01:00
|
|
|
* Files that require dual-license headers, settings
|
2019-04-05 18:45:23 +02:00
|
|
|
* are overridden below for files that require Elastic
|
|
|
|
* Licence headers
|
|
|
|
*/
|
|
|
|
{
|
2021-01-20 02:52:56 +01:00
|
|
|
files: [
|
|
|
|
'**/*.{js,mjs,ts,tsx}',
|
|
|
|
'!plugins/**/*',
|
|
|
|
'!packages/elastic-datemath/**/*',
|
|
|
|
'!packages/elastic-eslint-config-kibana/**/*',
|
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'@kbn/eslint/require-license-header': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
license: DUAL_LICENSE_HEADER,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'@kbn/eslint/disallow-license-headers': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
licenses: [
|
|
|
|
APACHE_2_0_LICENSE_HEADER,
|
|
|
|
ELASTIC_LICENSE_HEADER,
|
2021-02-04 03:12:39 +01:00
|
|
|
OLD_DUAL_LICENSE_HEADER,
|
|
|
|
OLD_ELASTIC_LICENSE_HEADER,
|
2021-01-20 02:52:56 +01:00
|
|
|
SAFER_LODASH_SET_HEADER,
|
|
|
|
SAFER_LODASH_SET_LODASH_HEADER,
|
|
|
|
SAFER_LODASH_SET_DEFINITELYTYPED_HEADER,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Files that require Apache headers
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'packages/elastic-datemath/**/*.{js,mjs,ts,tsx}',
|
|
|
|
'packages/elastic-eslint-config-kibana/**/*.{js,mjs,ts,tsx}',
|
|
|
|
],
|
2019-04-05 18:45:23 +02:00
|
|
|
rules: {
|
|
|
|
'@kbn/eslint/require-license-header': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
license: APACHE_2_0_LICENSE_HEADER,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'@kbn/eslint/disallow-license-headers': [
|
|
|
|
'error',
|
|
|
|
{
|
2020-07-15 10:29:57 +02:00
|
|
|
licenses: [
|
2021-01-20 02:52:56 +01:00
|
|
|
DUAL_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
ELASTIC_LICENSE_HEADER,
|
2021-02-04 03:12:39 +01:00
|
|
|
OLD_DUAL_LICENSE_HEADER,
|
|
|
|
OLD_ELASTIC_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
SAFER_LODASH_SET_HEADER,
|
|
|
|
SAFER_LODASH_SET_LODASH_HEADER,
|
|
|
|
SAFER_LODASH_SET_DEFINITELYTYPED_HEADER,
|
|
|
|
],
|
2019-04-05 18:45:23 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-05-05 18:33:09 +02:00
|
|
|
/**
|
|
|
|
* New Platform client-side
|
|
|
|
*/
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['{src,x-pack}/plugins/*/public/**/*.{js,mjs,ts,tsx}'],
|
2020-05-05 18:33:09 +02:00
|
|
|
rules: {
|
|
|
|
'import/no-commonjs': 'error',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-04-05 18:45:23 +02:00
|
|
|
/**
|
2021-01-20 02:52:56 +01:00
|
|
|
* Files that require Elastic license headers instead of dual-license header
|
2019-04-05 18:45:23 +02:00
|
|
|
*/
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['x-pack/**/*.{js,mjs,ts,tsx}'],
|
2019-04-05 18:45:23 +02:00
|
|
|
rules: {
|
|
|
|
'@kbn/eslint/require-license-header': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
license: ELASTIC_LICENSE_HEADER,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'@kbn/eslint/disallow-license-headers': [
|
|
|
|
'error',
|
|
|
|
{
|
2020-07-15 10:29:57 +02:00
|
|
|
licenses: [
|
|
|
|
APACHE_2_0_LICENSE_HEADER,
|
2021-02-04 03:12:39 +01:00
|
|
|
DUAL_LICENSE_HEADER,
|
|
|
|
OLD_DUAL_LICENSE_HEADER,
|
|
|
|
OLD_ELASTIC_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
SAFER_LODASH_SET_HEADER,
|
|
|
|
SAFER_LODASH_SET_LODASH_HEADER,
|
|
|
|
SAFER_LODASH_SET_DEFINITELYTYPED_HEADER,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* safer-lodash-set package requires special license headers
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
files: ['packages/elastic-safer-lodash-set/**/*.{js,mjs,ts,tsx}'],
|
|
|
|
rules: {
|
|
|
|
'@kbn/eslint/require-license-header': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
license: SAFER_LODASH_SET_LODASH_HEADER,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'@kbn/eslint/disallow-license-headers': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
licenses: [
|
2021-02-04 03:12:39 +01:00
|
|
|
APACHE_2_0_LICENSE_HEADER,
|
2021-01-20 02:52:56 +01:00
|
|
|
DUAL_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
ELASTIC_LICENSE_HEADER,
|
2021-02-04 03:12:39 +01:00
|
|
|
OLD_DUAL_LICENSE_HEADER,
|
|
|
|
OLD_ELASTIC_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
SAFER_LODASH_SET_HEADER,
|
|
|
|
SAFER_LODASH_SET_DEFINITELYTYPED_HEADER,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['packages/elastic-safer-lodash-set/test/*.{js,mjs,ts,tsx}'],
|
|
|
|
rules: {
|
|
|
|
'@kbn/eslint/require-license-header': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
license: SAFER_LODASH_SET_HEADER,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'@kbn/eslint/disallow-license-headers': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
licenses: [
|
2021-02-04 03:12:39 +01:00
|
|
|
APACHE_2_0_LICENSE_HEADER,
|
2021-01-20 02:52:56 +01:00
|
|
|
DUAL_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
ELASTIC_LICENSE_HEADER,
|
2021-02-04 03:12:39 +01:00
|
|
|
OLD_DUAL_LICENSE_HEADER,
|
|
|
|
OLD_ELASTIC_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
SAFER_LODASH_SET_LODASH_HEADER,
|
|
|
|
SAFER_LODASH_SET_DEFINITELYTYPED_HEADER,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['packages/elastic-safer-lodash-set/**/*.d.ts'],
|
|
|
|
rules: {
|
|
|
|
'@kbn/eslint/require-license-header': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
license: SAFER_LODASH_SET_DEFINITELYTYPED_HEADER,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'@kbn/eslint/disallow-license-headers': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
licenses: [
|
2021-02-04 03:12:39 +01:00
|
|
|
APACHE_2_0_LICENSE_HEADER,
|
2021-01-20 02:52:56 +01:00
|
|
|
DUAL_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
ELASTIC_LICENSE_HEADER,
|
2021-02-04 03:12:39 +01:00
|
|
|
OLD_ELASTIC_LICENSE_HEADER,
|
|
|
|
OLD_DUAL_LICENSE_HEADER,
|
2020-07-15 10:29:57 +02:00
|
|
|
SAFER_LODASH_SET_HEADER,
|
|
|
|
SAFER_LODASH_SET_LODASH_HEADER,
|
|
|
|
],
|
2019-04-05 18:45:23 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restricted paths
|
|
|
|
*/
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['**/*.{js,mjs,ts,tsx}'],
|
2019-04-05 18:45:23 +02:00
|
|
|
rules: {
|
|
|
|
'@kbn/eslint/no-restricted-paths': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
basePath: __dirname,
|
|
|
|
zones: [
|
2020-05-05 23:56:22 +02:00
|
|
|
{
|
|
|
|
target: ['(src|x-pack)/**/*', '!src/core/**/*'],
|
|
|
|
from: ['src/core/utils/**/*'],
|
|
|
|
errorMessage: `Plugins may only import from src/core/server and src/core/public.`,
|
|
|
|
},
|
2020-05-21 19:33:33 +02:00
|
|
|
{
|
2020-08-28 12:43:49 +02:00
|
|
|
target: ['(src|x-pack)/plugins/*/server/**/*'],
|
2020-06-10 17:39:52 +02:00
|
|
|
from: ['(src|x-pack)/plugins/*/public/**/*'],
|
|
|
|
errorMessage: `Server code can not import from public, use a common directory.`,
|
2020-05-21 19:33:33 +02:00
|
|
|
},
|
2020-06-03 21:21:38 +02:00
|
|
|
{
|
|
|
|
target: ['(src|x-pack)/plugins/*/common/**/*'],
|
|
|
|
from: ['(src|x-pack)/plugins/*/(server|public)/**/*'],
|
|
|
|
errorMessage: `Common code can not import from server or public, use a common directory.`,
|
|
|
|
},
|
2019-04-05 18:45:23 +02:00
|
|
|
{
|
|
|
|
target: [
|
2020-09-23 09:52:51 +02:00
|
|
|
'src/legacy/**/*',
|
2019-12-13 19:26:04 +01:00
|
|
|
'(src|x-pack)/plugins/**/(public|server)/**/*',
|
2020-01-08 17:20:07 +01:00
|
|
|
'examples/**/*',
|
2019-04-05 18:45:23 +02:00
|
|
|
],
|
|
|
|
from: [
|
|
|
|
'src/core/public/**/*',
|
2020-04-24 00:59:01 +02:00
|
|
|
'!src/core/public/index.ts', // relative import
|
|
|
|
'!src/core/public/mocks{,.ts}',
|
|
|
|
'!src/core/server/types{,.ts}',
|
2019-04-05 18:45:23 +02:00
|
|
|
'!src/core/public/utils/**/*',
|
2020-04-24 00:59:01 +02:00
|
|
|
'!src/core/public/*.test.mocks{,.ts}',
|
2019-04-05 18:45:23 +02:00
|
|
|
|
|
|
|
'src/core/server/**/*',
|
2020-04-24 00:59:01 +02:00
|
|
|
'!src/core/server/index.ts', // relative import
|
|
|
|
'!src/core/server/mocks{,.ts}',
|
|
|
|
'!src/core/server/types{,.ts}',
|
2020-06-04 16:18:02 +02:00
|
|
|
'!src/core/server/test_utils{,.ts}',
|
2020-09-03 10:57:03 +02:00
|
|
|
'!src/core/server/utils', // ts alias
|
|
|
|
'!src/core/server/utils/**/*',
|
2019-10-16 14:18:34 +02:00
|
|
|
// for absolute imports until fixed in
|
|
|
|
// https://github.com/elastic/kibana/issues/36096
|
2020-04-24 00:59:01 +02:00
|
|
|
'!src/core/server/*.test.mocks{,.ts}',
|
2020-05-15 11:03:46 +02:00
|
|
|
|
|
|
|
'target/types/**',
|
2020-04-24 00:59:01 +02:00
|
|
|
],
|
|
|
|
allowSameFolder: true,
|
|
|
|
errorMessage:
|
|
|
|
'Plugins may only import from top-level public and server modules in core.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: [
|
2020-09-23 09:52:51 +02:00
|
|
|
'src/legacy/**/*',
|
2020-04-24 00:59:01 +02:00
|
|
|
'(src|x-pack)/plugins/**/(public|server)/**/*',
|
|
|
|
'examples/**/*',
|
|
|
|
'!(src|x-pack)/**/*.test.*',
|
|
|
|
'!(x-pack/)?test/**/*',
|
|
|
|
],
|
|
|
|
from: [
|
2019-12-13 19:26:04 +01:00
|
|
|
'(src|x-pack)/plugins/**/(public|server)/**/*',
|
2020-06-30 16:13:28 +02:00
|
|
|
'!(src|x-pack)/plugins/**/(public|server)/mocks/index.{js,mjs,ts}',
|
|
|
|
'!(src|x-pack)/plugins/**/(public|server)/(index|mocks).{js,mjs,ts,tsx}',
|
2019-04-05 18:45:23 +02:00
|
|
|
],
|
|
|
|
allowSameFolder: true,
|
2019-12-13 19:26:04 +01:00
|
|
|
errorMessage: 'Plugins may only import from top-level public and server modules.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: [
|
|
|
|
'(src|x-pack)/plugins/**/*',
|
2020-01-27 20:25:39 +01:00
|
|
|
'!(src|x-pack)/plugins/**/server/**/*',
|
2019-12-13 19:26:04 +01:00
|
|
|
|
2020-01-08 17:20:07 +01:00
|
|
|
'examples/**/*',
|
|
|
|
'!examples/**/server/**/*',
|
2019-12-13 19:26:04 +01:00
|
|
|
],
|
|
|
|
from: [
|
|
|
|
'src/core/server',
|
|
|
|
'src/core/server/**/*',
|
|
|
|
'(src|x-pack)/plugins/*/server/**/*',
|
2020-01-08 17:20:07 +01:00
|
|
|
'examples/**/server/**/*',
|
2020-01-24 15:38:44 +01:00
|
|
|
// TODO: Remove the 'joi' eslint rule once IE11 support is dropped
|
|
|
|
'joi',
|
2019-12-13 19:26:04 +01:00
|
|
|
],
|
|
|
|
errorMessage:
|
|
|
|
'Server modules cannot be imported into client modules or shared modules.',
|
2019-04-05 18:45:23 +02:00
|
|
|
},
|
2019-11-28 22:54:21 +01:00
|
|
|
{
|
2019-12-13 21:24:14 +01:00
|
|
|
target: ['src/**/*'],
|
2019-11-28 22:54:21 +01:00
|
|
|
from: ['x-pack/**/*'],
|
|
|
|
errorMessage: 'OSS cannot import x-pack files.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
target: ['src/core/**/*'],
|
2020-09-23 09:52:51 +02:00
|
|
|
from: ['plugins/**/*', 'src/plugins/**/*', 'src/legacy/ui/**/*'],
|
2019-11-28 22:54:21 +01:00
|
|
|
errorMessage: 'The core cannot depend on any plugins.',
|
2019-12-13 19:26:04 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
target: ['(src|x-pack)/plugins/*/public/**/*'],
|
2020-08-13 18:08:44 +02:00
|
|
|
from: ['ui/**/*'],
|
2019-12-13 19:26:04 +01:00
|
|
|
errorMessage: 'Plugins cannot import legacy UI code.',
|
2019-11-28 22:54:21 +01:00
|
|
|
},
|
2019-07-18 22:52:13 +02:00
|
|
|
{
|
|
|
|
from: ['src/legacy/ui/**/*', 'ui/**/*'],
|
|
|
|
target: [
|
2019-08-30 18:04:32 +02:00
|
|
|
'test/plugin_functional/plugins/**/public/np_ready/**/*',
|
|
|
|
'test/plugin_functional/plugins/**/server/np_ready/**/*',
|
2019-07-18 22:52:13 +02:00
|
|
|
],
|
|
|
|
allowSameFolder: true,
|
|
|
|
errorMessage:
|
|
|
|
'NP-ready code should not import from /src/legacy/ui/** folder. ' +
|
|
|
|
'Instead of importing from /src/legacy/ui/** deeply within a np_ready folder, ' +
|
|
|
|
'import those things once at the top level of your plugin and pass those down, just ' +
|
|
|
|
'like you pass down `core` and `plugins` objects.',
|
|
|
|
},
|
2019-04-05 18:45:23 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-04-20 21:13:37 +02:00
|
|
|
/**
|
|
|
|
* Allow default exports
|
|
|
|
*/
|
2018-02-06 00:29:30 +01:00
|
|
|
{
|
2019-06-14 18:35:23 +02:00
|
|
|
files: [
|
2020-09-30 02:34:05 +02:00
|
|
|
'**/*.stories.tsx',
|
2020-06-30 16:35:52 +02:00
|
|
|
'x-pack/test/apm_api_integration/**/*.ts',
|
2019-06-14 18:35:23 +02:00
|
|
|
'x-pack/test/functional/apps/**/*.js',
|
2020-05-05 18:22:47 +02:00
|
|
|
'x-pack/plugins/apm/**/*.js',
|
2019-06-14 18:35:23 +02:00
|
|
|
'test/*/config.ts',
|
2020-03-16 15:13:03 +01:00
|
|
|
'test/*/config_open.ts',
|
2019-11-07 16:07:40 +01:00
|
|
|
'test/*/{tests,test_suites,apis,apps}/**/*',
|
2019-06-14 18:35:23 +02:00
|
|
|
'test/visual_regression/tests/**/*',
|
2019-08-03 00:43:05 +02:00
|
|
|
'x-pack/test/*/{tests,test_suites,apis,apps}/**/*',
|
|
|
|
'x-pack/test/*/*config.*ts',
|
|
|
|
'x-pack/test/saved_object_api_integration/*/apis/**/*',
|
|
|
|
'x-pack/test/ui_capabilities/*/tests/**/*',
|
2019-06-14 18:35:23 +02:00
|
|
|
],
|
2018-02-06 00:29:30 +01:00
|
|
|
rules: {
|
2019-04-02 08:37:01 +02:00
|
|
|
'import/no-default-export': 'off',
|
2018-04-20 21:13:37 +02:00
|
|
|
'import/no-named-as-default': 'off',
|
2018-02-06 00:29:30 +01:00
|
|
|
},
|
|
|
|
},
|
2018-03-13 18:43:39 +01:00
|
|
|
|
2018-04-20 21:13:37 +02:00
|
|
|
/**
|
|
|
|
* Files that are allowed to import webpack-specific stuff
|
|
|
|
*/
|
2018-03-13 18:43:39 +01:00
|
|
|
{
|
2018-04-20 21:13:37 +02:00
|
|
|
files: [
|
2019-04-05 18:45:23 +02:00
|
|
|
'**/public/**/*.js',
|
|
|
|
'src/fixtures/**/*.js', // TODO: this directory needs to be more obviously "public" (or go away)
|
2018-03-13 18:43:39 +01:00
|
|
|
],
|
2018-04-20 21:13:37 +02:00
|
|
|
settings: {
|
2020-01-10 23:22:18 +01:00
|
|
|
// instructs import/no-extraneous-dependencies to treat certain modules
|
|
|
|
// as core modules, even if they aren't listed in package.json
|
2020-09-23 09:52:51 +02:00
|
|
|
'import/core-modules': ['plugins'],
|
2018-04-20 21:13:37 +02:00
|
|
|
|
|
|
|
'import/resolver': {
|
|
|
|
'@kbn/eslint-import-resolver-kibana': {
|
2018-05-16 19:45:41 +02:00
|
|
|
forceNode: false,
|
2018-04-20 21:13:37 +02:00
|
|
|
rootPackageName: 'kibana',
|
|
|
|
kibanaPath: '.',
|
2020-09-23 09:52:51 +02:00
|
|
|
pluginMap: {},
|
2018-04-20 21:13:37 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2018-05-25 19:43:01 +02:00
|
|
|
* Files that ARE NOT allowed to use devDependencies
|
2018-04-20 21:13:37 +02:00
|
|
|
*/
|
|
|
|
{
|
2020-12-10 17:23:33 +01:00
|
|
|
files: ['x-pack/**/*.js', 'packages/kbn-interpreter/**/*.js'],
|
2018-03-13 18:43:39 +01:00
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
devDependencies: false,
|
|
|
|
peerDependencies: true,
|
2020-11-02 22:18:52 +01:00
|
|
|
packageDir: '.',
|
2018-03-13 18:43:39 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-04-20 21:13:37 +02:00
|
|
|
/**
|
2018-05-25 19:43:01 +02:00
|
|
|
* Files that ARE allowed to use devDependencies
|
2018-04-20 21:13:37 +02:00
|
|
|
*/
|
2018-03-13 18:43:39 +01:00
|
|
|
{
|
|
|
|
files: [
|
2019-04-05 18:45:23 +02:00
|
|
|
'packages/kbn-es/src/**/*.js',
|
|
|
|
'packages/kbn-interpreter/tasks/**/*.js',
|
|
|
|
'packages/kbn-interpreter/src/plugin/**/*.js',
|
|
|
|
'x-pack/{dev-tools,tasks,scripts,test,build_chromium}/**/*.js',
|
2020-08-25 17:27:15 +02:00
|
|
|
'x-pack/**/{__tests__,__test__,__jest__,__fixtures__,__mocks__,public}/**/*.js',
|
2018-04-20 21:13:37 +02:00
|
|
|
'x-pack/**/*.test.js',
|
2019-03-19 08:12:19 +01:00
|
|
|
'x-pack/test_utils/**/*',
|
2018-04-20 21:13:37 +02:00
|
|
|
'x-pack/gulpfile.js',
|
2020-05-05 18:22:47 +02:00
|
|
|
'x-pack/plugins/apm/public/utils/testHelpers.js',
|
2020-07-30 20:16:49 +02:00
|
|
|
'x-pack/plugins/canvas/shareable_runtime/postcss.config.js',
|
2018-03-13 18:43:39 +01:00
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
devDependencies: true,
|
|
|
|
peerDependencies: true,
|
2020-11-02 22:18:52 +01:00
|
|
|
packageDir: '.',
|
2018-03-13 18:43:39 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2018-04-20 21:13:37 +02:00
|
|
|
|
|
|
|
/**
|
2018-05-25 19:43:01 +02:00
|
|
|
* Files that run BEFORE node version check
|
|
|
|
*/
|
|
|
|
{
|
2019-04-05 18:45:23 +02:00
|
|
|
files: ['scripts/**/*.js', 'src/setup_node_env/**/*.js'],
|
2018-05-25 19:43:01 +02:00
|
|
|
rules: {
|
|
|
|
'import/no-commonjs': 'off',
|
|
|
|
'prefer-object-spread/prefer-object-spread': 'off',
|
|
|
|
'no-var': 'off',
|
|
|
|
'prefer-const': 'off',
|
|
|
|
'prefer-destructuring': 'off',
|
|
|
|
'no-restricted-syntax': [
|
|
|
|
'error',
|
|
|
|
'ImportDeclaration',
|
|
|
|
'ExportNamedDeclaration',
|
|
|
|
'ExportDefaultDeclaration',
|
|
|
|
'ExportAllDeclaration',
|
|
|
|
'ArrowFunctionExpression',
|
|
|
|
'AwaitExpression',
|
|
|
|
'ClassDeclaration',
|
|
|
|
'RestElement',
|
|
|
|
'SpreadElement',
|
|
|
|
'YieldExpression',
|
|
|
|
'VariableDeclaration[kind="const"]',
|
|
|
|
'VariableDeclaration[kind="let"]',
|
|
|
|
'VariableDeclarator[id.type="ArrayPattern"]',
|
|
|
|
'VariableDeclarator[id.type="ObjectPattern"]',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-01-16 21:37:40 +01:00
|
|
|
/**
|
|
|
|
* Files that run in the browser with only node-level transpilation
|
|
|
|
*/
|
|
|
|
{
|
2019-02-17 13:47:36 +01:00
|
|
|
files: [
|
2019-03-02 02:53:05 +01:00
|
|
|
'test/functional/services/lib/web_element_wrapper/scroll_into_view_if_necessary.js',
|
2020-06-16 07:15:31 +02:00
|
|
|
'src/legacy/ui/ui_render/bootstrap/kbn_bundles_loader_source.js',
|
2019-04-05 18:45:23 +02:00
|
|
|
'**/browser_exec_scripts/**/*.js',
|
2019-02-17 13:47:36 +01:00
|
|
|
],
|
2019-01-16 21:37:40 +01:00
|
|
|
rules: {
|
|
|
|
'prefer-object-spread/prefer-object-spread': 'off',
|
|
|
|
'no-var': 'off',
|
|
|
|
'prefer-const': 'off',
|
|
|
|
'prefer-destructuring': 'off',
|
|
|
|
'no-restricted-syntax': [
|
|
|
|
'error',
|
|
|
|
'ArrowFunctionExpression',
|
|
|
|
'AwaitExpression',
|
|
|
|
'ClassDeclaration',
|
2019-02-17 13:47:36 +01:00
|
|
|
'ImportDeclaration',
|
2019-01-16 21:37:40 +01:00
|
|
|
'RestElement',
|
|
|
|
'SpreadElement',
|
|
|
|
'YieldExpression',
|
|
|
|
'VariableDeclaration[kind="const"]',
|
|
|
|
'VariableDeclaration[kind="let"]',
|
|
|
|
'VariableDeclarator[id.type="ArrayPattern"]',
|
|
|
|
'VariableDeclarator[id.type="ObjectPattern"]',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-05-25 19:43:01 +02:00
|
|
|
/**
|
|
|
|
* Files that run AFTER node version check
|
|
|
|
* and are not also transpiled with babel
|
2018-04-20 21:13:37 +02:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'.eslintrc.js',
|
2019-04-05 18:45:23 +02:00
|
|
|
'packages/kbn-eslint-import-resolver-kibana/**/*.js',
|
2019-03-23 01:12:14 +01:00
|
|
|
'packages/kbn-eslint-plugin-eslint/**/*',
|
2018-04-20 21:13:37 +02:00
|
|
|
'x-pack/gulpfile.js',
|
2019-04-05 18:45:23 +02:00
|
|
|
'x-pack/scripts/*.js',
|
2018-04-20 21:13:37 +02:00
|
|
|
],
|
2020-03-27 18:54:54 +01:00
|
|
|
excludedFiles: ['**/integration_tests/**/*'],
|
2018-04-20 21:13:37 +02:00
|
|
|
rules: {
|
|
|
|
'import/no-commonjs': 'off',
|
|
|
|
'prefer-object-spread/prefer-object-spread': 'off',
|
|
|
|
'no-restricted-syntax': [
|
|
|
|
'error',
|
|
|
|
'ImportDeclaration',
|
|
|
|
'ExportNamedDeclaration',
|
|
|
|
'ExportDefaultDeclaration',
|
|
|
|
'ExportAllDeclaration',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-07-18 19:11:33 +02:00
|
|
|
/**
|
|
|
|
* Jest specific rules
|
|
|
|
*/
|
|
|
|
{
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['**/*.test.{js,mjs,ts,tsx}'],
|
2019-07-18 19:11:33 +02:00
|
|
|
rules: {
|
|
|
|
'jest/valid-describe': 'error',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-03-10 07:51:57 +01:00
|
|
|
/**
|
|
|
|
* Harden specific rules
|
|
|
|
*/
|
|
|
|
{
|
2020-07-15 10:29:57 +02:00
|
|
|
files: ['test/harden/*.js', 'packages/elastic-safer-lodash-set/test/*.js'],
|
2021-01-15 22:17:25 +01:00
|
|
|
rules: {
|
|
|
|
'mocha/handle-done-callback': 'off',
|
|
|
|
},
|
2020-03-10 07:51:57 +01:00
|
|
|
},
|
2020-07-15 10:29:57 +02:00
|
|
|
{
|
|
|
|
files: ['**/*.{js,mjs,ts,tsx}'],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-imports': [
|
|
|
|
2,
|
|
|
|
{
|
|
|
|
paths: [
|
|
|
|
{
|
|
|
|
name: 'lodash',
|
|
|
|
importNames: ['set', 'setWith'],
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash.set',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash.setwith',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/set',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/setWith',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/fp',
|
|
|
|
importNames: ['set', 'setWith', 'assoc', 'assocPath'],
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/fp/set',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/fp/setWith',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/fp/assoc',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/fp/assocPath',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
2020-11-10 15:15:26 +01:00
|
|
|
{
|
|
|
|
name: 'react-use',
|
|
|
|
message: 'Please use react-use/lib/{method} instead.',
|
|
|
|
},
|
2020-07-15 10:29:57 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'no-restricted-modules': [
|
|
|
|
2,
|
|
|
|
{
|
|
|
|
paths: [
|
|
|
|
{
|
|
|
|
name: 'lodash.set',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash.setwith',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/set',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash/setWith',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'no-restricted-properties': [
|
|
|
|
2,
|
|
|
|
{
|
|
|
|
object: 'lodash',
|
|
|
|
property: 'set',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
object: '_',
|
|
|
|
property: 'set',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
object: 'lodash',
|
|
|
|
property: 'setWith',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
object: '_',
|
|
|
|
property: 'setWith',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
object: 'lodash',
|
|
|
|
property: 'assoc',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
object: '_',
|
|
|
|
property: 'assoc',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
object: 'lodash',
|
|
|
|
property: 'assocPath',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
object: '_',
|
|
|
|
property: 'assocPath',
|
|
|
|
message: 'Please use @elastic/safer-lodash-set instead',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2020-03-10 07:51:57 +01:00
|
|
|
|
2018-04-20 21:13:37 +02:00
|
|
|
/**
|
2020-07-27 15:18:36 +02:00
|
|
|
* APM and Observability overrides
|
2018-04-20 21:13:37 +02:00
|
|
|
*/
|
|
|
|
{
|
2020-07-27 15:18:36 +02:00
|
|
|
files: [
|
|
|
|
'x-pack/plugins/apm/**/*.{js,mjs,ts,tsx}',
|
|
|
|
'x-pack/plugins/observability/**/*.{js,mjs,ts,tsx}',
|
|
|
|
],
|
2018-04-20 21:13:37 +02:00
|
|
|
rules: {
|
|
|
|
'no-console': ['warn', { allow: ['error'] }],
|
2020-07-27 15:18:36 +02:00
|
|
|
'react/function-component-definition': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
namedComponents: 'function-declaration',
|
|
|
|
unnamedComponents: 'arrow-function',
|
|
|
|
},
|
|
|
|
],
|
2019-07-29 20:36:24 +02:00
|
|
|
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
|
|
|
|
'react-hooks/exhaustive-deps': ['error', { additionalHooks: '^useFetcher$' }],
|
|
|
|
},
|
|
|
|
},
|
2018-04-20 21:13:37 +02:00
|
|
|
|
2019-04-19 02:37:46 +02:00
|
|
|
/**
|
2020-06-04 11:35:13 +02:00
|
|
|
* Security Solution overrides
|
2019-04-19 02:37:46 +02:00
|
|
|
*/
|
|
|
|
{
|
2020-06-10 16:54:27 +02:00
|
|
|
// front end and common typescript and javascript files only
|
|
|
|
files: [
|
2020-06-30 16:13:28 +02:00
|
|
|
'x-pack/plugins/security_solution/public/**/*.{js,mjs,ts,tsx}',
|
|
|
|
'x-pack/plugins/security_solution/common/**/*.{js,mjs,ts,tsx}',
|
2020-06-10 16:54:27 +02:00
|
|
|
],
|
2019-04-19 02:37:46 +02:00
|
|
|
rules: {
|
2019-05-28 19:14:17 +02:00
|
|
|
'import/no-nodejs-modules': 'error',
|
|
|
|
'no-restricted-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
// prevents UI code from importing server side code and then webpack including it when doing builds
|
|
|
|
patterns: ['**/server/*'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// typescript only for front and back end
|
2020-09-23 09:52:51 +02:00
|
|
|
files: ['x-pack/plugins/security_solution/**/*.{ts,tsx}'],
|
2019-05-28 19:14:17 +02:00
|
|
|
rules: {
|
|
|
|
// This will be turned on after bug fixes are complete
|
|
|
|
// '@typescript-eslint/explicit-member-accessibility': 'warn',
|
|
|
|
'@typescript-eslint/no-this-alias': 'error',
|
2019-04-19 02:37:46 +02:00
|
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'@typescript-eslint/no-useless-constructor': 'error',
|
|
|
|
// This will be turned on after bug fixes are complete
|
|
|
|
// '@typescript-eslint/no-object-literal-type-assertion': 'warn',
|
|
|
|
'@typescript-eslint/unified-signatures': 'error',
|
|
|
|
|
|
|
|
// eventually we want this to be a warn and then an error since this is a recommended linter rule
|
|
|
|
// for now, keeping it commented out to avoid too much IDE noise until the other linter issues
|
|
|
|
// are fixed in the next release or two
|
|
|
|
// '@typescript-eslint/explicit-function-return-type': 'warn',
|
|
|
|
|
|
|
|
// these rules cannot be turned on and tested at the moment until this issue is resolved:
|
|
|
|
// https://github.com/prettier/prettier-eslint/issues/201
|
|
|
|
// '@typescript-eslint/await-thenable': 'error',
|
|
|
|
// '@typescript-eslint/no-non-null-assertion': 'error'
|
|
|
|
// '@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
|
|
// '@typescript-eslint/no-unused-vars': 'error',
|
|
|
|
// '@typescript-eslint/prefer-includes': 'error',
|
|
|
|
// '@typescript-eslint/prefer-string-starts-ends-with': 'error',
|
|
|
|
// '@typescript-eslint/promise-function-async': 'error',
|
|
|
|
// '@typescript-eslint/prefer-regexp-exec': 'error',
|
|
|
|
// '@typescript-eslint/promise-function-async': 'error',
|
|
|
|
// '@typescript-eslint/require-array-sort-compare': 'error',
|
|
|
|
// '@typescript-eslint/restrict-plus-operands': 'error',
|
|
|
|
// '@typescript-eslint/unbound-method': 'error',
|
|
|
|
},
|
|
|
|
},
|
2020-02-04 11:22:40 +01:00
|
|
|
// {
|
|
|
|
// // will introduced after the other warns are fixed
|
|
|
|
// // typescript and javascript for front end react performance
|
2020-06-30 16:13:28 +02:00
|
|
|
// files: ['x-pack/plugins/security_solution/public/**/!(*.test).{js,mjs,ts,tsx}'],
|
2020-02-04 11:22:40 +01:00
|
|
|
// plugins: ['react-perf'],
|
|
|
|
// rules: {
|
|
|
|
// // 'react-perf/jsx-no-new-object-as-prop': 'error',
|
|
|
|
// // 'react-perf/jsx-no-new-array-as-prop': 'error',
|
|
|
|
// // 'react-perf/jsx-no-new-function-as-prop': 'error',
|
|
|
|
// // 'react/jsx-no-bind': 'error',
|
|
|
|
// },
|
|
|
|
// },
|
2019-05-28 19:14:17 +02:00
|
|
|
{
|
|
|
|
// typescript and javascript for front and back end
|
2020-09-23 09:52:51 +02:00
|
|
|
files: ['x-pack/plugins/security_solution/**/*.{js,mjs,ts,tsx}'],
|
2019-06-11 06:15:11 +02:00
|
|
|
plugins: ['eslint-plugin-node', 'react'],
|
2019-09-30 20:25:06 +02:00
|
|
|
env: {
|
|
|
|
jest: true,
|
|
|
|
},
|
2019-05-28 19:14:17 +02:00
|
|
|
rules: {
|
|
|
|
'accessor-pairs': 'error',
|
|
|
|
'array-callback-return': 'error',
|
|
|
|
'no-array-constructor': 'error',
|
|
|
|
complexity: 'warn',
|
|
|
|
// This will be turned on after bug fixes are mostly completed
|
|
|
|
// 'consistent-return': 'warn',
|
|
|
|
// This will be turned on after bug fixes are mostly completed
|
|
|
|
// 'func-style': ['warn', 'expression'],
|
|
|
|
// These will be turned on after bug fixes are mostly completed and we can
|
|
|
|
// run a fix-lint
|
|
|
|
/*
|
|
|
|
'import/order': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
|
|
|
|
'newlines-between': 'always',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
*/
|
2019-06-11 06:15:11 +02:00
|
|
|
'node/no-deprecated-api': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'no-bitwise': 'error',
|
|
|
|
'no-continue': 'error',
|
|
|
|
'no-dupe-keys': 'error',
|
|
|
|
'no-duplicate-case': 'error',
|
2019-09-13 15:15:42 +02:00
|
|
|
'no-duplicate-imports': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'no-empty-character-class': 'error',
|
|
|
|
'no-empty-pattern': 'error',
|
|
|
|
'no-ex-assign': 'error',
|
|
|
|
'no-extend-native': 'error',
|
|
|
|
'no-extra-bind': 'error',
|
|
|
|
'no-extra-boolean-cast': 'error',
|
|
|
|
'no-extra-label': 'error',
|
|
|
|
'no-func-assign': 'error',
|
|
|
|
'no-implicit-globals': 'error',
|
|
|
|
'no-implied-eval': 'error',
|
|
|
|
'no-invalid-regexp': 'error',
|
|
|
|
'no-inner-declarations': 'error',
|
|
|
|
'no-lone-blocks': 'error',
|
|
|
|
'no-multi-assign': 'error',
|
|
|
|
'no-misleading-character-class': 'error',
|
|
|
|
'no-new-symbol': 'error',
|
|
|
|
'no-obj-calls': 'error',
|
2019-09-18 01:18:50 +02:00
|
|
|
'no-param-reassign': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'no-process-exit': 'error',
|
|
|
|
'no-prototype-builtins': 'error',
|
2019-09-18 23:09:52 +02:00
|
|
|
'no-return-await': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'no-self-compare': 'error',
|
|
|
|
'no-shadow-restricted-names': 'error',
|
|
|
|
'no-sparse-arrays': 'error',
|
|
|
|
'no-this-before-super': 'error',
|
2020-11-18 18:23:08 +01:00
|
|
|
// rely on typescript
|
|
|
|
'no-undef': 'off',
|
2019-05-28 19:14:17 +02:00
|
|
|
'no-unreachable': 'error',
|
|
|
|
'no-unsafe-finally': 'error',
|
|
|
|
'no-useless-call': 'error',
|
2020-01-07 17:46:56 +01:00
|
|
|
'no-useless-catch': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'no-useless-concat': 'error',
|
|
|
|
'no-useless-computed-key': 'error',
|
|
|
|
// This will be turned on after bug fixes are mostly complete
|
|
|
|
// 'no-useless-escape': 'warn',
|
|
|
|
'no-useless-rename': 'error',
|
2020-01-07 17:46:56 +01:00
|
|
|
'no-useless-return': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
// This will be turned on after bug fixers are mostly complete
|
|
|
|
// 'no-void': 'warn',
|
|
|
|
'one-var-declaration-per-line': 'error',
|
|
|
|
'prefer-object-spread': 'error',
|
|
|
|
'prefer-promise-reject-errors': 'error',
|
|
|
|
'prefer-rest-params': 'error',
|
|
|
|
'prefer-spread': 'error',
|
2020-01-07 18:02:32 +01:00
|
|
|
'prefer-template': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'react/boolean-prop-naming': 'error',
|
|
|
|
'react/button-has-type': 'error',
|
2020-01-07 18:05:04 +01:00
|
|
|
'react/display-name': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'react/forbid-dom-props': 'error',
|
2019-05-28 21:10:53 +02:00
|
|
|
'react/no-access-state-in-setstate': 'error',
|
2020-01-07 17:46:56 +01:00
|
|
|
'react/no-children-prop': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'react/no-danger-with-children': 'error',
|
|
|
|
'react/no-deprecated': 'error',
|
|
|
|
'react/no-did-mount-set-state': 'error',
|
2019-05-28 21:10:53 +02:00
|
|
|
// Re-enable once we have better options per this issue:
|
|
|
|
// https://github.com/airbnb/javascript/issues/1875
|
|
|
|
// 'react/no-did-update-set-state': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'react/no-direct-mutation-state': 'error',
|
|
|
|
'react/no-find-dom-node': 'error',
|
|
|
|
'react/no-redundant-should-component-update': 'error',
|
|
|
|
'react/no-render-return-value': 'error',
|
|
|
|
'react/no-typos': 'error',
|
|
|
|
'react/no-string-refs': 'error',
|
|
|
|
'react/no-this-in-sfc': 'error',
|
2019-05-28 20:33:51 +02:00
|
|
|
'react/no-unescaped-entities': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'react/no-unsafe': 'error',
|
|
|
|
'react/no-unused-prop-types': 'error',
|
|
|
|
'react/no-unused-state': 'error',
|
|
|
|
// will introduced after the other warns are fixed
|
|
|
|
// 'react/sort-comp': 'error',
|
|
|
|
'react/void-dom-elements-no-children': 'error',
|
|
|
|
'react/jsx-no-comment-textnodes': 'error',
|
2019-05-30 22:17:29 +02:00
|
|
|
'react/jsx-no-literals': 'error',
|
2019-05-28 19:14:17 +02:00
|
|
|
'react/jsx-no-target-blank': 'error',
|
|
|
|
'react/jsx-fragments': 'error',
|
|
|
|
'react/jsx-sort-default-props': 'error',
|
|
|
|
'require-atomic-updates': 'error',
|
|
|
|
'symbol-description': 'error',
|
|
|
|
'vars-on-top': 'error',
|
2019-04-19 02:37:46 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-04-29 00:00:22 +02:00
|
|
|
/**
|
|
|
|
* Lists overrides
|
|
|
|
*/
|
2020-06-10 16:54:27 +02:00
|
|
|
{
|
|
|
|
// front end and common typescript and javascript files only
|
|
|
|
files: [
|
2020-06-30 16:13:28 +02:00
|
|
|
'x-pack/plugins/lists/public/**/*.{js,mjs,ts,tsx}',
|
|
|
|
'x-pack/plugins/lists/common/**/*.{js,mjs,ts,tsx}',
|
2020-06-10 16:54:27 +02:00
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'import/no-nodejs-modules': 'error',
|
|
|
|
'no-restricted-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
// prevents UI code from importing server side code and then webpack including it when doing builds
|
|
|
|
patterns: ['**/server/*'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2020-04-29 00:00:22 +02:00
|
|
|
{
|
|
|
|
// typescript and javascript for front and back end
|
2020-06-30 16:13:28 +02:00
|
|
|
files: ['x-pack/plugins/lists/**/*.{js,mjs,ts,tsx}'],
|
2020-04-29 00:00:22 +02:00
|
|
|
plugins: ['eslint-plugin-node'],
|
|
|
|
env: {
|
|
|
|
jest: true,
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
'accessor-pairs': 'error',
|
|
|
|
'array-callback-return': 'error',
|
|
|
|
'no-array-constructor': 'error',
|
|
|
|
complexity: 'error',
|
|
|
|
'consistent-return': 'error',
|
|
|
|
'func-style': ['error', 'expression'],
|
|
|
|
'import/order': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
|
|
|
|
'newlines-between': 'always',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'sort-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
ignoreDeclarationSort: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'node/no-deprecated-api': 'error',
|
|
|
|
'no-bitwise': 'error',
|
|
|
|
'no-continue': 'error',
|
|
|
|
'no-dupe-keys': 'error',
|
|
|
|
'no-duplicate-case': 'error',
|
|
|
|
'no-duplicate-imports': 'error',
|
|
|
|
'no-empty-character-class': 'error',
|
|
|
|
'no-empty-pattern': 'error',
|
|
|
|
'no-ex-assign': 'error',
|
|
|
|
'no-extend-native': 'error',
|
|
|
|
'no-extra-bind': 'error',
|
|
|
|
'no-extra-boolean-cast': 'error',
|
|
|
|
'no-extra-label': 'error',
|
|
|
|
'no-func-assign': 'error',
|
|
|
|
'no-implicit-globals': 'error',
|
|
|
|
'no-implied-eval': 'error',
|
|
|
|
'no-invalid-regexp': 'error',
|
|
|
|
'no-inner-declarations': 'error',
|
|
|
|
'no-lone-blocks': 'error',
|
|
|
|
'no-multi-assign': 'error',
|
|
|
|
'no-misleading-character-class': 'error',
|
|
|
|
'no-new-symbol': 'error',
|
|
|
|
'no-obj-calls': 'error',
|
|
|
|
'no-param-reassign': ['error', { props: true }],
|
|
|
|
'no-process-exit': 'error',
|
|
|
|
'no-prototype-builtins': 'error',
|
|
|
|
'no-return-await': 'error',
|
|
|
|
'no-self-compare': 'error',
|
|
|
|
'no-shadow-restricted-names': 'error',
|
|
|
|
'no-sparse-arrays': 'error',
|
|
|
|
'no-this-before-super': 'error',
|
2020-11-18 18:23:08 +01:00
|
|
|
// rely on typescript
|
|
|
|
'no-undef': 'off',
|
2020-04-29 00:00:22 +02:00
|
|
|
'no-unreachable': 'error',
|
|
|
|
'no-unsafe-finally': 'error',
|
|
|
|
'no-useless-call': 'error',
|
|
|
|
'no-useless-catch': 'error',
|
|
|
|
'no-useless-concat': 'error',
|
|
|
|
'no-useless-computed-key': 'error',
|
|
|
|
'no-useless-escape': 'error',
|
|
|
|
'no-useless-rename': 'error',
|
|
|
|
'no-useless-return': 'error',
|
|
|
|
'no-void': 'error',
|
|
|
|
'one-var-declaration-per-line': 'error',
|
|
|
|
'prefer-object-spread': 'error',
|
|
|
|
'prefer-promise-reject-errors': 'error',
|
|
|
|
'prefer-rest-params': 'error',
|
|
|
|
'prefer-spread': 'error',
|
|
|
|
'prefer-template': 'error',
|
|
|
|
'require-atomic-updates': 'error',
|
|
|
|
'symbol-description': 'error',
|
|
|
|
'vars-on-top': 'error',
|
|
|
|
'@typescript-eslint/explicit-member-accessibility': 'error',
|
|
|
|
'@typescript-eslint/no-this-alias': 'error',
|
|
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
|
|
'@typescript-eslint/no-useless-constructor': 'error',
|
|
|
|
'@typescript-eslint/unified-signatures': 'error',
|
|
|
|
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
|
|
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
|
|
'@typescript-eslint/no-unused-vars': 'error',
|
|
|
|
'no-template-curly-in-string': 'error',
|
|
|
|
'sort-keys': 'error',
|
|
|
|
'prefer-destructuring': 'error',
|
|
|
|
},
|
|
|
|
},
|
2020-04-24 18:04:36 +02:00
|
|
|
/**
|
|
|
|
* Alerting Services overrides
|
|
|
|
*/
|
|
|
|
{
|
2020-11-12 17:39:40 +01:00
|
|
|
// typescript for front and back end
|
2020-10-06 18:51:05 +02:00
|
|
|
files: ['x-pack/plugins/{alerts,stack_alerts,actions,task_manager,event_log}/**/*.{ts,tsx}'],
|
2020-04-24 18:04:36 +02:00
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
|
|
},
|
2020-11-12 17:39:40 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// typescript only for back end
|
|
|
|
files: ['x-pack/plugins/triggers_actions_ui/server/**/*.ts'],
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
|
|
},
|
2020-04-24 18:04:36 +02:00
|
|
|
},
|
|
|
|
|
2019-09-17 20:57:53 +02:00
|
|
|
/**
|
|
|
|
* Lens overrides
|
|
|
|
*/
|
|
|
|
{
|
2020-04-15 12:22:37 +02:00
|
|
|
files: ['x-pack/plugins/lens/**/*.{ts,tsx}'],
|
2019-09-17 20:57:53 +02:00
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
New Enterprise Search Kibana plugin (#66922)
* Initial App Search in Kibana plugin work
- Initializes a new platform plugin that ships out of the box w/ x-pack
- Contains a very basic front-end that shows AS engines, error states, or a Setup Guide
- Contains a very basic server that remotely calls the AS internal engines API and returns results
* Update URL casing to match Kibana best practices
- URL casing appears to be snake_casing, but kibana.json casing appears to be camelCase
* Register App Search plugin in Home Feature Catalogue
* Add custom App Search in Kibana logo
- I haven't had much success in surfacing a SVG file via a server-side endpoint/URL, but then I realized EuiIcon supports passing in a ReactElement directly. Woo!
* Fix appSearch.host config setting to be optional
- instead of crashing folks on load
* Rename plugin to Enterprise Search
- per product decision, URL should be enterprise_search/app_search and Workplace Search should also eventually live here
- reorganize folder structure in anticipation for another workplace_search plugin/codebase living alongside app_search
- rename app.tsx/main.tsx to a standard top-level index.tsx (which will contain top-level routes/state)
- rename AS->ES files/vars where applicable
- TODO: React Router
* Set up React Router URL structure
* Convert showSetupGuide action/flag to a React Router link
- remove showSetupGuide flag
- add a new shared helper component for combining EuiButton/EuiLink with React Router behavior (https://github.com/elastic/eui/blob/master/wiki/react-router.md#react-router-51)
* Implement Kibana Chrome breadcrumbs
- create shared helper (WS will presumably also want this) for generating EUI breadcrumb objects with React Router links+click behavior
- create React component that calls chrome.setBreadcrumbs on page mount
- clean up type definitions - move app-wide props to IAppSearchProps and update most pages/views to simply import it instead of calling their own definitions
* Added server unit tests (#2)
* Added unit test for server
* PR Feedback
* Refactor top-level Kibana props to a global context state
- rather them passing them around verbosely as props, the components that need them should be able to call the useContext hook
+ Remove IAppSearchProps in favor of IKibanaContext
+ Also rename `appSearchUrl` to `enterpriseSearchUrl`, since this context will contained shared/Kibana-wide values/actions useful to both AS and WS
* Added unit tests for public (#4)
* application.test.ts
* Added Unit Test for EngineOverviewHeader
* Added Unit Test for generate_breadcrumbs
* Added Unit Test for set_breadcrumb.tsx
* Added a unit test for link_events
- Also changed link_events.tsx to link_events.ts since it's just TS, no
React
- Modified letBrowserHandleEvent so it will still return a false
boolean when target is blank
* Betterize these tests
Co-Authored-By: Constance <constancecchen@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add UI telemetry tracking to AS in Kibana (#5)
* Set up Telemetry usageCollection, savedObjects, route, & shared helper
- The Kibana UsageCollection plugin handles collecting our telemetry UI data (views, clicks, errors, etc.) and pushing it to elastic's telemetry servers
- That data is stored in incremented in Kibana's savedObjects lib/plugin (as well as mapped)
- When an end-user hits a certain view or action, the shared helper will ping the app search telemetry route which increments the savedObject store
* Update client-side views/links to new shared telemetry helper
* Write tests for new telemetry files
* Implement remaining unit tests (#7)
* Write tests for React Router+EUI helper components
* Update generate_breadcrumbs test
- add test suite for generateBreadcrumb() itself (in order to cover a missing branch)
- minor lint fixes
- remove unnecessary import from set_breadcrumbs test
* Write test for get_username util
+ update test to return a more consistent falsey value (null)
* Add test for SetupGuide
* [Refactor] Pull out various Kibana context mocks into separate files
- I'm creating a reusable useContext mock for shallow()ed enzyme components
+ add more documentation comments + examples
* Write tests for empty state components
+ test new usecontext shallow mock
* Empty state components: Add extra getUserName branch test
* Write test for app search index/routes
* Write tests for engine overview table
+ fix bonus bug
* Write Engine Overview tests
+ Update EngineOverview logic to account for issues found during tests :)
- Move http to async/await syntax instead of promise syntax (works better with existing HttpServiceMock jest.fn()s)
- hasValidData wasn't strict enough in type checking/object nest checking and was causing the app itself to crash (no bueno)
* Refactor EngineOverviewHeader test to use shallow + to full coverage
- missed adding this test during telemetry work
- switching to shallow and beforeAll reduces the test time from 5s to 4s!
* [Refactor] Pull out React Router history mocks into a test util helper
+ minor refactors/updates
* Add small tests to increase branch coverage
- mostly testing fallbacks or removing fallbacks in favor of strict type interface
- these are slightly obsessive so I'd also be fine ditching them if they aren't terribly valuable
* Address larger tech debt/TODOs (#8)
* Fix optional chaining TODO
- turns out my local Prettier wasn't up to date, completely my bad
* Fix constants TODO
- adds a common folder/architecture for others to use in the future
* Remove TODO for eslint-disable-line and specify lint rule being skipped
- hopefully that's OK for review, I can't think of any other way to sanely do this without re-architecting the entire file or DDoSing our API
* Add server-side logging to route dependencies
+ add basic example of error catching/logging to Telemetry route
+ [extra] refactor mockResponseFactory name to something slightly easier to read
* Move more Engines Overview API logic/logging to server-side
- handle data validation in the server-side
- wrap server-side API in a try/catch to account for fetch issues
- more correctly return 2xx/4xx statuses and more correctly deal with those responses in the front-end
- Add server info/error/debug logs (addresses TODO)
- Update tests + minor refactors/cleanup
- remove expectResponseToBe200With helper (since we're now returning multiple response types) and instead make mockResponse var name more readable
- one-line header auth
- update tests with example error logs
- update schema validation for `type` to be an enum of `indexed`/`meta` (more accurately reflecting API)
* Per telemetry team feedback, rename usageCollection telemetry mapping name to simpler 'app_search'
- since their mapping already nests under 'kibana.plugins'
- note: I left the savedObjects name with the '_telemetry' suffix, as there very well may be a use case for top-level generic 'app_search' saved objects
* Update Setup Guide installation instructions (#9)
Co-authored-by: Chris Cressman <chris@chriscressman.com>
* [Refactor] DRY out route test helper
* [Refactor] Rename public/test_utils to public/__mocks__
- to better follow/use jest setups and for .mock.ts suffixes
* Add platinum licensing check to Meta Engines table/call (#11)
* Licensing plugin setup
* Add LicensingContext setup
* Update EngineOverview to not hit meta engines API on platinum license
* Add Jest test helpers for future shallow/context use
* Update plugin to use new Kibana nav + URL update (#12)
* Update new nav categories to add Enterprise Search + update plugin to use new category
- per @johnbarrierwilson and Matt Riley, Enterprise Search should be under Kibana and above Observability
- Run `node scripts/check_published_api_changes.js --accept` since this new category affects public API
* [URL UPDATE] Change '/app/enterprise_search/app_search' to '/app/app_search'
- This needs to be done because App Search and Workplace search *have* to be registered as separate plugins to have 2 distinct nav links
- Currently Kibana doesn't support nested app names (see: https://github.com/elastic/kibana/issues/59190) but potentially will in the future
- To support this change, we need to update applications/index.tsx to NOT handle '/app/enterprise_search' level routing, but instead accept an async imported app component (e.g. AppSearch, WorkplaceSearch).
- AppSearch should now treat its router as root '/' instead of '/app_search'
- (Addl) Per Josh Dover's recommendation, switch to `<Router history={params.history}>` from `<BrowserRouter basename={params.appBasePath}>` since they're deprecating appBasePath
* Update breadcrumbs helper to account for new URLs
- Remove path for Enterprise Search breadcrumb, since '/app/enterprise_search' will not link anywhere meaningful for the foreseeable future, so the Enterprise Search root should not go anywhere
- Update App Search helper to go to root path, per new React Router setup
Test changes:
- Mock custom basepath for App Search tests
- Swap enterpriseSearchBreadcrumbs and appSearchBreadcrumbs test order (since the latter overrides the default mock)
* Add create_first_engine_button telemetry tracking to EmptyState
* Switch plugin URLs back to /app/enterprise_search/app_search
Now that https://github.com/elastic/kibana/pull/66455 has been merged in :tada:
* Add i18n formatted messages / translations (#13)
* Add i18n provider and formatted/i18n translated messages
* Update tests to account for new I18nProvider context + FormattedMessage components
- Add new mountWithContext helper that provides all contexts+providers used in top-level app
- Add new shallowWithIntl helper for shallow() components that dive into FormattedMessage
* Format i18n dates and numbers
+ update some mock tests to not throw react-intl invalid date messages
* Update EngineOverviewHeader to disable button on prop
* Address review feedback (#14)
* Fix Prettier linting issues
* Escape App Search API endpoint URLs
- per PR feedback
- querystring should automatically encodeURIComponent / escape query param strings
* Update server plugin.ts to use getStartServices() rather than storing local references from start()
- Per feedback: https://github.com/elastic/kibana/blob/master/src/core/CONVENTIONS.md#applications
- Note: savedObjects.registerType needs to be outside of getStartServices, or an error is thrown
- Side update to registerTelemetryUsageCollector to simplify args
- Update/fix tests to account for changes
* E2E testing (#6)
* Wired up basics for E2E testing
* Added version with App Search
* Updated naming
* Switched configuration around
* Added concept of 'fixtures'
* Figured out how to log in as the enterprise_search user
* Refactored to use an App Search service
* Added some real tests
* Added a README
* Cleanup
* More cleanup
* Error handling + README updatre
* Removed unnecessary files
* Apply suggestions from code review
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Update x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_table.tsx
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* PR feedback - updated README
* Additional lint fixes
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add README and CODEOWNERS (#15)
* Add plugin README and CODEOWNERS
* Fix Typescript errors (#16)
* Fix public mocks
* Fix empty states types
* Fix engine table component errors
* Fix engine overview component errors
* Fix setup guide component errors
- SetBreadcrumbs will be fixed in a separate commit
* Fix App Search index errors
* Fix engine overview header component errors
* Fix applications context index errors
* Fix kibana breadcrumb helper errors
* Fix license helper errors
* :exclamation: Refactor React Router EUI link/button helpers
- in order to fix typescript errors
- this changes the component logic significantly to a react render prop, so that the Link and Button components can have different types - however, end behavior should still remain the same
* Fix telemetry helper errors
* Minor unused var cleanup in plugin files
* Fix telemetry collector/savedobjects errors
* Fix MockRouter type errors and add IRouteDependencies export
- routes will use IRouteDependencies in the next few commits
* Fix engines route errors
* Fix telemetry route errors
* Remove any type from source code
- thanks to Scotty for the inspiration
* Add eslint rules for Enterprise Search plugin
- Add checks for type any, but only on non-test files
- Disable react-hooks/exhaustive-deps, since we're already disabling it in a few files and other plugins also have it turned off
* Cover uncovered lines in engines_table and telemetry tests
* Fixed TS warnings in E2E tests (#17)
* Feedback: Convert static CSS values to EUI variables where possible
* Feedback: Flatten nested CSS where possible
- Prefer setting CSS class overrides on individual EUI components, not on a top-level page
+ Change CSS class casing from kebab-case to camelCase to better match EUI/Kibana
+ Remove unnecessary .euiPageContentHeader margin-bottom override by changing the panelPaddingSize of euiPageContent
+ Decrease engine overview table padding on mobile
* Refactor out components shared with Workplace Search (#18)
* Move getUserName helper to shared
- in preparation for Workplace Search plugin also using this helper
* Move Setup Guide layout to a shared component
* Setup Guide: add extra props for standard/native auth links
Note: It's possible this commit may be unnecessary if we can publish shared Enterprise Search security mode docs
* Update copy per feedback from copy team
* Address various telemetry issues
- saved objects: removing indexing per #43673
- add schema and generate json per #64942
- move definitions over to collectors since saved objects is mostly empty at this point, and schema throws an error when it imports an obj instead of being defined inline
- istanbul ignore saved_objects file since it doesn't have anything meaningful to test but was affecting code coverage
* Disable plugin access if a normal user does not have access to App Search (#19)
* Set up new server security dependency and configs
* Set up access capabilities
* Set up checkAccess helper/caller
* Remove NoUserState component from the public UI
- Since this is now being handled by checkAccess / normal users should never see the plugin at all if they don't have an account/access, the component is no longer needed
* Update server routes to account for new changes
- Remove login redirect catch from routes, since the access helper should now handle that for most users by disabling the plugin (superusers will see a generic cannot connect/error screen)
- Refactor out new config values to a shared mock
* Refactor Enterprise Search http call to hit/return new internal API endpoint
+ pull out the http call to a separate library for upcoming public URL work (so that other files can call it directly as well)
* [Discussion] Increase timeout but add another warning timeout for slow servers
- per recommendation/convo with Brandon
* Register feature control
* Remove no_as_account from UI telemetry
- since we're no longer tracking that in the UI
* Address PR feedback - isSuperUser check
* Public URL support for Elastic Cloud (#21)
* Add server-side public URL route
- Per feedback from Kibana platform team, it's not possible to pass info from server/ to public/ without a HTTP call :[
* Update MockRouter for routes without any payload/params
* Add client-side helper for calling the new public URL API
+ API seems to return a URL a trailing slash, which we need to omit
* Update public/plugin.ts to check and set a public URL
- relies on this.hasCheckedPublicUrl to only make the call once per page load instead of on every page nav
* Fix failing feature control tests
- Split up scenario cases as needed
- Add plugin as an exception alongside ML & Monitoring
* Address PR feedback
- version: kibana
- copy edits
- Sass vars
- code cleanup
* Casing feedback: change all plugin registration IDs from snake_case to camelCase
- note: current remainng snake_case exceptions are telemetry keys
- file names and api endpoints are snake_case per conventions
* Misc security feedback
- remove set
- remove unnecessary capabilities registration
- telemetry namespace agnostic
* Security feedback: add warn logging to telemetry collector
see https://github.com/elastic/kibana/pull/66922#discussion_r451215760
- add if statement
- pass log dependency around (this is kinda medium, should maybe refactor)
- update tests
- move test file comment to the right file (was meant for telemetry route file)
* Address feedback from Pierre
- Remove unnecessary ServerConfigType
- Remove unnecessary uiCapabilities
- Move registerTelemetryRoute / SavedObjectsServiceStart workaround
- Remove unnecessary license optional chaining
* PR feedback
Address type/typos
* Fix telemetry API call returning 415 on Chrome
- I can't even?? I swear charset=utf-8 fixed the same error a few weeks ago
* Fix failing tests
* Update Enterprise Search functional tests (without host) to run on CI
- Fix incorrect navigateToApp slug (hadn't realized this was a URL, not an ID)
- Update without_host_configured tests to run without API key
- Update README
* Address PR feedback from Pierre
- remove unnecessary authz?
- remove unnecessary content-type json headers
- add loggingSystemMock.collect(mockLogger).error assertion
- reconstrcut new MockRouter on beforeEach for better sandboxing
- fix incorrect describe()s -should be it()
- pull out reusable mockDependencies helper (renamed/extended from mockConfig) for tests that don't particularly use config/log but still want to pass type definitions
- Fix comment copy
Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
Co-authored-by: Chris Cressman <chris@chriscressman.com>
Co-authored-by: scottybollinger <scotty.bollinger@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-07-09 22:10:31 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enterprise Search overrides
|
2021-02-05 19:38:37 +01:00
|
|
|
* NOTE: We also have a single rule at the bottom of the file that
|
|
|
|
* overrides Prettier's default of not linting unnecessary backticks
|
New Enterprise Search Kibana plugin (#66922)
* Initial App Search in Kibana plugin work
- Initializes a new platform plugin that ships out of the box w/ x-pack
- Contains a very basic front-end that shows AS engines, error states, or a Setup Guide
- Contains a very basic server that remotely calls the AS internal engines API and returns results
* Update URL casing to match Kibana best practices
- URL casing appears to be snake_casing, but kibana.json casing appears to be camelCase
* Register App Search plugin in Home Feature Catalogue
* Add custom App Search in Kibana logo
- I haven't had much success in surfacing a SVG file via a server-side endpoint/URL, but then I realized EuiIcon supports passing in a ReactElement directly. Woo!
* Fix appSearch.host config setting to be optional
- instead of crashing folks on load
* Rename plugin to Enterprise Search
- per product decision, URL should be enterprise_search/app_search and Workplace Search should also eventually live here
- reorganize folder structure in anticipation for another workplace_search plugin/codebase living alongside app_search
- rename app.tsx/main.tsx to a standard top-level index.tsx (which will contain top-level routes/state)
- rename AS->ES files/vars where applicable
- TODO: React Router
* Set up React Router URL structure
* Convert showSetupGuide action/flag to a React Router link
- remove showSetupGuide flag
- add a new shared helper component for combining EuiButton/EuiLink with React Router behavior (https://github.com/elastic/eui/blob/master/wiki/react-router.md#react-router-51)
* Implement Kibana Chrome breadcrumbs
- create shared helper (WS will presumably also want this) for generating EUI breadcrumb objects with React Router links+click behavior
- create React component that calls chrome.setBreadcrumbs on page mount
- clean up type definitions - move app-wide props to IAppSearchProps and update most pages/views to simply import it instead of calling their own definitions
* Added server unit tests (#2)
* Added unit test for server
* PR Feedback
* Refactor top-level Kibana props to a global context state
- rather them passing them around verbosely as props, the components that need them should be able to call the useContext hook
+ Remove IAppSearchProps in favor of IKibanaContext
+ Also rename `appSearchUrl` to `enterpriseSearchUrl`, since this context will contained shared/Kibana-wide values/actions useful to both AS and WS
* Added unit tests for public (#4)
* application.test.ts
* Added Unit Test for EngineOverviewHeader
* Added Unit Test for generate_breadcrumbs
* Added Unit Test for set_breadcrumb.tsx
* Added a unit test for link_events
- Also changed link_events.tsx to link_events.ts since it's just TS, no
React
- Modified letBrowserHandleEvent so it will still return a false
boolean when target is blank
* Betterize these tests
Co-Authored-By: Constance <constancecchen@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add UI telemetry tracking to AS in Kibana (#5)
* Set up Telemetry usageCollection, savedObjects, route, & shared helper
- The Kibana UsageCollection plugin handles collecting our telemetry UI data (views, clicks, errors, etc.) and pushing it to elastic's telemetry servers
- That data is stored in incremented in Kibana's savedObjects lib/plugin (as well as mapped)
- When an end-user hits a certain view or action, the shared helper will ping the app search telemetry route which increments the savedObject store
* Update client-side views/links to new shared telemetry helper
* Write tests for new telemetry files
* Implement remaining unit tests (#7)
* Write tests for React Router+EUI helper components
* Update generate_breadcrumbs test
- add test suite for generateBreadcrumb() itself (in order to cover a missing branch)
- minor lint fixes
- remove unnecessary import from set_breadcrumbs test
* Write test for get_username util
+ update test to return a more consistent falsey value (null)
* Add test for SetupGuide
* [Refactor] Pull out various Kibana context mocks into separate files
- I'm creating a reusable useContext mock for shallow()ed enzyme components
+ add more documentation comments + examples
* Write tests for empty state components
+ test new usecontext shallow mock
* Empty state components: Add extra getUserName branch test
* Write test for app search index/routes
* Write tests for engine overview table
+ fix bonus bug
* Write Engine Overview tests
+ Update EngineOverview logic to account for issues found during tests :)
- Move http to async/await syntax instead of promise syntax (works better with existing HttpServiceMock jest.fn()s)
- hasValidData wasn't strict enough in type checking/object nest checking and was causing the app itself to crash (no bueno)
* Refactor EngineOverviewHeader test to use shallow + to full coverage
- missed adding this test during telemetry work
- switching to shallow and beforeAll reduces the test time from 5s to 4s!
* [Refactor] Pull out React Router history mocks into a test util helper
+ minor refactors/updates
* Add small tests to increase branch coverage
- mostly testing fallbacks or removing fallbacks in favor of strict type interface
- these are slightly obsessive so I'd also be fine ditching them if they aren't terribly valuable
* Address larger tech debt/TODOs (#8)
* Fix optional chaining TODO
- turns out my local Prettier wasn't up to date, completely my bad
* Fix constants TODO
- adds a common folder/architecture for others to use in the future
* Remove TODO for eslint-disable-line and specify lint rule being skipped
- hopefully that's OK for review, I can't think of any other way to sanely do this without re-architecting the entire file or DDoSing our API
* Add server-side logging to route dependencies
+ add basic example of error catching/logging to Telemetry route
+ [extra] refactor mockResponseFactory name to something slightly easier to read
* Move more Engines Overview API logic/logging to server-side
- handle data validation in the server-side
- wrap server-side API in a try/catch to account for fetch issues
- more correctly return 2xx/4xx statuses and more correctly deal with those responses in the front-end
- Add server info/error/debug logs (addresses TODO)
- Update tests + minor refactors/cleanup
- remove expectResponseToBe200With helper (since we're now returning multiple response types) and instead make mockResponse var name more readable
- one-line header auth
- update tests with example error logs
- update schema validation for `type` to be an enum of `indexed`/`meta` (more accurately reflecting API)
* Per telemetry team feedback, rename usageCollection telemetry mapping name to simpler 'app_search'
- since their mapping already nests under 'kibana.plugins'
- note: I left the savedObjects name with the '_telemetry' suffix, as there very well may be a use case for top-level generic 'app_search' saved objects
* Update Setup Guide installation instructions (#9)
Co-authored-by: Chris Cressman <chris@chriscressman.com>
* [Refactor] DRY out route test helper
* [Refactor] Rename public/test_utils to public/__mocks__
- to better follow/use jest setups and for .mock.ts suffixes
* Add platinum licensing check to Meta Engines table/call (#11)
* Licensing plugin setup
* Add LicensingContext setup
* Update EngineOverview to not hit meta engines API on platinum license
* Add Jest test helpers for future shallow/context use
* Update plugin to use new Kibana nav + URL update (#12)
* Update new nav categories to add Enterprise Search + update plugin to use new category
- per @johnbarrierwilson and Matt Riley, Enterprise Search should be under Kibana and above Observability
- Run `node scripts/check_published_api_changes.js --accept` since this new category affects public API
* [URL UPDATE] Change '/app/enterprise_search/app_search' to '/app/app_search'
- This needs to be done because App Search and Workplace search *have* to be registered as separate plugins to have 2 distinct nav links
- Currently Kibana doesn't support nested app names (see: https://github.com/elastic/kibana/issues/59190) but potentially will in the future
- To support this change, we need to update applications/index.tsx to NOT handle '/app/enterprise_search' level routing, but instead accept an async imported app component (e.g. AppSearch, WorkplaceSearch).
- AppSearch should now treat its router as root '/' instead of '/app_search'
- (Addl) Per Josh Dover's recommendation, switch to `<Router history={params.history}>` from `<BrowserRouter basename={params.appBasePath}>` since they're deprecating appBasePath
* Update breadcrumbs helper to account for new URLs
- Remove path for Enterprise Search breadcrumb, since '/app/enterprise_search' will not link anywhere meaningful for the foreseeable future, so the Enterprise Search root should not go anywhere
- Update App Search helper to go to root path, per new React Router setup
Test changes:
- Mock custom basepath for App Search tests
- Swap enterpriseSearchBreadcrumbs and appSearchBreadcrumbs test order (since the latter overrides the default mock)
* Add create_first_engine_button telemetry tracking to EmptyState
* Switch plugin URLs back to /app/enterprise_search/app_search
Now that https://github.com/elastic/kibana/pull/66455 has been merged in :tada:
* Add i18n formatted messages / translations (#13)
* Add i18n provider and formatted/i18n translated messages
* Update tests to account for new I18nProvider context + FormattedMessage components
- Add new mountWithContext helper that provides all contexts+providers used in top-level app
- Add new shallowWithIntl helper for shallow() components that dive into FormattedMessage
* Format i18n dates and numbers
+ update some mock tests to not throw react-intl invalid date messages
* Update EngineOverviewHeader to disable button on prop
* Address review feedback (#14)
* Fix Prettier linting issues
* Escape App Search API endpoint URLs
- per PR feedback
- querystring should automatically encodeURIComponent / escape query param strings
* Update server plugin.ts to use getStartServices() rather than storing local references from start()
- Per feedback: https://github.com/elastic/kibana/blob/master/src/core/CONVENTIONS.md#applications
- Note: savedObjects.registerType needs to be outside of getStartServices, or an error is thrown
- Side update to registerTelemetryUsageCollector to simplify args
- Update/fix tests to account for changes
* E2E testing (#6)
* Wired up basics for E2E testing
* Added version with App Search
* Updated naming
* Switched configuration around
* Added concept of 'fixtures'
* Figured out how to log in as the enterprise_search user
* Refactored to use an App Search service
* Added some real tests
* Added a README
* Cleanup
* More cleanup
* Error handling + README updatre
* Removed unnecessary files
* Apply suggestions from code review
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Update x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_table.tsx
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* PR feedback - updated README
* Additional lint fixes
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add README and CODEOWNERS (#15)
* Add plugin README and CODEOWNERS
* Fix Typescript errors (#16)
* Fix public mocks
* Fix empty states types
* Fix engine table component errors
* Fix engine overview component errors
* Fix setup guide component errors
- SetBreadcrumbs will be fixed in a separate commit
* Fix App Search index errors
* Fix engine overview header component errors
* Fix applications context index errors
* Fix kibana breadcrumb helper errors
* Fix license helper errors
* :exclamation: Refactor React Router EUI link/button helpers
- in order to fix typescript errors
- this changes the component logic significantly to a react render prop, so that the Link and Button components can have different types - however, end behavior should still remain the same
* Fix telemetry helper errors
* Minor unused var cleanup in plugin files
* Fix telemetry collector/savedobjects errors
* Fix MockRouter type errors and add IRouteDependencies export
- routes will use IRouteDependencies in the next few commits
* Fix engines route errors
* Fix telemetry route errors
* Remove any type from source code
- thanks to Scotty for the inspiration
* Add eslint rules for Enterprise Search plugin
- Add checks for type any, but only on non-test files
- Disable react-hooks/exhaustive-deps, since we're already disabling it in a few files and other plugins also have it turned off
* Cover uncovered lines in engines_table and telemetry tests
* Fixed TS warnings in E2E tests (#17)
* Feedback: Convert static CSS values to EUI variables where possible
* Feedback: Flatten nested CSS where possible
- Prefer setting CSS class overrides on individual EUI components, not on a top-level page
+ Change CSS class casing from kebab-case to camelCase to better match EUI/Kibana
+ Remove unnecessary .euiPageContentHeader margin-bottom override by changing the panelPaddingSize of euiPageContent
+ Decrease engine overview table padding on mobile
* Refactor out components shared with Workplace Search (#18)
* Move getUserName helper to shared
- in preparation for Workplace Search plugin also using this helper
* Move Setup Guide layout to a shared component
* Setup Guide: add extra props for standard/native auth links
Note: It's possible this commit may be unnecessary if we can publish shared Enterprise Search security mode docs
* Update copy per feedback from copy team
* Address various telemetry issues
- saved objects: removing indexing per #43673
- add schema and generate json per #64942
- move definitions over to collectors since saved objects is mostly empty at this point, and schema throws an error when it imports an obj instead of being defined inline
- istanbul ignore saved_objects file since it doesn't have anything meaningful to test but was affecting code coverage
* Disable plugin access if a normal user does not have access to App Search (#19)
* Set up new server security dependency and configs
* Set up access capabilities
* Set up checkAccess helper/caller
* Remove NoUserState component from the public UI
- Since this is now being handled by checkAccess / normal users should never see the plugin at all if they don't have an account/access, the component is no longer needed
* Update server routes to account for new changes
- Remove login redirect catch from routes, since the access helper should now handle that for most users by disabling the plugin (superusers will see a generic cannot connect/error screen)
- Refactor out new config values to a shared mock
* Refactor Enterprise Search http call to hit/return new internal API endpoint
+ pull out the http call to a separate library for upcoming public URL work (so that other files can call it directly as well)
* [Discussion] Increase timeout but add another warning timeout for slow servers
- per recommendation/convo with Brandon
* Register feature control
* Remove no_as_account from UI telemetry
- since we're no longer tracking that in the UI
* Address PR feedback - isSuperUser check
* Public URL support for Elastic Cloud (#21)
* Add server-side public URL route
- Per feedback from Kibana platform team, it's not possible to pass info from server/ to public/ without a HTTP call :[
* Update MockRouter for routes without any payload/params
* Add client-side helper for calling the new public URL API
+ API seems to return a URL a trailing slash, which we need to omit
* Update public/plugin.ts to check and set a public URL
- relies on this.hasCheckedPublicUrl to only make the call once per page load instead of on every page nav
* Fix failing feature control tests
- Split up scenario cases as needed
- Add plugin as an exception alongside ML & Monitoring
* Address PR feedback
- version: kibana
- copy edits
- Sass vars
- code cleanup
* Casing feedback: change all plugin registration IDs from snake_case to camelCase
- note: current remainng snake_case exceptions are telemetry keys
- file names and api endpoints are snake_case per conventions
* Misc security feedback
- remove set
- remove unnecessary capabilities registration
- telemetry namespace agnostic
* Security feedback: add warn logging to telemetry collector
see https://github.com/elastic/kibana/pull/66922#discussion_r451215760
- add if statement
- pass log dependency around (this is kinda medium, should maybe refactor)
- update tests
- move test file comment to the right file (was meant for telemetry route file)
* Address feedback from Pierre
- Remove unnecessary ServerConfigType
- Remove unnecessary uiCapabilities
- Move registerTelemetryRoute / SavedObjectsServiceStart workaround
- Remove unnecessary license optional chaining
* PR feedback
Address type/typos
* Fix telemetry API call returning 415 on Chrome
- I can't even?? I swear charset=utf-8 fixed the same error a few weeks ago
* Fix failing tests
* Update Enterprise Search functional tests (without host) to run on CI
- Fix incorrect navigateToApp slug (hadn't realized this was a URL, not an ID)
- Update without_host_configured tests to run without API key
- Update README
* Address PR feedback from Pierre
- remove unnecessary authz?
- remove unnecessary content-type json headers
- add loggingSystemMock.collect(mockLogger).error assertion
- reconstrcut new MockRouter on beforeEach for better sandboxing
- fix incorrect describe()s -should be it()
- pull out reusable mockDependencies helper (renamed/extended from mockConfig) for tests that don't particularly use config/log but still want to pass type definitions
- Fix comment copy
Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
Co-authored-by: Chris Cressman <chris@chriscressman.com>
Co-authored-by: scottybollinger <scotty.bollinger@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-07-09 22:10:31 +02:00
|
|
|
*/
|
|
|
|
{
|
2021-02-05 18:01:01 +01:00
|
|
|
// All files
|
New Enterprise Search Kibana plugin (#66922)
* Initial App Search in Kibana plugin work
- Initializes a new platform plugin that ships out of the box w/ x-pack
- Contains a very basic front-end that shows AS engines, error states, or a Setup Guide
- Contains a very basic server that remotely calls the AS internal engines API and returns results
* Update URL casing to match Kibana best practices
- URL casing appears to be snake_casing, but kibana.json casing appears to be camelCase
* Register App Search plugin in Home Feature Catalogue
* Add custom App Search in Kibana logo
- I haven't had much success in surfacing a SVG file via a server-side endpoint/URL, but then I realized EuiIcon supports passing in a ReactElement directly. Woo!
* Fix appSearch.host config setting to be optional
- instead of crashing folks on load
* Rename plugin to Enterprise Search
- per product decision, URL should be enterprise_search/app_search and Workplace Search should also eventually live here
- reorganize folder structure in anticipation for another workplace_search plugin/codebase living alongside app_search
- rename app.tsx/main.tsx to a standard top-level index.tsx (which will contain top-level routes/state)
- rename AS->ES files/vars where applicable
- TODO: React Router
* Set up React Router URL structure
* Convert showSetupGuide action/flag to a React Router link
- remove showSetupGuide flag
- add a new shared helper component for combining EuiButton/EuiLink with React Router behavior (https://github.com/elastic/eui/blob/master/wiki/react-router.md#react-router-51)
* Implement Kibana Chrome breadcrumbs
- create shared helper (WS will presumably also want this) for generating EUI breadcrumb objects with React Router links+click behavior
- create React component that calls chrome.setBreadcrumbs on page mount
- clean up type definitions - move app-wide props to IAppSearchProps and update most pages/views to simply import it instead of calling their own definitions
* Added server unit tests (#2)
* Added unit test for server
* PR Feedback
* Refactor top-level Kibana props to a global context state
- rather them passing them around verbosely as props, the components that need them should be able to call the useContext hook
+ Remove IAppSearchProps in favor of IKibanaContext
+ Also rename `appSearchUrl` to `enterpriseSearchUrl`, since this context will contained shared/Kibana-wide values/actions useful to both AS and WS
* Added unit tests for public (#4)
* application.test.ts
* Added Unit Test for EngineOverviewHeader
* Added Unit Test for generate_breadcrumbs
* Added Unit Test for set_breadcrumb.tsx
* Added a unit test for link_events
- Also changed link_events.tsx to link_events.ts since it's just TS, no
React
- Modified letBrowserHandleEvent so it will still return a false
boolean when target is blank
* Betterize these tests
Co-Authored-By: Constance <constancecchen@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add UI telemetry tracking to AS in Kibana (#5)
* Set up Telemetry usageCollection, savedObjects, route, & shared helper
- The Kibana UsageCollection plugin handles collecting our telemetry UI data (views, clicks, errors, etc.) and pushing it to elastic's telemetry servers
- That data is stored in incremented in Kibana's savedObjects lib/plugin (as well as mapped)
- When an end-user hits a certain view or action, the shared helper will ping the app search telemetry route which increments the savedObject store
* Update client-side views/links to new shared telemetry helper
* Write tests for new telemetry files
* Implement remaining unit tests (#7)
* Write tests for React Router+EUI helper components
* Update generate_breadcrumbs test
- add test suite for generateBreadcrumb() itself (in order to cover a missing branch)
- minor lint fixes
- remove unnecessary import from set_breadcrumbs test
* Write test for get_username util
+ update test to return a more consistent falsey value (null)
* Add test for SetupGuide
* [Refactor] Pull out various Kibana context mocks into separate files
- I'm creating a reusable useContext mock for shallow()ed enzyme components
+ add more documentation comments + examples
* Write tests for empty state components
+ test new usecontext shallow mock
* Empty state components: Add extra getUserName branch test
* Write test for app search index/routes
* Write tests for engine overview table
+ fix bonus bug
* Write Engine Overview tests
+ Update EngineOverview logic to account for issues found during tests :)
- Move http to async/await syntax instead of promise syntax (works better with existing HttpServiceMock jest.fn()s)
- hasValidData wasn't strict enough in type checking/object nest checking and was causing the app itself to crash (no bueno)
* Refactor EngineOverviewHeader test to use shallow + to full coverage
- missed adding this test during telemetry work
- switching to shallow and beforeAll reduces the test time from 5s to 4s!
* [Refactor] Pull out React Router history mocks into a test util helper
+ minor refactors/updates
* Add small tests to increase branch coverage
- mostly testing fallbacks or removing fallbacks in favor of strict type interface
- these are slightly obsessive so I'd also be fine ditching them if they aren't terribly valuable
* Address larger tech debt/TODOs (#8)
* Fix optional chaining TODO
- turns out my local Prettier wasn't up to date, completely my bad
* Fix constants TODO
- adds a common folder/architecture for others to use in the future
* Remove TODO for eslint-disable-line and specify lint rule being skipped
- hopefully that's OK for review, I can't think of any other way to sanely do this without re-architecting the entire file or DDoSing our API
* Add server-side logging to route dependencies
+ add basic example of error catching/logging to Telemetry route
+ [extra] refactor mockResponseFactory name to something slightly easier to read
* Move more Engines Overview API logic/logging to server-side
- handle data validation in the server-side
- wrap server-side API in a try/catch to account for fetch issues
- more correctly return 2xx/4xx statuses and more correctly deal with those responses in the front-end
- Add server info/error/debug logs (addresses TODO)
- Update tests + minor refactors/cleanup
- remove expectResponseToBe200With helper (since we're now returning multiple response types) and instead make mockResponse var name more readable
- one-line header auth
- update tests with example error logs
- update schema validation for `type` to be an enum of `indexed`/`meta` (more accurately reflecting API)
* Per telemetry team feedback, rename usageCollection telemetry mapping name to simpler 'app_search'
- since their mapping already nests under 'kibana.plugins'
- note: I left the savedObjects name with the '_telemetry' suffix, as there very well may be a use case for top-level generic 'app_search' saved objects
* Update Setup Guide installation instructions (#9)
Co-authored-by: Chris Cressman <chris@chriscressman.com>
* [Refactor] DRY out route test helper
* [Refactor] Rename public/test_utils to public/__mocks__
- to better follow/use jest setups and for .mock.ts suffixes
* Add platinum licensing check to Meta Engines table/call (#11)
* Licensing plugin setup
* Add LicensingContext setup
* Update EngineOverview to not hit meta engines API on platinum license
* Add Jest test helpers for future shallow/context use
* Update plugin to use new Kibana nav + URL update (#12)
* Update new nav categories to add Enterprise Search + update plugin to use new category
- per @johnbarrierwilson and Matt Riley, Enterprise Search should be under Kibana and above Observability
- Run `node scripts/check_published_api_changes.js --accept` since this new category affects public API
* [URL UPDATE] Change '/app/enterprise_search/app_search' to '/app/app_search'
- This needs to be done because App Search and Workplace search *have* to be registered as separate plugins to have 2 distinct nav links
- Currently Kibana doesn't support nested app names (see: https://github.com/elastic/kibana/issues/59190) but potentially will in the future
- To support this change, we need to update applications/index.tsx to NOT handle '/app/enterprise_search' level routing, but instead accept an async imported app component (e.g. AppSearch, WorkplaceSearch).
- AppSearch should now treat its router as root '/' instead of '/app_search'
- (Addl) Per Josh Dover's recommendation, switch to `<Router history={params.history}>` from `<BrowserRouter basename={params.appBasePath}>` since they're deprecating appBasePath
* Update breadcrumbs helper to account for new URLs
- Remove path for Enterprise Search breadcrumb, since '/app/enterprise_search' will not link anywhere meaningful for the foreseeable future, so the Enterprise Search root should not go anywhere
- Update App Search helper to go to root path, per new React Router setup
Test changes:
- Mock custom basepath for App Search tests
- Swap enterpriseSearchBreadcrumbs and appSearchBreadcrumbs test order (since the latter overrides the default mock)
* Add create_first_engine_button telemetry tracking to EmptyState
* Switch plugin URLs back to /app/enterprise_search/app_search
Now that https://github.com/elastic/kibana/pull/66455 has been merged in :tada:
* Add i18n formatted messages / translations (#13)
* Add i18n provider and formatted/i18n translated messages
* Update tests to account for new I18nProvider context + FormattedMessage components
- Add new mountWithContext helper that provides all contexts+providers used in top-level app
- Add new shallowWithIntl helper for shallow() components that dive into FormattedMessage
* Format i18n dates and numbers
+ update some mock tests to not throw react-intl invalid date messages
* Update EngineOverviewHeader to disable button on prop
* Address review feedback (#14)
* Fix Prettier linting issues
* Escape App Search API endpoint URLs
- per PR feedback
- querystring should automatically encodeURIComponent / escape query param strings
* Update server plugin.ts to use getStartServices() rather than storing local references from start()
- Per feedback: https://github.com/elastic/kibana/blob/master/src/core/CONVENTIONS.md#applications
- Note: savedObjects.registerType needs to be outside of getStartServices, or an error is thrown
- Side update to registerTelemetryUsageCollector to simplify args
- Update/fix tests to account for changes
* E2E testing (#6)
* Wired up basics for E2E testing
* Added version with App Search
* Updated naming
* Switched configuration around
* Added concept of 'fixtures'
* Figured out how to log in as the enterprise_search user
* Refactored to use an App Search service
* Added some real tests
* Added a README
* Cleanup
* More cleanup
* Error handling + README updatre
* Removed unnecessary files
* Apply suggestions from code review
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Update x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_table.tsx
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* PR feedback - updated README
* Additional lint fixes
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add README and CODEOWNERS (#15)
* Add plugin README and CODEOWNERS
* Fix Typescript errors (#16)
* Fix public mocks
* Fix empty states types
* Fix engine table component errors
* Fix engine overview component errors
* Fix setup guide component errors
- SetBreadcrumbs will be fixed in a separate commit
* Fix App Search index errors
* Fix engine overview header component errors
* Fix applications context index errors
* Fix kibana breadcrumb helper errors
* Fix license helper errors
* :exclamation: Refactor React Router EUI link/button helpers
- in order to fix typescript errors
- this changes the component logic significantly to a react render prop, so that the Link and Button components can have different types - however, end behavior should still remain the same
* Fix telemetry helper errors
* Minor unused var cleanup in plugin files
* Fix telemetry collector/savedobjects errors
* Fix MockRouter type errors and add IRouteDependencies export
- routes will use IRouteDependencies in the next few commits
* Fix engines route errors
* Fix telemetry route errors
* Remove any type from source code
- thanks to Scotty for the inspiration
* Add eslint rules for Enterprise Search plugin
- Add checks for type any, but only on non-test files
- Disable react-hooks/exhaustive-deps, since we're already disabling it in a few files and other plugins also have it turned off
* Cover uncovered lines in engines_table and telemetry tests
* Fixed TS warnings in E2E tests (#17)
* Feedback: Convert static CSS values to EUI variables where possible
* Feedback: Flatten nested CSS where possible
- Prefer setting CSS class overrides on individual EUI components, not on a top-level page
+ Change CSS class casing from kebab-case to camelCase to better match EUI/Kibana
+ Remove unnecessary .euiPageContentHeader margin-bottom override by changing the panelPaddingSize of euiPageContent
+ Decrease engine overview table padding on mobile
* Refactor out components shared with Workplace Search (#18)
* Move getUserName helper to shared
- in preparation for Workplace Search plugin also using this helper
* Move Setup Guide layout to a shared component
* Setup Guide: add extra props for standard/native auth links
Note: It's possible this commit may be unnecessary if we can publish shared Enterprise Search security mode docs
* Update copy per feedback from copy team
* Address various telemetry issues
- saved objects: removing indexing per #43673
- add schema and generate json per #64942
- move definitions over to collectors since saved objects is mostly empty at this point, and schema throws an error when it imports an obj instead of being defined inline
- istanbul ignore saved_objects file since it doesn't have anything meaningful to test but was affecting code coverage
* Disable plugin access if a normal user does not have access to App Search (#19)
* Set up new server security dependency and configs
* Set up access capabilities
* Set up checkAccess helper/caller
* Remove NoUserState component from the public UI
- Since this is now being handled by checkAccess / normal users should never see the plugin at all if they don't have an account/access, the component is no longer needed
* Update server routes to account for new changes
- Remove login redirect catch from routes, since the access helper should now handle that for most users by disabling the plugin (superusers will see a generic cannot connect/error screen)
- Refactor out new config values to a shared mock
* Refactor Enterprise Search http call to hit/return new internal API endpoint
+ pull out the http call to a separate library for upcoming public URL work (so that other files can call it directly as well)
* [Discussion] Increase timeout but add another warning timeout for slow servers
- per recommendation/convo with Brandon
* Register feature control
* Remove no_as_account from UI telemetry
- since we're no longer tracking that in the UI
* Address PR feedback - isSuperUser check
* Public URL support for Elastic Cloud (#21)
* Add server-side public URL route
- Per feedback from Kibana platform team, it's not possible to pass info from server/ to public/ without a HTTP call :[
* Update MockRouter for routes without any payload/params
* Add client-side helper for calling the new public URL API
+ API seems to return a URL a trailing slash, which we need to omit
* Update public/plugin.ts to check and set a public URL
- relies on this.hasCheckedPublicUrl to only make the call once per page load instead of on every page nav
* Fix failing feature control tests
- Split up scenario cases as needed
- Add plugin as an exception alongside ML & Monitoring
* Address PR feedback
- version: kibana
- copy edits
- Sass vars
- code cleanup
* Casing feedback: change all plugin registration IDs from snake_case to camelCase
- note: current remainng snake_case exceptions are telemetry keys
- file names and api endpoints are snake_case per conventions
* Misc security feedback
- remove set
- remove unnecessary capabilities registration
- telemetry namespace agnostic
* Security feedback: add warn logging to telemetry collector
see https://github.com/elastic/kibana/pull/66922#discussion_r451215760
- add if statement
- pass log dependency around (this is kinda medium, should maybe refactor)
- update tests
- move test file comment to the right file (was meant for telemetry route file)
* Address feedback from Pierre
- Remove unnecessary ServerConfigType
- Remove unnecessary uiCapabilities
- Move registerTelemetryRoute / SavedObjectsServiceStart workaround
- Remove unnecessary license optional chaining
* PR feedback
Address type/typos
* Fix telemetry API call returning 415 on Chrome
- I can't even?? I swear charset=utf-8 fixed the same error a few weeks ago
* Fix failing tests
* Update Enterprise Search functional tests (without host) to run on CI
- Fix incorrect navigateToApp slug (hadn't realized this was a URL, not an ID)
- Update without_host_configured tests to run without API key
- Update README
* Address PR feedback from Pierre
- remove unnecessary authz?
- remove unnecessary content-type json headers
- add loggingSystemMock.collect(mockLogger).error assertion
- reconstrcut new MockRouter on beforeEach for better sandboxing
- fix incorrect describe()s -should be it()
- pull out reusable mockDependencies helper (renamed/extended from mockConfig) for tests that don't particularly use config/log but still want to pass type definitions
- Fix comment copy
Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
Co-authored-by: Chris Cressman <chris@chriscressman.com>
Co-authored-by: scottybollinger <scotty.bollinger@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-07-09 22:10:31 +02:00
|
|
|
files: ['x-pack/plugins/enterprise_search/**/*.{ts,tsx}'],
|
|
|
|
rules: {
|
2021-02-09 18:33:39 +01:00
|
|
|
'import/order': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
groups: ['unknown', ['builtin', 'external'], 'internal', 'parent', 'sibling', 'index'],
|
|
|
|
pathGroups: [
|
|
|
|
{
|
|
|
|
pattern:
|
|
|
|
'{../../../../../../,../../../../../,../../../../,../../../,../../,../}{common/,*}__mocks__{*,/**}',
|
|
|
|
group: 'unknown',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pattern: '{**,.}/*.mock',
|
|
|
|
group: 'unknown',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pattern: 'react*',
|
|
|
|
group: 'external',
|
|
|
|
position: 'before',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
pattern: '{@elastic/**,@kbn/**,src/**}',
|
|
|
|
group: 'internal',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
pathGroupsExcludedImportTypes: [],
|
|
|
|
alphabetize: {
|
|
|
|
order: 'asc',
|
|
|
|
caseInsensitive: true,
|
|
|
|
},
|
|
|
|
'newlines-between': 'always-and-inside-groups',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'import/newline-after-import': 'error',
|
New Enterprise Search Kibana plugin (#66922)
* Initial App Search in Kibana plugin work
- Initializes a new platform plugin that ships out of the box w/ x-pack
- Contains a very basic front-end that shows AS engines, error states, or a Setup Guide
- Contains a very basic server that remotely calls the AS internal engines API and returns results
* Update URL casing to match Kibana best practices
- URL casing appears to be snake_casing, but kibana.json casing appears to be camelCase
* Register App Search plugin in Home Feature Catalogue
* Add custom App Search in Kibana logo
- I haven't had much success in surfacing a SVG file via a server-side endpoint/URL, but then I realized EuiIcon supports passing in a ReactElement directly. Woo!
* Fix appSearch.host config setting to be optional
- instead of crashing folks on load
* Rename plugin to Enterprise Search
- per product decision, URL should be enterprise_search/app_search and Workplace Search should also eventually live here
- reorganize folder structure in anticipation for another workplace_search plugin/codebase living alongside app_search
- rename app.tsx/main.tsx to a standard top-level index.tsx (which will contain top-level routes/state)
- rename AS->ES files/vars where applicable
- TODO: React Router
* Set up React Router URL structure
* Convert showSetupGuide action/flag to a React Router link
- remove showSetupGuide flag
- add a new shared helper component for combining EuiButton/EuiLink with React Router behavior (https://github.com/elastic/eui/blob/master/wiki/react-router.md#react-router-51)
* Implement Kibana Chrome breadcrumbs
- create shared helper (WS will presumably also want this) for generating EUI breadcrumb objects with React Router links+click behavior
- create React component that calls chrome.setBreadcrumbs on page mount
- clean up type definitions - move app-wide props to IAppSearchProps and update most pages/views to simply import it instead of calling their own definitions
* Added server unit tests (#2)
* Added unit test for server
* PR Feedback
* Refactor top-level Kibana props to a global context state
- rather them passing them around verbosely as props, the components that need them should be able to call the useContext hook
+ Remove IAppSearchProps in favor of IKibanaContext
+ Also rename `appSearchUrl` to `enterpriseSearchUrl`, since this context will contained shared/Kibana-wide values/actions useful to both AS and WS
* Added unit tests for public (#4)
* application.test.ts
* Added Unit Test for EngineOverviewHeader
* Added Unit Test for generate_breadcrumbs
* Added Unit Test for set_breadcrumb.tsx
* Added a unit test for link_events
- Also changed link_events.tsx to link_events.ts since it's just TS, no
React
- Modified letBrowserHandleEvent so it will still return a false
boolean when target is blank
* Betterize these tests
Co-Authored-By: Constance <constancecchen@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add UI telemetry tracking to AS in Kibana (#5)
* Set up Telemetry usageCollection, savedObjects, route, & shared helper
- The Kibana UsageCollection plugin handles collecting our telemetry UI data (views, clicks, errors, etc.) and pushing it to elastic's telemetry servers
- That data is stored in incremented in Kibana's savedObjects lib/plugin (as well as mapped)
- When an end-user hits a certain view or action, the shared helper will ping the app search telemetry route which increments the savedObject store
* Update client-side views/links to new shared telemetry helper
* Write tests for new telemetry files
* Implement remaining unit tests (#7)
* Write tests for React Router+EUI helper components
* Update generate_breadcrumbs test
- add test suite for generateBreadcrumb() itself (in order to cover a missing branch)
- minor lint fixes
- remove unnecessary import from set_breadcrumbs test
* Write test for get_username util
+ update test to return a more consistent falsey value (null)
* Add test for SetupGuide
* [Refactor] Pull out various Kibana context mocks into separate files
- I'm creating a reusable useContext mock for shallow()ed enzyme components
+ add more documentation comments + examples
* Write tests for empty state components
+ test new usecontext shallow mock
* Empty state components: Add extra getUserName branch test
* Write test for app search index/routes
* Write tests for engine overview table
+ fix bonus bug
* Write Engine Overview tests
+ Update EngineOverview logic to account for issues found during tests :)
- Move http to async/await syntax instead of promise syntax (works better with existing HttpServiceMock jest.fn()s)
- hasValidData wasn't strict enough in type checking/object nest checking and was causing the app itself to crash (no bueno)
* Refactor EngineOverviewHeader test to use shallow + to full coverage
- missed adding this test during telemetry work
- switching to shallow and beforeAll reduces the test time from 5s to 4s!
* [Refactor] Pull out React Router history mocks into a test util helper
+ minor refactors/updates
* Add small tests to increase branch coverage
- mostly testing fallbacks or removing fallbacks in favor of strict type interface
- these are slightly obsessive so I'd also be fine ditching them if they aren't terribly valuable
* Address larger tech debt/TODOs (#8)
* Fix optional chaining TODO
- turns out my local Prettier wasn't up to date, completely my bad
* Fix constants TODO
- adds a common folder/architecture for others to use in the future
* Remove TODO for eslint-disable-line and specify lint rule being skipped
- hopefully that's OK for review, I can't think of any other way to sanely do this without re-architecting the entire file or DDoSing our API
* Add server-side logging to route dependencies
+ add basic example of error catching/logging to Telemetry route
+ [extra] refactor mockResponseFactory name to something slightly easier to read
* Move more Engines Overview API logic/logging to server-side
- handle data validation in the server-side
- wrap server-side API in a try/catch to account for fetch issues
- more correctly return 2xx/4xx statuses and more correctly deal with those responses in the front-end
- Add server info/error/debug logs (addresses TODO)
- Update tests + minor refactors/cleanup
- remove expectResponseToBe200With helper (since we're now returning multiple response types) and instead make mockResponse var name more readable
- one-line header auth
- update tests with example error logs
- update schema validation for `type` to be an enum of `indexed`/`meta` (more accurately reflecting API)
* Per telemetry team feedback, rename usageCollection telemetry mapping name to simpler 'app_search'
- since their mapping already nests under 'kibana.plugins'
- note: I left the savedObjects name with the '_telemetry' suffix, as there very well may be a use case for top-level generic 'app_search' saved objects
* Update Setup Guide installation instructions (#9)
Co-authored-by: Chris Cressman <chris@chriscressman.com>
* [Refactor] DRY out route test helper
* [Refactor] Rename public/test_utils to public/__mocks__
- to better follow/use jest setups and for .mock.ts suffixes
* Add platinum licensing check to Meta Engines table/call (#11)
* Licensing plugin setup
* Add LicensingContext setup
* Update EngineOverview to not hit meta engines API on platinum license
* Add Jest test helpers for future shallow/context use
* Update plugin to use new Kibana nav + URL update (#12)
* Update new nav categories to add Enterprise Search + update plugin to use new category
- per @johnbarrierwilson and Matt Riley, Enterprise Search should be under Kibana and above Observability
- Run `node scripts/check_published_api_changes.js --accept` since this new category affects public API
* [URL UPDATE] Change '/app/enterprise_search/app_search' to '/app/app_search'
- This needs to be done because App Search and Workplace search *have* to be registered as separate plugins to have 2 distinct nav links
- Currently Kibana doesn't support nested app names (see: https://github.com/elastic/kibana/issues/59190) but potentially will in the future
- To support this change, we need to update applications/index.tsx to NOT handle '/app/enterprise_search' level routing, but instead accept an async imported app component (e.g. AppSearch, WorkplaceSearch).
- AppSearch should now treat its router as root '/' instead of '/app_search'
- (Addl) Per Josh Dover's recommendation, switch to `<Router history={params.history}>` from `<BrowserRouter basename={params.appBasePath}>` since they're deprecating appBasePath
* Update breadcrumbs helper to account for new URLs
- Remove path for Enterprise Search breadcrumb, since '/app/enterprise_search' will not link anywhere meaningful for the foreseeable future, so the Enterprise Search root should not go anywhere
- Update App Search helper to go to root path, per new React Router setup
Test changes:
- Mock custom basepath for App Search tests
- Swap enterpriseSearchBreadcrumbs and appSearchBreadcrumbs test order (since the latter overrides the default mock)
* Add create_first_engine_button telemetry tracking to EmptyState
* Switch plugin URLs back to /app/enterprise_search/app_search
Now that https://github.com/elastic/kibana/pull/66455 has been merged in :tada:
* Add i18n formatted messages / translations (#13)
* Add i18n provider and formatted/i18n translated messages
* Update tests to account for new I18nProvider context + FormattedMessage components
- Add new mountWithContext helper that provides all contexts+providers used in top-level app
- Add new shallowWithIntl helper for shallow() components that dive into FormattedMessage
* Format i18n dates and numbers
+ update some mock tests to not throw react-intl invalid date messages
* Update EngineOverviewHeader to disable button on prop
* Address review feedback (#14)
* Fix Prettier linting issues
* Escape App Search API endpoint URLs
- per PR feedback
- querystring should automatically encodeURIComponent / escape query param strings
* Update server plugin.ts to use getStartServices() rather than storing local references from start()
- Per feedback: https://github.com/elastic/kibana/blob/master/src/core/CONVENTIONS.md#applications
- Note: savedObjects.registerType needs to be outside of getStartServices, or an error is thrown
- Side update to registerTelemetryUsageCollector to simplify args
- Update/fix tests to account for changes
* E2E testing (#6)
* Wired up basics for E2E testing
* Added version with App Search
* Updated naming
* Switched configuration around
* Added concept of 'fixtures'
* Figured out how to log in as the enterprise_search user
* Refactored to use an App Search service
* Added some real tests
* Added a README
* Cleanup
* More cleanup
* Error handling + README updatre
* Removed unnecessary files
* Apply suggestions from code review
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Update x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_table.tsx
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* PR feedback - updated README
* Additional lint fixes
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add README and CODEOWNERS (#15)
* Add plugin README and CODEOWNERS
* Fix Typescript errors (#16)
* Fix public mocks
* Fix empty states types
* Fix engine table component errors
* Fix engine overview component errors
* Fix setup guide component errors
- SetBreadcrumbs will be fixed in a separate commit
* Fix App Search index errors
* Fix engine overview header component errors
* Fix applications context index errors
* Fix kibana breadcrumb helper errors
* Fix license helper errors
* :exclamation: Refactor React Router EUI link/button helpers
- in order to fix typescript errors
- this changes the component logic significantly to a react render prop, so that the Link and Button components can have different types - however, end behavior should still remain the same
* Fix telemetry helper errors
* Minor unused var cleanup in plugin files
* Fix telemetry collector/savedobjects errors
* Fix MockRouter type errors and add IRouteDependencies export
- routes will use IRouteDependencies in the next few commits
* Fix engines route errors
* Fix telemetry route errors
* Remove any type from source code
- thanks to Scotty for the inspiration
* Add eslint rules for Enterprise Search plugin
- Add checks for type any, but only on non-test files
- Disable react-hooks/exhaustive-deps, since we're already disabling it in a few files and other plugins also have it turned off
* Cover uncovered lines in engines_table and telemetry tests
* Fixed TS warnings in E2E tests (#17)
* Feedback: Convert static CSS values to EUI variables where possible
* Feedback: Flatten nested CSS where possible
- Prefer setting CSS class overrides on individual EUI components, not on a top-level page
+ Change CSS class casing from kebab-case to camelCase to better match EUI/Kibana
+ Remove unnecessary .euiPageContentHeader margin-bottom override by changing the panelPaddingSize of euiPageContent
+ Decrease engine overview table padding on mobile
* Refactor out components shared with Workplace Search (#18)
* Move getUserName helper to shared
- in preparation for Workplace Search plugin also using this helper
* Move Setup Guide layout to a shared component
* Setup Guide: add extra props for standard/native auth links
Note: It's possible this commit may be unnecessary if we can publish shared Enterprise Search security mode docs
* Update copy per feedback from copy team
* Address various telemetry issues
- saved objects: removing indexing per #43673
- add schema and generate json per #64942
- move definitions over to collectors since saved objects is mostly empty at this point, and schema throws an error when it imports an obj instead of being defined inline
- istanbul ignore saved_objects file since it doesn't have anything meaningful to test but was affecting code coverage
* Disable plugin access if a normal user does not have access to App Search (#19)
* Set up new server security dependency and configs
* Set up access capabilities
* Set up checkAccess helper/caller
* Remove NoUserState component from the public UI
- Since this is now being handled by checkAccess / normal users should never see the plugin at all if they don't have an account/access, the component is no longer needed
* Update server routes to account for new changes
- Remove login redirect catch from routes, since the access helper should now handle that for most users by disabling the plugin (superusers will see a generic cannot connect/error screen)
- Refactor out new config values to a shared mock
* Refactor Enterprise Search http call to hit/return new internal API endpoint
+ pull out the http call to a separate library for upcoming public URL work (so that other files can call it directly as well)
* [Discussion] Increase timeout but add another warning timeout for slow servers
- per recommendation/convo with Brandon
* Register feature control
* Remove no_as_account from UI telemetry
- since we're no longer tracking that in the UI
* Address PR feedback - isSuperUser check
* Public URL support for Elastic Cloud (#21)
* Add server-side public URL route
- Per feedback from Kibana platform team, it's not possible to pass info from server/ to public/ without a HTTP call :[
* Update MockRouter for routes without any payload/params
* Add client-side helper for calling the new public URL API
+ API seems to return a URL a trailing slash, which we need to omit
* Update public/plugin.ts to check and set a public URL
- relies on this.hasCheckedPublicUrl to only make the call once per page load instead of on every page nav
* Fix failing feature control tests
- Split up scenario cases as needed
- Add plugin as an exception alongside ML & Monitoring
* Address PR feedback
- version: kibana
- copy edits
- Sass vars
- code cleanup
* Casing feedback: change all plugin registration IDs from snake_case to camelCase
- note: current remainng snake_case exceptions are telemetry keys
- file names and api endpoints are snake_case per conventions
* Misc security feedback
- remove set
- remove unnecessary capabilities registration
- telemetry namespace agnostic
* Security feedback: add warn logging to telemetry collector
see https://github.com/elastic/kibana/pull/66922#discussion_r451215760
- add if statement
- pass log dependency around (this is kinda medium, should maybe refactor)
- update tests
- move test file comment to the right file (was meant for telemetry route file)
* Address feedback from Pierre
- Remove unnecessary ServerConfigType
- Remove unnecessary uiCapabilities
- Move registerTelemetryRoute / SavedObjectsServiceStart workaround
- Remove unnecessary license optional chaining
* PR feedback
Address type/typos
* Fix telemetry API call returning 415 on Chrome
- I can't even?? I swear charset=utf-8 fixed the same error a few weeks ago
* Fix failing tests
* Update Enterprise Search functional tests (without host) to run on CI
- Fix incorrect navigateToApp slug (hadn't realized this was a URL, not an ID)
- Update without_host_configured tests to run without API key
- Update README
* Address PR feedback from Pierre
- remove unnecessary authz?
- remove unnecessary content-type json headers
- add loggingSystemMock.collect(mockLogger).error assertion
- reconstrcut new MockRouter on beforeEach for better sandboxing
- fix incorrect describe()s -should be it()
- pull out reusable mockDependencies helper (renamed/extended from mockConfig) for tests that don't particularly use config/log but still want to pass type definitions
- Fix comment copy
Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
Co-authored-by: Chris Cressman <chris@chriscressman.com>
Co-authored-by: scottybollinger <scotty.bollinger@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-07-09 22:10:31 +02:00
|
|
|
'react-hooks/exhaustive-deps': 'off',
|
2021-02-05 18:01:01 +01:00
|
|
|
'react/jsx-boolean-value': ['error', 'never'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Source files only - allow `any` in test/mock files
|
|
|
|
files: ['x-pack/plugins/enterprise_search/**/*.{ts,tsx}'],
|
|
|
|
excludedFiles: ['x-pack/plugins/enterprise_search/**/*.{test,mock}.{ts,tsx}'],
|
|
|
|
rules: {
|
New Enterprise Search Kibana plugin (#66922)
* Initial App Search in Kibana plugin work
- Initializes a new platform plugin that ships out of the box w/ x-pack
- Contains a very basic front-end that shows AS engines, error states, or a Setup Guide
- Contains a very basic server that remotely calls the AS internal engines API and returns results
* Update URL casing to match Kibana best practices
- URL casing appears to be snake_casing, but kibana.json casing appears to be camelCase
* Register App Search plugin in Home Feature Catalogue
* Add custom App Search in Kibana logo
- I haven't had much success in surfacing a SVG file via a server-side endpoint/URL, but then I realized EuiIcon supports passing in a ReactElement directly. Woo!
* Fix appSearch.host config setting to be optional
- instead of crashing folks on load
* Rename plugin to Enterprise Search
- per product decision, URL should be enterprise_search/app_search and Workplace Search should also eventually live here
- reorganize folder structure in anticipation for another workplace_search plugin/codebase living alongside app_search
- rename app.tsx/main.tsx to a standard top-level index.tsx (which will contain top-level routes/state)
- rename AS->ES files/vars where applicable
- TODO: React Router
* Set up React Router URL structure
* Convert showSetupGuide action/flag to a React Router link
- remove showSetupGuide flag
- add a new shared helper component for combining EuiButton/EuiLink with React Router behavior (https://github.com/elastic/eui/blob/master/wiki/react-router.md#react-router-51)
* Implement Kibana Chrome breadcrumbs
- create shared helper (WS will presumably also want this) for generating EUI breadcrumb objects with React Router links+click behavior
- create React component that calls chrome.setBreadcrumbs on page mount
- clean up type definitions - move app-wide props to IAppSearchProps and update most pages/views to simply import it instead of calling their own definitions
* Added server unit tests (#2)
* Added unit test for server
* PR Feedback
* Refactor top-level Kibana props to a global context state
- rather them passing them around verbosely as props, the components that need them should be able to call the useContext hook
+ Remove IAppSearchProps in favor of IKibanaContext
+ Also rename `appSearchUrl` to `enterpriseSearchUrl`, since this context will contained shared/Kibana-wide values/actions useful to both AS and WS
* Added unit tests for public (#4)
* application.test.ts
* Added Unit Test for EngineOverviewHeader
* Added Unit Test for generate_breadcrumbs
* Added Unit Test for set_breadcrumb.tsx
* Added a unit test for link_events
- Also changed link_events.tsx to link_events.ts since it's just TS, no
React
- Modified letBrowserHandleEvent so it will still return a false
boolean when target is blank
* Betterize these tests
Co-Authored-By: Constance <constancecchen@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add UI telemetry tracking to AS in Kibana (#5)
* Set up Telemetry usageCollection, savedObjects, route, & shared helper
- The Kibana UsageCollection plugin handles collecting our telemetry UI data (views, clicks, errors, etc.) and pushing it to elastic's telemetry servers
- That data is stored in incremented in Kibana's savedObjects lib/plugin (as well as mapped)
- When an end-user hits a certain view or action, the shared helper will ping the app search telemetry route which increments the savedObject store
* Update client-side views/links to new shared telemetry helper
* Write tests for new telemetry files
* Implement remaining unit tests (#7)
* Write tests for React Router+EUI helper components
* Update generate_breadcrumbs test
- add test suite for generateBreadcrumb() itself (in order to cover a missing branch)
- minor lint fixes
- remove unnecessary import from set_breadcrumbs test
* Write test for get_username util
+ update test to return a more consistent falsey value (null)
* Add test for SetupGuide
* [Refactor] Pull out various Kibana context mocks into separate files
- I'm creating a reusable useContext mock for shallow()ed enzyme components
+ add more documentation comments + examples
* Write tests for empty state components
+ test new usecontext shallow mock
* Empty state components: Add extra getUserName branch test
* Write test for app search index/routes
* Write tests for engine overview table
+ fix bonus bug
* Write Engine Overview tests
+ Update EngineOverview logic to account for issues found during tests :)
- Move http to async/await syntax instead of promise syntax (works better with existing HttpServiceMock jest.fn()s)
- hasValidData wasn't strict enough in type checking/object nest checking and was causing the app itself to crash (no bueno)
* Refactor EngineOverviewHeader test to use shallow + to full coverage
- missed adding this test during telemetry work
- switching to shallow and beforeAll reduces the test time from 5s to 4s!
* [Refactor] Pull out React Router history mocks into a test util helper
+ minor refactors/updates
* Add small tests to increase branch coverage
- mostly testing fallbacks or removing fallbacks in favor of strict type interface
- these are slightly obsessive so I'd also be fine ditching them if they aren't terribly valuable
* Address larger tech debt/TODOs (#8)
* Fix optional chaining TODO
- turns out my local Prettier wasn't up to date, completely my bad
* Fix constants TODO
- adds a common folder/architecture for others to use in the future
* Remove TODO for eslint-disable-line and specify lint rule being skipped
- hopefully that's OK for review, I can't think of any other way to sanely do this without re-architecting the entire file or DDoSing our API
* Add server-side logging to route dependencies
+ add basic example of error catching/logging to Telemetry route
+ [extra] refactor mockResponseFactory name to something slightly easier to read
* Move more Engines Overview API logic/logging to server-side
- handle data validation in the server-side
- wrap server-side API in a try/catch to account for fetch issues
- more correctly return 2xx/4xx statuses and more correctly deal with those responses in the front-end
- Add server info/error/debug logs (addresses TODO)
- Update tests + minor refactors/cleanup
- remove expectResponseToBe200With helper (since we're now returning multiple response types) and instead make mockResponse var name more readable
- one-line header auth
- update tests with example error logs
- update schema validation for `type` to be an enum of `indexed`/`meta` (more accurately reflecting API)
* Per telemetry team feedback, rename usageCollection telemetry mapping name to simpler 'app_search'
- since their mapping already nests under 'kibana.plugins'
- note: I left the savedObjects name with the '_telemetry' suffix, as there very well may be a use case for top-level generic 'app_search' saved objects
* Update Setup Guide installation instructions (#9)
Co-authored-by: Chris Cressman <chris@chriscressman.com>
* [Refactor] DRY out route test helper
* [Refactor] Rename public/test_utils to public/__mocks__
- to better follow/use jest setups and for .mock.ts suffixes
* Add platinum licensing check to Meta Engines table/call (#11)
* Licensing plugin setup
* Add LicensingContext setup
* Update EngineOverview to not hit meta engines API on platinum license
* Add Jest test helpers for future shallow/context use
* Update plugin to use new Kibana nav + URL update (#12)
* Update new nav categories to add Enterprise Search + update plugin to use new category
- per @johnbarrierwilson and Matt Riley, Enterprise Search should be under Kibana and above Observability
- Run `node scripts/check_published_api_changes.js --accept` since this new category affects public API
* [URL UPDATE] Change '/app/enterprise_search/app_search' to '/app/app_search'
- This needs to be done because App Search and Workplace search *have* to be registered as separate plugins to have 2 distinct nav links
- Currently Kibana doesn't support nested app names (see: https://github.com/elastic/kibana/issues/59190) but potentially will in the future
- To support this change, we need to update applications/index.tsx to NOT handle '/app/enterprise_search' level routing, but instead accept an async imported app component (e.g. AppSearch, WorkplaceSearch).
- AppSearch should now treat its router as root '/' instead of '/app_search'
- (Addl) Per Josh Dover's recommendation, switch to `<Router history={params.history}>` from `<BrowserRouter basename={params.appBasePath}>` since they're deprecating appBasePath
* Update breadcrumbs helper to account for new URLs
- Remove path for Enterprise Search breadcrumb, since '/app/enterprise_search' will not link anywhere meaningful for the foreseeable future, so the Enterprise Search root should not go anywhere
- Update App Search helper to go to root path, per new React Router setup
Test changes:
- Mock custom basepath for App Search tests
- Swap enterpriseSearchBreadcrumbs and appSearchBreadcrumbs test order (since the latter overrides the default mock)
* Add create_first_engine_button telemetry tracking to EmptyState
* Switch plugin URLs back to /app/enterprise_search/app_search
Now that https://github.com/elastic/kibana/pull/66455 has been merged in :tada:
* Add i18n formatted messages / translations (#13)
* Add i18n provider and formatted/i18n translated messages
* Update tests to account for new I18nProvider context + FormattedMessage components
- Add new mountWithContext helper that provides all contexts+providers used in top-level app
- Add new shallowWithIntl helper for shallow() components that dive into FormattedMessage
* Format i18n dates and numbers
+ update some mock tests to not throw react-intl invalid date messages
* Update EngineOverviewHeader to disable button on prop
* Address review feedback (#14)
* Fix Prettier linting issues
* Escape App Search API endpoint URLs
- per PR feedback
- querystring should automatically encodeURIComponent / escape query param strings
* Update server plugin.ts to use getStartServices() rather than storing local references from start()
- Per feedback: https://github.com/elastic/kibana/blob/master/src/core/CONVENTIONS.md#applications
- Note: savedObjects.registerType needs to be outside of getStartServices, or an error is thrown
- Side update to registerTelemetryUsageCollector to simplify args
- Update/fix tests to account for changes
* E2E testing (#6)
* Wired up basics for E2E testing
* Added version with App Search
* Updated naming
* Switched configuration around
* Added concept of 'fixtures'
* Figured out how to log in as the enterprise_search user
* Refactored to use an App Search service
* Added some real tests
* Added a README
* Cleanup
* More cleanup
* Error handling + README updatre
* Removed unnecessary files
* Apply suggestions from code review
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Update x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_table.tsx
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* PR feedback - updated README
* Additional lint fixes
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add README and CODEOWNERS (#15)
* Add plugin README and CODEOWNERS
* Fix Typescript errors (#16)
* Fix public mocks
* Fix empty states types
* Fix engine table component errors
* Fix engine overview component errors
* Fix setup guide component errors
- SetBreadcrumbs will be fixed in a separate commit
* Fix App Search index errors
* Fix engine overview header component errors
* Fix applications context index errors
* Fix kibana breadcrumb helper errors
* Fix license helper errors
* :exclamation: Refactor React Router EUI link/button helpers
- in order to fix typescript errors
- this changes the component logic significantly to a react render prop, so that the Link and Button components can have different types - however, end behavior should still remain the same
* Fix telemetry helper errors
* Minor unused var cleanup in plugin files
* Fix telemetry collector/savedobjects errors
* Fix MockRouter type errors and add IRouteDependencies export
- routes will use IRouteDependencies in the next few commits
* Fix engines route errors
* Fix telemetry route errors
* Remove any type from source code
- thanks to Scotty for the inspiration
* Add eslint rules for Enterprise Search plugin
- Add checks for type any, but only on non-test files
- Disable react-hooks/exhaustive-deps, since we're already disabling it in a few files and other plugins also have it turned off
* Cover uncovered lines in engines_table and telemetry tests
* Fixed TS warnings in E2E tests (#17)
* Feedback: Convert static CSS values to EUI variables where possible
* Feedback: Flatten nested CSS where possible
- Prefer setting CSS class overrides on individual EUI components, not on a top-level page
+ Change CSS class casing from kebab-case to camelCase to better match EUI/Kibana
+ Remove unnecessary .euiPageContentHeader margin-bottom override by changing the panelPaddingSize of euiPageContent
+ Decrease engine overview table padding on mobile
* Refactor out components shared with Workplace Search (#18)
* Move getUserName helper to shared
- in preparation for Workplace Search plugin also using this helper
* Move Setup Guide layout to a shared component
* Setup Guide: add extra props for standard/native auth links
Note: It's possible this commit may be unnecessary if we can publish shared Enterprise Search security mode docs
* Update copy per feedback from copy team
* Address various telemetry issues
- saved objects: removing indexing per #43673
- add schema and generate json per #64942
- move definitions over to collectors since saved objects is mostly empty at this point, and schema throws an error when it imports an obj instead of being defined inline
- istanbul ignore saved_objects file since it doesn't have anything meaningful to test but was affecting code coverage
* Disable plugin access if a normal user does not have access to App Search (#19)
* Set up new server security dependency and configs
* Set up access capabilities
* Set up checkAccess helper/caller
* Remove NoUserState component from the public UI
- Since this is now being handled by checkAccess / normal users should never see the plugin at all if they don't have an account/access, the component is no longer needed
* Update server routes to account for new changes
- Remove login redirect catch from routes, since the access helper should now handle that for most users by disabling the plugin (superusers will see a generic cannot connect/error screen)
- Refactor out new config values to a shared mock
* Refactor Enterprise Search http call to hit/return new internal API endpoint
+ pull out the http call to a separate library for upcoming public URL work (so that other files can call it directly as well)
* [Discussion] Increase timeout but add another warning timeout for slow servers
- per recommendation/convo with Brandon
* Register feature control
* Remove no_as_account from UI telemetry
- since we're no longer tracking that in the UI
* Address PR feedback - isSuperUser check
* Public URL support for Elastic Cloud (#21)
* Add server-side public URL route
- Per feedback from Kibana platform team, it's not possible to pass info from server/ to public/ without a HTTP call :[
* Update MockRouter for routes without any payload/params
* Add client-side helper for calling the new public URL API
+ API seems to return a URL a trailing slash, which we need to omit
* Update public/plugin.ts to check and set a public URL
- relies on this.hasCheckedPublicUrl to only make the call once per page load instead of on every page nav
* Fix failing feature control tests
- Split up scenario cases as needed
- Add plugin as an exception alongside ML & Monitoring
* Address PR feedback
- version: kibana
- copy edits
- Sass vars
- code cleanup
* Casing feedback: change all plugin registration IDs from snake_case to camelCase
- note: current remainng snake_case exceptions are telemetry keys
- file names and api endpoints are snake_case per conventions
* Misc security feedback
- remove set
- remove unnecessary capabilities registration
- telemetry namespace agnostic
* Security feedback: add warn logging to telemetry collector
see https://github.com/elastic/kibana/pull/66922#discussion_r451215760
- add if statement
- pass log dependency around (this is kinda medium, should maybe refactor)
- update tests
- move test file comment to the right file (was meant for telemetry route file)
* Address feedback from Pierre
- Remove unnecessary ServerConfigType
- Remove unnecessary uiCapabilities
- Move registerTelemetryRoute / SavedObjectsServiceStart workaround
- Remove unnecessary license optional chaining
* PR feedback
Address type/typos
* Fix telemetry API call returning 415 on Chrome
- I can't even?? I swear charset=utf-8 fixed the same error a few weeks ago
* Fix failing tests
* Update Enterprise Search functional tests (without host) to run on CI
- Fix incorrect navigateToApp slug (hadn't realized this was a URL, not an ID)
- Update without_host_configured tests to run without API key
- Update README
* Address PR feedback from Pierre
- remove unnecessary authz?
- remove unnecessary content-type json headers
- add loggingSystemMock.collect(mockLogger).error assertion
- reconstrcut new MockRouter on beforeEach for better sandboxing
- fix incorrect describe()s -should be it()
- pull out reusable mockDependencies helper (renamed/extended from mockConfig) for tests that don't particularly use config/log but still want to pass type definitions
- Fix comment copy
Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
Co-authored-by: Chris Cressman <chris@chriscressman.com>
Co-authored-by: scottybollinger <scotty.bollinger@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-07-09 22:10:31 +02:00
|
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
2019-09-17 20:57:53 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-09-04 22:14:47 +02:00
|
|
|
/**
|
|
|
|
* Canvas overrides
|
|
|
|
*/
|
|
|
|
{
|
2020-05-06 02:52:56 +02:00
|
|
|
files: ['x-pack/plugins/canvas/**/*.js'],
|
2018-09-04 22:14:47 +02:00
|
|
|
rules: {
|
2018-12-18 02:32:06 +01:00
|
|
|
radix: 'error',
|
2018-09-04 22:14:47 +02:00
|
|
|
|
|
|
|
// module importing
|
|
|
|
'import/order': [
|
2018-12-18 02:32:06 +01:00
|
|
|
'error',
|
|
|
|
{
|
|
|
|
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
|
|
|
|
},
|
2018-09-04 22:14:47 +02:00
|
|
|
],
|
2018-12-18 02:32:06 +01:00
|
|
|
'import/extensions': ['error', 'never', { json: 'always', less: 'always', svg: 'always' }],
|
2018-09-04 22:14:47 +02:00
|
|
|
|
|
|
|
// react
|
2018-12-18 02:32:06 +01:00
|
|
|
'react/no-did-mount-set-state': 'error',
|
|
|
|
'react/no-did-update-set-state': 'error',
|
|
|
|
'react/no-multi-comp': ['error', { ignoreStateless: true }],
|
|
|
|
'react/self-closing-comp': 'error',
|
|
|
|
'react/sort-comp': 'error',
|
|
|
|
'react/jsx-boolean-value': 'error',
|
|
|
|
'react/no-unescaped-entities': ['error', { forbid: ['>', '}'] }],
|
2018-09-04 22:14:47 +02:00
|
|
|
'react/forbid-elements': [
|
2018-12-18 02:32:06 +01:00
|
|
|
'error',
|
2018-09-04 22:14:47 +02:00
|
|
|
{
|
|
|
|
forbid: [
|
|
|
|
{
|
|
|
|
element: 'EuiConfirmModal',
|
|
|
|
message: 'Use <ConfirmModal> instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: 'EuiPopover',
|
|
|
|
message: 'Use <Popover> instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: 'EuiIconTip',
|
|
|
|
message: 'Use <TooltipIcon> instead',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: [
|
2020-05-06 02:52:56 +02:00
|
|
|
'x-pack/plugins/canvas/gulpfile.js',
|
|
|
|
'x-pack/plugins/canvas/scripts/*.js',
|
|
|
|
'x-pack/plugins/canvas/tasks/*.js',
|
|
|
|
'x-pack/plugins/canvas/tasks/**/*.js',
|
|
|
|
'x-pack/plugins/canvas/__tests__/**/*.js',
|
|
|
|
'x-pack/plugins/canvas/**/{__tests__,__test__,__jest__,__fixtures__,__mocks__}/**/*.js',
|
2018-09-04 22:14:47 +02:00
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
devDependencies: true,
|
|
|
|
peerDependencies: true,
|
2020-11-02 22:18:52 +01:00
|
|
|
packageDir: '.',
|
2018-09-04 22:14:47 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-05-06 02:52:56 +02:00
|
|
|
files: ['x-pack/plugins/canvas/canvas_plugin_src/**/*.js'],
|
2018-09-04 22:14:47 +02:00
|
|
|
globals: { canvas: true, $: true },
|
|
|
|
rules: {
|
|
|
|
'import/no-unresolved': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
ignore: ['!!raw-loader.+.svg$'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2018-11-07 17:33:39 +01:00
|
|
|
{
|
2020-05-06 02:52:56 +02:00
|
|
|
files: ['x-pack/plugins/canvas/public/**/*.js'],
|
2018-11-07 17:33:39 +01:00
|
|
|
env: {
|
|
|
|
browser: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-10-14 15:58:35 +02:00
|
|
|
files: ['packages/kbn-ui-shared-deps/flot_charts/**/*.js'],
|
2020-04-30 21:59:35 +02:00
|
|
|
env: {
|
|
|
|
jquery: true,
|
|
|
|
},
|
|
|
|
},
|
2019-05-24 15:16:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TSVB overrides
|
|
|
|
*/
|
|
|
|
{
|
2020-09-23 09:52:51 +02:00
|
|
|
files: ['src/plugins/vis_type_timeseries/**/*.{js,mjs,ts,tsx}'],
|
2019-05-24 15:16:54 +02:00
|
|
|
rules: {
|
|
|
|
'import/no-default-export': 'error',
|
|
|
|
},
|
|
|
|
},
|
2019-12-14 23:17:59 +01:00
|
|
|
|
2021-01-28 08:24:55 +01:00
|
|
|
/**
|
|
|
|
* Osquery overrides
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
extends: ['eslint:recommended', 'plugin:react/recommended'],
|
|
|
|
plugins: ['react'],
|
|
|
|
files: ['x-pack/plugins/osquery/**/*.{js,mjs,ts,tsx}'],
|
|
|
|
rules: {
|
|
|
|
'arrow-body-style': ['error', 'as-needed'],
|
|
|
|
'prefer-arrow-callback': 'error',
|
|
|
|
'no-unused-vars': 'off',
|
|
|
|
'react/prop-types': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// typescript and javascript for front end react performance
|
|
|
|
files: ['x-pack/plugins/osquery/public/**/!(*.test).{js,mjs,ts,tsx}'],
|
|
|
|
plugins: ['react', 'react-perf'],
|
|
|
|
rules: {
|
|
|
|
'react-perf/jsx-no-new-object-as-prop': 'error',
|
|
|
|
'react-perf/jsx-no-new-array-as-prop': 'error',
|
|
|
|
'react-perf/jsx-no-new-function-as-prop': 'error',
|
|
|
|
'react/jsx-no-bind': 'error',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-12-14 23:17:59 +01:00
|
|
|
/**
|
|
|
|
* Prettier disables all conflicting rules, listing as last override so it takes precedence
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
files: ['**/*'],
|
|
|
|
rules: {
|
|
|
|
...require('eslint-config-prettier').rules,
|
|
|
|
...require('eslint-config-prettier/react').rules,
|
|
|
|
...require('eslint-config-prettier/@typescript-eslint').rules,
|
|
|
|
},
|
|
|
|
},
|
2021-02-05 19:38:37 +01:00
|
|
|
/**
|
|
|
|
* Enterprise Search Prettier override
|
|
|
|
* Lints unnecessary backticks - @see https://github.com/prettier/eslint-config-prettier/blob/main/README.md#forbid-unnecessary-backticks
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
files: ['x-pack/plugins/enterprise_search/**/*.{ts,tsx}'],
|
|
|
|
rules: {
|
|
|
|
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
|
|
|
|
},
|
|
|
|
},
|
2020-06-30 07:37:42 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
files: [
|
|
|
|
// platform-team owned code
|
|
|
|
'src/core/**',
|
|
|
|
'x-pack/plugins/features/**',
|
|
|
|
'x-pack/plugins/licensing/**',
|
|
|
|
'x-pack/plugins/global_search/**',
|
|
|
|
'x-pack/plugins/cloud/**',
|
|
|
|
'packages/kbn-config-schema',
|
|
|
|
'src/plugins/status_page/**',
|
|
|
|
'src/plugins/saved_objects_management/**',
|
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
|
|
|
},
|
|
|
|
},
|
2020-09-24 18:38:11 +02:00
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'**/public/**/*.{js,mjs,ts,tsx}',
|
|
|
|
'**/common/**/*.{js,mjs,ts,tsx}',
|
|
|
|
'packages/**/*.{js,mjs,ts,tsx}',
|
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
patterns: ['lodash/*', '!lodash/fp'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2020-11-02 22:18:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Single package.json rules, it tells eslint to ignore the child package.json files
|
|
|
|
* and look for dependencies declarations in the single and root level package.json
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
files: ['**/*.{js,mjs,ts,tsx}'],
|
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
packageDir: '.',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2018-02-06 00:29:30 +01:00
|
|
|
],
|
|
|
|
};
|