Skip to content

Commit

Permalink
chore: enable @typescript-eslint/member-ordering rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Joozty committed Nov 6, 2024
1 parent 9b3e3f1 commit e15f6b0
Show file tree
Hide file tree
Showing 28 changed files with 1,020 additions and 1,015 deletions.
147 changes: 73 additions & 74 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,80 +82,79 @@ export default [
],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
// '@typescript-eslint/member-ordering': [
// 'error',
// {
// default: {
// memberTypes: [
// // Index signature
// 'signature',
//
// // Fields
// 'public-static-field',
// 'protected-static-field',
// 'private-static-field',
//
// 'public-decorated-field',
// 'protected-decorated-field',
// 'private-decorated-field',
//
// 'public-instance-field',
// 'protected-instance-field',
// 'private-instance-field',
//
// 'public-abstract-field',
// 'protected-abstract-field',
//
// 'public-field',
// 'protected-field',
// 'private-field',
//
// 'static-field',
// 'instance-field',
// 'abstract-field',
//
// 'decorated-field',
//
// 'field',
//
// // Constructors
// 'public-constructor',
// 'protected-constructor',
// 'private-constructor',
//
// 'constructor',
//
// // Methods
// 'public-decorated-method',
// 'public-static-method',
// 'public-instance-method',
// 'protected-decorated-method',
// 'protected-static-method',
// 'protected-instance-method',
// 'private-decorated-method',
// 'private-static-method',
// 'private-instance-method',
//
// 'public-abstract-method',
// 'protected-abstract-method',
//
// 'public-method',
// 'protected-method',
// 'private-method',
//
// 'static-method',
// 'instance-method',
// 'abstract-method',
//
// 'decorated-method',
//
// 'method',
// ],
// order: 'alphabetically',
// },
// },
// ],
'@typescript-eslint/member-ordering': 'off', // TODO: temporarily disabled
'@typescript-eslint/member-ordering': [
'error',
{
default: {
memberTypes: [
// Index signature
'signature',

// Fields
'public-static-field',
'protected-static-field',
'private-static-field',

'public-decorated-field',
'protected-decorated-field',
'private-decorated-field',

'public-instance-field',
'protected-instance-field',
'private-instance-field',

'public-abstract-field',
'protected-abstract-field',

'public-field',
'protected-field',
'private-field',

'static-field',
'instance-field',
'abstract-field',

'decorated-field',

'field',

// Constructors
'public-constructor',
'protected-constructor',
'private-constructor',

'constructor',

// Methods
'public-decorated-method',
'public-static-method',
'public-instance-method',
'protected-decorated-method',
'protected-static-method',
'protected-instance-method',
'private-decorated-method',
'private-static-method',
'private-instance-method',

'public-abstract-method',
'protected-abstract-method',

'public-method',
'protected-method',
'private-method',

'static-method',
'instance-method',
'abstract-method',

'decorated-method',

'method',
],
order: 'alphabetically',
},
},
],
'@typescript-eslint/naming-convention': ['error', { format: ['UPPER_CASE'], selector: ['enumMember'] }],
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-empty-interface': 'off',
Expand Down
26 changes: 13 additions & 13 deletions packages/session-recorder/src/BatchLogProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ export interface BatchLogProcessorConfig {
}

export class BatchLogProcessor {
private logs: Log[] = []
exporter: LogExporter

lastBatchSent: number

scheduledDelayMillis: number

timeout: NodeJS.Timeout | undefined

exporter: LogExporter

lastBatchSent: number
private logs: Log[] = []

constructor(exporter: LogExporter, config: BatchLogProcessorConfig) {
this.scheduledDelayMillis = config?.scheduledDelayMillis || 5000
Expand All @@ -45,6 +45,15 @@ export class BatchLogProcessor {
})
}

_flushAll(): void {
this.lastBatchSent = Date.now()

context.with(suppressTracing(context.active()), () => {
const logsToExport = this.logs.splice(0, this.logs.length)
this.exporter.export(logsToExport)
})
}

onLog(log: Log): void {
this.logs.push(log)

Expand All @@ -55,15 +64,6 @@ export class BatchLogProcessor {
}, this.scheduledDelayMillis)
}
}

_flushAll(): void {
this.lastBatchSent = Date.now()

context.with(suppressTracing(context.active()), () => {
const logsToExport = this.logs.splice(0, this.logs.length)
this.exporter.export(logsToExport)
})
}
}

