Skip to content

Commit 625f01b

Browse files
Merge branch '7.x' into backport/7.x/pr-46569
2 parents 839a608 + 2949b83 commit 625f01b

102 files changed

Lines changed: 2947 additions & 918 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

STYLEGUIDE.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,39 @@ function addBar(foos, foo) {
141141
}
142142
```
143143
144+
### Avoid `any` whenever possible
145+
146+
Since TypeScript 3.0 and the introduction of the
147+
[`unknown` type](https://mariusschulz.com/blog/the-unknown-type-in-typescript) there are rarely any
148+
reasons to use `any` as a type. Nearly all places of former `any` usage can be replace by either a
149+
generic or `unknown` (in cases the type is really not known).
150+
151+
You should always prefer using those mechanisms over using `any`, since they are stricter typed and
152+
less likely to introduce bugs in the future due to insufficient types.
153+
154+
If you’re not having `any` in your plugin or are starting a new plugin, you should enable the
155+
[`@typescript-eslint/no-explicit-any`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-explicit-any.md)
156+
linting rule for your plugin via the [`.eslintrc.js`](https://github.com/elastic/kibana/blob/master/.eslintrc.js) config.
157+
158+
### Avoid non-null assertions
159+
160+
You should try avoiding non-null assertions (`!.`) wherever possible. By using them you tell
161+
TypeScript, that something is not null even though by it’s type it could be. Usage of non-null
162+
assertions is most often a side-effect of you actually checked that the variable is not `null`
163+
but TypeScript doesn’t correctly carry on that information till the usage of the variable.
164+
165+
In most cases it’s possible to replace the non-null assertion by structuring your code/checks slightly different
166+
or using [user defined type guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards)
167+
to properly tell TypeScript what type a variable has.
168+
169+
Using non-null assertion increases the risk for future bugs. In case the condition under which we assumed that the
170+
variable can’t be null has changed (potentially even due to changes in compeltely different files), the non-null
171+
assertion would now wrongly disable proper type checking for us.
172+
173+
If you’re not using non-null assertions in your plugin or are starting a new plugin, consider enabling the
174+
[`@typescript-eslint/no-non-null-assertion`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-assertion.md)
175+
linting rule for you plugin in the [`.eslintrc.js`](https://github.com/elastic/kibana/blob/master/.eslintrc.js) config.
176+
144177
### Return/throw early from functions
145178
146179
To avoid deep nesting of if-statements, always return a function's value as early

docs/api/saved-objects/find.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ experimental[] Retrieve a paginated set of {kib} saved objects by various condit
4141
`has_reference`::
4242
(Optional, object) Filters to objects that have a relationship with the type and ID combination.
4343

44+
`filter`::
45+
(Optional, string) The filter is a KQL string with the caveat that if you filter with an attribute from your type saved object.
46+
It should look like that savedObjectType.attributes.title: "myTitle". However, If you used a direct attribute of a saved object like `updatedAt`,
47+
you will have to define your filter like that savedObjectType.updatedAt > 2018-12-22.
48+
4449
NOTE: As objects change in {kib}, the results on each page of the response also
4550
change. Use the find API for traditional paginated results, but avoid using it to export large amounts of data.
4651

docs/development/core/public/kibana-plugin-public.savedobjectsclient.find.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Search for objects
99
<b>Signature:</b>
1010

1111
```typescript
12-
find: <T extends SavedObjectAttributes>(options: Pick<SavedObjectFindOptionsServer, "search" | "type" | "defaultSearchOperator" | "searchFields" | "sortField" | "hasReference" | "page" | "perPage" | "fields">) => Promise<SavedObjectsFindResponsePublic<T>>;
12+
find: <T extends SavedObjectAttributes>(options: Pick<SavedObjectFindOptionsServer, "search" | "filter" | "type" | "page" | "perPage" | "sortField" | "fields" | "searchFields" | "hasReference" | "defaultSearchOperator">) => Promise<SavedObjectsFindResponsePublic<T>>;
1313
```

docs/development/core/public/kibana-plugin-public.savedobjectsclient.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export declare class SavedObjectsClient
2020
| [bulkGet](./kibana-plugin-public.savedobjectsclient.bulkget.md) | | <code>(objects?: {</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }[]) =&gt; Promise&lt;SavedObjectsBatchResponse&lt;SavedObjectAttributes&gt;&gt;</code> | Returns an array of objects by id |
2121
| [create](./kibana-plugin-public.savedobjectsclient.create.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(type: string, attributes: T, options?: SavedObjectsCreateOptions) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Persists an object |
2222
| [delete](./kibana-plugin-public.savedobjectsclient.delete.md) | | <code>(type: string, id: string) =&gt; Promise&lt;{}&gt;</code> | Deletes an object |
23-
| [find](./kibana-plugin-public.savedobjectsclient.find.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(options: Pick&lt;SavedObjectFindOptionsServer, &quot;search&quot; &#124; &quot;type&quot; &#124; &quot;defaultSearchOperator&quot; &#124; &quot;searchFields&quot; &#124; &quot;sortField&quot; &#124; &quot;hasReference&quot; &#124; &quot;page&quot; &#124; &quot;perPage&quot; &#124; &quot;fields&quot;&gt;) =&gt; Promise&lt;SavedObjectsFindResponsePublic&lt;T&gt;&gt;</code> | Search for objects |
23+
| [find](./kibana-plugin-public.savedobjectsclient.find.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(options: Pick&lt;SavedObjectFindOptionsServer, &quot;search&quot; &#124; &quot;filter&quot; &#124; &quot;type&quot; &#124; &quot;page&quot; &#124; &quot;perPage&quot; &#124; &quot;sortField&quot; &#124; &quot;fields&quot; &#124; &quot;searchFields&quot; &#124; &quot;hasReference&quot; &#124; &quot;defaultSearchOperator&quot;&gt;) =&gt; Promise&lt;SavedObjectsFindResponsePublic&lt;T&gt;&gt;</code> | Search for objects |
2424
| [get](./kibana-plugin-public.savedobjectsclient.get.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(type: string, id: string) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Fetches a single object |
2525

2626
## Methods
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [SavedObjectsFindOptions](./kibana-plugin-public.savedobjectsfindoptions.md) &gt; [filter](./kibana-plugin-public.savedobjectsfindoptions.filter.md)
4+
5+
## SavedObjectsFindOptions.filter property
6+
7+
<b>Signature:</b>
8+
9+
```typescript
10+
filter?: string;
11+
```

docs/development/core/public/kibana-plugin-public.savedobjectsfindoptions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface SavedObjectsFindOptions extends SavedObjectsBaseOptions
1717
| --- | --- | --- |
1818
| [defaultSearchOperator](./kibana-plugin-public.savedobjectsfindoptions.defaultsearchoperator.md) | <code>'AND' &#124; 'OR'</code> | |
1919
| [fields](./kibana-plugin-public.savedobjectsfindoptions.fields.md) | <code>string[]</code> | An array of fields to include in the results |
20+
| [filter](./kibana-plugin-public.savedobjectsfindoptions.filter.md) | <code>string</code> | |
2021
| [hasReference](./kibana-plugin-public.savedobjectsfindoptions.hasreference.md) | <code>{</code><br/><code> type: string;</code><br/><code> id: string;</code><br/><code> }</code> | |
2122
| [page](./kibana-plugin-public.savedobjectsfindoptions.page.md) | <code>number</code> | |
2223
| [perPage](./kibana-plugin-public.savedobjectsfindoptions.perpage.md) | <code>number</code> | |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) &gt; [filter](./kibana-plugin-server.savedobjectsfindoptions.filter.md)
4+
5+
## SavedObjectsFindOptions.filter property
6+
7+
<b>Signature:</b>
8+
9+
```typescript
10+
filter?: string;
11+
```

docs/development/core/server/kibana-plugin-server.savedobjectsfindoptions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface SavedObjectsFindOptions extends SavedObjectsBaseOptions
1717
| --- | --- | --- |
1818
| [defaultSearchOperator](./kibana-plugin-server.savedobjectsfindoptions.defaultsearchoperator.md) | <code>'AND' &#124; 'OR'</code> | |
1919
| [fields](./kibana-plugin-server.savedobjectsfindoptions.fields.md) | <code>string[]</code> | An array of fields to include in the results |
20+
| [filter](./kibana-plugin-server.savedobjectsfindoptions.filter.md) | <code>string</code> | |
2021
| [hasReference](./kibana-plugin-server.savedobjectsfindoptions.hasreference.md) | <code>{</code><br/><code> type: string;</code><br/><code> id: string;</code><br/><code> }</code> | |
2122
| [page](./kibana-plugin-server.savedobjectsfindoptions.page.md) | <code>number</code> | |
2223
| [perPage](./kibana-plugin-server.savedobjectsfindoptions.perpage.md) | <code>number</code> | |

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
"expiry-js": "0.1.7",
160160
"file-loader": "4.2.0",
161161
"font-awesome": "4.7.0",
162-
"fp-ts": "^2.0.5",
163162
"getos": "^3.1.0",
164163
"glob": "^7.1.2",
165164
"glob-all": "^3.1.0",
@@ -176,7 +175,6 @@
176175
"https-proxy-agent": "^2.2.2",
177176
"inert": "^5.1.0",
178177
"inline-style": "^2.0.0",
179-
"io-ts": "^2.0.1",
180178
"joi": "^13.5.2",
181179
"jquery": "^3.4.1",
182180
"js-yaml": "3.13.1",

packages/kbn-babel-code-parser/src/can_require.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
* under the License.
1818
*/
1919

20-
export function canRequire(cwd, entry) {
20+
export function canRequire(entry, cwd = require.resolve.paths(entry) || []) {
2121
try {
2222
// We will try to test if we can resolve
2323
// this entry through the require.resolve
2424
// setting as the start looking path the
25-
// given cwd. Require.resolve will keep
25+
// given cwd. That cwd variable could be
26+
// a path or an array of paths
27+
// from where Require.resolve will keep
2628
// looking recursively as normal starting
27-
// from that location.
29+
// from those locations.
2830
return require.resolve(entry, {
29-
paths: [
30-
cwd
31-
]
31+
paths: [].concat(cwd)
3232
});
3333
} catch (e) {
3434
return false;

0 commit comments

Comments
 (0)