Skip to content

Commit

Permalink
Merge branch 'master' into fix/siem-eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Nov 15, 2019
2 parents 5fcc3ef + 1a8bb3a commit 0a00329
Show file tree
Hide file tree
Showing 30 changed files with 158 additions and 106 deletions.
1 change: 1 addition & 0 deletions STYLEGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ You should prefer modern language features in a lot of cases, e.g.:
* Prefer arrow function over storing `this` (no `const self = this;`)
* Prefer template strings over string concatenation
* Prefer the spread operator for copying arrays (`[...arr]`) over `arr.slice()`
* Use optional chaining (`?.`) and nullish Coalescing (`??`) over `lodash.get` (and similar utilities)
### Avoid mutability and state
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"**/@types/react": "16.8.3",
"**/@types/hapi": "^17.0.18",
"**/@types/angular": "^1.6.56",
"**/typescript": "3.5.3",
"**/typescript": "3.7.2",
"**/graphql-toolkit/lodash": "^4.17.13",
"**/isomorphic-git/**/base64-js": "^1.2.1",
"**/image-diff/gm/debug": "^2.6.9"
Expand Down Expand Up @@ -346,8 +346,8 @@
"@types/uuid": "^3.4.4",
"@types/vinyl-fs": "^2.4.11",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^2.5.0",
"@typescript-eslint/parser": "^2.5.0",
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
"angular-mocks": "^1.7.8",
"archiver": "^3.1.1",
"axe-core": "^3.3.2",
Expand Down Expand Up @@ -444,7 +444,7 @@
"supertest": "^3.1.0",
"supertest-as-promised": "^4.0.2",
"tree-kill": "^1.2.1",
"typescript": "3.5.3",
"typescript": "3.7.2",
"typings-tester": "^0.3.2",
"vinyl-fs": "^3.0.3",
"xml2js": "^0.4.22",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-kibana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"homepage": "https://github.com/elastic/eslint-config-kibana#readme",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^2.5.0",
"@typescript-eslint/parser": "^2.5.0",
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.5.1",
"eslint-plugin-babel": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"@babel/cli": "7.5.5",
"@kbn/dev-utils": "1.0.0",
"@kbn/babel-preset": "1.0.0",
"typescript": "3.5.3"
"typescript": "3.7.2"
}
}
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"kbn:bootstrap": "yarn build"
},
"devDependencies": {
"typescript": "3.5.3"
"typescript": "3.7.2"
},
"peerDependencies": {
"joi": "^13.5.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"tslib": "^1.9.3"
},
"devDependencies": {
"typescript": "3.5.3",
"typescript": "3.7.2",
"@kbn/expect": "1.0.0",
"chance": "1.0.18"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-elastic-idx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@babel/core": "^7.5.5",
"@babel/plugin-transform-async-to-generator": "^7.5.0",
"jest": "^24.9.0",
"typescript": "3.5.3"
"typescript": "3.7.2"
},
"jest": {
"testEnvironment": "node"
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"del": "^5.1.0",
"getopts": "^2.2.4",
"supports-color": "^7.0.0",
"typescript": "3.5.3"
"typescript": "3.7.2"
},
"dependencies": {
"intl-format-cache": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"strip-ansi": "^4.0.0",
"strong-log-transformer": "^2.1.0",
"tempy": "^0.3.0",
"typescript": "3.5.3",
"typescript": "3.7.2",
"unlazy-loader": "^0.1.3",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9",
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/console/server/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
import http from 'http';
import http, { ClientRequest } from 'http';
import * as sinon from 'sinon';
import { sendRequest } from './request';
import { URL } from 'url';
import { fail } from 'assert';

describe(`Console's send request`, () => {
let sandbox: sinon.SinonSandbox;
let stub: sinon.SinonStub;
let stub: sinon.SinonStub<Parameters<typeof http['request']>, ClientRequest>;
let fakeRequest: http.ClientRequest;

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function TopNavMenuItem(props: TopNavMenuData) {
isDisabled={isDisabled()}
onClick={handleClick}
data-test-subj={props.testId}
className={props.className}
>
{capitalize(props.label || props.id!)}
</EuiButtonEmpty>
Expand Down
19 changes: 11 additions & 8 deletions src/legacy/core_plugins/tile_map/public/components/wms_options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,26 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

import { TmsLayer } from 'ui/vis/map/service_settings';
import { Vis } from 'ui/vis';
import { RegionMapVisParams } from '../../../region_map/public/types';
import { SelectOption, SwitchOption } from '../../../kbn_vislib_vis_types/public/components';
import { RegionMapOptionsProps } from '../../../region_map/public/components/region_map_options';
import { WmsInternalOptions } from './wms_internal_options';
import { TileMapOptionsProps } from './tile_map_options';
import { TileMapVisParams } from '../types';
import { WMSOptions, TileMapVisParams } from '../types';

interface Props {
stateParams: TileMapVisParams | RegionMapVisParams;
setValue: (title: 'wms', options: WMSOptions) => void;
vis: Vis;
}

const mapLayerForOption = ({ id }: TmsLayer) => ({ text: id, value: id });

function WmsOptions({ stateParams, setValue, vis }: TileMapOptionsProps | RegionMapOptionsProps) {
function WmsOptions({ stateParams, setValue, vis }: Props) {
const { wms } = stateParams;
const { tmsLayers } = vis.type.editorConfig.collections;
const tmsLayerOptions = useMemo(() => tmsLayers.map(mapLayerForOption), [tmsLayers]);

const setWmsOption = <T extends keyof TileMapVisParams['wms']>(
paramName: T,
value: TileMapVisParams['wms'][T]
) =>
const setWmsOption = <T extends keyof WMSOptions>(paramName: T, value: WMSOptions[T]) =>
setValue('wms', {
...wms,
[paramName]: value,
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/expressions/public/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { ExpressionInterpret } from '../interpreter_provider';
import { TimeRange } from '../../../data/public';
import { Adapters } from '../../../inspector/public';
import { Query } from '../../../data/public';
import { ExpressionAST } from '../../../expressions/public';
import { ExpressionArgAST } from '../../../../plugins/expressions/public';
import { esFilters } from '../../../../plugins/data/public';

export { ArgumentType } from './arguments';
Expand Down
2 changes: 1 addition & 1 deletion test/plugin_functional/plugins/core_plugin_a/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.5.3"
"typescript": "3.7.2"
}
}
2 changes: 1 addition & 1 deletion test/plugin_functional/plugins/core_plugin_b/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.5.3"
"typescript": "3.7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.5.3"
"typescript": "3.7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"devDependencies": {
"@kbn/plugin-helpers": "9.0.2",
"typescript": "3.5.3"
"typescript": "3.7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"devDependencies": {
"@kbn/plugin-helpers": "9.0.2",
"typescript": "3.5.3"
"typescript": "3.7.2"
}
}
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/apm/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"@cypress/snapshot": "^2.1.3",
"@cypress/webpack-preprocessor": "^4.1.0",
"@types/js-yaml": "^3.12.1",
"cypress": "^3.4.1",
"cypress": "^3.5.0",
"js-yaml": "^3.13.1",
"p-limit": "^2.2.1",
"ts-loader": "^6.1.0",
"typescript": "^3.6.3",
"typescript": "3.7.2",
"webpack": "^4.40.2"
}
}
24 changes: 20 additions & 4 deletions x-pack/legacy/plugins/apm/server/lib/helpers/setup_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
import { Legacy } from 'kibana';
import { Server } from 'hapi';
import moment from 'moment';
import { KibanaConfig } from 'src/legacy/server/kbn_server';
import { getESClient } from './es_client';
import { getUiFiltersES } from './convert_ui_filters/get_ui_filters_es';
import { PromiseReturnType } from '../../../typings/common';
import { getApmIndices } from '../settings/apm_indices/get_apm_indices';
import {
getApmIndices,
ApmIndicesConfig
} from '../settings/apm_indices/get_apm_indices';
import { ESFilter } from '../../../typings/elasticsearch';
import { ESClient } from './es_client';

function decodeUiFilters(server: Server, uiFiltersEncoded?: string) {
if (!uiFiltersEncoded) {
Expand All @@ -26,9 +31,20 @@ export interface APMRequestQuery {
end?: string;
uiFilters?: string;
}
// Explicitly type Setup to prevent TS initialization errors
// https://github.com/microsoft/TypeScript/issues/34933

export type Setup = PromiseReturnType<typeof setupRequest>;
export async function setupRequest(req: Legacy.Request) {
export interface Setup {
start: number;
end: number;
uiFiltersES: ESFilter[];
client: ESClient;
internalClient: ESClient;
config: KibanaConfig;
indices: ApmIndicesConfig;
}

export async function setupRequest(req: Legacy.Request): Promise<Setup> {
const query = (req.query as unknown) as APMRequestQuery;
const { server } = req;
const savedObjectsClient = server.savedObjects.getScopedSavedObjectsClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ type GenericMetricsRequest = Overwrite<
}
>;

export function transformDataToMetricsChart<
TRequest extends GenericMetricsRequest
>(result: ESSearchResponse<unknown, TRequest>, chartBase: ChartBase) {
export function transformDataToMetricsChart(
result: ESSearchResponse<unknown, GenericMetricsRequest>,
chartBase: ChartBase
) {
const { aggregations, hits } = result;
const timeseriesData = idx(aggregations, _ => _.timeseriesData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const asChildFunctionRenderer = <InjectedProps, OwnProps>(
}

public render() {
return this.props.children(this.getRendererArgs());
return (this.props.children as ChildFunctionRendererProps<InjectedProps>['children'])(
this.getRendererArgs()
);
}

private getRendererArgs = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ describe('IndexPattern Data Panel', () => {
act(() => {
((inst.setProps as unknown) as (props: unknown) => {})({
...props,
...(propChanges || {}),
...((propChanges as object) || {}),
state: {
...props.state,
...(stateChanges || {}),
...((stateChanges as object) || {}),
},
});
inst.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Subscription } from 'rxjs';
import { idx } from '@kbn/elastic-idx';
import { ml } from '../../services/ml_api_service';
import { getErrorMessage } from '../pages/analytics_management/hooks/use_create_analytics_form';
import { RegressionEvaluateResponse } from '../common';

export type IndexName = string;
export type IndexPattern = string;
Expand Down
14 changes: 6 additions & 8 deletions x-pack/legacy/plugins/ml/public/overview/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ function getCreateJobLink(createAnomalyDetectionJobDisabled: boolean) {
return createAnomalyDetectionJobDisabled === true ? (
<FormattedMessage
id="xpack.ml.overview.gettingStartedSectionCreateJob"
defaultMessage="creating a new job"
defaultMessage="creating a new job"
/>
) : (
<EuiLink href={createJobLink} target="blank">
<FormattedMessage
id="xpack.ml.overview.gettingStartedSectionCreateJob"
defaultMessage="creating a new job"
defaultMessage="creating a new job"
/>
</EuiLink>
);
Expand All @@ -43,15 +43,13 @@ export const OverviewSideBar: FC<Props> = ({ createAnomalyDetectionJobDisabled }
<h2>
<FormattedMessage
id="xpack.ml.overview.gettingStartedSectionTitle"
defaultMessage="Getting Started"
defaultMessage="Getting started"
/>
</h2>
<p>
<FormattedMessage
id="xpack.ml.overview.gettingStartedSectionText"
defaultMessage="Welcome to Machine Learning. Get started by reviewing our {docs} or {createJob}.
For more information about machine learning in the Elastic stack please see {whatIsMachineLearning}.
We recommend using {transforms} to create feature indices for analytics jobs."
defaultMessage="Welcome to Machine Learning. Get started by reviewing our {docs} or {createJob}. For more information about machine learning in the Elastic stack please see {whatIsMachineLearning}. We recommend using {transforms} to create feature indices for analytics jobs."
values={{
docs: (
<EuiLink href={docsLink} target="blank">
Expand Down Expand Up @@ -87,13 +85,13 @@ export const OverviewSideBar: FC<Props> = ({ createAnomalyDetectionJobDisabled }
<p>
<FormattedMessage
id="xpack.ml.overview.feedbackSectionText"
defaultMessage="If you have input or suggestions regarding your experience with Machine Learning please feel free to submit {feedbackLink}."
defaultMessage="If you have input or suggestions regarding your experience with Machine Learning please feel free to submit {feedbackLink}."
values={{
feedbackLink: (
<EuiLink href={feedbackLink} target="blank">
<FormattedMessage
id="xpack.ml.overview.feedbackSectionLink"
defaultMessage="feedback online"
defaultMessage="feedback online"
/>
</EuiLink>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const mockCallEndpoint = sinon.stub();
const mockSearchRequest = {};
const mockConfig: ScrollConfig = { duration: '2s', size: 123 };
let realCancellationToken = new CancellationToken();
let isCancelledStub: sinon.SinonStub;
let isCancelledStub: sinon.SinonStub<[], boolean>;

describe('hitIterator', function() {
beforeEach(() => {
Expand Down
Loading

0 comments on commit 0a00329

Please sign in to comment.