export function convert(body: JsonValue, timeUnixNano: number, attributes?: JsonObject): Log {
Expand Down
4 changes: 2 additions & 2 deletions packages/session-recorder/src/OTLPLogExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import { IAnyValue, Log } from './types'
import { VERSION } from './version.js'

interface OTLPLogExporterConfig {
headers?: Record<string, string>
beaconUrl: string
getResourceAttributes: () => JsonObject
debug?: boolean
getResourceAttributes: () => JsonObject
headers?: Record<string, string>
}

const defaultHeaders = {
Expand Down
16 changes: 8 additions & 8 deletions packages/session-recorder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ interface BasicTracerProvider extends TracerProvider {
type RRWebOptions = Parameters<typeof record>[0]

export type SplunkRumRecorderConfig = RRWebOptions & {
/**
* @deprecated Use RUM token in rumAccessToken
*/
apiToken?: string

/** Destination for the captured data */
beaconEndpoint?: string

Expand All @@ -41,6 +46,9 @@ export type SplunkRumRecorderConfig = RRWebOptions & {
*/
beaconUrl?: string

/** Debug mode */
debug?: boolean

/**
* The name of your organization’s realm. Automatically configures beaconUrl with correct URL
*/
Expand All @@ -58,14 +66,6 @@ export type SplunkRumRecorderConfig = RRWebOptions & {
* @deprecated Renamed to `rumAccessToken`
**/
rumAuth?: string

/**
* @deprecated Use RUM token in rumAccessToken
*/
apiToken?: string

/** Debug mode */
debug?: boolean
}

function migrateConfigOption(
Expand Down
20 changes: 10 additions & 10 deletions packages/session-recorder/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import type { JsonObject, JsonValue } from 'type-fest'

export interface Log {
attributes?: JsonObject
body?: JsonValue
timeUnixNano: number
attributes?: JsonObject
}

export interface LogExporter {
Expand All @@ -36,28 +36,28 @@ export interface LogExporter {

// OTLP Logs Interfaces
export interface IAnyValue {
/** AnyValue stringValue */
stringValue?: string | null
/** AnyValue arrayValue */

arrayValue?: IArrayValue | null

/** AnyValue boolValue */
boolValue?: boolean | null

/** AnyValue intValue */
intValue?: number | null
/** AnyValue bytesValue */
bytesValue?: Uint8Array | null

/** AnyValue doubleValue */
doubleValue?: number | null

/** AnyValue arrayValue */

arrayValue?: IArrayValue | null
/** AnyValue intValue */
intValue?: number | null

/** AnyValue kvlistValue */

kvlistValue?: IKeyValueList | null

/** AnyValue bytesValue */
bytesValue?: Uint8Array | null
/** AnyValue stringValue */
stringValue?: string | null
}

export interface IArrayValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,40 @@
const { Transform } = require('stream')

exports.HtmlInjectorTransform = class HtmlInjectorTransform extends Transform {
__scriptInjected = false

__wordIdx = 0
__content = []

__contentIdx = 0

__content = []
__scriptInjected = false

__wordIdx = 0

constructor({ matchingSuffix, contentToInject }) {
super()
this.__word = matchingSuffix
this.__injectable = contentToInject
}

__runPartialOnlineMatch() {
while (true) {
if (this.__contentIdx === this.__content.length) {
return false
} else if (this.__wordIdx === this.__word.length) {
return true
} else if (this.__contentIdx + this.__wordIdx === this.__content.length) {
return false
} else if (this.__content[this.__contentIdx + this.__wordIdx] === this.__word[this.__wordIdx]) {
this.__wordIdx += 1
} else if (this.__wordIdx === 0) {
this.__contentIdx += 1
} else {
// TODO: speed up using KMP failure function
this.__wordIdx = 0
this.__contentIdx += 1
}
}
}

_transform(chunk, enc, callback) {
if (this.__scriptInjected) {
this.push(chunk)
Expand Down Expand Up @@ -63,24 +83,4 @@ exports.HtmlInjectorTransform = class HtmlInjectorTransform extends Transform {
callback()
}
}

__runPartialOnlineMatch() {
while (true) {
if (this.__contentIdx === this.__content.length) {
return false
} else if (this.__wordIdx === this.__word.length) {
return true
} else if (this.__contentIdx + this.__wordIdx === this.__content.length) {
return false
} else if (this.__content[this.__contentIdx + this.__wordIdx] === this.__word[this.__wordIdx]) {
this.__wordIdx += 1
} else if (this.__wordIdx === 0) {
this.__contentIdx += 1
} else {
// TODO: speed up using KMP failure function
this.__wordIdx = 0
this.__contentIdx += 1
}
}
}
}
Loading

0 comments on commit e15f6b0

Please sign in to comment.