Skip to content

Commit

Permalink
chore: add 'prettier' + 'simple-import-sort' linting rules (#169)
Browse files Browse the repository at this point in the history
Only apply linting fixes
  • Loading branch information
wrn14897 authored Jul 22, 2024
1 parent 6472326 commit 5ddd5dd
Show file tree
Hide file tree
Showing 60 changed files with 256 additions and 176 deletions.
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
"prepare": "husky install"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
"**/*.{ts,tsx}": [
"prettier --write --ignore-unknown",
"eslint --fix"
],
"**/*.{json,yml}": [
"prettier --write --ignore-unknown"
]
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
Expand All @@ -29,13 +35,15 @@
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
"lint-staged": "^13.2.2",
"nx": "^15.9.2",
"prettier": "^2.8.7",
"prettier": "^3.3.3",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
Expand Down
13 changes: 6 additions & 7 deletions packages/browser/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
"sourceType": "module",
"ecmaVersion": 2020
},
"plugins": ["@typescript-eslint", "jest"],
"plugins": ["@typescript-eslint", "jest", "prettier", "simple-import-sort"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"prettier"
"plugin:prettier/recommended"
],
"rules": {
// The following rule is enabled only to supplement the inline suppression
// examples, and because it is not a recommended rule, you should either
// disable it, or understand what it enforces.
// https://typescript-eslint.io/rules/explicit-function-return-type/
"@typescript-eslint/explicit-function-return-type": "warn"
"@typescript-eslint/explicit-function-return-type": "warn",
"prettier/prettier": "error",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error"
}
}
3 changes: 1 addition & 2 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { RumOtelWebConfig } from '@hyperdx/otel-web';
import Rum from '@hyperdx/otel-web';
import SessionRecorder from '@hyperdx/otel-web-session-recorder';
import opentelemetry, { Attributes } from '@opentelemetry/api';

import { resolveAsyncGlobal } from './utils';

import type { RumOtelWebConfig } from '@hyperdx/otel-web';

type ErrorBoundaryComponent = any; // TODO: Define ErrorBoundary type

