kibana/packages
Spencer 96206bd092
[eslint] merge custom rules into a single plugin (#33733)
I'd like to add another custom eslint rule, but there isn't a very good place to do that right now. We have the `eslint-plugin-kibana-custom` package, which is super simple but isn't in the `@kbn` namespace and isn't included in the root eslint config, and `@kbn/eslint-plugin-license-header` is too specific, so I've merged those two packages into `@kbn/eslint-plugin-eslint`, which is a little redundant but allows is to refer to the rules within it as `@kbn/eslint/{rule}`, which feels nice.

Thoughts?

_**NOTE:**_ merging the eslint rules from the two packages means enabling prettier for the code from `@kbn/eslint-plugin-license-header`, all those changes are made in 42c7da6fe2. [View the changes without the prettier updates](b647f2b...74e07a0)
2019-03-22 17:12:14 -07:00
..
elastic-datemath move moment to peerDependency in elastic-datemath (#27264) 2018-12-14 15:42:32 -08:00
eslint-config-kibana Fix: set react version to string, not semver object (#33079) 2019-03-13 10:50:01 -07:00
kbn-babel-code-parser Upgrade @babel/* dependencies. (#32031) 2019-02-27 19:27:40 +02:00
kbn-babel-preset [kbn-test] upgrade to babel7, add ts support (#32168) 2019-02-28 09:56:19 -08:00
kbn-config-schema [ts][ftr] improve types for ftr and expect.js, cleanup changes to tsconfig files (#31948) 2019-02-28 12:06:00 -08:00
kbn-dev-utils [esArchiver] stable archives (#30477) 2019-02-11 11:16:25 -08:00
kbn-es [kbn-es] Platform specific snapshots (#29673) 2019-02-01 20:59:59 -08:00
kbn-es-query [KQL] Better warning messages when using Lucene-like syntax (#31837) 2019-03-04 16:53:02 -07:00
kbn-eslint-import-resolver-kibana Prefer third-party plugin development in ./plugins instead of ../kibana-extra (#31748) 2019-03-07 17:04:29 -06:00
kbn-eslint-plugin-eslint [eslint] merge custom rules into a single plugin (#33733) 2019-03-22 17:12:14 -07:00
kbn-i18n Update Typescript to the latest version (#32063) 2019-02-28 17:21:47 +01:00
kbn-interpreter moving interpreter package to plugin (#32997) 2019-03-15 07:45:46 +01:00
kbn-plugin-generator Prefer third-party plugin development in ./plugins instead of ../kibana-extra (#31748) 2019-03-07 17:04:29 -06:00
kbn-plugin-helpers Fix plugin-helpers test:server task (#31034) 2019-02-13 22:47:26 -08:00
kbn-pm update kbn/pm dist 2019-03-22 15:42:26 -07:00
kbn-test Refactor ES-related environment variables (#33036) 2019-03-13 11:51:06 -07:00
kbn-test-subj-selector
kbn-ui-framework Fixes focus state issue around EUI combo boxes in kibana (#33073) 2019-03-13 11:58:00 -07:00
README.md [npm] prepare @kbn/datemath for publishing (#26559) 2018-12-03 16:01:16 -08: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 tasks/config/simplemocha.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.