Skip to content

Commit

Permalink
build: Add @typescript-eslint/consistent-type-imports rule (#6662)
Browse files Browse the repository at this point in the history
This ensures we use a `type` import when we only need type stuff.
  • Loading branch information
mydea authored Jan 11, 2023
1 parent 9ec436b commit 2aa4e94
Show file tree
Hide file tree
Showing 412 changed files with 791 additions and 703 deletions.
3 changes: 2 additions & 1 deletion packages/angular/src/errorhandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HttpErrorResponse } from '@angular/common/http';
import { ErrorHandler as AngularErrorHandler, Inject, Injectable } from '@angular/core';
import type { ErrorHandler as AngularErrorHandler } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import * as Sentry from '@sentry/browser';
import { captureException } from '@sentry/browser';
import { addExceptionMechanism, isString } from '@sentry/utils';
Expand Down
3 changes: 2 additions & 1 deletion packages/angular/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { VERSION } from '@angular/core';
import { BrowserOptions, init as browserInit, SDK_VERSION, setContext } from '@sentry/browser';
import type { BrowserOptions } from '@sentry/browser';
import { init as browserInit, SDK_VERSION, setContext } from '@sentry/browser';
import { logger } from '@sentry/utils';

import { ANGULAR_MINIMUM_VERSION } from './constants';
Expand Down
11 changes: 7 additions & 4 deletions packages/angular/src/tracing.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* eslint-disable max-lines */
import { AfterViewInit, Directive, Injectable, Input, NgModule, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRouteSnapshot, Event, NavigationEnd, NavigationStart, ResolveEnd, Router } from '@angular/router';
import type { AfterViewInit, OnDestroy, OnInit } from '@angular/core';
import { Directive, Injectable, Input, NgModule } from '@angular/core';
import type { ActivatedRouteSnapshot, Event, Router } from '@angular/router';
import { NavigationEnd, NavigationStart, ResolveEnd } from '@angular/router';
import { getCurrentHub, WINDOW } from '@sentry/browser';
import { Span, Transaction, TransactionContext } from '@sentry/types';
import type { Span, Transaction, TransactionContext } from '@sentry/types';
import { logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';
import { Observable, Subscription } from 'rxjs';
import type { Observable } from 'rxjs';
import { Subscription } from 'rxjs';
import { filter, tap } from 'rxjs/operators';

import { ANGULAR_INIT_OP, ANGULAR_OP, ANGULAR_ROUTING_OP } from './constants';
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/test/tracing.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Hub } from '@sentry/types';
import type { ActivatedRouteSnapshot } from '@angular/router';
import type { Hub } from '@sentry/types';

import { instrumentAngularRouting, TraceClassDecorator, TraceDirective, TraceMethodDecorator } from '../src';
import { getParameterizedRouteFromSnapshot } from '../src/tracing';
Expand Down
8 changes: 5 additions & 3 deletions packages/angular/test/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Component, NgModule } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Router, Routes } from '@angular/router';
import type { ComponentFixture } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import type { Routes } from '@angular/router';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { Transaction } from '@sentry/types';
import type { Transaction } from '@sentry/types';

import { instrumentAngularRouting, TraceService } from '../../src';

Expand Down
18 changes: 13 additions & 5 deletions packages/browser/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { BaseClient, getEnvelopeEndpointWithUrlEncodedAuth, Scope, SDK_VERSION } from '@sentry/core';
import type { BrowserClientReplayOptions } from '@sentry/types';
import { ClientOptions, Event, EventHint, Options, Severity, SeverityLevel } from '@sentry/types';
import type { Scope } from '@sentry/core';
import { BaseClient, getEnvelopeEndpointWithUrlEncodedAuth, SDK_VERSION } from '@sentry/core';
import type {
BrowserClientReplayOptions,
ClientOptions,
Event,
EventHint,
Options,
Severity,
SeverityLevel,
} from '@sentry/types';
import { createClientReportEnvelope, dsnToString, logger, serializeEnvelope } from '@sentry/utils';