type Instrumentations = RumOtelWebConfig['instrumentations'];
Expand Down
13 changes: 6 additions & 7 deletions packages/instrumentation-exception/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@
"sourceType": "module",
"ecmaVersion": 2020
},
"plugins": ["@typescript-eslint", "jest"],
"plugins": ["@typescript-eslint", "jest", "prettier", "simple-import-sort"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"prettier"
"plugin:prettier/recommended"
],
"rules": {
// The following rule is enabled only to supplement the inline suppression
// examples, and because it is not a recommended rule, you should either
// disable it, or understand what it enforces.
// https://typescript-eslint.io/rules/explicit-function-return-type/
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-this-alias": "warn"
"@typescript-eslint/no-this-alias": "warn",
"prettier/prettier": "error",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ function eventFromPlainObject(
type: isEvent(exception)
? exception.constructor.name
: isUnhandledRejection
? 'UnhandledRejection'
: 'Error',
? 'UnhandledRejection'
: 'Error',
value: getNonErrorObjectExceptionValue(exception, {
isUnhandledRejection,
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-exception/src/browser/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { captureException, withScope } from '@sentry/core';
import type { Mechanism, WrappedFunction } from '@sentry/types';
import {
GLOBAL_OBJ,
addExceptionMechanism,
addExceptionTypeValue,
addNonEnumerableProperty,
getOriginalFunction,
GLOBAL_OBJ,
markFunctionWrapped,
} from '@sentry/utils';

Expand Down
12 changes: 6 additions & 6 deletions packages/instrumentation-exception/src/browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import type { ClientOptions, Event, EventHint } from '@sentry/types';
import { getEventProcessor } from '@hyperdx/instrumentation-sentry-node';
import { Attributes, diag, Span, trace, Tracer } from '@opentelemetry/api';
import {
dedupeIntegration,
functionToStringIntegration,
inboundFiltersIntegration,
prepareEvent,
} from '@sentry/core';
import { Attributes, Span, Tracer, diag, trace } from '@opentelemetry/api';
import { getEventProcessor } from '@hyperdx/instrumentation-sentry-node';
import type { ClientOptions, Event, EventHint } from '@sentry/types';

import { name as PKG_NAME, version as PKG_VERSION } from '../../package.json';
import { eventFromUnknownInput } from './eventbuilder';
import { browserApiErrorsIntegration } from './integrations/browserapierrors';
import { contextLinesIntegration } from './integrations/contextlines';
import { defaultStackParser } from './stack-parsers';
import { eventFromUnknownInput } from './eventbuilder';
import { globalHandlersIntegration } from './integrations/globalhandlers';
import { httpContextIntegration } from './integrations/httpcontext';
import { hyperdxIntegration } from './integrations/hyperdx';
import { linkedErrorsIntegration } from './integrations/linkederrors';
import { name as PKG_NAME, version as PKG_VERSION } from '../../package.json';
import { defaultStackParser } from './stack-parsers';

// TODO: does it make sense to have a default tracer here?
const defaultTracer = trace.getTracer(PKG_NAME, PKG_VERSION);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as shimmer from 'shimmer';
import { Span } from '@opentelemetry/api';
import {
InstrumentationBase,
InstrumentationConfig,
} from '@opentelemetry/instrumentation';
import * as shimmer from 'shimmer';

import { recordException } from '../';
import { limitLen, getElementXPath } from './utils';
import { getElementXPath, limitLen } from './utils';

// FIXME take timestamps from events?

Expand Down Expand Up @@ -109,8 +109,8 @@ export class HyperDXErrorInstrumentation extends InstrumentationBase {
useful(err.name)
? err.name
: err.constructor && err.constructor.name
? err.constructor.name
: 'Error',
? err.constructor.name
: 'Error',
);
span.setAttribute('error.message', limitLen(msg, MESSAGE_LIMIT));
addStackIfUseful(span, err);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineIntegration } from '@sentry/core';
import type { Event, IntegrationFn, StackFrame } from '@sentry/types';
import {
GLOBAL_OBJ,
addContextToFrame,
GLOBAL_OBJ,
stripUrlQueryAndFragment,
} from '@sentry/utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { captureEvent, defineIntegration, getClient } from '@sentry/core';
import { diag } from '@opentelemetry/api';
import { captureEvent, defineIntegration, getClient } from '@sentry/core';
import type {
Client,
Event,
Expand All @@ -8,12 +8,12 @@ import type {
StackParser,
} from '@sentry/types';
import {
UNKNOWN_FUNCTION,
addGlobalErrorInstrumentationHandler,
addGlobalUnhandledRejectionInstrumentationHandler,
getLocationHref,
isPrimitive,
isString,
UNKNOWN_FUNCTION,
} from '@sentry/utils';

import { eventFromUnknownInput } from '../eventbuilder';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineIntegration } from '@sentry/core';

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

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Event, IntegrationFn, StackFrame } from '@sentry/types';
import { defineIntegration } from '@sentry/core';
import type { Event, IntegrationFn, StackFrame } from '@sentry/types';

const INTEGRATION_NAME = 'HyperDX';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineIntegration } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';
import { applyAggregateErrorsToEvent } from '@sentry/utils';

import { exceptionFromError } from '../eventbuilder';

interface LinkedErrorsOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type {
StackLineParser,
StackLineParserFn,
} from '@sentry/types';
import { UNKNOWN_FUNCTION, createStackParser } from '@sentry/utils';
import { createStackParser, UNKNOWN_FUNCTION } from '@sentry/utils';

const OPERA10_PRIORITY = 10;
const OPERA11_PRIORITY = 20;
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-exception/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { recordException } from './node';
export * from './instrumentation';
export { recordException } from './node';
export * from './types';

// error handlers
Expand Down
4 changes: 2 additions & 2 deletions packages/instrumentation-exception/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { diag, trace, TracerProvider } from '@opentelemetry/api';
import { InstrumentationBase } from '@opentelemetry/instrumentation';
import { TracerProvider, diag, trace } from '@opentelemetry/api';

import { ExceptionInstrumentationConfig } from './types';
import { name as PKG_NAME, version as PKG_VERSION } from '../package.json';
import { onUncaughtExceptionIntegration } from './node/integrations/onuncaughtexception';
import { onUnhandledRejectionIntegration } from './node/integrations/onunhandledrejection';
import { ExceptionInstrumentationConfig } from './types';

/** Exception instrumentation for OpenTelemetry */
export class ExceptionInstrumentation extends InstrumentationBase {
Expand Down
14 changes: 7 additions & 7 deletions packages/instrumentation-exception/src/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { getEventProcessor } from '@hyperdx/instrumentation-sentry-node';
import { Attributes, diag, Span, trace, Tracer } from '@opentelemetry/api';
import { inboundFiltersIntegration, prepareEvent } from '@sentry/core';
import type {
Client,
ClientOptions,
Event,
EventHint,
Integration,
} from '@sentry/types';
import { inboundFiltersIntegration, prepareEvent } from '@sentry/core';
import { Attributes, Span, Tracer, diag, trace } from '@opentelemetry/api';
import { eventFromUnknownInput } from '@sentry/utils';
import { getEventProcessor } from '@hyperdx/instrumentation-sentry-node';

import { name as PKG_NAME, version as PKG_VERSION } from '../../package.json';
import { nodeContextIntegration } from './integrations/context';
import { contextLinesIntegration } from './integrations/contextlines';
import { defaultStackParser } from './sdk/api';
import { hyperdxIntegration } from './integrations/hyperdx';
import { isCjs } from './utils/commonjs';
import { localVariablesIntegration } from './integrations/local-variables';
import { modulesIntegration } from './integrations/modules';
import { nodeContextIntegration } from './integrations/context';
import { name as PKG_NAME, version as PKG_VERSION } from '../../package.json';
import { defaultStackParser } from './sdk/api';
import { isCjs } from './utils/commonjs';

// TODO: does it make sense to have a default tracer here?
const defaultTracer = trace.getTracer(PKG_NAME, PKG_VERSION);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable max-lines */
import { execFile } from 'node:child_process';
import { readFile, readdir } from 'node:fs';
import { readdir, readFile } from 'node:fs';
import * as os from 'node:os';
import { join } from 'node:path';
import { promisify } from 'node:util';

import { defineIntegration } from '@sentry/core';
import type {
AppContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { promises } from 'node:fs';

import { defineIntegration } from '@sentry/core';
import type { Event, IntegrationFn, StackFrame } from '@sentry/types';
import { LRUMap, addContextToFrame } from '@sentry/utils';
import { addContextToFrame, LRUMap } from '@sentry/utils';

const FILE_CONTENT_CACHE = new LRUMap<string, string[] | null>(100);
const DEFAULT_LINES_OF_CONTEXT = 7;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Event, IntegrationFn } from '@sentry/types';
import { defineIntegration } from '@sentry/core';
import type { Event, IntegrationFn } from '@sentry/types';

import { getSentryRelease } from '../sdk/api';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Debugger } from 'node:inspector';

import type { StackFrame, StackParser } from '@sentry/types';

export type Variables = Record<string, unknown>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Integration } from '@sentry/types';

