kibana/packages
Mikhail Shustov f593455a62
Bump TypeScript to v3.9 (#67666)
* add babel support for export type

* bump ts version to 3.9.3

* rebuild kbn-pm

* bump typescript-eslint

* fix error in security plugin UI

* check export as works

* fix app migration type

* use correct test subj attribute

* fix errors from the old PR

* embeddable is already passed in props

* explicitly define type of fetch

* add some types for viz

* fix fetch type p.2

* add null to allow spreading without type errors due to override

* add type guard to fix type error

* cast to any, since cannot assign unknown

* add timestamp to known types

* fix type error in fetch

* fix type error. id is always defined in attibutes

* declare a type

* move ts-ignore to the lines with errors

* declare tuple type explicitly

* mute type error. cannot assign unknown

* fix errors. id is always defined

* fix error type

* fix override errors. id is always defined

* fix error. extends any doesn't work anymore

* fix type error. type is always defined

* env doesn't always contain values

* fix type error

* cast to string

* add: logs is already declared in getNodeLogsUrl

* state is already  passed in props

* fix some errors in timelion

* number of fragments is always defined

* 'absolute' is not just string, but value

* TEMP: option is always defined

* always true if cast to promise manually

* both props are always defined

* explicitly define returned SO type

* workaround type

* bump tslib to be compatible with ts v3.9

* test private property

* rebuild kbn-pm

* Fix ts errors for beats management

* Fix type inference broken by the TS 3.9 upgrade

* Fix ingest manager saved object attributes typings

* Fix TS errors in cross_cluster_replication and index_management.

* Fix TS error in Watcher.

* roll back colorRange wrong type

* fix security plugin types

* TypeScript 3.9 fixes for APM

* Fix ColorRange types.

* fix actions & alerts errors. ByGidi

* fix lists error

* More APM fixes

* Remove paramaterization from `removeEmpty in agent config SettingsPage component (it's only used there and doesn't need to be parameterized.)
* Add option chain for case in registerTransactionDurationAlertType
* Cast `overallValue` in transform_metrics_chart
* Use more specific type for custom link filters
* Add more option chaining for local UI filters buckets response
* Remove unused parameters from routes
* Fix getProjection type parameter
* Use destructuring in serviceNodesLocalFiltersRoute to hide `never` error
* Revert `UnionToIntersection` change in `AggregationResponseMap`

Fixes #67804.

* fix platform type error

* Fix visualizations types.

* Fix data plugin types.

* bump TS version to 3.9.5

* Fix telemetry TS errors

* Fix dashboard code

* Adding Canvas Fixes for TS 3.9

* Fix case and security_solution types

* roll back to the old export syntax. new one might cause problems in api-extractor

* update docs

* Fix timelion code

* Fix meta

* Fix types

* fix type errors om ingest_manager

* bump babel deps

* enable private props & methods syntax

* update kbn-pm dist

* whitelist 0BSD license

* use @babel/plugin-proposal-private-methods in default set as well

* disable new babel plugins

* Revert "disable new babel plugins"

This reverts commit 04d959431d.

* cleanup security_solution types

* Fixes type error for newer TypeScript

* update docs

Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
Co-authored-by: Felix Stürmer <stuermer@weltenwort.de>
Co-authored-by: CJ Cenizal <cj@cenizal.com>
Co-authored-by: Larry Gregory <larry.gregory@elastic.co>
Co-authored-by: Nathan L Smith <smith@nlsmith.com>
Co-authored-by: Walter Rafelsberger <walter@elastic.co>
Co-authored-by: Luke Elmers <luke.elmers@elastic.co>
Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
Co-authored-by: Tim Roes <tim.roes@elastic.co>
Co-authored-by: Clint Andrew Hall <clint.hall@elastic.co>
Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com>
Co-authored-by: FrankHassanabad <frank.hassanabad@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-06-11 10:04:09 +02:00
..
elastic-datemath Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
eslint-config-kibana Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-analytics Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-babel-code-parser Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-babel-preset Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-config-schema Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-dev-utils Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-es upgrade npm-run-path (#68539) 2020-06-08 11:29:09 -07:00
kbn-eslint-import-resolver-kibana apply prettier styles 2020-05-22 09:08:58 +02:00
kbn-eslint-plugin-eslint apply prettier styles 2020-05-22 09:08:58 +02:00
kbn-expect [kbn-expect] add optional error message (#48895) 2019-10-26 15:51:45 +02:00
kbn-i18n Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-interpreter Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-monaco Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-optimizer Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-plugin-generator upgrade npm-run-path (#68539) 2020-06-08 11:29:09 -07:00
kbn-plugin-helpers Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-pm Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-spec-to-console apply prettier styles 2020-05-22 09:08:58 +02:00
kbn-storybook APM Storybook fixes (#68671) 2020-06-09 16:17:28 -05:00
kbn-test Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-test-subj-selector apply prettier styles 2020-05-22 09:08:58 +02:00
kbn-ui-framework Bump TypeScript to v3.9 (#67666) 2020-06-11 10:04:09 +02:00
kbn-ui-shared-deps Upgrade EUI to v24.1.0 (#68141) 2020-06-09 15:07:40 -06:00
kbn-utility-types apply prettier styles 2020-05-22 09:08:58 +02:00
README.md [test] remove x-pack mocha configuration (#42979) 2019-08-15 12:21:42 -05:00

Kibana-related packages

This folder contains packages that are intended for use in Kibana and Kibana plugins.

tl;dr:

  • Don't publish to npm registry
  • Always use the @kbn namespace
  • Always set "private": true in package.json

Using these packages

We no longer publish these packages to the npm registry. Now, instead of specifying a version when including these packages, we rely on yarn workspaces, which sets up a symlink to the package.

For example if you want to use the @kbn/i18n package in Kibana itself, you can specify the dependency like this:

"@kbn/i18n": "1.0.0"

However, if you want to use this from a Kibana plugin, you need to use a link: dependency and account for the relative location of the Kibana repo, so it would instead be:

"@kbn/i18n": "link:../../kibana/packages/kbn-i18n"

How all of this works is described in more detail in the @kbn/pm docs.

Creating a new package

Create a new sub-folder. The name of the folder should mirror the name in the package's package.json. E.g. if the name is @kbn/i18n the folder name should be kbn-i18n.

All new packages should use the @kbn namespace, and should be marked with "private": true.

Unit tests for a package

Currently there are two patterns used to test packages, one using Mocha and one using Jest. These patterns emerged out of convention and we'd like to make them more similar to each other in the near future.

1. Mocha

Today a package can follow the pattern of having a __tests__ directory in each source code directory of a package which contains the tests for that module. These are usually run by Mocha.

If a package's tests should be run with Mocha, you'll have to opt-in to run them by appending the package's test file pattern(s) to Kibana's src/dev/mocha/run_mocha_cli.js file. These will then be run by the unit test runner.

  • yarn test or yarn grunt test runs all unit tests.
  • node scripts/mocha runs all Mocha tests.

2. Jest

A package can also follow the pattern of having .test.js files as siblings of the source code files, and these run by Jest.

A package using the .test.js naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana test script in the root package.json.

  • yarn test or yarn grunt test runs all unit tests.
  • node scripts/jest runs all Jest tests in Kibana.

Each package can also specify its own test script in the package's package.json, for cases where you'd prefer to run the tests from the local package directory.