import { eventFromException, eventFromMessage } from './eventbuilder';
import { WINDOW } from './helpers';
import { Breadcrumbs } from './integrations';
import type { Breadcrumbs } from './integrations';
import { BREADCRUMB_INTEGRATION_ID } from './integrations/breadcrumbs';
import { BrowserTransportOptions } from './transports/types';
import type { BrowserTransportOptions } from './transports/types';
/**
* Configuration options for the Sentry Browser SDK.
* @see @sentry/types Options for more information.
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/eventbuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCurrentHub } from '@sentry/core';
import { Event, EventHint, Exception, Severity, SeverityLevel, StackFrame, StackParser } from '@sentry/types';
import type { Event, EventHint, Exception, Severity, SeverityLevel, StackFrame, StackParser } from '@sentry/types';
import {
addExceptionMechanism,
addExceptionTypeValue,
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { captureException, withScope } from '@sentry/core';
import { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';
import type { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';
import {
addExceptionMechanism,
addExceptionTypeValue,
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable max-lines */
import { getCurrentHub } from '@sentry/core';
import { Event, Integration } from '@sentry/types';
import type { Event, Integration } from '@sentry/types';
import {
addInstrumentationHandler,
getEventDescription,
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/dedupe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Event, EventProcessor, Exception, Hub, Integration, StackFrame } from '@sentry/types';
import type { Event, EventProcessor, Exception, Hub, Integration, StackFrame } from '@sentry/types';
import { logger } from '@sentry/utils';

/** Deduplication filter */
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/integrations/globalhandlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { getCurrentHub } from '@sentry/core';
import { Event, EventHint, Hub, Integration, Primitive, StackParser } from '@sentry/types';
import type { Event, EventHint, Hub, Integration, Primitive, StackParser } from '@sentry/types';
import {
addExceptionMechanism,
addInstrumentationHandler,
Expand All @@ -11,7 +11,7 @@ import {
logger,
} from '@sentry/utils';

import { BrowserClient } from '../client';
import type { BrowserClient } from '../client';
import { eventFromUnknownInput } from '../eventbuilder';
import { shouldIgnoreOnError } from '../helpers';

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/httpcontext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
import { Event, Integration } from '@sentry/types';
import type { Event, Integration } from '@sentry/types';

import { WINDOW } from '../helpers';

Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/integrations/linkederrors.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
import { Event, EventHint, Exception, ExtendedError, Integration, StackParser } from '@sentry/types';
import type { Event, EventHint, Exception, ExtendedError, Integration, StackParser } from '@sentry/types';
import { isInstanceOf } from '@sentry/utils';

import { BrowserClient } from '../client';
import type { BrowserClient } from '../client';
import { exceptionFromError } from '../eventbuilder';

const DEFAULT_KEY = 'cause';
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/trycatch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Integration, WrappedFunction } from '@sentry/types';
import type { Integration, WrappedFunction } from '@sentry/types';
import { fill, getFunctionName, getOriginalFunction } from '@sentry/utils';

import { WINDOW, wrap } from '../helpers';
Expand Down
8 changes: 5 additions & 3 deletions packages/browser/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Hub } from '@sentry/core';
import {
getCurrentHub,
getIntegrationsToSetup,
getReportDialogEndpoint,
Hub,
initAndBind,
Integrations as CoreIntegrations,
} from '@sentry/core';
Expand All @@ -14,8 +14,10 @@ import {
supportsFetch,
} from '@sentry/utils';

import { BrowserClient, BrowserClientOptions, BrowserOptions } from './client';
import { ReportDialogOptions, WINDOW, wrap as internalWrap } from './helpers';
import type { BrowserClientOptions, BrowserOptions } from './client';
import { BrowserClient } from './client';
import type { ReportDialogOptions } from './helpers';
import { WINDOW, wrap as internalWrap } from './helpers';
import { Breadcrumbs, Dedupe, GlobalHandlers, HttpContext, LinkedErrors, TryCatch } from './integrations';
import { defaultStackParser } from './stack-parsers';
import { makeFetchTransport, makeXHRTransport } from './transports';
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/stack-parsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StackFrame, StackLineParser, StackLineParserFn } from '@sentry/types';
import type { StackFrame, StackLineParser, StackLineParserFn } from '@sentry/types';
import { createStackParser } from '@sentry/utils';

