* Update eslint related packages
* add errorMessage to no-restricted-paths validation
* add license to eslintrc file
* ignore broken plugin fixture
* upgrade tangled peer deps
* give name to unnamed func to avoid typescript-eslint/typescript-eslint#1078
* migrate away from removed prefer-interface
* migrate away from removed no-angle-bracket-type-assertions rule
* migrate away from removed no-triple-slash-reference rule
* old config was invalid and made this rule a noop
* fix array-type rule config
* fix readonly paramProperties that weren't being checked
* fix propType ordering
* remove references to non-existent rules
* remove unnecessary disable that is improperly formatted
* fix comment-related spacing
* fix typo/invalid namespace overrides
* rename fn to avoid hook-alike behavior
* remove reference to old removed rule
* use caret version for prettier
* reference babel-eslint with absolute path
* Enable one-var rule
* Prevent built-in extension
* Group more rules into modern language features
* Fix typing error use eslint disable instead
* Improve wording slightly
* Update jest related packages
* use correct type
* adapt spy and describe.each types
* update yarn.lock
* update snapshot
* define types before passing to describe.each
* upgrade all babel related modules, and bump lodash minors
* update kbn-pm dist
* update fetch-mock, necessary to use core-js 3
* use regenerator transform in jest tests, as required by EUI
* disable useBuiltIns rather than using regenerator plugin
* remove extra regenerator-runtime import
* [ts] upgrade to 3.5.2
* [ts] run from cwd so that relative paths are correct
* move eslint-disable-line comment into jsx attribute
* autofix eslint violations
* avoid generic type, it's not necessary and problematic
* make elasticsearch.cluster optional, many instances don't have them
* remove invalid prop
* expand AllowUnknownProperties to cleanly handle arrays
* esfilter values can sometimes be an array of strings
* allow exception objects to have unknown properties
* define accumulator as a boolean
* fix return type
* return a 404 if beat isn't found after update
* use Object.values for better types
* define return type of get() call
* define value type for Set
* define return value of get()
* define State property type
* use less get(), so ts can infer types
* define Set item type
* map state type
* make default_operator optional, since it's not always defined
* remove seemingly unused prop
* define return type of get() fn
* define inner type for state
* don't define base types are objects with index signatues
* regenerate public api docs
* make indices privileges optional too
* remove unnecessary index-signature from Exception interface
* use variadic _arg instead
* [core/plugin] use Record<string, any> rather than {}
* replace a couple more instances of {}
* revert some unnecessary changes
* remove unused types
* [reporting] output, payload, and meta are required properties
* bump to latest patch version
* Always mock metadata/chrome in OSS
* Enable jest env in jest mocks
* Exclude jest mocks in karma bundles
* Use setupFilesAfterEnv in config
* Remove chrome/metadata mock from x-pack
* Remove kuery mock
* Add missing mock to SIEM test
* Fix typo in mock import
* Remove top level capabilities x-pack mock
* Move kfetch mock to ui/public
* Move moment-timezone to mocks file
* Unmock kfetch in kfetch specific tests
* Make kfetch mock manual
* Removed unnecessary jest.mock
* Remove kfetch unmocks
* Warn in Typescript when using Array.flat() or .flatMap() without polyfill
* Update ecma version provided to babel in eslint
* Update per review comments
* Pin dependencies
* include core-js in babel packages
* specify core-js version when using `useBuiltIns`
* dedupe @babel/types to avoid "range of null" problem
* chore(NA): first changes on every package.json order to support new babel 7. chore(NA): build for kbn-pm with babel 7.
* chore(NA): patch babel register to load typescrit
* chore(NA): first working version with babel 7 replacing typescript compiler.
* fix(NA): common preset declaration in order to make it work with babel-loader.
* chore(na): organizing babel preset env package json.
* chore(NA): mocha tests enabled.
* fix(NA): typo on importing
* test(NA): majority of x-pack tests ported to use babel-jest
* fix(NA): report info button test with babel-jest.
* fix(NA): polling service tests.
* test(na): fix server plugins plugin tests.
* test(NA): batch of test fixs for jest tests under babel-jest hoisting.
* chore(NA): add babel plugin to hoist mock prefixed vars on jest tests.
* chore(NA): update yarn.lock file.
* chore(NA): tests passing.
* chore(NA): remove wrong dep
* chore(NA): fix tsconfig
* chore(NA): skip babel for ts-jest.
* chore(NA): selectively apply the plugin to strip off namespace from ts files.
* chore(NA): remove not needed changes from ts tests
* chore(NA): removed ts-jest dependency. chore(NA): migrate ts tests on x-pack to use babel-jest with the new pattern.
* chore(NA): migrate kibana default distribution typescript tests to run with babel-jest and the new test mock pattern.
* chore(NA): merge and solve conflicts with master.
* chore(NA): fix problems reported by eslint
* chore(NA): fix license ovveride for babel-plugin-mock-imports
* chore(NA): update jest integration tests for kbn pm
* chore(NA): update babel jest integration tests for kbn pm.
* test(NA): update jest integration snapshot for kbn pm.
* chore(NA): apply changes according to the pull request reviews.
* chore(NA): apply changes according to the pull request reviews.
* refact(NA): migrate jest tests to the new pattern.
* fix(NA): babel 7 polyfill in the tests bundle.
* chore(NA): restore needed step in order to compile x-pack with typescript.
* chore(NA): change build to compile typescript with babel for the oss code. chore(NA): change transpile typescript task to only transpile types for x-pack. refact(NA): common preset for babel 7
* Revert "chore(NA): change build to compile typescript with babel for the oss code. chore(NA): change transpile typescript task to only transpile types for x-pack. refact(NA): common preset for babel 7"
This reverts commit 2707d538f5.
* fix(NA): import paths for tabConfigConst
* chore(NA): fix transpiling error on browser tests
* chore(NA): simplify kbn babel preset package.
* chore(NA): migrate build to use babel transpiler for typescript excluding xpack.
* fix(NA): introduced error on test quick task.
* fix(NA): fix preset for client side code on build.
* fix(NA): build with babel
* fix(NA): negated patterns in the end.
* fix(NA): kbn_tp_sample_panel_action creation.
* fix(NA): babel typescript transform plugin workaround when exporting interface name.
* refact(NA): remove not needed type cast to any on jest test.
* docs(NA): add developement documentation about jest mocks test pattern.
* chore(NA): missing unmerged path.
* chore(NA): fix jest tests for template.
* [CCR] Client integration tests (table lists) (#33525)
* Force user to re-authenticate if token refresh fails with `400` status code. (#33774)
* Improve performance of the Logstash Pipeline Viewer (#33793)
Resolves#27513.
_This PR is a combination of #31293 (the code changes) + #33570 (test updates). These two PRs were individually reviewed and merged into a feature branch. This combo PR here simply sets up the merge from the feature branch to `master`._
Summary of changes, taken from #31293:
## Before this PR
The Logstash Pipeline Viewer UI would make a single Kibana API call to fetch all the information necessary to render the Logstash pipeline. This included information necessary to render the detail drawer that opens up when a user clicks on an individual vertex in the pipeline.
Naturally, this single API call fetched _a lot_ of data, not just from the Kibana server but also, in turn, from Elasticsearch as well. The "pro" of this approach was that the user would see instantaneous results if they clicked on a vertex in a pipeline and opened the detail drawer for that vertex. The "cons" were the amount of computation Elasticsearch had to perform and the amount of data being transferred over the wire between Elasticsearch and the Kibana server as well as between the Kibana server and the browser.
## With this PR
This PR makes the Kibana API call to fetch data necessary for **initially** rendering the pipeline — that is, with the detail drawer closed — much lighter. When the user clicks on a vertex in a pipeline, a second API call is then made to fetch data necessary for the detail drawer.
## Gains, by the numbers
Based on a simple, 1-input, 1-filter, and 1-output pipeline.
* Before this PR, the Elasticsearch `logstash_stats` API responses (multiple calls were made using the `composite` aggregation over the `date_histogram` aggregation) generated a total of 1228 aggregation buckets (before any `filter_path`s were applied but across all `composite` "pages"). With this PR, the single `logstash_stats` API response (note that this is just for the initial rendering of the pipeline, with the detail drawer closed) generated 12 buckets (also before any `filter_path`s were applied). That's a **99.02% reduction** in number of buckets.
* Before this PR, the Elasticsearch `logstash_stats` API responses added up to 70319 bytes. With this PR, the single `logstash_stats` API response for the same pipeline is 746 bytes. That's a **98.93% reduction** in size.
* Before this PR, the Elasticsearch `logstash_state` API response was 7718 bytes. With this PR, the API response for the same pipeline is 2328 bytes. That's a **69.83% reduction** in size.
* Before this PR the Kibana API response was 51777 bytes. With this PR, the API response for the same pipeline is 2567 bytes (again, note that this is just for the initial rendering of the pipeline, with the detail drawer closed). That's a **95.04% reduction** in size.
* [Maps] split settings into layer and source panels (#33788)
* [Maps] split settings into layer and source panels
* fix SCSS import
* [env] exit if starting as root (#21563)
* [env] exit if starting as root
* fix windows
* s/--allow-root
* Typescript sample panel action (#33602)
* Typescript sample panel action
* Update EUI version to match main cabana version
* update yarn.lock
* add back typings include
* use correct relative path
* Home page "recent links" should communicate saved object type #21896 (#33694)
* adds object type for screen order
* adds object type for pointer hovering
* Update src/legacy/ui/public/chrome/directives/header_global_nav/components/header.tsx
Co-Authored-By: rockfield <philipp.b@ya.ru>
## Summary
While working on a plugin that was just using the Kibana eslint config, I saw a stream of these messages:
> Warning: React version specified in eslint-plugin-react-settings must be a string; got “object”
Looking into our eslint config, I noticed we're using `semver.coerce` to get the version from the `package.json` file in Kibana. This looked right, except that method actually returns an object:
```js
const ver = semver.coerce('^16.8.0');
console.log(ver);
```
That produces:
```
SemVer {
options: { loose: false, includePrerelease: false },
loose: false,
raw: '16.8.0',
major: 16,
minor: 8,
patch: 0,
prerelease: [],
build: [],
version: '16.8.0' }
```
The [semver package](https://www.npmjs.com/package/semver) includes some examples where they wrap that value in `semver.valid`, which produces a string and fixes the warning.
```js
const ver = semver.valid(semver.coerce('^16.8.0'));
console.log(ver); // outputs 16.8.0
```
### So why don't we see this warning in Kibana?
I'm not sure, but I suspect it's because it's a console warning and our tooling prevents that output from showing up.
This change stops the warning output when you run eslint in my plugin though.
UPDATE: After some more digging, it looks like it's related to the version override in Kibana's eslintrc. Removing the override stops the linter from running, without the changes in this PR.
We have had `insert_final_newline = true` in our `.editorconfig` file since April 2015, but never validated it with eslint. I'm a little tired of extra changes showing up in PRs because some people use editors which respect the `.editorconfig` file and some don't, so I figured we might want to enable the rule in eslint so that the can be autofixed.
Votes requested please :)
* [kbn-plugin-generator] add eslint-plugin-jsx-a11y to plugin devDeps, specify react version in config
* [eslint/react] use semver package to coerce version range
* fix semicolons
I'd really like to upgrade to Typescript 3 for its `unknown` type, but we need to upgrade to `jest@23` to support a recent version of `ts-jest@23`.
The [jest changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md) breaks down the breaking changes in 23.x, but I found it to be slightly incomplete so I've broken down the changes that actually caused breaks for us here, and addressed each in individual commits to make review a little easier:
- the `testURL` config default was changed from `about:blank` to `http://localhost`
- this cause some XHR requests powered by JSdom to start failing. It seems these requests just do nothing in master but start to fail when JSdom is initialized with an actual URL... I think we would ideally stop sending meaningless XHR requests in the tests, but it was a lot easier to just set the config to `about:blank` for now, and we can worry about cleanup later if necessary
- `expect(...).toThrow()` only passes if an actual error was thrown.
- In two places in the index pattern code we were throwing strings, which broke the assertions. Fortunately/Unfortunately the errors are not being consumed by anything, so I was able to wrap them in `new Error()` without causing any issues.
- snapshots of mock functions now include a `results` array, detailing the return values of the function
- React fragments are now serialized as `<React.Fragment>` instead of `<UNDEFINED>`
- undefined props in React components are now stripped from snapshots
- minor changes to the ordering of mocks, imports resolution, and before hooks caused the uiSettings API tests to start breaking, but I'm replacing them with totally new tests in #22694 so I just deleted them here
- mocks created with `jest.spyOn()` that are restored now have their `mock.calls` reset, so some of the kbn-pm tests stated failing. This was fixed by restoring them with `jest.restoreAllMocks()` rather than trying to do it before the assertions