Skip to content

Commit

Permalink
Use rxjs instead of rxjs/operators (#179553)
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Apr 2, 2024
1 parent e43dd0e commit 1c1e20a
Show file tree
Hide file tree
Showing 447 changed files with 498 additions and 537 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ const RESTRICTED_IMPORTS = [
importNames: ['Route'],
message: 'Please use @kbn/shared-ux-router instead',
},
{
name: 'rxjs/operators',
message:
'Please, use rxjs instead: rxjs/operators is just a subset, unnecessarily duplicating the package import.',
},
];

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion examples/expressions_explorer/public/run_expressions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React, { useState, useEffect } from 'react';
import { pluck } from 'rxjs/operators';
import { pluck } from 'rxjs';
import {
EuiCodeBlock,
EuiFlexItem,
Expand Down
2 changes: 1 addition & 1 deletion examples/partial_results_example/public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React, { useContext, useEffect, useState } from 'react';
import { pluck } from 'rxjs/operators';
import { pluck } from 'rxjs';
import {
EuiBasicTable,
EuiCallOut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Observable, fromEvent } from 'rxjs';
import { scan, startWith } from 'rxjs/operators';
import { scan, startWith } from 'rxjs';
import type { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';

export interface CountEventArguments {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Observable, fromEvent, merge } from 'rxjs';
import { distinct, map, pluck, scan, take } from 'rxjs/operators';
import { distinct, map, pluck, scan, take } from 'rxjs';
import type { Datatable, ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';

const EVENTS: Array<keyof WindowEventMap> = [
Expand Down
2 changes: 1 addition & 1 deletion examples/search_examples/public/search_sessions/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
EuiText,
EuiTitle,
} from '@elastic/eui';
import { catchError, map, tap } from 'rxjs/operators';
import { catchError, map, tap } from 'rxjs';
import { lastValueFrom, of } from 'rxjs';

import { CoreStart } from '@kbn/core/public';
Expand Down
2 changes: 1 addition & 1 deletion examples/search_examples/server/my_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { map } from 'rxjs/operators';
import { map } from 'rxjs';
import { ISearchStrategy, PluginStart } from '@kbn/data-plugin/server';
import { IMyStrategyRequest, IMyStrategyResponse } from '../common/types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
skipWhile,
takeUntil,
tap,
} from 'rxjs/operators';
} from 'rxjs';
import type { LogMeta } from '@kbn/logging';
import type { IShipper } from '../shippers';
import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* Side Public License, v 1.
*/

import { firstValueFrom, ReplaySubject } from 'rxjs';
import { firstValueFrom, ReplaySubject, take } from 'rxjs';
import { analyticsClientMock } from './analytics_service.test.mocks';
import { trackClicks } from './track_clicks';
import { take } from 'rxjs/operators';

describe('trackClicks', () => {
const addEventListenerSpy = jest.spyOn(window, 'addEventListener');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* Side Public License, v 1.
*/

import { BehaviorSubject, type Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import { BehaviorSubject, type Observable, take } from 'rxjs';
import { act } from 'react-dom/test-utils';
import { createMemoryHistory, MemoryHistory } from 'history';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

import { createElement } from 'react';
import { BehaviorSubject, firstValueFrom, Subject } from 'rxjs';
import { bufferCount, takeUntil } from 'rxjs/operators';
import { bufferCount, takeUntil } from 'rxjs';
import { mount, shallow } from 'enzyme';
import { createBrowserHistory } from 'history';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import { BehaviorSubject, firstValueFrom, type Observable, Subject, type Subscription } from 'rxjs';
import { map, shareReplay, takeUntil, distinctUntilChanged, filter, take } from 'rxjs/operators';
import { map, shareReplay, takeUntil, distinctUntilChanged, filter, take } from 'rxjs';
import { createBrowserHistory, History } from 'history';

import type { PluginOpaqueId } from '@kbn/core-base-common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { createReadStream, Stats } from 'fs';
import { createHash } from 'crypto';
import * as Rx from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { map, takeUntil } from 'rxjs';

export const generateFileHash = (fd: number): Promise<string> => {
const hash = createHash('sha1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { registerAnalyticsContextProviderMock } from './chrome_service.test.mock
import { shallow, mount } from 'enzyme';
import React from 'react';
import * as Rx from 'rxjs';
import { toArray } from 'rxjs/operators';
import { toArray } from 'rxjs';
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
import { httpServiceMock } from '@kbn/core-http-browser-mocks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React, { useMemo } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { BehaviorSubject, combineLatest, merge, type Observable, of, ReplaySubject } from 'rxjs';
import { mergeMap, map, takeUntil, filter } from 'rxjs/operators';
import { mergeMap, map, takeUntil, filter } from 'rxjs';
import { parse } from 'url';
import { EuiLink } from '@elastic/eui';
import useObservable from 'react-use/lib/useObservable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { take } from 'rxjs/operators';
import { take } from 'rxjs';
import { NavControlsService } from './nav_controls_service';

describe('RecentlyAccessed#start()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { sortBy } from 'lodash';
import { BehaviorSubject, ReplaySubject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { map, takeUntil } from 'rxjs';
import type {
ChromeNavControl,
ChromeNavControls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { BehaviorSubject, lastValueFrom } from 'rxjs';
import { take, map, takeLast } from 'rxjs/operators';
import { take, map, takeLast } from 'rxjs';
import { type App, AppStatus } from '@kbn/core-application-browser';
import { NavLinksService } from './nav_links_service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { sortBy } from 'lodash';
import { BehaviorSubject, ReplaySubject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { map, takeUntil } from 'rxjs';
import type { IBasePath } from '@kbn/core-http-browser';
import type { InternalHttpStart } from '@kbn/core-http-browser-internal';
import type { PublicAppDeepLinkInfo, PublicAppInfo } from '@kbn/core-application-browser';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { cloneDeep, isEqual, take } from 'lodash';
import * as Rx from 'rxjs';
import { map } from 'rxjs/operators';
import { map } from 'rxjs';

interface PersistedLogOptions<T = any> {
maxLength: number | string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Subject } from 'rxjs';
import { takeUntil, bufferCount } from 'rxjs/operators';
import { takeUntil, bufferCount } from 'rxjs';
import { httpServiceMock } from '@kbn/core-http-browser-mocks';
import { RecentlyAccessedService } from './recently_accessed_service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Subject, BehaviorSubject } from 'rxjs';
import { shareReplay, takeUntil, map } from 'rxjs/operators';
import { shareReplay, takeUntil, map } from 'rxjs';
import type {
CustomBrandingStart,
CustomBrandingSetup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {

import type { NodesVersionCompatibility } from './version_check/ensure_es_version';
import { BehaviorSubject, firstValueFrom, of } from 'rxjs';
import { first, concatMap } from 'rxjs/operators';
import { first, concatMap } from 'rxjs';
import { REPO_ROOT } from '@kbn/repo-info';
import { Env } from '@kbn/config';
import { configServiceMock, getEnvOptions } from '@kbn/config-mocks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { firstValueFrom, Observable, Subject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { map, takeUntil } from 'rxjs';

import type { Logger } from '@kbn/logging';
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { filter } from 'rxjs/operators';
import { filter } from 'rxjs';
import { errors } from '@elastic/elasticsearch';
import { Observable, firstValueFrom } from 'rxjs';
import { NodesVersionCompatibility } from './version_check/ensure_es_version';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { defer, throwError, iif, timer } from 'rxjs';
import { concatMap, retryWhen } from 'rxjs/operators';
import { concatMap, retryWhen } from 'rxjs';

const retryResponseStatuses = [
503, // ServiceUnavailable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { take } from 'rxjs/operators';
import { take } from 'rxjs';
import { Subject, of } from 'rxjs';

import { ServiceStatusLevels, ServiceStatusLevel, ServiceStatus } from '@kbn/core-status-common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Observable, merge, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { map } from 'rxjs';
import { ServiceStatus, ServiceStatusLevels } from '@kbn/core-status-common';
import { ElasticsearchStatusMeta } from './types';
import { NodesVersionCompatibility } from './version_check/ensure_es_version';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { mapNodesVersionCompatibility, pollEsNodesVersion, NodesInfo } from './ensure_es_version';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
import { take, delay } from 'rxjs/operators';
import { take, delay } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { of } from 'rxjs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
tap,
startWith,
shareReplay,
} from 'rxjs/operators';
} from 'rxjs';
import type { Logger } from '@kbn/logging';
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { compact, isEqual, isUndefined, omitBy } from 'lodash';
import type { Observable } from 'rxjs';
import { BehaviorSubject, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import { map } from 'rxjs';
import type { CoreService } from '@kbn/core-base-browser-internal';
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-browser';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import fetchMock from 'fetch-mock/es5/client';
import { readFileSync } from 'fs';
import { join } from 'path';
import { first } from 'rxjs/operators';
import { first } from 'rxjs';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import type { HttpResponse, HttpFetchOptionsWithPath } from '@kbn/core-http-browser';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Observable, throwError, of, Subject } from 'rxjs';
import { toArray } from 'rxjs/operators';
import { toArray } from 'rxjs';

import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { LoadingCountService } from './loading_count_service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
*/

import { BehaviorSubject, Observable, Subject } from 'rxjs';
import {
distinctUntilChanged,
endWith,
map,
pairwise,
startWith,
takeUntil,
tap,
} from 'rxjs/operators';
import { distinctUntilChanged, endWith, map, pairwise, startWith, takeUntil, tap } from 'rxjs';
import type { CoreService } from '@kbn/core-base-browser-internal';
import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { v4 as uuidv4 } from 'uuid';
import { inspect } from 'util';
import type { Request, RouteOptions } from '@hapi/hapi';
import { fromEvent, NEVER } from 'rxjs';
import { shareReplay, first, filter } from 'rxjs/operators';
import { shareReplay, first, filter } from 'rxjs';
import { RecursiveReadonly } from '@kbn/utility-types';
import { deepFreeze } from '@kbn/std';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {

import type { Duration } from 'moment';
import { firstValueFrom, Observable, Subscription } from 'rxjs';
import { take, pairwise } from 'rxjs/operators';
import { take, pairwise } from 'rxjs';
import apm from 'elastic-apm-node';
// @ts-expect-error no type definition
import Brok from 'brok';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Observable, Subscription, combineLatest, firstValueFrom } from 'rxjs';
import { map } from 'rxjs/operators';
import { map } from 'rxjs';
import { pick } from '@kbn/std';

import { Logger } from '@kbn/logging';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import moment from 'moment-timezone';
import { merge, Subscription } from 'rxjs';
import { tap } from 'rxjs/operators';
import { tap } from 'rxjs';

import type { CoreService } from '@kbn/core-base-browser-internal';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import moment from 'moment';

import { take } from 'rxjs/operators';
import { take } from 'rxjs';
import { configServiceMock } from '@kbn/config-mocks';
import { mockCoreContext } from '@kbn/core-base-server-mocks';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { InternalOverlayBannersStart, OverlayBannersService } from './banners_service';
import { take } from 'rxjs/operators';
import { take } from 'rxjs';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import { BehaviorSubject, type Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { map } from 'rxjs';

import type { I18nStart } from '@kbn/core-i18n-browser';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { filter } from 'rxjs/operators';
import { filter } from 'rxjs';
import { Subscription } from 'rxjs';

import { FormattedMessage } from '@kbn/i18n-react';
Expand Down
Loading

0 comments on commit 1c1e20a

Please sign in to comment.