// global reference to slice
Expand Down
7 changes: 4 additions & 3 deletions packages/browser/src/transports/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createTransport } from '@sentry/core';
import { Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';
import type { Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';
import { rejectedSyncPromise } from '@sentry/utils';

import { BrowserTransportOptions } from './types';
import { clearCachedFetchImplementation, FetchImpl, getNativeFetchImplementation } from './utils';
import type { BrowserTransportOptions } from './types';
import type { FetchImpl } from './utils';
import { clearCachedFetchImplementation, getNativeFetchImplementation } from './utils';

/**
* Creates a Transport that uses the Fetch API to send events to Sentry.
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/transports/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseTransportOptions } from '@sentry/types';
import type { BaseTransportOptions } from '@sentry/types';

export interface BrowserTransportOptions extends BaseTransportOptions {
/** Fetch API init parameters. Used by the FetchTransport */
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/transports/xhr.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createTransport } from '@sentry/core';
import { Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';
import type { Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';
import { SyncPromise } from '@sentry/utils';

import { BrowserTransportOptions } from './types';
import type { BrowserTransportOptions } from './types';

/**
* The DONE ready state for XmlHttpRequest
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/unit/eventbuilder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client } from '@sentry/types';
import type { Client } from '@sentry/types';

import { defaultStackParser } from '../../src';
import { eventFromPlainObject } from '../../src/eventbuilder';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createTransport } from '@sentry/core';
import { resolvedSyncPromise } from '@sentry/utils';

import { BrowserClientOptions } from '../../../src/client';
import type { BrowserClientOptions } from '../../../src/client';

export function getDefaultBrowserClientOptions(options: Partial<BrowserClientOptions> = {}): BrowserClientOptions {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/unit/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getReportDialogEndpoint, SDK_VERSION } from '@sentry/core';

import type { Event } from '../../src';
import {
addBreadcrumb,
BrowserClient,
captureEvent,
captureException,
captureMessage,
configureScope,
Event,
flush,
getCurrentHub,
init,
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/unit/integrations/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WrappedFunction } from '@sentry/types';
import type { WrappedFunction } from '@sentry/types';
import { spy } from 'sinon';

import { wrap } from '../../../src/helpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Event as SentryEvent, Exception, ExtendedError } from '@sentry/types';
import type { Event as SentryEvent, Exception, ExtendedError } from '@sentry/types';

import { BrowserClient } from '../../../src/client';
import * as LinkedErrorsModule from '../../../src/integrations/linkederrors';
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/test/unit/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { createTransport, Scope } from '@sentry/core';
import { MockIntegration } from '@sentry/core/test/lib/sdk.test';
import { Client, Integration } from '@sentry/types';
import type { Client, Integration } from '@sentry/types';
import { resolvedSyncPromise } from '@sentry/utils';

import { BrowserOptions } from '../../src';
import type { BrowserOptions } from '../../src';
import { init } from '../../src/sdk';

const PUBLIC_DSN = 'https://username@domain/123';
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/test/unit/transports/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { EventEnvelope, EventItem } from '@sentry/types';
import type { EventEnvelope, EventItem } from '@sentry/types';
import { createEnvelope, serializeEnvelope } from '@sentry/utils';
import { TextEncoder } from 'util';

import { makeFetchTransport } from '../../../src/transports/fetch';
import { BrowserTransportOptions } from '../../../src/transports/types';
import { FetchImpl } from '../../../src/transports/utils';
import type { BrowserTransportOptions } from '../../../src/transports/types';
import type { FetchImpl } from '../../../src/transports/utils';

const DEFAULT_FETCH_TRANSPORT_OPTIONS: BrowserTransportOptions = {
url: 'https://sentry.io/api/42/store/?sentry_key=123&sentry_version=7',
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/test/unit/transports/xhr.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EventEnvelope, EventItem } from '@sentry/types';
import type { EventEnvelope, EventItem } from '@sentry/types';
import { createEnvelope, serializeEnvelope } from '@sentry/utils';
import { TextEncoder } from 'util';

import { BrowserTransportOptions } from '../../../src/transports/types';
import type { BrowserTransportOptions } from '../../../src/transports/types';
import { makeXHRTransport } from '../../../src/transports/xhr';

const DEFAULT_XHR_TRANSPORT_OPTIONS: BrowserTransportOptions = {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClientOptions, DsnComponents, DsnLike, SdkInfo } from '@sentry/types';
import type { ClientOptions, DsnComponents, DsnLike, SdkInfo } from '@sentry/types';
import { dsnToString, makeDsn, urlEncode } from '@sentry/utils';

const SENTRY_API_VERSION = '7';
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-lines */
import {
import type {
Client,
ClientOptions,
DataCategory,
Expand Down Expand Up @@ -37,8 +37,9 @@ import {

import { getEnvelopeEndpointWithUrlEncodedAuth } from './api';
import { createEventEnvelope, createSessionEnvelope } from './envelope';
import { IntegrationIndex, setupIntegration, setupIntegrations } from './integration';
import { Scope } from './scope';
import type { IntegrationIndex } from './integration';
import { setupIntegration, setupIntegrations } from './integration';
import type { Scope } from './scope';
import { updateSession } from './session';
import { prepareEvent } from './utils/prepareEvent';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/envelope.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
DsnComponents,
Event,
EventEnvelope,
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/exports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Breadcrumb,
CaptureContext,
CustomSamplingContext,
Expand All @@ -13,8 +13,9 @@ import {
User,
} from '@sentry/types';

import { getCurrentHub, Hub } from './hub';
import { Scope } from './scope';
import type { Hub } from './hub';
import { getCurrentHub } from './hub';
import type { Scope } from './scope';

// Note: All functions in this file are typed with a return value of `ReturnType<Hub[HUB_FUNCTION]>`,
// where HUB_FUNCTION is some method on the Hub class.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hub.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-lines */
import {
import type {
Breadcrumb,
BreadcrumbHint,
Client,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Integration, Options } from '@sentry/types';
import type { Integration, Options } from '@sentry/types';
import { arrayify, logger } from '@sentry/utils';

import { getCurrentHub } from './hub';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/functiontostring.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Integration, WrappedFunction } from '@sentry/types';
import type { Integration, WrappedFunction } from '@sentry/types';
import { getOriginalFunction } from '@sentry/utils';

let originalFunctionToString: () => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/inboundfilters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Event, EventProcessor, Hub, Integration, StackFrame } from '@sentry/types';
import type { Event, EventProcessor, Hub, Integration, StackFrame } from '@sentry/types';
import { getEventDescription, logger, stringMatchesSomePattern } from '@sentry/utils';

// "Script error." is hard coded into browsers for errors that it can't read.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/scope.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-lines */
import {
import type {
Attachment,
Breadcrumb,
CaptureContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, ClientOptions } from '@sentry/types';
import type { Client, ClientOptions } from '@sentry/types';
import { logger } from '@sentry/utils';

import { getCurrentHub } from './hub';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SerializedSession, Session, SessionContext, SessionStatus } from '@sentry/types';
import type { SerializedSession, Session, SessionContext, SessionStatus } from '@sentry/types';
import { dropUndefinedKeys, timestampInSeconds, uuid4 } from '@sentry/utils';

/**
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/sessionflusher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { AggregationCounts, Client, RequestSessionStatus, SessionAggregates, SessionFlusherLike } from '@sentry/types';
import type {
AggregationCounts,
Client,
RequestSessionStatus,
SessionAggregates,
SessionFlusherLike,
} from '@sentry/types';
import { dropUndefinedKeys } from '@sentry/utils';

import { getCurrentHub } from './hub';
Expand Down
Loading

0 comments on commit 2aa4e94

Please sign in to comment.