mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
update code style
This commit is contained in:
parent
3e28b90281
commit
2fefd60e90
7131 changed files with 31567 additions and 37324 deletions
|
@ -50,7 +50,7 @@ const ELASTIC_LICENSE_HEADER = `
|
|||
`;
|
||||
|
||||
const allMochaRulesOff = {};
|
||||
Object.keys(require('eslint-plugin-mocha').rules).forEach(k => {
|
||||
Object.keys(require('eslint-plugin-mocha').rules).forEach((k) => {
|
||||
allMochaRulesOff['mocha/' + k] = 'off';
|
||||
});
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
require('./src/setup_node_env');
|
||||
|
||||
module.exports = function(grunt) {
|
||||
module.exports = function (grunt) {
|
||||
// set the config once before calling load-grunt-config
|
||||
// and once during so that we have access to it via
|
||||
// grunt.config.get() within the config files
|
||||
|
|
|
@ -71,7 +71,7 @@ export const AlwaysFiringExpression: React.FunctionComponent<AlwaysFiringParamsP
|
|||
<EuiFieldNumber
|
||||
name="instances"
|
||||
value={instances}
|
||||
onChange={event => {
|
||||
onChange={(event) => {
|
||||
setAlertParams('instances', event.target.valueAsNumber);
|
||||
}}
|
||||
/>
|
||||
|
|
|
@ -51,7 +51,7 @@ interface PeopleinSpaceParamsProps {
|
|||
}
|
||||
|
||||
function isValueInEnum(enumeratin: Record<string, any>, value: any): boolean {
|
||||
return !!Object.values(enumeratin).find(enumVal => enumVal === value);
|
||||
return !!Object.values(enumeratin).find((enumVal) => enumVal === value);
|
||||
}
|
||||
|
||||
export function getAlertType(): AlertTypeModel {
|
||||
|
@ -139,7 +139,7 @@ export const PeopleinSpaceExpression: React.FunctionComponent<PeopleinSpaceParam
|
|||
|
||||
const errorsCallout = flatten(
|
||||
Object.entries(errors).map(([field, errs]: [string, string[]]) =>
|
||||
errs.map(e => (
|
||||
errs.map((e) => (
|
||||
<p>
|
||||
<EuiTextColor color="accent">{field}:</EuiTextColor>`: ${errs}`
|
||||
</p>
|
||||
|
@ -189,7 +189,7 @@ export const PeopleinSpaceExpression: React.FunctionComponent<PeopleinSpaceParam
|
|||
<EuiSelect
|
||||
compressed
|
||||
value={craftTrigger.craft}
|
||||
onChange={event => {
|
||||
onChange={(event) => {
|
||||
setAlertParams('craft', event.target.value);
|
||||
setCraftTrigger({
|
||||
craft: event.target.value,
|
||||
|
@ -238,7 +238,7 @@ export const PeopleinSpaceExpression: React.FunctionComponent<PeopleinSpaceParam
|
|||
<EuiSelect
|
||||
compressed
|
||||
value={outerSpaceCapacityTrigger.op}
|
||||
onChange={event => {
|
||||
onChange={(event) => {
|
||||
setAlertParams('op', event.target.value);
|
||||
setOuterSpaceCapacity({
|
||||
...outerSpaceCapacityTrigger,
|
||||
|
@ -258,7 +258,7 @@ export const PeopleinSpaceExpression: React.FunctionComponent<PeopleinSpaceParam
|
|||
<EuiFieldNumber
|
||||
compressed
|
||||
value={outerSpaceCapacityTrigger.outerSpaceCapacity}
|
||||
onChange={event => {
|
||||
onChange={(event) => {
|
||||
setAlertParams('outerSpaceCapacity', event.target.valueAsNumber);
|
||||
setOuterSpaceCapacity({
|
||||
...outerSpaceCapacityTrigger,
|
||||
|
|
|
@ -68,10 +68,7 @@ export const alertType: AlertType = {
|
|||
|
||||
if (getOperator(op)(peopleInCraft.length, outerSpaceCapacity)) {
|
||||
peopleInCraft.forEach(({ craft, name }) => {
|
||||
services
|
||||
.alertInstanceFactory(name)
|
||||
.replaceState({ craft })
|
||||
.scheduleActions('default');
|
||||
services.alertInstanceFactory(name).replaceState({ craft }).scheduleActions('default');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ export const CountUntil: React.FC<Props> = ({ fetchStreaming }) => {
|
|||
<EuiFieldNumber
|
||||
placeholder="Some integer"
|
||||
value={data}
|
||||
onChange={e => setData(Number(e.target.value))}
|
||||
onChange={(e) => setData(Number(e.target.value))}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
<EuiButton type="submit" fill onClick={handleSubmit}>
|
||||
|
|
|
@ -49,18 +49,18 @@ export const DoubleIntegers: React.FC<Props> = ({ double }) => {
|
|||
setShowingResults(true);
|
||||
const nums = numbers
|
||||
.split('\n')
|
||||
.map(num => num.trim())
|
||||
.map((num) => num.trim())
|
||||
.filter(Boolean)
|
||||
.map(Number);
|
||||
counter.set(nums.length);
|
||||
nums.forEach(num => {
|
||||
nums.forEach((num) => {
|
||||
double({ num }).then(
|
||||
result => {
|
||||
(result) => {
|
||||
if (!isMounted()) return;
|
||||
counter.dec();
|
||||
pushResult({ num, result });
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
if (!isMounted()) return;
|
||||
counter.dec();
|
||||
pushResult({ num, error });
|
||||
|
@ -94,7 +94,7 @@ export const DoubleIntegers: React.FC<Props> = ({ double }) => {
|
|||
fullWidth
|
||||
placeholder="Enter numbers in milliseconds separated by new line"
|
||||
value={numbers}
|
||||
onChange={e => setNumbers(e.target.value)}
|
||||
onChange={(e) => setNumbers(e.target.value)}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
<EuiButton type="submit" fill onClick={handleSubmit}>
|
||||
|
|
|
@ -30,7 +30,7 @@ export const App: React.FC = () => {
|
|||
const routeElements: React.ReactElement[] = [];
|
||||
for (const { items } of routes) {
|
||||
for (const { id, component } of items) {
|
||||
routeElements.push(<Route key={id} path={`/${id}`} render={props => component} />);
|
||||
routeElements.push(<Route key={id} path={`/${id}`} render={(props) => component} />);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ export const Sidebar: React.FC<SidebarProps> = () => {
|
|||
id,
|
||||
name: title,
|
||||
isSelected: true,
|
||||
items: items.map(route => ({
|
||||
items: items.map((route) => ({
|
||||
id: route.id,
|
||||
name: route.title,
|
||||
onClick: () => history.push(`/${route.id}`),
|
||||
|
|
|
@ -54,7 +54,7 @@ export class BfetchExplorerPlugin implements Plugin {
|
|||
// Validate inputs.
|
||||
if (num < 0) throw new Error('Invalid number');
|
||||
// Wait number of specified milliseconds.
|
||||
await new Promise(r => setTimeout(r, num));
|
||||
await new Promise((r) => setTimeout(r, num));
|
||||
// Double the number and send it back.
|
||||
return { num: 2 * num };
|
||||
},
|
||||
|
|
|
@ -40,7 +40,7 @@ const totalMap = new Map<string, number>();
|
|||
|
||||
export const asyncDemoSearchStrategyProvider: TSearchStrategyProvider<typeof ASYNC_DEMO_SEARCH_STRATEGY> = () => {
|
||||
return {
|
||||
search: async request => {
|
||||
search: async (request) => {
|
||||
const id = request.id ?? generateId();
|
||||
|
||||
const loaded = (loadedMap.get(id) ?? 0) + 1;
|
||||
|
@ -52,7 +52,7 @@ export const asyncDemoSearchStrategyProvider: TSearchStrategyProvider<typeof ASY
|
|||
const fibonacciSequence = getFibonacciSequence(loaded);
|
||||
return { id, total, loaded, fibonacciSequence };
|
||||
},
|
||||
cancel: async id => {
|
||||
cancel: async (id) => {
|
||||
loadedMap.delete(id);
|
||||
totalMap.delete(id);
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@ import { DEMO_SEARCH_STRATEGY } from '../common';
|
|||
|
||||
export const demoSearchStrategyProvider: TSearchStrategyProvider<typeof DEMO_SEARCH_STRATEGY> = () => {
|
||||
return {
|
||||
search: request => {
|
||||
search: (request) => {
|
||||
return Promise.resolve({
|
||||
greeting:
|
||||
request.mood === 'happy'
|
||||
|
|
|
@ -40,7 +40,7 @@ function renderList(
|
|||
embeddableServices: EmbeddableStart
|
||||
) {
|
||||
let number = 0;
|
||||
const list = Object.values(panels).map(panel => {
|
||||
const list = Object.values(panels).map((panel) => {
|
||||
const child = embeddable.getChild(panel.explicitInput.id);
|
||||
number++;
|
||||
return (
|
||||
|
|
|
@ -55,7 +55,7 @@ function wrapSearchTerms(task: string, search?: string) {
|
|||
}
|
||||
|
||||
function renderTasks(tasks: MultiTaskTodoInput['tasks'], search?: string) {
|
||||
return tasks.map(task => (
|
||||
return tasks.map((task) => (
|
||||
<EuiListGroupItem
|
||||
key={task}
|
||||
data-test-subj="multiTaskTodoTask"
|
||||
|
|
|
@ -48,7 +48,7 @@ function getHasMatch(tasks: string[], title?: string, search?: string) {
|
|||
|
||||
if (title && title.match(search)) return true;
|
||||
|
||||
const match = tasks.find(task => task.match(search));
|
||||
const match = tasks.find((task) => task.match(search));
|
||||
if (match) return true;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -65,12 +65,12 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
|
||||
const checked: { [id: string]: boolean } = {};
|
||||
const hasMatch: { [id: string]: boolean } = {};
|
||||
props.embeddable.getChildIds().forEach(id => {
|
||||
props.embeddable.getChildIds().forEach((id) => {
|
||||
checked[id] = false;
|
||||
const output = props.embeddable.getChild(id).getOutput();
|
||||
hasMatch[id] = hasHasMatchOutput(output) && output.hasMatch;
|
||||
});
|
||||
props.embeddable.getChildIds().forEach(id => (checked[id] = false));
|
||||
props.embeddable.getChildIds().forEach((id) => (checked[id] = false));
|
||||
this.state = {
|
||||
checked,
|
||||
hasMatch,
|
||||
|
@ -78,13 +78,13 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.embeddable.getChildIds().forEach(id => {
|
||||
this.props.embeddable.getChildIds().forEach((id) => {
|
||||
this.subscriptions[id] = this.props.embeddable
|
||||
.getChild(id)
|
||||
.getOutput$()
|
||||
.subscribe(output => {
|
||||
.subscribe((output) => {
|
||||
if (hasHasMatchOutput(output)) {
|
||||
this.setState(prevState => ({
|
||||
this.setState((prevState) => ({
|
||||
hasMatch: {
|
||||
...prevState.hasMatch,
|
||||
[id]: output.hasMatch,
|
||||
|
@ -96,7 +96,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Object.values(this.subscriptions).forEach(sub => sub.unsubscribe());
|
||||
Object.values(this.subscriptions).forEach((sub) => sub.unsubscribe());
|
||||
}
|
||||
|
||||
private updateSearch = (search: string) => {
|
||||
|
@ -104,7 +104,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
};
|
||||
|
||||
private deleteChecked = () => {
|
||||
Object.values(this.props.input.panels).map(panel => {
|
||||
Object.values(this.props.input.panels).map((panel) => {
|
||||
if (this.state.checked[panel.explicitInput.id]) {
|
||||
this.props.embeddable.removeEmbeddable(panel.explicitInput.id);
|
||||
this.subscriptions[panel.explicitInput.id].unsubscribe();
|
||||
|
@ -115,7 +115,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
private checkMatching = () => {
|
||||
const { input, embeddable } = this.props;
|
||||
const checked: { [key: string]: boolean } = {};
|
||||
Object.values(input.panels).map(panel => {
|
||||
Object.values(input.panels).map((panel) => {
|
||||
const child = embeddable.getChild(panel.explicitInput.id);
|
||||
const output = child.getOutput();
|
||||
if (hasHasMatchOutput(output) && output.hasMatch) {
|
||||
|
@ -126,7 +126,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
};
|
||||
|
||||
private toggleCheck = (isChecked: boolean, id: string) => {
|
||||
this.setState(prevState => ({ checked: { ...prevState.checked, [id]: isChecked } }));
|
||||
this.setState((prevState) => ({ checked: { ...prevState.checked, [id]: isChecked } }));
|
||||
};
|
||||
|
||||
public renderControls() {
|
||||
|
@ -156,7 +156,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
<EuiFieldText
|
||||
data-test-subj="filterTodos"
|
||||
value={this.props.input.search || ''}
|
||||
onChange={ev => this.updateSearch(ev.target.value)}
|
||||
onChange={(ev) => this.updateSearch(ev.target.value)}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
@ -183,7 +183,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
private renderList() {
|
||||
const { embeddableServices, input, embeddable } = this.props;
|
||||
let id = 0;
|
||||
const list = Object.values(input.panels).map(panel => {
|
||||
const list = Object.values(input.panels).map((panel) => {
|
||||
const childEmbeddable = embeddable.getChild(panel.explicitInput.id);
|
||||
id++;
|
||||
return childEmbeddable ? (
|
||||
|
@ -195,7 +195,7 @@ export class SearchableListContainerComponentInner extends Component<Props, Stat
|
|||
disabled={!childEmbeddable}
|
||||
id={childEmbeddable ? childEmbeddable.id : ''}
|
||||
checked={this.state.checked[childEmbeddable.id]}
|
||||
onChange={e => this.toggleCheck(e.target.checked, childEmbeddable.id)}
|
||||
onChange={(e) => this.toggleCheck(e.target.checked, childEmbeddable.id)}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
|
|
|
@ -34,7 +34,7 @@ function TaskInput({ onSave }: { onSave: (task: string) => void }) {
|
|||
data-test-subj="taskInputField"
|
||||
value={task}
|
||||
placeholder="Enter task here"
|
||||
onChange={e => setTask(e.target.value)}
|
||||
onChange={(e) => setTask(e.target.value)}
|
||||
/>
|
||||
<EuiButton data-test-subj="createTodoEmbeddable" onClick={() => onSave(task)}>
|
||||
Save
|
||||
|
@ -69,7 +69,7 @@ export class TodoEmbeddableFactory
|
|||
*/
|
||||
public getExplicitInput = async () => {
|
||||
const { openModal } = await this.getStartServices();
|
||||
return new Promise<{ task: string }>(resolve => {
|
||||
return new Promise<{ task: string }>((resolve) => {
|
||||
const onSave = (task: string) => resolve({ task });
|
||||
const overlay = openModal(
|
||||
toMountPoint(
|
||||
|
|
|
@ -51,7 +51,7 @@ type NavProps = RouteComponentProps & {
|
|||
};
|
||||
|
||||
const Nav = withRouter(({ history, navigateToApp, pages }: NavProps) => {
|
||||
const navItems = pages.map(page => ({
|
||||
const navItems = pages.map((page) => ({
|
||||
id: page.id,
|
||||
name: page.title,
|
||||
onClick: () => history.push(`/${page.id}`),
|
||||
|
@ -122,7 +122,7 @@ const EmbeddableExplorerApp = ({
|
|||
];
|
||||
|
||||
const routes = pages.map((page, i) => (
|
||||
<Route key={i} path={`/${page.id}`} render={props => page.component} />
|
||||
<Route key={i} path={`/${page.id}`} render={(props) => page.component} />
|
||||
));
|
||||
|
||||
return (
|
||||
|
|
|
@ -84,7 +84,7 @@ export function EmbeddablePanelExample({ embeddableServices }: Props) {
|
|||
const factory = embeddableServices.getEmbeddableFactory(SEARCHABLE_LIST_CONTAINER);
|
||||
const promise = factory?.create(searchableInput);
|
||||
if (promise) {
|
||||
promise.then(e => {
|
||||
promise.then((e) => {
|
||||
if (ref.current) {
|
||||
setEmbeddable(e);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ export class TodoEmbeddableExample extends React.Component<Props, State> {
|
|||
icon: 'broom',
|
||||
title: 'Trash',
|
||||
})
|
||||
.then(embeddable => {
|
||||
.then((embeddable) => {
|
||||
this.embeddable = embeddable;
|
||||
this.setState({ loading: false });
|
||||
});
|
||||
|
@ -135,7 +135,7 @@ export class TodoEmbeddableExample extends React.Component<Props, State> {
|
|||
<EuiFormRow label="Title">
|
||||
<EuiFieldText
|
||||
data-test-subj="titleTodo"
|
||||
onChange={ev => this.setState({ title: ev.target.value })}
|
||||
onChange={(ev) => this.setState({ title: ev.target.value })}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
@ -143,7 +143,7 @@ export class TodoEmbeddableExample extends React.Component<Props, State> {
|
|||
<EuiFormRow label="Icon">
|
||||
<EuiFieldText
|
||||
data-test-subj="iconTodo"
|
||||
onChange={ev => this.setState({ icon: ev.target.value })}
|
||||
onChange={(ev) => this.setState({ icon: ev.target.value })}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
@ -153,7 +153,7 @@ export class TodoEmbeddableExample extends React.Component<Props, State> {
|
|||
fullWidth
|
||||
resize="horizontal"
|
||||
data-test-subj="taskTodo"
|
||||
onChange={ev => this.setState({ task: ev.target.value })}
|
||||
onChange={(ev) => this.setState({ task: ev.target.value })}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
|
|
@ -51,7 +51,7 @@ type NavProps = RouteComponentProps & {
|
|||
};
|
||||
|
||||
const Nav = withRouter(({ history, navigateToApp, pages }: NavProps) => {
|
||||
const navItems = pages.map(page => ({
|
||||
const navItems = pages.map((page) => ({
|
||||
id: page.id,
|
||||
name: page.title,
|
||||
onClick: () => history.push(`/${page.id}`),
|
||||
|
@ -103,7 +103,7 @@ const SearchApp = ({ basename, data, application }: SearchBarComponentParams) =>
|
|||
];
|
||||
|
||||
const routes = pages.map((page, i) => (
|
||||
<Route key={i} path={`/${page.id}`} render={props => buildPage(page)} />
|
||||
<Route key={i} path={`/${page.id}`} render={(props) => buildPage(page)} />
|
||||
));
|
||||
|
||||
return (
|
||||
|
|
|
@ -73,7 +73,7 @@ export class AsyncDemoStrategy extends React.Component<Props, State> {
|
|||
<EuiFormRow label="How many Fibonacci numbers to generate?">
|
||||
<EuiFieldNumber
|
||||
value={this.state.fibonacciNumbers}
|
||||
onChange={e => this.setState({ fibonacciNumbers: parseFloat(e.target.value) })}
|
||||
onChange={(e) => this.setState({ fibonacciNumbers: parseFloat(e.target.value) })}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
|
|
@ -81,7 +81,7 @@ export class DemoStrategy extends React.Component<Props, State> {
|
|||
<EuiFormRow label="What is your name?">
|
||||
<EuiFieldText
|
||||
value={this.state.name}
|
||||
onChange={e => this.setState({ name: e.target.value })}
|
||||
onChange={(e) => this.setState({ name: e.target.value })}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
@ -90,7 +90,7 @@ export class DemoStrategy extends React.Component<Props, State> {
|
|||
<EuiFormRow label="How are you feeling today?">
|
||||
<EuiFieldText
|
||||
value={this.state.mood}
|
||||
onChange={e => this.setState({ mood: e.target.value })}
|
||||
onChange={(e) => this.setState({ mood: e.target.value })}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
|
|
@ -61,10 +61,10 @@ export class DoSearch extends React.Component<Props, State> {
|
|||
this.abortController = new AbortController();
|
||||
|
||||
this.props.search(this.abortController.signal).subscribe(
|
||||
response => {
|
||||
(response) => {
|
||||
this.setState({ response, error: undefined });
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
this.setState({ error, searching: false, response: undefined });
|
||||
},
|
||||
() => {
|
||||
|
|
|
@ -92,7 +92,7 @@ export class EsSearchTest extends React.Component<Props, State> {
|
|||
<EuiFormRow label="Index pattern">
|
||||
<EuiFieldText
|
||||
value={this.state.index}
|
||||
onChange={e => this.setState({ index: e.target.value, changes: true })}
|
||||
onChange={(e) => this.setState({ index: e.target.value, changes: true })}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
@ -101,7 +101,7 @@ export class EsSearchTest extends React.Component<Props, State> {
|
|||
<EuiFormRow label="Query string query">
|
||||
<EuiFieldText
|
||||
value={this.state.query}
|
||||
onChange={e => this.setState({ query: e.target.value, changes: true })}
|
||||
onChange={(e) => this.setState({ query: e.target.value, changes: true })}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiFlexItem>
|
||||
|
|
|
@ -59,7 +59,7 @@ export class GuideSection extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
if (props.codeSections) {
|
||||
props.codeSections.forEach(section => {
|
||||
props.codeSections.forEach((section) => {
|
||||
this.tabs.push({
|
||||
name: section.title,
|
||||
displayName: section.title,
|
||||
|
@ -79,7 +79,7 @@ export class GuideSection extends React.Component<Props, State> {
|
|||
};
|
||||
|
||||
renderTabs() {
|
||||
return this.tabs.map(tab => (
|
||||
return this.tabs.map((tab) => (
|
||||
<EuiTab
|
||||
onClick={() => this.onSelectedTabChanged(tab.name)}
|
||||
isSelected={tab.name === this.state.selectedTab}
|
||||
|
@ -98,7 +98,7 @@ export class GuideSection extends React.Component<Props, State> {
|
|||
if (!this.props.codeSections) {
|
||||
return undefined;
|
||||
}
|
||||
const section = this.props.codeSections.find(s => s.title === this.state.selectedTab);
|
||||
const section = this.props.codeSections.find((s) => s.title === this.state.selectedTab);
|
||||
|
||||
if (!section) {
|
||||
throw new Error('No section named ' + this.state.selectedTab);
|
||||
|
|
|
@ -61,7 +61,7 @@ const defaultGlobalState: GlobalState = { text: '' };
|
|||
const globalStateContainer = createStateContainer<GlobalState, GlobalStateAction>(
|
||||
defaultGlobalState,
|
||||
{
|
||||
setText: state => text => ({ ...state, text }),
|
||||
setText: (state) => (text) => ({ ...state, text }),
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -81,7 +81,7 @@ const TodoApp: React.FC<TodoAppProps> = ({ filter }) => {
|
|||
const { text } = GlobalStateHelpers.useState();
|
||||
const { edit: editTodo, delete: deleteTodo, add: addTodo } = useTransitions();
|
||||
const todos = useState().todos;
|
||||
const filteredTodos = todos.filter(todo => {
|
||||
const filteredTodos = todos.filter((todo) => {
|
||||
if (!filter) return true;
|
||||
if (filter === 'completed') return todo.completed;
|
||||
if (filter === 'not-completed') return !todo.completed;
|
||||
|
@ -111,13 +111,13 @@ const TodoApp: React.FC<TodoAppProps> = ({ filter }) => {
|
|||
</Link>
|
||||
</div>
|
||||
<ul>
|
||||
{filteredTodos.map(todo => (
|
||||
{filteredTodos.map((todo) => (
|
||||
<li key={todo.id} style={{ display: 'flex', alignItems: 'center', margin: '16px 0px' }}>
|
||||
<EuiCheckbox
|
||||
id={todo.id + ''}
|
||||
key={todo.id}
|
||||
checked={todo.completed}
|
||||
onChange={e => {
|
||||
onChange={(e) => {
|
||||
editTodo({
|
||||
...todo,
|
||||
completed: e.target.checked,
|
||||
|
@ -139,7 +139,7 @@ const TodoApp: React.FC<TodoAppProps> = ({ filter }) => {
|
|||
))}
|
||||
</ul>
|
||||
<form
|
||||
onSubmit={e => {
|
||||
onSubmit={(e) => {
|
||||
const inputRef = (e.target as HTMLFormElement).elements.namedItem(
|
||||
'newTodo'
|
||||
) as HTMLInputElement;
|
||||
|
@ -147,7 +147,7 @@ const TodoApp: React.FC<TodoAppProps> = ({ filter }) => {
|
|||
addTodo({
|
||||
text: inputRef.value,
|
||||
completed: false,
|
||||
id: todos.map(todo => todo.id).reduce((a, b) => Math.max(a, b), 0) + 1,
|
||||
id: todos.map((todo) => todo.id).reduce((a, b) => Math.max(a, b), 0) + 1,
|
||||
});
|
||||
inputRef.value = '';
|
||||
e.preventDefault();
|
||||
|
@ -157,7 +157,7 @@ const TodoApp: React.FC<TodoAppProps> = ({ filter }) => {
|
|||
</form>
|
||||
<div style={{ margin: '16px 0px' }}>
|
||||
<label htmlFor="globalInput">Global state piece: </label>
|
||||
<input name="globalInput" value={text} onChange={e => setText(e.target.value)} />
|
||||
<input name="globalInput" value={text} onChange={(e) => setText(e.target.value)} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
@ -173,7 +173,7 @@ export const TodoAppPage: React.FC<{
|
|||
appTitle: string;
|
||||
appBasePath: string;
|
||||
isInitialRoute: () => boolean;
|
||||
}> = props => {
|
||||
}> = (props) => {
|
||||
const initialAppUrl = React.useRef(window.location.href);
|
||||
const [useHashedUrl, setUseHashedUrl] = React.useState(false);
|
||||
|
||||
|
@ -181,7 +181,7 @@ export const TodoAppPage: React.FC<{
|
|||
* Replicates what src/legacy/ui/public/chrome/api/nav.ts did
|
||||
* Persists the url in sessionStorage and tries to restore it on "componentDidMount"
|
||||
*/
|
||||
useUrlTracker(`lastUrlTracker:${props.appInstanceId}`, props.history, urlToRestore => {
|
||||
useUrlTracker(`lastUrlTracker:${props.appInstanceId}`, props.history, (urlToRestore) => {
|
||||
// shouldRestoreUrl:
|
||||
// App decides if it should restore url or not
|
||||
// In this specific case, restore only if navigated to initial route
|
||||
|
|
|
@ -135,7 +135,7 @@ const App = ({
|
|||
<EuiFieldText
|
||||
placeholder="Additional application state: My name is..."
|
||||
value={appState.name}
|
||||
onChange={e => appStateContainer.set({ ...appState, name: e.target.value })}
|
||||
onChange={(e) => appStateContainer.set({ ...appState, name: e.target.value })}
|
||||
aria-label="My name"
|
||||
/>
|
||||
</EuiPageContent>
|
||||
|
@ -217,7 +217,7 @@ function useAppStateSyncing<AppState extends QueryState>(
|
|||
stateContainer: {
|
||||
...appStateContainer,
|
||||
// stateSync utils requires explicit handling of default state ("null")
|
||||
set: state => state && appStateContainer.set(state),
|
||||
set: (state) => state && appStateContainer.set(state),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -47,14 +47,14 @@ export interface PhoneContext {
|
|||
export const makePhoneCallAction = createAction<typeof ACTION_CALL_PHONE_NUMBER>({
|
||||
type: ACTION_CALL_PHONE_NUMBER,
|
||||
getDisplayName: () => 'Call phone number',
|
||||
execute: async context => alert(`Pretend calling ${context.phone}...`),
|
||||
execute: async (context) => alert(`Pretend calling ${context.phone}...`),
|
||||
});
|
||||
|
||||
export const lookUpWeatherAction = createAction<typeof ACTION_TRAVEL_GUIDE>({
|
||||
type: ACTION_TRAVEL_GUIDE,
|
||||
getIconType: () => 'popout',
|
||||
getDisplayName: () => 'View travel guide',
|
||||
execute: async context => {
|
||||
execute: async (context) => {
|
||||
window.open(`https://www.worldtravelguide.net/?s=${context.country}`, '_blank');
|
||||
},
|
||||
});
|
||||
|
@ -67,7 +67,7 @@ export const viewInMapsAction = createAction<typeof ACTION_VIEW_IN_MAPS>({
|
|||
type: ACTION_VIEW_IN_MAPS,
|
||||
getIconType: () => 'popout',
|
||||
getDisplayName: () => 'View in maps',
|
||||
execute: async context => {
|
||||
execute: async (context) => {
|
||||
window.open(`https://www.google.com/maps/place/${context.country}`, '_blank');
|
||||
},
|
||||
});
|
||||
|
@ -90,7 +90,7 @@ function EditUserModal({
|
|||
const [name, setName] = useState(user.name);
|
||||
return (
|
||||
<EuiModalBody>
|
||||
<EuiFieldText prepend="Name" value={name} onChange={e => setName(e.target.value)} />
|
||||
<EuiFieldText prepend="Name" value={name} onChange={(e) => setName(e.target.value)} />
|
||||
<EuiButton
|
||||
onClick={() => {
|
||||
update({ ...user, name });
|
||||
|
|
|
@ -72,7 +72,7 @@ const ActionsExplorer = ({ uiActionsApi, openModal }: Props) => {
|
|||
from. Using the UI Action and Trigger API makes your plugin extensible by other
|
||||
plugins. Any actions attached to the `HELLO_WORLD_TRIGGER_ID` will show up here!
|
||||
</p>
|
||||
<EuiFieldText prepend="Name" value={name} onChange={e => setName(e.target.value)} />
|
||||
<EuiFieldText prepend="Name" value={name} onChange={(e) => setName(e.target.value)} />
|
||||
<EuiButton
|
||||
data-test-subj="addDynamicAction"
|
||||
onClick={() => {
|
||||
|
|
|
@ -105,7 +105,7 @@ export function TriggerContextExample({ uiActionsApi }: Props) {
|
|||
];
|
||||
|
||||
const updateUser = (newUser: User, oldName: string) => {
|
||||
const index = rows.findIndex(u => u.name === oldName);
|
||||
const index = rows.findIndex((u) => u.name === oldName);
|
||||
const newRows = [...rows];
|
||||
newRows.splice(index, 1, createRowData(newUser, uiActionsApi, updateUser));
|
||||
setRows(newRows);
|
||||
|
|
|
@ -67,7 +67,7 @@ export const Routes: React.FC<{}> = () => {
|
|||
|
||||
export const LinksExample: React.FC<{
|
||||
appBasePath: string;
|
||||
}> = props => {
|
||||
}> = (props) => {
|
||||
const history = React.useMemo(
|
||||
() =>
|
||||
createBrowserHistory({
|
||||
|
|
|
@ -38,7 +38,7 @@ export const createHelloPageLinkGenerator = (
|
|||
getStartServices: () => Promise<{ appBasePath: string }>
|
||||
): UrlGeneratorsDefinition<typeof HELLO_URL_GENERATOR> => ({
|
||||
id: HELLO_URL_GENERATOR,
|
||||
createUrl: async state => {
|
||||
createUrl: async (state) => {
|
||||
const startServices = await getStartServices();
|
||||
const appBasePath = startServices.appBasePath;
|
||||
const parsedUrl = url.parse(window.location.href);
|
||||
|
@ -72,7 +72,7 @@ export type LegacyHelloLinkGeneratorState = UrlGeneratorState<
|
|||
export const helloPageLinkGeneratorV1: UrlGeneratorsDefinition<typeof HELLO_URL_GENERATOR_V1> = {
|
||||
id: HELLO_URL_GENERATOR_V1,
|
||||
isDeprecated: true,
|
||||
migrate: async state => {
|
||||
migrate: async (state) => {
|
||||
return { id: HELLO_URL_GENERATOR, state: { firstName: state.name, lastName: '' } };
|
||||
},
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ const ActionsExplorer = ({ getLinkGenerator }: Props) => {
|
|||
|
||||
const updateLinks = async () => {
|
||||
const updatedLinks = await Promise.all(
|
||||
persistedLinks.map(async savedLink => {
|
||||
persistedLinks.map(async (savedLink) => {
|
||||
const generator = getLinkGenerator(savedLink.id);
|
||||
const link = await generator.createUrl(savedLink.state);
|
||||
return {
|
||||
|
@ -109,11 +109,11 @@ const ActionsExplorer = ({ getLinkGenerator }: Props) => {
|
|||
</EuiText>
|
||||
<EuiFieldText
|
||||
prepend="First name"
|
||||
onChange={e => {
|
||||
onChange={(e) => {
|
||||
setFirstName(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<EuiFieldText prepend="Last name" onChange={e => setLastName(e.target.value)} />
|
||||
<EuiFieldText prepend="Last name" onChange={(e) => setLastName(e.target.value)} />
|
||||
<EuiButton
|
||||
onClick={() =>
|
||||
setPersistedLinks([
|
||||
|
@ -142,7 +142,7 @@ const ActionsExplorer = ({ getLinkGenerator }: Props) => {
|
|||
{buildingLinks ? (
|
||||
<div>loading...</div>
|
||||
) : (
|
||||
migratedLinks.map(link => (
|
||||
migratedLinks.map((link) => (
|
||||
<React.Fragment>
|
||||
<EuiLink
|
||||
color={link.isDeprecated ? 'danger' : 'primary'}
|
||||
|
|
|
@ -36,7 +36,7 @@ function momentClone() {
|
|||
return require('moment');
|
||||
}
|
||||
|
||||
describe('dateMath', function() {
|
||||
describe('dateMath', function () {
|
||||
// Test each of these intervals when testing relative time
|
||||
const spans = ['s', 'm', 'h', 'd', 'w', 'M', 'y', 'ms'];
|
||||
const anchor = '2014-01-01T06:06:06.666Z';
|
||||
|
@ -45,53 +45,53 @@ describe('dateMath', function() {
|
|||
const format = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
|
||||
let clock;
|
||||
|
||||
describe('errors', function() {
|
||||
it('should return undefined if passed something falsy', function() {
|
||||
describe('errors', function () {
|
||||
it('should return undefined if passed something falsy', function () {
|
||||
expect(dateMath.parse()).to.be(undefined);
|
||||
});
|
||||
|
||||
it('should return undefined if I pass an operator besides [+-/]', function() {
|
||||
it('should return undefined if I pass an operator besides [+-/]', function () {
|
||||
expect(dateMath.parse('now&1d')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('should return undefined if I pass a unit besides' + spans.toString(), function() {
|
||||
it('should return undefined if I pass a unit besides' + spans.toString(), function () {
|
||||
expect(dateMath.parse('now+5f')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('should return undefined if rounding unit is not 1', function() {
|
||||
it('should return undefined if rounding unit is not 1', function () {
|
||||
expect(dateMath.parse('now/2y')).to.be(undefined);
|
||||
expect(dateMath.parse('now/0.5y')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('should not go into an infinite loop when missing a unit', function() {
|
||||
it('should not go into an infinite loop when missing a unit', function () {
|
||||
expect(dateMath.parse('now-0')).to.be(undefined);
|
||||
expect(dateMath.parse('now-00')).to.be(undefined);
|
||||
expect(dateMath.parse('now-000')).to.be(undefined);
|
||||
});
|
||||
|
||||
describe('forceNow', function() {
|
||||
it('should throw an Error if passed a string', function() {
|
||||
describe('forceNow', function () {
|
||||
it('should throw an Error if passed a string', function () {
|
||||
const fn = () => dateMath.parse('now', { forceNow: '2000-01-01T00:00:00.000Z' });
|
||||
expect(fn).to.throwError();
|
||||
});
|
||||
|
||||
it('should throw an Error if passed a moment', function() {
|
||||
it('should throw an Error if passed a moment', function () {
|
||||
expect(() => dateMath.parse('now', { forceNow: moment() })).to.throwError();
|
||||
});
|
||||
|
||||
it('should throw an Error if passed an invalid date', function() {
|
||||
it('should throw an Error if passed an invalid date', function () {
|
||||
expect(() => dateMath.parse('now', { forceNow: new Date('foobar') })).to.throwError();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('objects and strings', function() {
|
||||
describe('objects and strings', function () {
|
||||
let mmnt;
|
||||
let date;
|
||||
let string;
|
||||
let now;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
clock = sinon.useFakeTimers(unix);
|
||||
now = moment();
|
||||
mmnt = moment(anchor);
|
||||
|
@ -99,61 +99,61 @@ describe('dateMath', function() {
|
|||
string = mmnt.format(format);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
clock.restore();
|
||||
});
|
||||
|
||||
it('should return the same moment if passed a moment', function() {
|
||||
it('should return the same moment if passed a moment', function () {
|
||||
expect(dateMath.parse(mmnt)).to.eql(mmnt);
|
||||
});
|
||||
|
||||
it('should return a moment if passed a date', function() {
|
||||
it('should return a moment if passed a date', function () {
|
||||
expect(dateMath.parse(date).format(format)).to.eql(mmnt.format(format));
|
||||
});
|
||||
|
||||
it('should return a moment if passed an ISO8601 string', function() {
|
||||
it('should return a moment if passed an ISO8601 string', function () {
|
||||
expect(dateMath.parse(string).format(format)).to.eql(mmnt.format(format));
|
||||
});
|
||||
|
||||
it('should return the current time when parsing now', function() {
|
||||
it('should return the current time when parsing now', function () {
|
||||
expect(dateMath.parse('now').format(format)).to.eql(now.format(format));
|
||||
});
|
||||
|
||||
it('should use the forceNow parameter when parsing now', function() {
|
||||
it('should use the forceNow parameter when parsing now', function () {
|
||||
expect(dateMath.parse('now', { forceNow: anchoredDate }).valueOf()).to.eql(unix);
|
||||
});
|
||||
});
|
||||
|
||||
describe('subtraction', function() {
|
||||
describe('subtraction', function () {
|
||||
let now;
|
||||
let anchored;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
clock = sinon.useFakeTimers(unix);
|
||||
now = moment();
|
||||
anchored = moment(anchor);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
clock.restore();
|
||||
});
|
||||
|
||||
[5, 12, 247].forEach(len => {
|
||||
spans.forEach(span => {
|
||||
[5, 12, 247].forEach((len) => {
|
||||
spans.forEach((span) => {
|
||||
const nowEx = `now-${len}${span}`;
|
||||
const thenEx = `${anchor}||-${len}${span}`;
|
||||
|
||||
it('should return ' + len + span + ' ago', function() {
|
||||
it('should return ' + len + span + ' ago', function () {
|
||||
const parsed = dateMath.parse(nowEx).format(format);
|
||||
expect(parsed).to.eql(now.subtract(len, span).format(format));
|
||||
});
|
||||
|
||||
it('should return ' + len + span + ' before ' + anchor, function() {
|
||||
it('should return ' + len + span + ' before ' + anchor, function () {
|
||||
const parsed = dateMath.parse(thenEx).format(format);
|
||||
expect(parsed).to.eql(anchored.subtract(len, span).format(format));
|
||||
});
|
||||
|
||||
it('should return ' + len + span + ' before forceNow', function() {
|
||||
it('should return ' + len + span + ' before forceNow', function () {
|
||||
const parsed = dateMath.parse(nowEx, { forceNow: anchoredDate }).valueOf();
|
||||
expect(parsed).to.eql(anchored.subtract(len, span).valueOf());
|
||||
});
|
||||
|
@ -161,36 +161,36 @@ describe('dateMath', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('addition', function() {
|
||||
describe('addition', function () {
|
||||
let now;
|
||||
let anchored;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
clock = sinon.useFakeTimers(unix);
|
||||
now = moment();
|
||||
anchored = moment(anchor);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
clock.restore();
|
||||
});
|
||||
|
||||
[5, 12, 247].forEach(len => {
|
||||
spans.forEach(span => {
|
||||
[5, 12, 247].forEach((len) => {
|
||||
spans.forEach((span) => {
|
||||
const nowEx = `now+${len}${span}`;
|
||||
const thenEx = `${anchor}||+${len}${span}`;
|
||||
|
||||
it('should return ' + len + span + ' from now', function() {
|
||||
it('should return ' + len + span + ' from now', function () {
|
||||
expect(dateMath.parse(nowEx).format(format)).to.eql(now.add(len, span).format(format));
|
||||
});
|
||||
|
||||
it('should return ' + len + span + ' after ' + anchor, function() {
|
||||
it('should return ' + len + span + ' after ' + anchor, function () {
|
||||
expect(dateMath.parse(thenEx).format(format)).to.eql(
|
||||
anchored.add(len, span).format(format)
|
||||
);
|
||||
});
|
||||
|
||||
it('should return ' + len + span + ' after forceNow', function() {
|
||||
it('should return ' + len + span + ' after forceNow', function () {
|
||||
expect(dateMath.parse(nowEx, { forceNow: anchoredDate }).valueOf()).to.eql(
|
||||
anchored.add(len, span).valueOf()
|
||||
);
|
||||
|
@ -199,40 +199,40 @@ describe('dateMath', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('rounding', function() {
|
||||
describe('rounding', function () {
|
||||
let now;
|
||||
let anchored;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
clock = sinon.useFakeTimers(unix);
|
||||
now = moment();
|
||||
anchored = moment(anchor);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
clock.restore();
|
||||
});
|
||||
|
||||
spans.forEach(span => {
|
||||
it(`should round now to the beginning of the ${span}`, function() {
|
||||
spans.forEach((span) => {
|
||||
it(`should round now to the beginning of the ${span}`, function () {
|
||||
expect(dateMath.parse('now/' + span).format(format)).to.eql(
|
||||
now.startOf(span).format(format)
|
||||
);
|
||||
});
|
||||
|
||||
it(`should round now to the beginning of forceNow's ${span}`, function() {
|
||||
it(`should round now to the beginning of forceNow's ${span}`, function () {
|
||||
expect(dateMath.parse('now/' + span, { forceNow: anchoredDate }).valueOf()).to.eql(
|
||||
anchored.startOf(span).valueOf()
|
||||
);
|
||||
});
|
||||
|
||||
it(`should round now to the end of the ${span}`, function() {
|
||||
it(`should round now to the end of the ${span}`, function () {
|
||||
expect(dateMath.parse('now/' + span, { roundUp: true }).format(format)).to.eql(
|
||||
now.endOf(span).format(format)
|
||||
);
|
||||
});
|
||||
|
||||
it(`should round now to the end of forceNow's ${span}`, function() {
|
||||
it(`should round now to the end of forceNow's ${span}`, function () {
|
||||
expect(
|
||||
dateMath.parse('now/' + span, { roundUp: true, forceNow: anchoredDate }).valueOf()
|
||||
).to.eql(anchored.endOf(span).valueOf());
|
||||
|
@ -240,61 +240,46 @@ describe('dateMath', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('math and rounding', function() {
|
||||
describe('math and rounding', function () {
|
||||
let now;
|
||||
let anchored;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
clock = sinon.useFakeTimers(unix);
|
||||
now = moment();
|
||||
anchored = moment(anchor);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
clock.restore();
|
||||
});
|
||||
|
||||
it('should round to the nearest second with 0 value', function() {
|
||||
it('should round to the nearest second with 0 value', function () {
|
||||
const val = dateMath.parse('now-0s/s').format(format);
|
||||
expect(val).to.eql(now.startOf('s').format(format));
|
||||
});
|
||||
|
||||
it('should subtract 17s, rounded to the nearest second', function() {
|
||||
it('should subtract 17s, rounded to the nearest second', function () {
|
||||
const val = dateMath.parse('now-17s/s').format(format);
|
||||
expect(val).to.eql(
|
||||
now
|
||||
.startOf('s')
|
||||
.subtract(17, 's')
|
||||
.format(format)
|
||||
);
|
||||
expect(val).to.eql(now.startOf('s').subtract(17, 's').format(format));
|
||||
});
|
||||
|
||||
it('should add 555ms, rounded to the nearest millisecond', function() {
|
||||
it('should add 555ms, rounded to the nearest millisecond', function () {
|
||||
const val = dateMath.parse('now+555ms/ms').format(format);
|
||||
expect(val).to.eql(
|
||||
now
|
||||
.add(555, 'ms')
|
||||
.startOf('ms')
|
||||
.format(format)
|
||||
);
|
||||
expect(val).to.eql(now.add(555, 'ms').startOf('ms').format(format));
|
||||
});
|
||||
|
||||
it('should subtract 555ms, rounded to the nearest second', function() {
|
||||
it('should subtract 555ms, rounded to the nearest second', function () {
|
||||
const val = dateMath.parse('now-555ms/s').format(format);
|
||||
expect(val).to.eql(
|
||||
now
|
||||
.subtract(555, 'ms')
|
||||
.startOf('s')
|
||||
.format(format)
|
||||
);
|
||||
expect(val).to.eql(now.subtract(555, 'ms').startOf('s').format(format));
|
||||
});
|
||||
|
||||
it('should round weeks to Sunday by default', function() {
|
||||
it('should round weeks to Sunday by default', function () {
|
||||
const val = dateMath.parse('now-1w/w');
|
||||
expect(val.isoWeekday()).to.eql(7);
|
||||
});
|
||||
|
||||
it('should round weeks based on the passed moment locale start of week setting', function() {
|
||||
it('should round weeks based on the passed moment locale start of week setting', function () {
|
||||
const m = momentClone();
|
||||
// Define a locale, that has Tuesday as beginning of the week
|
||||
m.defineLocale('x-test', {
|
||||
|
@ -304,7 +289,7 @@ describe('dateMath', function() {
|
|||
expect(val.isoWeekday()).to.eql(2);
|
||||
});
|
||||
|
||||
it('should round up weeks based on the passed moment locale start of week setting', function() {
|
||||
it('should round up weeks based on the passed moment locale start of week setting', function () {
|
||||
const m = momentClone();
|
||||
// Define a locale, that has Tuesday as beginning of the week
|
||||
m.defineLocale('x-test', {
|
||||
|
@ -319,7 +304,7 @@ describe('dateMath', function() {
|
|||
expect(val.isoWeekday()).to.eql(3 - 1);
|
||||
});
|
||||
|
||||
it('should round relative to forceNow', function() {
|
||||
it('should round relative to forceNow', function () {
|
||||
const val = dateMath.parse('now-0s/s', { forceNow: anchoredDate }).valueOf();
|
||||
expect(val).to.eql(anchored.startOf('s').valueOf());
|
||||
});
|
||||
|
@ -329,15 +314,15 @@ describe('dateMath', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('used momentjs instance', function() {
|
||||
it('should use the default moment instance if parameter not specified', function() {
|
||||
describe('used momentjs instance', function () {
|
||||
it('should use the default moment instance if parameter not specified', function () {
|
||||
const momentSpy = sinon.spy(moment, 'isMoment');
|
||||
dateMath.parse('now');
|
||||
expect(momentSpy.called).to.be(true);
|
||||
momentSpy.restore();
|
||||
});
|
||||
|
||||
it('should not use default moment instance if parameter is specified', function() {
|
||||
it('should not use default moment instance if parameter is specified', function () {
|
||||
const m = momentClone();
|
||||
const momentSpy = sinon.spy(moment, 'isMoment');
|
||||
const cloneSpy = sinon.spy(m, 'isMoment');
|
||||
|
@ -348,7 +333,7 @@ describe('dateMath', function() {
|
|||
cloneSpy.restore();
|
||||
});
|
||||
|
||||
it('should work with multiple different instances', function() {
|
||||
it('should work with multiple different instances', function () {
|
||||
const m1 = momentClone();
|
||||
const m2 = momentClone();
|
||||
const m1Spy = sinon.spy(m1, 'isMoment');
|
||||
|
@ -365,7 +350,7 @@ describe('dateMath', function() {
|
|||
m2Spy.restore();
|
||||
});
|
||||
|
||||
it('should use global instance after passing an instance', function() {
|
||||
it('should use global instance after passing an instance', function () {
|
||||
const m = momentClone();
|
||||
const momentSpy = sinon.spy(moment, 'isMoment');
|
||||
const cloneSpy = sinon.spy(m, 'isMoment');
|
||||
|
@ -382,12 +367,12 @@ describe('dateMath', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('units', function() {
|
||||
it('should have units descending for unitsDesc', function() {
|
||||
describe('units', function () {
|
||||
it('should have units descending for unitsDesc', function () {
|
||||
expect(dateMath.unitsDesc).to.eql(['y', 'M', 'w', 'd', 'h', 'm', 's', 'ms']);
|
||||
});
|
||||
|
||||
it('should have units ascending for unitsAsc', function() {
|
||||
it('should have units ascending for unitsAsc', function () {
|
||||
expect(dateMath.unitsAsc).to.eql(['ms', 's', 'm', 'h', 'd', 'w', 'M', 'y']);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,9 +34,9 @@ const units = Object.keys(unitsMap).sort((a, b) => unitsMap[b].weight - unitsMap
|
|||
const unitsDesc = [...units];
|
||||
const unitsAsc = [...units].reverse();
|
||||
|
||||
const isDate = d => Object.prototype.toString.call(d) === '[object Date]';
|
||||
const isDate = (d) => Object.prototype.toString.call(d) === '[object Date]';
|
||||
|
||||
const isValidDate = d => isDate(d) && !isNaN(d.valueOf());
|
||||
const isValidDate = (d) => isDate(d) && !isNaN(d.valueOf());
|
||||
|
||||
/*
|
||||
* This is a simplified version of elasticsearch's date parser.
|
||||
|
|
|
@ -31,7 +31,7 @@ const padRight = (width, str) =>
|
|||
|
||||
run(
|
||||
async ({ log, flags }) => {
|
||||
await withProcRunner(log, async proc => {
|
||||
await withProcRunner(log, async (proc) => {
|
||||
log.info('Deleting old output');
|
||||
await del(BUILD_DIR);
|
||||
|
||||
|
@ -43,7 +43,7 @@ run(
|
|||
|
||||
log.info(`Starting babel and typescript${flags.watch ? ' in watch mode' : ''}`);
|
||||
await Promise.all([
|
||||
...['web', 'node'].map(subTask =>
|
||||
...['web', 'node'].map((subTask) =>
|
||||
proc.run(padRight(10, `babel:${subTask}`), {
|
||||
cmd: 'babel',
|
||||
args: [
|
||||
|
|
|
@ -86,7 +86,7 @@ export class ReportManager {
|
|||
};
|
||||
}
|
||||
assignReports(newMetrics: Metric | Metric[]) {
|
||||
wrapArray(newMetrics).forEach(newMetric => this.assignReport(this.report, newMetric));
|
||||
wrapArray(newMetrics).forEach((newMetric) => this.assignReport(this.report, newMetric));
|
||||
return { report: this.report };
|
||||
}
|
||||
static createMetricKey(metric: Metric): string {
|
||||
|
|
|
@ -115,7 +115,7 @@ export class Reporter {
|
|||
eventNames: string | string[],
|
||||
count?: number
|
||||
) => {
|
||||
const metrics = wrapArray(eventNames).map(eventName => {
|
||||
const metrics = wrapArray(eventNames).map((eventName) => {
|
||||
this.log(`${type} Metric -> (${appName}:${eventName}):`);
|
||||
const report = createUiStatsMetric({ type, appName, eventName, count });
|
||||
this.log(report);
|
||||
|
|
|
@ -79,7 +79,7 @@ export async function parseEntries(cwd, entries, strategy, results, wasParsed =
|
|||
const sanitizedCwd = cwd || process.cwd();
|
||||
|
||||
// Test each entry against canRequire function
|
||||
const entriesQueue = entries.map(entry => canRequire(entry));
|
||||
const entriesQueue = entries.map((entry) => canRequire(entry));
|
||||
|
||||
while (entriesQueue.length) {
|
||||
// Get the first element in the queue as
|
||||
|
|
|
@ -59,7 +59,7 @@ export async function dependenciesParseStrategy(
|
|||
// Get dependencies from a single file and filter
|
||||
// out node native modules from the result
|
||||
const dependencies = (await parseSingleFile(mainEntry, dependenciesVisitorsGenerator)).filter(
|
||||
dep => !builtinModules.includes(dep)
|
||||
(dep) => !builtinModules.includes(dep)
|
||||
);
|
||||
|
||||
// Return the list of all the new entries found into
|
||||
|
|
|
@ -84,7 +84,7 @@ describe('Code Parser Strategies', () => {
|
|||
cb(null, `require('./relative_dep')`);
|
||||
});
|
||||
|
||||
canRequire.mockImplementation(entry => {
|
||||
canRequire.mockImplementation((entry) => {
|
||||
if (entry === `${mockCwd}dep1/relative_dep`) {
|
||||
return `${entry}/index.js`;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
|
|||
// raw values on require + require.resolve
|
||||
CallExpression: ({ node }) => {
|
||||
// AST check for require expressions
|
||||
const isRequire = node => {
|
||||
const isRequire = (node) => {
|
||||
return matches({
|
||||
callee: {
|
||||
type: 'Identifier',
|
||||
|
@ -31,7 +31,7 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
|
|||
};
|
||||
|
||||
// AST check for require.resolve expressions
|
||||
const isRequireResolve = node => {
|
||||
const isRequireResolve = (node) => {
|
||||
return matches({
|
||||
callee: {
|
||||
type: 'MemberExpression',
|
||||
|
@ -66,7 +66,7 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
|
|||
// raw values on import
|
||||
ImportDeclaration: ({ node }) => {
|
||||
// AST check for supported import expressions
|
||||
const isImport = node => {
|
||||
const isImport = (node) => {
|
||||
return matches({
|
||||
type: 'ImportDeclaration',
|
||||
source: {
|
||||
|
@ -85,7 +85,7 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
|
|||
// raw values on export from
|
||||
ExportNamedDeclaration: ({ node }) => {
|
||||
// AST check for supported export from expressions
|
||||
const isExportFrom = node => {
|
||||
const isExportFrom = (node) => {
|
||||
return matches({
|
||||
type: 'ExportNamedDeclaration',
|
||||
source: {
|
||||
|
@ -104,7 +104,7 @@ export function dependenciesVisitorsGenerator(dependenciesAcc) {
|
|||
// raw values on export * from
|
||||
ExportAllDeclaration: ({ node }) => {
|
||||
// AST check for supported export * from expressions
|
||||
const isExportAllFrom = node => {
|
||||
const isExportAllFrom = (node) => {
|
||||
return matches({
|
||||
type: 'ExportAllDeclaration',
|
||||
source: {
|
||||
|
|
|
@ -21,7 +21,7 @@ import * as parser from '@babel/parser';
|
|||
import traverse from '@babel/traverse';
|
||||
import { dependenciesVisitorsGenerator } from './visitors';
|
||||
|
||||
const visitorsApplier = code => {
|
||||
const visitorsApplier = (code) => {
|
||||
const result = [];
|
||||
traverse(
|
||||
parser.parse(code, {
|
||||
|
|
|
@ -26,8 +26,8 @@ import { SchemaError } from '.';
|
|||
export const cleanStack = (stack: string) =>
|
||||
stack
|
||||
.split('\n')
|
||||
.filter(line => !line.includes('node_modules/') && !line.includes('internal/'))
|
||||
.map(line => {
|
||||
.filter((line) => !line.includes('node_modules/') && !line.includes('internal/'))
|
||||
.map((line) => {
|
||||
const parts = /.*\((.*)\).?/.exec(line) || [];
|
||||
|
||||
if (parts.length === 0) {
|
||||
|
|
|
@ -26,12 +26,12 @@ export class ValidationError extends SchemaError {
|
|||
let message = error.message;
|
||||
if (error instanceof SchemaTypesError) {
|
||||
const indentLevel = level || 0;
|
||||
const childErrorMessages = error.errors.map(childError =>
|
||||
const childErrorMessages = error.errors.map((childError) =>
|
||||
ValidationError.extractMessage(childError, namespace, indentLevel + 1)
|
||||
);
|
||||
|
||||
message = `${message}\n${childErrorMessages
|
||||
.map(childErrorMessage => `${' '.repeat(indentLevel)}- ${childErrorMessage}`)
|
||||
.map((childErrorMessage) => `${' '.repeat(indentLevel)}- ${childErrorMessage}`)
|
||||
.join('\n')}`;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,9 +42,7 @@ function isMap<K, V>(o: any): o is Map<K, V> {
|
|||
const anyCustomRule: Rules = {
|
||||
name: 'custom',
|
||||
params: {
|
||||
validator: Joi.func()
|
||||
.maxArity(1)
|
||||
.required(),
|
||||
validator: Joi.func().maxArity(1).required(),
|
||||
},
|
||||
validate(params, value, state, options) {
|
||||
let validationResultMessage;
|
||||
|
|
|
@ -47,7 +47,7 @@ describe('isConfigSchema', () => {
|
|||
expect(isConfigSchema(undefined)).toBe(false);
|
||||
expect(isConfigSchema([1, 2, 3])).toBe(false);
|
||||
expect(isConfigSchema({ foo: 'bar' })).toBe(false);
|
||||
expect(isConfigSchema(function() {})).toBe(false);
|
||||
expect(isConfigSchema(function () {})).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true as long as `__isKbnConfigSchemaType` is true', () => {
|
||||
|
|
|
@ -28,10 +28,7 @@ export type ArrayOptions<T> = TypeOptions<T[]> & {
|
|||
|
||||
export class ArrayType<T> extends Type<T[]> {
|
||||
constructor(type: Type<T>, options: ArrayOptions<T> = {}) {
|
||||
let schema = internals
|
||||
.array()
|
||||
.items(type.getSchema().optional())
|
||||
.sparse(false);
|
||||
let schema = internals.array().items(type.getSchema().optional()).sparse(false);
|
||||
|
||||
if (options.minSize !== undefined) {
|
||||
schema = schema.min(options.minSize);
|
||||
|
|
|
@ -36,14 +36,14 @@ export class StringType extends Type<string> {
|
|||
let schema =
|
||||
options.hostname === true
|
||||
? internals.string().hostname()
|
||||
: internals.any().custom(value => {
|
||||
: internals.any().custom((value) => {
|
||||
if (typeof value !== 'string') {
|
||||
return `expected value of type [string] but got [${typeDetect(value)}]`;
|
||||
}
|
||||
});
|
||||
|
||||
if (options.minLength !== undefined) {
|
||||
schema = schema.custom(value => {
|
||||
schema = schema.custom((value) => {
|
||||
if (value.length < options.minLength!) {
|
||||
return `value has length [${value.length}] but it must have a minimum length of [${options.minLength}].`;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export class StringType extends Type<string> {
|
|||
}
|
||||
|
||||
if (options.maxLength !== undefined) {
|
||||
schema = schema.custom(value => {
|
||||
schema = schema.custom((value) => {
|
||||
if (value.length > options.maxLength!) {
|
||||
return `value has length [${value.length}] but it must have a maximum length of [${options.maxLength}].`;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import { Type, TypeOptions } from './type';
|
|||
|
||||
export class UnionType<RTS extends Array<Type<any>>, T> extends Type<T> {
|
||||
constructor(types: RTS, options?: TypeOptions<T>) {
|
||||
const schema = internals.alternatives(types.map(type => type.getSchema()));
|
||||
const schema = internals.alternatives(types.map((type) => type.getSchema()));
|
||||
|
||||
super(schema, options);
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ export class CiStatsReporter {
|
|||
`failed to reach kibana-ci-stats service [reason=${reason}], retrying in ${attempt} seconds`
|
||||
);
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, attempt * 1000));
|
||||
await new Promise((resolve) => setTimeout(resolve, attempt * 1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ export interface ReqOptions {
|
|||
}
|
||||
|
||||
const delay = (ms: number) =>
|
||||
new Promise(resolve => {
|
||||
new Promise((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ export function observeReadable(readable: Readable): Rx.Observable<never> {
|
|||
|
||||
Rx.fromEvent(readable, 'error').pipe(
|
||||
first(),
|
||||
mergeMap(err => Rx.throwError(err))
|
||||
mergeMap((err) => Rx.throwError(err))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ export function startProc(name: string, options: ProcOptions, log: ToolingLog) {
|
|||
// observe first error event
|
||||
Rx.fromEvent(childProcess, 'error').pipe(
|
||||
take(1),
|
||||
mergeMap(err => Rx.throwError(err))
|
||||
mergeMap((err) => Rx.throwError(err))
|
||||
)
|
||||
).pipe(share());
|
||||
|
||||
|
@ -126,7 +126,7 @@ export function startProc(name: string, options: ProcOptions, log: ToolingLog) {
|
|||
observeLines(childProcess.stdout),
|
||||
observeLines(childProcess.stderr)
|
||||
).pipe(
|
||||
tap(line => log.write(` ${chalk.gray('proc')} [${chalk.gray(name)}] ${line}`)),
|
||||
tap((line) => log.write(` ${chalk.gray('proc')} [${chalk.gray(name)}] ${line}`)),
|
||||
share()
|
||||
);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ export class ProcRunner {
|
|||
|
||||
constructor(private log: ToolingLog) {
|
||||
this.signalUnsubscribe = exitHook(() => {
|
||||
this.teardown().catch(error => {
|
||||
this.teardown().catch((error) => {
|
||||
log.error(`ProcRunner teardown error: ${error.stack}`);
|
||||
});
|
||||
});
|
||||
|
@ -105,9 +105,9 @@ export class ProcRunner {
|
|||
// wait for process to log matching line
|
||||
await Rx.race(
|
||||
proc.lines$.pipe(
|
||||
filter(line => wait.test(line)),
|
||||
filter((line) => wait.test(line)),
|
||||
first(),
|
||||
catchError(err => {
|
||||
catchError((err) => {
|
||||
if (err.name !== 'EmptyError') {
|
||||
throw createCliError(`[${name}] exited without matching pattern: ${wait}`);
|
||||
} else {
|
||||
|
@ -159,7 +159,7 @@ export class ProcRunner {
|
|||
* @return {Promise<undefined>}
|
||||
*/
|
||||
async waitForAllToStop() {
|
||||
await Promise.all(this.procs.map(proc => proc.outcomePromise));
|
||||
await Promise.all(this.procs.map((proc) => proc.outcomePromise));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,19 +181,19 @@ export class ProcRunner {
|
|||
this.log.warning(
|
||||
'%d processes left running, stop them with procs.stop(name):',
|
||||
this.procs.length,
|
||||
this.procs.map(proc => proc.name)
|
||||
this.procs.map((proc) => proc.name)
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
this.procs.map(async proc => {
|
||||
this.procs.map(async (proc) => {
|
||||
await proc.stop(signal === 'exit' ? 'SIGKILL' : signal);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private getProc(name: string) {
|
||||
return this.procs.find(proc => {
|
||||
return this.procs.find((proc) => {
|
||||
return proc.name === name;
|
||||
});
|
||||
}
|
||||
|
@ -209,14 +209,14 @@ export class ProcRunner {
|
|||
|
||||
// tie into proc outcome$, remove from _procs on compete
|
||||
proc.outcome$.subscribe({
|
||||
next: code => {
|
||||
next: (code) => {
|
||||
const duration = moment.duration(Date.now() - startMs);
|
||||
this.log.info('[%s] exited with %s after %s', name, code, duration.humanize());
|
||||
},
|
||||
complete: () => {
|
||||
remove();
|
||||
},
|
||||
error: error => {
|
||||
error: (error) => {
|
||||
if (this.closing) {
|
||||
this.log.error(error);
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@ import { withProcRunner } from './with_proc_runner';
|
|||
import { ProcRunner } from './proc_runner';
|
||||
|
||||
it('passes proc runner to a function', async () => {
|
||||
await withProcRunner(new ToolingLog(), async proc => {
|
||||
await withProcRunner(new ToolingLog(), async (proc) => {
|
||||
expect(proc).toBeInstanceOf(ProcRunner);
|
||||
});
|
||||
});
|
||||
|
||||
it('calls procRunner.teardown() if function returns synchronously', async () => {
|
||||
let teardownSpy;
|
||||
await withProcRunner(new ToolingLog(), async proc => {
|
||||
await withProcRunner(new ToolingLog(), async (proc) => {
|
||||
teardownSpy = jest.spyOn(proc, 'teardown');
|
||||
});
|
||||
|
||||
|
@ -41,7 +41,7 @@ it('calls procRunner.teardown() if function throw synchronous error, and rejects
|
|||
let teardownSpy;
|
||||
|
||||
await expect(
|
||||
withProcRunner(new ToolingLog(), async proc => {
|
||||
withProcRunner(new ToolingLog(), async (proc) => {
|
||||
teardownSpy = jest.spyOn(proc, 'teardown');
|
||||
throw error;
|
||||
})
|
||||
|
@ -53,8 +53,8 @@ it('calls procRunner.teardown() if function throw synchronous error, and rejects
|
|||
it('waits for promise to resolve before tearing down proc', async () => {
|
||||
let teardownSpy;
|
||||
|
||||
await withProcRunner(new ToolingLog(), async proc => {
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
await withProcRunner(new ToolingLog(), async (proc) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
teardownSpy = jest.spyOn(proc, 'teardown');
|
||||
});
|
||||
|
||||
|
@ -67,8 +67,8 @@ it('waits for promise to reject before tearing down proc and rejecting with the
|
|||
let teardownSpy;
|
||||
|
||||
await expect(
|
||||
withProcRunner(new ToolingLog(), async proc => {
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
withProcRunner(new ToolingLog(), async (proc) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
teardownSpy = jest.spyOn(proc, 'teardown');
|
||||
throw error;
|
||||
})
|
||||
|
|
|
@ -61,7 +61,7 @@ export function combineErrors(errors: Array<Error | FailError>) {
|
|||
.filter(isFailError)
|
||||
.reduce((acc, error) => Math.max(acc, error.exitCode), 1);
|
||||
|
||||
const showHelp = errors.some(error => isFailError(error) && error.showHelp);
|
||||
const showHelp = errors.some((error) => isFailError(error) && error.showHelp);
|
||||
|
||||
const message = errors.reduce((acc, error) => {
|
||||
if (isFailError(error)) {
|
||||
|
|
|
@ -62,7 +62,7 @@ export async function run(fn: RunFn, options: Options = {}) {
|
|||
writeTo: process.stdout,
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', error => {
|
||||
process.on('unhandledRejection', (error) => {
|
||||
log.error('UNHANDLED PROMISE REJECTION');
|
||||
log.error(
|
||||
error instanceof Error
|
||||
|
@ -110,7 +110,7 @@ export async function run(fn: RunFn, options: Options = {}) {
|
|||
}
|
||||
|
||||
try {
|
||||
await withProcRunner(log, async procRunner => {
|
||||
await withProcRunner(log, async (procRunner) => {
|
||||
await fn({
|
||||
log,
|
||||
flags,
|
||||
|
|
|
@ -80,29 +80,31 @@ describe('#indent()', () => {
|
|||
});
|
||||
});
|
||||
|
||||
(['verbose', 'debug', 'info', 'success', 'warning', 'error', 'write'] as const).forEach(method => {
|
||||
describe(`#${method}()`, () => {
|
||||
it(`sends a msg of type "${method}" to each writer with indent and arguments`, () => {
|
||||
const log = new ToolingLog();
|
||||
const writeA = jest.fn();
|
||||
const writeB = jest.fn();
|
||||
(['verbose', 'debug', 'info', 'success', 'warning', 'error', 'write'] as const).forEach(
|
||||
(method) => {
|
||||
describe(`#${method}()`, () => {
|
||||
it(`sends a msg of type "${method}" to each writer with indent and arguments`, () => {
|
||||
const log = new ToolingLog();
|
||||
const writeA = jest.fn();
|
||||
const writeB = jest.fn();
|
||||
|
||||
log.setWriters([{ write: writeA }, { write: writeB }]);
|
||||
log.setWriters([{ write: writeA }, { write: writeB }]);
|
||||
|
||||
if (method === 'error') {
|
||||
const error = new Error('error message');
|
||||
error.stack = '... stack trace ...';
|
||||
log.error(error);
|
||||
log.error('string message');
|
||||
} else {
|
||||
log[method]('foo', 'bar', 'baz');
|
||||
}
|
||||
if (method === 'error') {
|
||||
const error = new Error('error message');
|
||||
error.stack = '... stack trace ...';
|
||||
log.error(error);
|
||||
log.error('string message');
|
||||
} else {
|
||||
log[method]('foo', 'bar', 'baz');
|
||||
}
|
||||
|
||||
expect(writeA.mock.calls).toMatchSnapshot();
|
||||
expect(writeA.mock.calls).toEqual(writeB.mock.calls);
|
||||
expect(writeA.mock.calls).toMatchSnapshot();
|
||||
expect(writeA.mock.calls).toEqual(writeB.mock.calls);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
describe('#getWritten$()', () => {
|
||||
async function testWrittenMsgs(writers: Writer[]) {
|
||||
|
@ -110,10 +112,7 @@ describe('#getWritten$()', () => {
|
|||
log.setWriters(writers);
|
||||
|
||||
const done$ = new Rx.Subject();
|
||||
const promise = log
|
||||
.getWritten$()
|
||||
.pipe(takeUntil(done$), toArray())
|
||||
.toPromise();
|
||||
const promise = log.getWritten$().pipe(takeUntil(done$), toArray()).toPromise();
|
||||
|
||||
log.debug('foo');
|
||||
log.info('bar');
|
||||
|
|
|
@ -26,7 +26,7 @@ export class ToolingLogCollectingWriter extends ToolingLogTextWriter {
|
|||
super({
|
||||
level: 'verbose',
|
||||
writeTo: {
|
||||
write: msg => {
|
||||
write: (msg) => {
|
||||
// trim trailing new line
|
||||
this.messages.push(msg.slice(0, -1));
|
||||
},
|
||||
|
|
|
@ -60,7 +60,7 @@ async function retry(log, fn) {
|
|||
}
|
||||
|
||||
log.warning('...failure, retrying in 5 seconds:', error.message);
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
log.info('...retrying');
|
||||
return await doAttempt(attempt + 1);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ async function getArtifactSpecForSnapshot(urlVersion, license, log) {
|
|||
const arch = process.arch === 'arm64' ? 'aarch64' : 'x86_64';
|
||||
|
||||
const archive = manifest.archives.find(
|
||||
archive =>
|
||||
(archive) =>
|
||||
archive.version === desiredVersion &&
|
||||
archive.platform === platform &&
|
||||
archive.license === desiredLicense &&
|
||||
|
|
|
@ -52,14 +52,14 @@ const createArchive = (params = {}) => {
|
|||
};
|
||||
};
|
||||
|
||||
const mockFetch = mock =>
|
||||
const mockFetch = (mock) =>
|
||||
fetch.mockReturnValue(Promise.resolve(new Response(JSON.stringify(mock))));
|
||||
|
||||
const previousEnvVars = {};
|
||||
const ENV_VARS_TO_RESET = ['ES_SNAPSHOT_MANIFEST', 'KBN_ES_SNAPSHOT_USE_UNVERIFIED'];
|
||||
|
||||
beforeAll(() => {
|
||||
ENV_VARS_TO_RESET.forEach(key => {
|
||||
ENV_VARS_TO_RESET.forEach((key) => {
|
||||
if (key in process.env) {
|
||||
previousEnvVars[key] = process.env[key];
|
||||
delete process.env[key];
|
||||
|
@ -68,7 +68,7 @@ beforeAll(() => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
Object.keys(previousEnvVars).forEach(key => {
|
||||
Object.keys(previousEnvVars).forEach((key) => {
|
||||
process.env[key] = previousEnvVars[key];
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ const { log } = require('./utils');
|
|||
|
||||
function help() {
|
||||
const availableCommands = Object.keys(commands).map(
|
||||
name => `${name} - ${commands[name].description}`
|
||||
(name) => `${name} - ${commands[name].description}`
|
||||
);
|
||||
|
||||
console.log(dedent`
|
||||
|
|
|
@ -40,8 +40,8 @@ const readFile = util.promisify(fs.readFile);
|
|||
|
||||
// listen to data on stream until map returns anything but undefined
|
||||
const first = (stream, map) =>
|
||||
new Promise(resolve => {
|
||||
const onData = data => {
|
||||
new Promise((resolve) => {
|
||||
const onData = (data) => {
|
||||
const result = map(data);
|
||||
if (result !== undefined) {
|
||||
resolve(result);
|
||||
|
@ -180,7 +180,7 @@ exports.Cluster = class Cluster {
|
|||
await Promise.race([
|
||||
// wait for native realm to be setup and es to be started
|
||||
Promise.all([
|
||||
first(this._process.stdout, data => {
|
||||
first(this._process.stdout, (data) => {
|
||||
if (/started/.test(data)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ exports.Cluster = class Cluster {
|
|||
this._exec(installPath, options);
|
||||
|
||||
// log native realm setup errors so they aren't uncaught
|
||||
this._nativeRealmSetup.catch(error => {
|
||||
this._nativeRealmSetup.catch((error) => {
|
||||
this._log.error(error);
|
||||
this.stop();
|
||||
});
|
||||
|
@ -287,7 +287,7 @@ exports.Cluster = class Cluster {
|
|||
});
|
||||
|
||||
// parse log output to find http port
|
||||
const httpPort = first(this._process.stdout, data => {
|
||||
const httpPort = first(this._process.stdout, (data) => {
|
||||
const match = data.toString('utf8').match(/HttpServer.+publish_address {[0-9.]+:([0-9]+)/);
|
||||
|
||||
if (match) {
|
||||
|
@ -296,7 +296,7 @@ exports.Cluster = class Cluster {
|
|||
});
|
||||
|
||||
// once the http port is available setup the native realm
|
||||
this._nativeRealmSetup = httpPort.then(async port => {
|
||||
this._nativeRealmSetup = httpPort.then(async (port) => {
|
||||
const caCert = await this._caCertPromise;
|
||||
const nativeRealm = new NativeRealm({
|
||||
port,
|
||||
|
@ -309,19 +309,19 @@ exports.Cluster = class Cluster {
|
|||
});
|
||||
|
||||
// parse and forward es stdout to the log
|
||||
this._process.stdout.on('data', data => {
|
||||
this._process.stdout.on('data', (data) => {
|
||||
const lines = parseEsLog(data.toString());
|
||||
lines.forEach(line => {
|
||||
lines.forEach((line) => {
|
||||
this._log.info(line.formattedMessage);
|
||||
});
|
||||
});
|
||||
|
||||
// forward es stderr to the log
|
||||
this._process.stderr.on('data', data => this._log.error(chalk.red(data.toString())));
|
||||
this._process.stderr.on('data', (data) => this._log.error(chalk.red(data.toString())));
|
||||
|
||||
// observe the exit code of the process and reflect in _outcome promies
|
||||
const exitCode = new Promise(resolve => this._process.once('exit', resolve));
|
||||
this._outcome = exitCode.then(code => {
|
||||
const exitCode = new Promise((resolve) => this._process.once('exit', resolve));
|
||||
this._outcome = exitCode.then((code) => {
|
||||
if (this._stopCalled) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
exports.createCliError = function(message) {
|
||||
exports.createCliError = function (message) {
|
||||
const error = new Error(message);
|
||||
error.isCliError = true;
|
||||
return error;
|
||||
};
|
||||
|
||||
exports.isCliError = function(error) {
|
||||
exports.isCliError = function (error) {
|
||||
return error && error.isCliError;
|
||||
};
|
||||
|
|
|
@ -99,15 +99,11 @@ async function sourceInfo(cwd, license, log = defaultLog) {
|
|||
etag.update(sha);
|
||||
|
||||
// for changed files, use last modified times in hash calculation
|
||||
status.files.forEach(file => {
|
||||
status.files.forEach((file) => {
|
||||
etag.update(fs.statSync(path.join(cwd, file.path)).mtime.toString());
|
||||
});
|
||||
|
||||
const cwdHash = crypto
|
||||
.createHash('md5')
|
||||
.update(cwd)
|
||||
.digest('hex')
|
||||
.substr(0, 8);
|
||||
const cwdHash = crypto.createHash('md5').update(cwd).digest('hex').substr(0, 8);
|
||||
|
||||
const basename = `${branch}-${task}-${cwdHash}`;
|
||||
const filename = `${basename}.${ext}`;
|
||||
|
|
|
@ -71,7 +71,7 @@ const delayServerClose = () => {
|
|||
server.on('request', delayServerClose);
|
||||
server.on('listening', delayServerClose);
|
||||
|
||||
server.listen(0, '127.0.0.1', function() {
|
||||
server.listen(0, '127.0.0.1', function () {
|
||||
const { port, address: hostname } = server.address();
|
||||
serverUrl = new URL(
|
||||
formatUrl({
|
||||
|
|
|
@ -37,7 +37,7 @@ jest.mock('../utils/extract_config_files', () => ({
|
|||
const log = new ToolingLog();
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function ensureNoResolve(promise) {
|
||||
|
@ -77,7 +77,7 @@ function mockEsBin({ exitCode, start }) {
|
|||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
extractConfigFiles.mockImplementation(config => config);
|
||||
extractConfigFiles.mockImplementation((config) => config);
|
||||
});
|
||||
|
||||
describe('#installSource()', () => {
|
||||
|
@ -85,7 +85,7 @@ describe('#installSource()', () => {
|
|||
let resolveInstallSource;
|
||||
installSource.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise(resolve => {
|
||||
new Promise((resolve) => {
|
||||
resolveInstallSource = () => {
|
||||
resolve({ installPath: 'foo' });
|
||||
};
|
||||
|
@ -124,7 +124,7 @@ describe('#installSnapshot()', () => {
|
|||
let resolveInstallSnapshot;
|
||||
installSnapshot.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise(resolve => {
|
||||
new Promise((resolve) => {
|
||||
resolveInstallSnapshot = () => {
|
||||
resolve({ installPath: 'foo' });
|
||||
};
|
||||
|
@ -163,7 +163,7 @@ describe('#installArchive(path)', () => {
|
|||
let resolveInstallArchive;
|
||||
installArchive.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise(resolve => {
|
||||
new Promise((resolve) => {
|
||||
resolveInstallArchive = () => {
|
||||
resolve({ installPath: 'foo' });
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ const SECURE_SETTINGS_LIST = [
|
|||
];
|
||||
|
||||
function isSecureSetting(settingName: string) {
|
||||
return SECURE_SETTINGS_LIST.some(secureSettingNameRegex =>
|
||||
return SECURE_SETTINGS_LIST.some((secureSettingNameRegex) =>
|
||||
secureSettingNameRegex.test(settingName)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ const { createCliError } = require('../errors');
|
|||
const { findMostRecentlyChanged } = require('../utils');
|
||||
const { GRADLE_BIN } = require('../paths');
|
||||
|
||||
const onceEvent = (emitter, event) => new Promise(resolve => emitter.once(event, resolve));
|
||||
const onceEvent = (emitter, event) => new Promise((resolve) => emitter.once(event, resolve));
|
||||
|
||||
/**
|
||||
* Creates archive from source
|
||||
|
@ -59,13 +59,13 @@ exports.buildSnapshot = async ({ license, sourcePath, log, platform = os.platfor
|
|||
const stdout = readline.createInterface({ input: build.stdout });
|
||||
const stderr = readline.createInterface({ input: build.stderr });
|
||||
|
||||
stdout.on('line', line => log.debug(line));
|
||||
stderr.on('line', line => log.error(line));
|
||||
stdout.on('line', (line) => log.debug(line));
|
||||
stderr.on('line', (line) => log.error(line));
|
||||
|
||||
const [exitCode] = await Promise.all([
|
||||
Promise.race([
|
||||
onceEvent(build, 'exit'),
|
||||
onceEvent(build, 'error').then(error => {
|
||||
onceEvent(build, 'error').then((error) => {
|
||||
throw createCliError(`Error spawning gradle: ${error.message}`);
|
||||
}),
|
||||
]),
|
||||
|
|
|
@ -50,15 +50,12 @@ function decompressZip(input, output) {
|
|||
resolve();
|
||||
});
|
||||
|
||||
zipfile.on('error', err => {
|
||||
zipfile.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
zipfile.on('entry', entry => {
|
||||
const zipPath = entry.fileName
|
||||
.split(/\/|\\/)
|
||||
.slice(1)
|
||||
.join(path.sep);
|
||||
zipfile.on('entry', (entry) => {
|
||||
const zipPath = entry.fileName.split(/\/|\\/).slice(1).join(path.sep);
|
||||
const fileName = path.resolve(output, zipPath);
|
||||
|
||||
if (/\/$/.test(entry.fileName)) {
|
||||
|
@ -83,7 +80,7 @@ function decompressZip(input, output) {
|
|||
});
|
||||
}
|
||||
|
||||
exports.decompress = async function(input, output) {
|
||||
exports.decompress = async function (input, output) {
|
||||
const ext = path.extname(input);
|
||||
|
||||
switch (path.extname(input)) {
|
||||
|
|
|
@ -32,7 +32,7 @@ exports.extractConfigFiles = function extractConfigFiles(config, dest, options =
|
|||
const originalConfig = typeof config === 'string' ? [config] : config;
|
||||
const localConfig = [];
|
||||
|
||||
originalConfig.forEach(prop => {
|
||||
originalConfig.forEach((prop) => {
|
||||
const [key, value] = prop.split('=');
|
||||
|
||||
if (isFile(value)) {
|
||||
|
|
|
@ -32,7 +32,7 @@ exports.findMostRecentlyChanged = function findMostRecentlyChanged(pattern) {
|
|||
throw new TypeError(`Pattern must be absolute, got ${pattern}`);
|
||||
}
|
||||
|
||||
const ctime = path => fs.statSync(path).ctime.getTime();
|
||||
const ctime = (path) => fs.statSync(path).ctime.getTime();
|
||||
|
||||
return glob
|
||||
.sync(pattern)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
jest.mock('fs', () => ({
|
||||
statSync: jest.fn().mockImplementation(path => {
|
||||
statSync: jest.fn().mockImplementation((path) => {
|
||||
if (path.includes('oldest')) {
|
||||
return {
|
||||
ctime: new Date(2018, 2, 1),
|
||||
|
|
|
@ -77,7 +77,7 @@ exports.NativeRealm = class NativeRealm {
|
|||
|
||||
const reservedUsers = await this.getReservedUsers();
|
||||
await Promise.all(
|
||||
reservedUsers.map(async user => {
|
||||
reservedUsers.map(async (user) => {
|
||||
await this.setPassword(user, options[`password.${user}`]);
|
||||
})
|
||||
);
|
||||
|
@ -87,7 +87,7 @@ exports.NativeRealm = class NativeRealm {
|
|||
return await this._autoRetry(async () => {
|
||||
const resp = await this._client.security.getUser();
|
||||
const usernames = Object.keys(resp.body).filter(
|
||||
user => resp.body[user].metadata._reserved === true
|
||||
(user) => resp.body[user].metadata._reserved === true
|
||||
);
|
||||
|
||||
if (!usernames?.length) {
|
||||
|
@ -125,7 +125,7 @@ exports.NativeRealm = class NativeRealm {
|
|||
|
||||
const sec = 1.5 * attempt;
|
||||
this._log.warning(`assuming ES isn't initialized completely, trying again in ${sec} seconds`);
|
||||
await new Promise(resolve => setTimeout(resolve, sec * 1000));
|
||||
await new Promise((resolve) => setTimeout(resolve, sec * 1000));
|
||||
return await this._autoRetry(fn, attempt + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,6 @@
|
|||
//
|
||||
const PATH_IMPORT_RE = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/;
|
||||
|
||||
exports.getIsPathRequest = function(source) {
|
||||
exports.getIsPathRequest = function (source) {
|
||||
return PATH_IMPORT_RE.test(source);
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ const DEFAULT_PLUGIN_PATH = '../..';
|
|||
/*
|
||||
* Resolves the path to Kibana, either from default setting or config
|
||||
*/
|
||||
exports.getKibanaPath = function(config, projectRoot) {
|
||||
exports.getKibanaPath = function (config, projectRoot) {
|
||||
const inConfig = config != null && config.kibanaPath;
|
||||
|
||||
// We only allow `.` in the config as we need it for Kibana itself
|
||||
|
|
|
@ -49,10 +49,10 @@ function getPathType(path) {
|
|||
return type;
|
||||
}
|
||||
|
||||
exports.isDirectory = function(path) {
|
||||
exports.isDirectory = function (path) {
|
||||
return getPathType(path) === DIR;
|
||||
};
|
||||
|
||||
exports.isFile = function(path) {
|
||||
exports.isFile = function (path) {
|
||||
return getPathType(path) === FILE;
|
||||
};
|
||||
|
|
|
@ -21,8 +21,8 @@ const { dirname, resolve } = require('path');
|
|||
|
||||
const glob = require('glob-all');
|
||||
|
||||
exports.getPlugins = function(config, kibanaPath, projectRoot) {
|
||||
const resolveToRoot = path => resolve(projectRoot, path);
|
||||
exports.getPlugins = function (config, kibanaPath, projectRoot) {
|
||||
const resolveToRoot = (path) => resolve(projectRoot, path);
|
||||
|
||||
const pluginDirs = [
|
||||
...(config.pluginDirs || []).map(resolveToRoot),
|
||||
|
@ -39,11 +39,11 @@ exports.getPlugins = function(config, kibanaPath, projectRoot) {
|
|||
];
|
||||
|
||||
const globPatterns = [
|
||||
...pluginDirs.map(dir => resolve(dir, '*/package.json')),
|
||||
...pluginPaths.map(path => resolve(path, 'package.json')),
|
||||
...pluginDirs.map((dir) => resolve(dir, '*/package.json')),
|
||||
...pluginPaths.map((path) => resolve(path, 'package.json')),
|
||||
];
|
||||
|
||||
const pluginsFromMap = Object.keys(config.pluginMap || {}).map(name => {
|
||||
const pluginsFromMap = Object.keys(config.pluginMap || {}).map((name) => {
|
||||
const directory = resolveToRoot(config.pluginMap[name]);
|
||||
return {
|
||||
name,
|
||||
|
@ -53,7 +53,7 @@ exports.getPlugins = function(config, kibanaPath, projectRoot) {
|
|||
});
|
||||
|
||||
return pluginsFromMap.concat(
|
||||
glob.sync(globPatterns).map(pkgJsonPath => {
|
||||
glob.sync(globPatterns).map((pkgJsonPath) => {
|
||||
const path = dirname(pkgJsonPath);
|
||||
const pkg = require(pkgJsonPath); // eslint-disable-line import/no-dynamic-require
|
||||
return {
|
||||
|
|
|
@ -55,7 +55,7 @@ function getRootPackageDir(dirRoot, dir, rootPackageName) {
|
|||
}
|
||||
}
|
||||
|
||||
exports.getProjectRoot = function(file, config) {
|
||||
exports.getProjectRoot = function (file, config) {
|
||||
const { root, dir } = parse(resolve(file));
|
||||
const { rootPackageName } = config;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ const { resolve } = require('path');
|
|||
const { debug } = require('./debug');
|
||||
const { getPlugins } = require('./get_plugins');
|
||||
|
||||
exports.getWebpackConfig = function(kibanaPath, projectRoot, config) {
|
||||
exports.getWebpackConfig = function (kibanaPath, projectRoot, config) {
|
||||
const fromKibana = (...path) => resolve(kibanaPath, ...path);
|
||||
|
||||
const alias = {
|
||||
|
@ -39,7 +39,7 @@ exports.getWebpackConfig = function(kibanaPath, projectRoot, config) {
|
|||
test_utils: fromKibana('src/test_utils/public'),
|
||||
};
|
||||
|
||||
getPlugins(config, kibanaPath, projectRoot).forEach(plugin => {
|
||||
getPlugins(config, kibanaPath, projectRoot).forEach((plugin) => {
|
||||
alias[`plugins/${plugin.name}`] = plugin.publicDirectory;
|
||||
});
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ function readShimNames(shimDirectory) {
|
|||
}
|
||||
|
||||
return readdirSync(shimDirectory)
|
||||
.filter(name => !name.startsWith('.') && !name.startsWith('_'))
|
||||
.map(name => (name.endsWith('.js') ? name.slice(0, -3) : name));
|
||||
.filter((name) => !name.startsWith('.') && !name.startsWith('_'))
|
||||
.map((name) => (name.endsWith('.js') ? name.slice(0, -3) : name));
|
||||
}
|
||||
|
||||
function findRelativeWebpackShims(directory) {
|
||||
|
@ -53,7 +53,7 @@ function findRelativeWebpackShims(directory) {
|
|||
return allShims;
|
||||
}
|
||||
|
||||
exports.isProbablyWebpackShim = function(source, file) {
|
||||
exports.isProbablyWebpackShim = function (source, file) {
|
||||
const shims = findRelativeWebpackShims(dirname(file));
|
||||
return shims.some(shim => source === shim || source.startsWith(shim + '/'));
|
||||
return shims.some((shim) => source === shim || source.startsWith(shim + '/'));
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
* @param {Array<[alias,path]>} aliasEntries
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
exports.resolveWebpackAlias = function(source, aliasEntries) {
|
||||
exports.resolveWebpackAlias = function (source, aliasEntries) {
|
||||
for (const [alias, path] of aliasEntries) {
|
||||
if (source === alias) {
|
||||
return path;
|
||||
|
|
|
@ -31,7 +31,7 @@ exports.normalizeWhitespace = function normalizeWhitespace(string) {
|
|||
return string.replace(/\s+/g, ' ');
|
||||
};
|
||||
|
||||
exports.init = function(context, program, initStep) {
|
||||
exports.init = function (context, program, initStep) {
|
||||
try {
|
||||
return initStep();
|
||||
} catch (error) {
|
||||
|
|
|
@ -39,7 +39,7 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
create: context => {
|
||||
create: (context) => {
|
||||
return {
|
||||
Program(program) {
|
||||
const licenses = init(context, program, () => {
|
||||
|
@ -70,8 +70,8 @@ module.exports = {
|
|||
|
||||
sourceCode
|
||||
.getAllComments()
|
||||
.filter(node => licenses.includes(normalizeWhitespace(node.value)))
|
||||
.forEach(node => {
|
||||
.filter((node) => licenses.includes(normalizeWhitespace(node.value)))
|
||||
.forEach((node) => {
|
||||
context.report({
|
||||
node,
|
||||
message: 'This license header is not allowed in this file.',
|
||||
|
|
|
@ -22,7 +22,7 @@ const KIBANA_ROOT = path.resolve(__dirname, '../../..');
|
|||
|
||||
function checkModuleNameNode(context, mappings, node) {
|
||||
const mapping = mappings.find(
|
||||
mapping => mapping.from === node.value || node.value.startsWith(`${mapping.from}/`)
|
||||
(mapping) => mapping.from === node.value || node.value.startsWith(`${mapping.from}/`)
|
||||
);
|
||||
|
||||
if (!mapping) {
|
||||
|
@ -105,7 +105,7 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
create: context => {
|
||||
create: (context) => {
|
||||
const mappings = context.options[0];
|
||||
|
||||
return {
|
||||
|
|
|
@ -40,10 +40,10 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
create: context => {
|
||||
create: (context) => {
|
||||
return {
|
||||
Program(program) {
|
||||
const license = init(context, program, function() {
|
||||
const license = init(context, program, function () {
|
||||
const options = context.options[0] || {};
|
||||
const license = options.license;
|
||||
|
||||
|
@ -69,7 +69,7 @@ module.exports = {
|
|||
const sourceCode = context.getSourceCode();
|
||||
const comment = sourceCode
|
||||
.getAllComments()
|
||||
.find(node => normalizeWhitespace(node.value) === license.nodeValue);
|
||||
.find((node) => normalizeWhitespace(node.value) === license.nodeValue);
|
||||
|
||||
// no licence comment
|
||||
if (!comment) {
|
||||
|
|
|
@ -31,7 +31,7 @@ const padRight = (width, str) =>
|
|||
|
||||
run(
|
||||
async ({ log, flags }) => {
|
||||
await withProcRunner(log, async proc => {
|
||||
await withProcRunner(log, async (proc) => {
|
||||
log.info('Deleting old output');
|
||||
await del(BUILD_DIR);
|
||||
|
||||
|
@ -43,7 +43,7 @@ run(
|
|||
|
||||
log.info(`Starting babel and typescript${flags.watch ? ' in watch mode' : ''}`);
|
||||
await Promise.all([
|
||||
...['web', 'node'].map(subTask =>
|
||||
...['web', 'node'].map((subTask) =>
|
||||
proc.run(padRight(10, `babel:${subTask}`), {
|
||||
cmd: 'babel',
|
||||
args: [
|
||||
|
|
|
@ -28,17 +28,14 @@ import * as i18n from '../core/i18n';
|
|||
import { i18nFilter as angularI18nFilter } from './filter';
|
||||
import { I18nProvider, I18nServiceType } from './provider';
|
||||
|
||||
angular
|
||||
.module('app', [])
|
||||
.provider('i18n', I18nProvider)
|
||||
.filter('i18n', angularI18nFilter);
|
||||
angular.module('app', []).provider('i18n', I18nProvider).filter('i18n', angularI18nFilter);
|
||||
|
||||
describe('i18nFilter', () => {
|
||||
let filter: I18nServiceType;
|
||||
|
||||
beforeEach(angular.mock.module('app'));
|
||||
beforeEach(
|
||||
angular.mock.inject(i18nFilter => {
|
||||
angular.mock.inject((i18nFilter) => {
|
||||
filter = i18nFilter;
|
||||
})
|
||||
);
|
||||
|
|
|
@ -127,7 +127,7 @@ export function getRegisteredLocales() {
|
|||
*/
|
||||
export async function getTranslationsByLocale(locale: string): Promise<Translation> {
|
||||
const files = translationsRegistry[locale] || [];
|
||||
const notLoadedFiles = files.filter(file => !loadedFiles[file]);
|
||||
const notLoadedFiles = files.filter((file) => !loadedFiles[file]);
|
||||
|
||||
if (notLoadedFiles.length) {
|
||||
await loadAndCacheFiles(notLoadedFiles);
|
||||
|
|
|
@ -37,7 +37,7 @@ function translateFormattedMessageUsingPseudoLocale(message: string) {
|
|||
if (formattedMessageDelimiter !== null) {
|
||||
return message
|
||||
.split(formattedMessageDelimiter[0])
|
||||
.map(part => (part.startsWith('ELEMENT-') ? part : translateUsingPseudoLocale(part)))
|
||||
.map((part) => (part.startsWith('ELEMENT-') ? part : translateUsingPseudoLocale(part)))
|
||||
.join(formattedMessageDelimiter[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export function Arg(config) {
|
|||
this.multi = config.multi == null ? false : config.multi;
|
||||
this.resolve = config.resolve == null ? true : config.resolve;
|
||||
this.options = config.options || [];
|
||||
this.accepts = type => {
|
||||
this.accepts = (type) => {
|
||||
if (!this.types.length) return true;
|
||||
return includes(config.types, type);
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ function getExpressionArgs(block, level = 0) {
|
|||
|
||||
const argKeys = Object.keys(args);
|
||||
const MAX_LINE_LENGTH = 80; // length before wrapping arguments
|
||||
return argKeys.map(argKey =>
|
||||
return argKeys.map((argKey) =>
|
||||
args[argKey].reduce((acc, arg) => {
|
||||
const argString = getArgumentString(arg, argKey, level);
|
||||
const lineLength = acc.split('\n').pop().length;
|
||||
|
@ -86,7 +86,7 @@ function getExpression(chain, level = 0) {
|
|||
const separator = level > 0 ? ' | ' : '\n| ';
|
||||
|
||||
return chain
|
||||
.map(chainObj => {
|
||||
.map((chainObj) => {
|
||||
const type = getType(chainObj);
|
||||
|
||||
if (type === 'function') {
|
||||
|
|
|
@ -39,7 +39,7 @@ export function Fn(config) {
|
|||
|
||||
this.context = config.context || {};
|
||||
|
||||
this.accepts = type => {
|
||||
this.accepts = (type) => {
|
||||
if (!this.context.types) return true; // If you don't tell us about context, we'll assume you don't care what you get
|
||||
return includes(this.context.types, type); // Otherwise, check it
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ export function getByAlias(specs, name) {
|
|||
const lowerCaseName = name.toLowerCase();
|
||||
return Object.values(specs).find(({ name, aliases }) => {
|
||||
if (name.toLowerCase() === lowerCaseName) return true;
|
||||
return (aliases || []).some(alias => {
|
||||
return (aliases || []).some((alias) => {
|
||||
return alias.toLowerCase() === lowerCaseName;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -48,7 +48,7 @@ export class Registry {
|
|||
}
|
||||
|
||||
toArray() {
|
||||
return Object.keys(this._indexed).map(key => this.get(key));
|
||||
return Object.keys(this._indexed).map((key) => this.get(key));
|
||||
}
|
||||
|
||||
get(name) {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* @param {*} newRegistries - The new set of registries
|
||||
*/
|
||||
export function addRegistries(registries, newRegistries) {
|
||||
Object.keys(newRegistries).forEach(registryName => {
|
||||
Object.keys(newRegistries).forEach((registryName) => {
|
||||
if (registries[registryName]) {
|
||||
throw new Error(`There is already a registry named "${registryName}".`);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ export function addRegistries(registries, newRegistries) {
|
|||
* @param {*} specs - The specs to be regsitered (e.g. { types: [], browserFunctions: [] })
|
||||
*/
|
||||
export function register(registries, specs) {
|
||||
Object.keys(specs).forEach(registryName => {
|
||||
Object.keys(specs).forEach((registryName) => {
|
||||
if (!registries[registryName]) {
|
||||
throw new Error(`There is no registry named "${registryName}".`);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ export function register(registries, specs) {
|
|||
if (!registries[registryName].register) {
|
||||
throw new Error(`Registry "${registryName}" must have a register function.`);
|
||||
}
|
||||
specs[registryName].forEach(f => registries[registryName].register(f));
|
||||
specs[registryName].forEach((f) => registries[registryName].register(f));
|
||||
});
|
||||
|
||||
return registries;
|
||||
|
|
|
@ -56,7 +56,7 @@ if (flags.help) {
|
|||
process.exit();
|
||||
}
|
||||
|
||||
withProcRunner(log, async proc => {
|
||||
withProcRunner(log, async (proc) => {
|
||||
log.info('Deleting old output');
|
||||
await del(BUILD_DIR);
|
||||
|
||||
|
@ -87,7 +87,7 @@ withProcRunner(log, async proc => {
|
|||
]);
|
||||
|
||||
log.success('Complete');
|
||||
}).catch(error => {
|
||||
}).catch((error) => {
|
||||
log.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
|
@ -77,8 +77,8 @@ run(
|
|||
|
||||
const extraPluginScanDirs = ([] as string[])
|
||||
.concat((flags['scan-dir'] as string | string[]) || [])
|
||||
.map(p => Path.resolve(p));
|
||||
if (!extraPluginScanDirs.every(s => typeof s === 'string')) {
|
||||
.map((p) => Path.resolve(p));
|
||||
if (!extraPluginScanDirs.every((s) => typeof s === 'string')) {
|
||||
throw createFlagError('expected --scan-dir to be a string');
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue