Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: automatic type-only imports #7382

Merged
merged 3 commits into from Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/rxjs/.eslintrc.json
Expand Up @@ -3,10 +3,15 @@
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"project": ["./tsconfig.json"]
},
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/consistent-type-exports": "warn",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Should these be "error" instead of warn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7391. I also discovered that eslint also checks dist. I will create a separate PR.

"no-prototype-builtins": "off"
},
"env": {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/Observable-spec.ts
@@ -1,4 +1,5 @@
import { Observable, of, OperatorFunction, map, filter } from 'rxjs';
import type { OperatorFunction } from 'rxjs';
import { Observable, of, map, filter } from 'rxjs';

function a<I extends string, O extends string>(input: I, output: O): OperatorFunction<I, O>;
function a<I, O extends string>(output: O): OperatorFunction<I, O>;
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/observables/bindCallback-spec.ts
@@ -1,5 +1,6 @@
import { bindCallback } from 'rxjs';
import { a, b, c, d, e, f, g, A, B, C, D, E, F, G } from '../helpers';
import type { A, B, C, D, E, F, G } from '../helpers';
import { a, b, c, d, e, f, g } from '../helpers';

describe('callbackFunc', () => {
const f0 = (cb: () => void) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/observables/combineLatest-spec.ts
@@ -1,5 +1,6 @@
import { combineLatest } from 'rxjs';
import { a$, b$, c$, d$, e$, f$, g$, A, B, C, D, E, F } from '../helpers';
import type { B, C, D, E, F } from '../helpers';
import { a$, b$, c$, d$, e$, f$, g$, A } from '../helpers';

it('should accept 1 param', () => {
const o = combineLatest([a$]); // $ExpectType Observable<[A]>
Expand Down
4 changes: 2 additions & 2 deletions packages/rxjs/spec-dtslint/observables/fromEvent-spec.ts
@@ -1,11 +1,11 @@
import { fromEvent } from 'rxjs';
import {
import type {
HasEventTargetAddRemove,
NodeStyleEventEmitter,
NodeCompatibleEventEmitter,
JQueryStyleEventEmitter
} from '../../src/internal/observable/fromEvent';
import { B } from '../helpers';
import type { B } from '../helpers';

declare const eventTargetSource: EventTarget;

Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/catchError-spec.ts
@@ -1,4 +1,5 @@
import { of, Observable, EMPTY } from 'rxjs';
import type { Observable} from 'rxjs';
import { of, EMPTY } from 'rxjs';
import { catchError } from 'rxjs/operators';

it('should infer correctly', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/count-spec.ts
@@ -1,4 +1,5 @@
import { of, Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import { of } from 'rxjs';
import { count } from 'rxjs/operators';

it('should always infer number', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/rxjs/spec-dtslint/operators/distinct-spec.ts
@@ -1,7 +1,7 @@
import { of } from 'rxjs';
import { asInteropObservable } from '../../spec/helpers/interop-helper';
import { distinct } from 'rxjs/operators';
import { ReadableStreamLike } from '../../src/internal/types';
import type { ReadableStreamLike } from '../../src/internal/types';

it('should infer correctly', () => {
const o = of(1, 2, 3).pipe(distinct()); // $ExpectType Observable<number>
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/endWith-spec.ts
@@ -1,6 +1,7 @@
import { of } from 'rxjs';
import { endWith } from 'rxjs/operators';
import { A, B, a, b, c, d, e, f, g, h } from '../helpers';
import type { A, B} from '../helpers';
import { a, b, c, d, e, f, g, h } from '../helpers';

it('should infer type for N values', () => {
const r0 = of(a).pipe(endWith()); // $ExpectType Observable<A>
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/every-spec.ts
@@ -1,4 +1,5 @@
import { of, Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import { of } from 'rxjs';
import { every } from 'rxjs/operators';

it('should infer correctly', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/filter-spec.ts
@@ -1,4 +1,5 @@
import { Observable, of } from 'rxjs';
import type { Observable} from 'rxjs';
import { of } from 'rxjs';
import { filter, map } from 'rxjs/operators';

it('should support a predicate', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/findIndex-spec.ts
@@ -1,4 +1,5 @@
import { of, Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import { of } from 'rxjs';
import { findIndex } from 'rxjs/operators';

it('should infer correctly', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/groupBy-spec.ts
@@ -1,4 +1,5 @@
import { of, Subject, GroupedObservable } from 'rxjs';
import type { GroupedObservable } from 'rxjs';
import { of, Subject } from 'rxjs';
import { groupBy, mergeMap } from 'rxjs/operators';

it('should infer correctly', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/single-spec.ts
@@ -1,4 +1,5 @@
import { of, Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import { of } from 'rxjs';
import { single } from 'rxjs/operators';

it('should infer correctly', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/operators/startWith-spec.ts
@@ -1,5 +1,6 @@
import { of, startWith } from 'rxjs';
import { A, B, a, b, c, d, e, f, g, h } from '../helpers';
import type { A, B} from '../helpers';
import { a, b, c, d, e, f, g, h } from '../helpers';

it('should infer correctly with N values', () => {
const r0 = of(a).pipe(startWith()); // $ExpectType Observable<A>
Expand Down
4 changes: 2 additions & 2 deletions packages/rxjs/spec-dtslint/types-spec.ts
@@ -1,4 +1,4 @@
import {
import type {
Observable,
ObservedValueOf,
ObservedValueUnionFromArray,
Expand All @@ -7,7 +7,7 @@ import {
Head,
Tail
} from 'rxjs';
import { A, B, C } from './helpers';
import type { A, B, C } from './helpers';

describe('ObservedValueOf', () => {
it('should infer from an observable', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec-dtslint/util/pipe-spec.ts
@@ -1,4 +1,5 @@
import { pipe, UnaryFunction, of, Observable } from 'rxjs';
import type { UnaryFunction, Observable } from 'rxjs';
import { pipe, of } from 'rxjs';

/**
* Used to keep the tests uncluttered.
Expand Down
2 changes: 1 addition & 1 deletion packages/rxjs/spec/Scheduler-spec.ts
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { queueScheduler as queue } from 'rxjs';
import { QueueScheduler } from 'rxjs/internal/scheduler/QueueScheduler';
import type { QueueScheduler } from 'rxjs/internal/scheduler/QueueScheduler';

/** @test {Scheduler} */
describe('Scheduler.queue', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/Subject-spec.ts
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { Subject, Observable, AsyncSubject, Observer, of, config, Subscription, Subscriber, noop, operate } from 'rxjs';
import type { Subscription} from 'rxjs';
import { Subject, Observable, AsyncSubject, of, config, Subscriber, noop, operate } from 'rxjs';
import { delay } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from './helpers/observableMatcher';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/Subscriber-spec.ts
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { Subscriber, Observable, of, Observer, config, operate } from 'rxjs';
import type { Observer} from 'rxjs';
import { Subscriber, Observable, of, config, operate } from 'rxjs';
import * as sinon from 'sinon';
import { asInteropSubscriber } from './helpers/interop-helper';
import { getRegisteredFinalizers } from './helpers/subscription';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/helpers/interop-helper.ts
@@ -1,4 +1,5 @@
import { Observable, Subject, Subscriber, Subscription } from 'rxjs';
import type { Observable, Subject, Subscription } from 'rxjs';
import { Subscriber } from 'rxjs';

/**
* Returns an observable that will be deemed by this package's implementation
Expand Down
10 changes: 5 additions & 5 deletions packages/rxjs/spec/helpers/marble-testing.ts
@@ -1,8 +1,8 @@
import { Observable } from 'rxjs';
import { SubscriptionLog } from '../../src/internal/testing/subscription-logging';
import { ColdObservable } from '../../src/internal/testing/ColdObservable';
import { HotObservable } from '../../src/internal/testing/HotObservable';
import { observableToBeFn, subscriptionLogsToBeFn } from '../../src/internal/testing/TestScheduler';
import type { Observable } from 'rxjs';
import type { SubscriptionLog } from '../../src/internal/testing/subscription-logging';
import type { ColdObservable } from '../../src/internal/testing/ColdObservable';
import type { HotObservable } from '../../src/internal/testing/HotObservable';
import type { observableToBeFn, subscriptionLogsToBeFn } from '../../src/internal/testing/TestScheduler';

declare const global: any;

Expand Down
2 changes: 1 addition & 1 deletion packages/rxjs/spec/helpers/subscription.ts
@@ -1,5 +1,5 @@
/** @prettier */
import { TeardownLogic } from 'rxjs';
import type { TeardownLogic } from 'rxjs';

export function getRegisteredFinalizers(subscription: any): Exclude<TeardownLogic, void>[] {
if ('_finalizers' in subscription) {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/helpers/test-helper.ts
@@ -1,4 +1,5 @@
import { of, asyncScheduler, Observable, scheduled, ObservableInput } from 'rxjs';
import type { Observable, ObservableInput } from 'rxjs';
import { of, asyncScheduler, scheduled } from 'rxjs';
import { iterator } from 'rxjs/internal/symbol/iterator';

if (process && process.on) {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/observables/dom/ajax-spec.ts
@@ -1,7 +1,8 @@
/** @prettier */
import { expect } from 'chai';
import * as sinon from 'sinon';
import { ajax, AjaxConfig, AjaxResponse, AjaxError, AjaxTimeoutError } from 'rxjs/ajax';
import type { AjaxConfig, AjaxResponse} from 'rxjs/ajax';
import { ajax, AjaxError, AjaxTimeoutError } from 'rxjs/ajax';
import { TestScheduler } from 'rxjs/testing';
import { noop } from 'rxjs';
import * as nodeFormData from 'form-data';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/observables/from-spec.ts
@@ -1,7 +1,8 @@
/** @prettier */
import { expect } from 'chai';
import { TestScheduler } from 'rxjs/testing';
import { of, from, Observer, Subject, noop, Subscription } from 'rxjs';
import type { Observer, Subscription } from 'rxjs';
import { of, from, Subject, noop } from 'rxjs';
import { first, concatMap, delay, take, tap } from 'rxjs/operators';
import { ReadableStream } from 'web-streams-polyfill';
import { observableMatcher } from '../helpers/observableMatcher';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/observables/partition-spec.ts
@@ -1,6 +1,7 @@
/** @prettier */
import { expect } from 'chai';
import { Observable, partition, of } from 'rxjs';
import type { Observable} from 'rxjs';
import { partition, of } from 'rxjs';
import { mergeMap } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/dematerialize-spec.ts
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { of, ObservableNotification, Observable } from 'rxjs';
import type { ObservableNotification} from 'rxjs';
import { of, Observable } from 'rxjs';
import { COMPLETE_NOTIFICATION, errorNotification, nextNotification } from 'rxjs/internal/Observable';
import { dematerialize, map, mergeMap, materialize, take } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/every-spec.ts
@@ -1,7 +1,8 @@
import { expect } from 'chai';
import { every, mergeMap } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { of, Observable, Observer } from 'rxjs';
import type { Observer } from 'rxjs';
import { of, Observable } from 'rxjs';
import { observableMatcher } from '../helpers/observableMatcher';

/** @test {every} */
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/expand-spec.ts
@@ -1,7 +1,8 @@
import { expect } from 'chai';
import { expand, mergeMap, map, take, toArray } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { EMPTY, Observable, of, Observer, asapScheduler, asyncScheduler, InteropObservable } from 'rxjs';
import type { Observer, InteropObservable } from 'rxjs';
import { EMPTY, Observable, of, asapScheduler, asyncScheduler } from 'rxjs';
import { observableMatcher } from '../helpers/observableMatcher';

/** @test {expand} */
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/groupBy-spec.ts
@@ -1,7 +1,8 @@
import { expect } from 'chai';
import { groupBy, delay, tap, map, take, mergeMap, materialize, skip, ignoreElements } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { ReplaySubject, of, Observable, Subject, NextNotification, ErrorNotification } from 'rxjs';
import type { NextNotification, ErrorNotification } from 'rxjs';
import { ReplaySubject, of, Observable, Subject } from 'rxjs';
import { createNotification } from 'rxjs/internal/Observable';
import { observableMatcher } from '../helpers/observableMatcher';

Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/last-spec.ts
@@ -1,6 +1,7 @@
import { TestScheduler } from 'rxjs/testing';
import { last, mergeMap } from 'rxjs/operators';
import { EmptyError, of, from, Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import { EmptyError, of, from } from 'rxjs';
import { observableMatcher } from '../helpers/observableMatcher';

/** @test {last} */
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/map-spec.ts
@@ -1,7 +1,8 @@
import { expect } from 'chai';
import { map, tap, mergeMap, take } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { of, Observable, identity, Observer } from 'rxjs';
import type { Observer } from 'rxjs';
import { of, Observable, identity } from 'rxjs';
import { observableMatcher } from '../helpers/observableMatcher';

// function shortcuts
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/retry-spec.ts
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import { retry, map, take, mergeMap, concatWith, share } from 'rxjs/operators';
import { Observable, Observer, defer, range, of, throwError, Subject, timer, EMPTY } from 'rxjs';
import type { Observer} from 'rxjs';
import { Observable, defer, range, of, throwError, Subject, timer, EMPTY } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';

Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/tap-spec.ts
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import { tap, mergeMap, take } from 'rxjs/operators';
import { Subject, of, throwError, Observer, EMPTY, Observable, noop } from 'rxjs';
import type { Observer} from 'rxjs';
import { Subject, of, throwError, EMPTY, Observable, noop } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';

Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/window-spec.ts
@@ -1,6 +1,7 @@
import { window, mergeMap, take } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { EMPTY, of, Observable, interval } from 'rxjs';
import type { Observable} from 'rxjs';
import { EMPTY, of, interval } from 'rxjs';
import { observableMatcher } from '../helpers/observableMatcher';
import { expect } from 'chai';

Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/windowTime-spec.ts
@@ -1,6 +1,7 @@
import { windowTime, mergeMap } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { of, Observable } from 'rxjs';
import type { Observable } from 'rxjs';
import { of } from 'rxjs';
import { observableMatcher } from '../helpers/observableMatcher';

/** @test {windowTime} */
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/windowToggle-spec.ts
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { Observable, NEVER, of, EMPTY } from 'rxjs';
import type { Observable} from 'rxjs';
import { NEVER, of, EMPTY } from 'rxjs';
import { windowToggle, tap, mergeMap } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/operators/windowWhen-spec.ts
@@ -1,5 +1,6 @@
import { windowWhen, mergeMap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import type { Observable} from 'rxjs';
import { of } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';

Expand Down
@@ -1,7 +1,8 @@
/** @prettier */
import { expect } from 'chai';
import * as sinon from 'sinon';
import { animationFrameScheduler, Subscription, merge } from 'rxjs';
import type { Subscription} from 'rxjs';
import { animationFrameScheduler, merge } from 'rxjs';
import { delay } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/schedulers/AsapScheduler-spec.ts
@@ -1,7 +1,8 @@
/** @prettier */
import { expect } from 'chai';
import * as sinon from 'sinon';
import { asapScheduler, Subscription, SchedulerAction, merge } from 'rxjs';
import type { Subscription, SchedulerAction} from 'rxjs';
import { asapScheduler, merge } from 'rxjs';
import { delay } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/schedulers/QueueScheduler-spec.ts
@@ -1,7 +1,8 @@
/** @prettier */
import { expect } from 'chai';
import * as sinon from 'sinon';
import { queueScheduler, Subscription, merge } from 'rxjs';
import type { Subscription} from 'rxjs';
import { queueScheduler, merge } from 'rxjs';
import { delay } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/schedulers/VirtualTimeScheduler-spec.ts
@@ -1,6 +1,7 @@
/** @prettier */
import { expect } from 'chai';
import { SchedulerAction, VirtualAction, VirtualTimeScheduler } from 'rxjs';
import type { SchedulerAction} from 'rxjs';
import { VirtualAction, VirtualTimeScheduler } from 'rxjs';

/** @test {VirtualTimeScheduler} */
describe('VirtualTimeScheduler', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rxjs/spec/subjects/AsyncSubject-spec.ts
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { AsyncSubject, Observer } from 'rxjs';
import type { Observer } from 'rxjs';
import { AsyncSubject } from 'rxjs';

class TestObserver implements Observer<number> {
results: (number | string)[] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/rxjs/src/ajax/index.ts
@@ -1,4 +1,4 @@
export { ajax } from '../internal/ajax/ajax.js';
export { AjaxError, AjaxTimeoutError } from '../internal/ajax/errors.js';
export { AjaxResponse } from '../internal/ajax/AjaxResponse.js';
export { AjaxRequest, AjaxConfig, AjaxDirection } from '../internal/ajax/types.js';
export type { AjaxRequest, AjaxConfig, AjaxDirection } from '../internal/ajax/types.js';