import { NODE_VERSION } from '../../nodeVersion';
import type { LocalVariablesIntegrationOptions } from './common';
import { localVariablesAsyncIntegration } from './local-variables-async';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Worker } from 'node:worker_threads';

import { defineIntegration } from '@sentry/core';
import type { Event, Exception, IntegrationFn } from '@sentry/types';
import { LRUMap, logger } from '@sentry/utils';
import { logger, LRUMap } from '@sentry/utils';

import type {
FrameVariables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import type {
Runtime,
Session,
} from 'node:inspector';

import { defineIntegration } from '@sentry/core';
import type {
Event,
Exception,
IntegrationFn,
StackParser,
} from '@sentry/types';
import { LRUMap, logger } from '@sentry/utils';
import { logger, LRUMap } from '@sentry/utils';

import { NODE_MAJOR } from '../../nodeVersion';
import { defaultStackParser } from '../../sdk/api';
import type {
FrameVariables,
LocalVariablesIntegrationOptions,
Expand All @@ -27,7 +29,6 @@ import {
hashFrames,
hashFromStack,
} from './common';
import { defaultStackParser } from '../../sdk/api';

type OnPauseEvent = InspectorNotification<Debugger.PausedEventDataType>;
export interface DebugSession {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Debugger, InspectorNotification, Runtime } from 'node:inspector';
import { Session } from 'node:inspector/promises';
import { parentPort, workerData } from 'node:worker_threads';

import type { StackParser } from '@sentry/types';
import { createStackParser, nodeStackLineParser } from '@sentry/utils';

import { createGetModuleFromFilename } from '../../utils/module';
import type {
LocalVariablesWorkerArgs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync, readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';

import { defineIntegration } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineIntegration } from '@sentry/core';
import { diag } from '@opentelemetry/api';
import { defineIntegration } from '@sentry/core';

import { logAndExitProcess } from '../utils/errorhandling';
import { recordException } from '..';
import { logAndExitProcess } from '../utils/errorhandling';

type OnFatalErrorHandler = typeof logAndExitProcess;

Expand Down
Loading

0 comments on commit 5ddd5dd

Please sign in to comment.