Skip to content

Commit d54b6f5

Browse files
committed
feat: apply rule @typescript-eslint/explicit-member-accessibility
1 parent cf80246 commit d54b6f5

File tree

28 files changed

+106
-93
lines changed

28 files changed

+106
-93
lines changed

eslint.config.mjs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ const baseConfig = tseslint.config(
156156
'@typescript-eslint/no-empty-function': ['off'],
157157
'@typescript-eslint/no-shadow': ['warn'],
158158
'prefer-rest-params': 'off',
159+
'@typescript-eslint/explicit-member-accessibility': ['error', {
160+
overrides: {
161+
// `constructor` is public by default.
162+
'constructors': 'no-public',
163+
},
164+
}],
159165
},
160166
},
161167

@@ -184,6 +190,7 @@ const baseConfig = tseslint.config(
184190
'warn',
185191
{ argsIgnorePattern: '^_' },
186192
],
193+
'@typescript-eslint/explicit-member-accessibility': 'off',
187194
'no-empty': 'off',
188195
},
189196
},
@@ -213,7 +220,17 @@ const baseConfig = tseslint.config(
213220
Task: 'readonly',
214221
},
215222
},
216-
}
223+
},
224+
225+
// Gradual adoption of explicit-member-accessibility
226+
{
227+
files: [
228+
'**/packages/instrumentation-*/**',
229+
],
230+
rules: {
231+
'@typescript-eslint/explicit-member-accessibility': 'off',
232+
},
233+
},
217234
);
218235

219236
export default baseConfig;

packages/baggage-log-record-processor/src/baggage-log-record-processor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class BaggageLogRecordProcessor implements LogRecordProcessor {
4444
/**
4545
* Forces to export all finished log records.
4646
*/
47-
forceFlush(): Promise<void> {
47+
public forceFlush(): Promise<void> {
4848
// no-op
4949
return Promise.resolve();
5050
}
@@ -54,7 +54,7 @@ export class BaggageLogRecordProcessor implements LogRecordProcessor {
5454
* @param logRecord the ReadWriteLogRecord that just emitted.
5555
* @param context the current Context, or an empty Context if the Logger was obtained with include_trace_context=false
5656
*/
57-
onEmit(logRecord: SdkLogRecord, context?: Context): void {
57+
public onEmit(logRecord: SdkLogRecord, context?: Context): void {
5858
if (context) {
5959
(propagation.getBaggage(context)?.getAllEntries() ?? [])
6060
.filter(entry => this._keyPredicate(entry[0]))
@@ -66,7 +66,7 @@ export class BaggageLogRecordProcessor implements LogRecordProcessor {
6666
* Shuts down the processor. Called when SDK is shut down. This is an
6767
* opportunity for processor to do any cleanup required.
6868
*/
69-
shutdown(): Promise<void> {
69+
public shutdown(): Promise<void> {
7070
// no-op
7171
return Promise.resolve();
7272
}

packages/baggage-span-processor/src/baggage-span-processor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class BaggageSpanProcessor implements SpanProcessor {
5757
/**
5858
* Forces to export all finished spans
5959
*/
60-
forceFlush(): Promise<void> {
60+
public forceFlush(): Promise<void> {
6161
// no-op
6262
return Promise.resolve();
6363
}
@@ -67,7 +67,7 @@ export class BaggageSpanProcessor implements SpanProcessor {
6767
* returns true.
6868
* @param span the Span that just started.
6969
*/
70-
onStart(span: Span, parentContext: Context): void {
70+
public onStart(span: Span, parentContext: Context): void {
7171
(propagation.getBaggage(parentContext)?.getAllEntries() ?? [])
7272
.filter(entry => this._keyPredicate(entry[0]))
7373
.forEach(entry => span.setAttribute(entry[0], entry[1].value));
@@ -78,15 +78,15 @@ export class BaggageSpanProcessor implements SpanProcessor {
7878
* returns true.
7979
* @param span the Span that just ended.
8080
*/
81-
onEnd(_: ReadableSpan): void {
81+
public onEnd(_: ReadableSpan): void {
8282
// no-op
8383
}
8484

8585
/**
8686
* Shuts down the processor. Called when SDK is shut down. This is an
8787
* opportunity for processor to do any cleanup required.
8888
*/
89-
shutdown(): Promise<void> {
89+
public shutdown(): Promise<void> {
9090
// no-op
9191
return Promise.resolve();
9292
}

packages/contrib-test-utils/src/test-fixtures.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ export type TestSpan = ISpan & {
6767
* There is little error checking here; we are assuming valid OTLP.
6868
*/
6969
export class TestCollector {
70-
endpointUrl?: string;
71-
spans: Array<TestSpan> = [];
70+
public endpointUrl?: string;
71+
public spans: Array<TestSpan> = [];
7272
private _http;
7373

7474
constructor() {
7575
this.clear();
7676
this._http = createServer(this._onRequest.bind(this));
7777
}
7878

79-
clear(): void {
79+
public clear(): void {
8080
this.spans = [];
8181
}
8282

8383
// Start listening and set address to `endpointUrl`.
84-
async start(): Promise<void> {
84+
public async start(): Promise<void> {
8585
return new Promise(resolve => {
8686
this._http.listen(() => {
8787
this.endpointUrl = `http://localhost:${
@@ -92,7 +92,7 @@ export class TestCollector {
9292
});
9393
}
9494

95-
close() {
95+
public close() {
9696
this.endpointUrl = undefined;
9797
return this._http.close();
9898
}
@@ -106,7 +106,7 @@ export class TestCollector {
106106
* same, this attempts to get the correct ordering using `parentSpanId` -- a
107107
* parent span starts before any of its direct children. This isn't perfect.
108108
*/
109-
get sortedSpans(): Array<TestSpan> {
109+
public get sortedSpans(): Array<TestSpan> {
110110
return this.spans.slice().sort((a, b) => {
111111
assert(typeof a.startTimeUnixNano === 'string');
112112
assert(typeof b.startTimeUnixNano === 'string');
@@ -132,7 +132,7 @@ export class TestCollector {
132132
});
133133
}
134134

135-
_onRequest(req: IncomingMessage, res: ServerResponse) {
135+
private _onRequest(req: IncomingMessage, res: ServerResponse) {
136136
const parsedUrl = new URL(req.url as string, this.endpointUrl);
137137
let instream: EventEmitter;
138138
if (req.headers['content-encoding'] === 'gzip') {
@@ -171,7 +171,7 @@ export class TestCollector {
171171
});
172172
}
173173

174-
_ingestTraces(body: string) {
174+
private _ingestTraces(body: string) {
175175
const data = JSON.parse(body);
176176
// Read an OTLP `resourceSpans` body into `this.spans`.
177177
for (const resourceSpan of data.resourceSpans) {

packages/host-metrics/src/metric.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export class HostMetrics extends BaseMetrics {
334334
/**
335335
* Starts collecting metrics
336336
*/
337-
start() {
337+
public start() {
338338
this._createMetrics();
339339
}
340340

packages/id-generator-aws-xray/src/platform/browser/AWSXRayIdGenerator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ export class AWSXRayIdGenerator implements IdGenerator {
3232
* characters corresponding to 128 bits. The first 4 bytes correspond to the current
3333
* time, in seconds, as per X-Ray trace ID format.
3434
*/
35-
generateTraceId(): string {
35+
public generateTraceId(): string {
3636
return generateTraceId(generateRandomBytes);
3737
}
3838

3939
/**
4040
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
4141
* characters corresponding to 64 bits.
4242
*/
43-
generateSpanId(): string {
43+
public generateSpanId(): string {
4444
return generateSpanId(generateRandomBytes);
4545
}
4646
}

packages/id-generator-aws-xray/src/platform/node/AWSXRayIdGenerator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ export class AWSXRayIdGenerator implements IdGenerator {
3232
* characters corresponding to 128 bits. The first 4 bytes correspond to the current
3333
* time, in seconds, as per X-Ray trace ID format.
3434
*/
35-
generateTraceId(): string {
35+
public generateTraceId(): string {
3636
return generateTraceId(generateRandomBytes);
3737
}
3838

3939
/**
4040
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
4141
* characters corresponding to 64 bits.
4242
*/
43-
generateSpanId(): string {
43+
public generateSpanId(): string {
4444
return generateSpanId(generateRandomBytes);
4545
}
4646
}

packages/plugin-react-load/src/BaseOpenTelemetryComponent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import {
3636
* This class is the base component for a React component with lifecycle instrumentation
3737
*/
3838
export class BaseOpenTelemetryComponent extends React.Component {
39-
readonly component: string = 'react-load';
40-
moduleName = this.component;
39+
private readonly component: string = 'react-load';
40+
private moduleName = this.component;
4141
private _parentSpanMap: WeakMap<React.Component, api.Span>;
4242
private static _tracer: api.Tracer;
4343
private static _logger: api.DiagLogger = api.diag;
@@ -56,7 +56,7 @@ export class BaseOpenTelemetryComponent extends React.Component {
5656
* @param name Name of tracer
5757
* @param version Version of tracer, this is optional. When not provided it will use the latest.
5858
*/
59-
static setTracer(name: string, version?: string): void {
59+
public static setTracer(name: string, version?: string): void {
6060
BaseOpenTelemetryComponent._tracer = api.trace.getTracer(
6161
name,
6262
version ? version : PACKAGE_VERSION
@@ -67,7 +67,7 @@ export class BaseOpenTelemetryComponent extends React.Component {
6767
* Sets the logger for all components being instrumented
6868
* @param logger
6969
*/
70-
static setLogger(logger: api.DiagLogger): void {
70+
public static setLogger(logger: api.DiagLogger): void {
7171
api.diag.setLogger(logger);
7272
BaseOpenTelemetryComponent._logger = logger;
7373
}

packages/propagator-aws-xray-lambda/src/AWSXRayLambdaPropagator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ export const AWSXRAY_TRACE_ID_ENV_VAR = '_X_AMZN_TRACE_ID';
4040
export class AWSXRayLambdaPropagator implements TextMapPropagator {
4141
private _awsXrayPropagator = new AWSXRayPropagator();
4242

43-
inject(context: Context, carrier: unknown, setter: TextMapSetter) {
43+
public inject(context: Context, carrier: unknown, setter: TextMapSetter) {
4444
this._awsXrayPropagator.inject(context, carrier, setter);
4545
}
4646

47-
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {
47+
public extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {
4848
const xrayContext = this._awsXrayPropagator.extract(
4949
context,
5050
carrier,
@@ -68,7 +68,7 @@ export class AWSXRayLambdaPropagator implements TextMapPropagator {
6868
);
6969
}
7070

71-
fields(): string[] {
71+
public fields(): string[] {
7272
return this._awsXrayPropagator.fields();
7373
}
7474
}

packages/propagator-aws-xray/src/AWSXRayPropagator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const NOT_SAMPLED = '0';
5858
* X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1
5959
*/
6060
export class AWSXRayPropagator implements TextMapPropagator {
61-
inject(context: Context, carrier: unknown, setter: TextMapSetter) {
61+
public inject(context: Context, carrier: unknown, setter: TextMapSetter) {
6262
const spanContext = trace.getSpan(context)?.spanContext();
6363
if (!spanContext || !isSpanContextValid(spanContext)) return;
6464

@@ -77,7 +77,7 @@ export class AWSXRayPropagator implements TextMapPropagator {
7777
setter.set(carrier, AWSXRAY_TRACE_ID_HEADER, traceHeader);
7878
}
7979

80-
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {
80+
public extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {
8181
const spanContext = this.getSpanContextFromHeader(carrier, getter);
8282
if (!isSpanContextValid(spanContext)) return context;
8383

@@ -90,7 +90,7 @@ export class AWSXRayPropagator implements TextMapPropagator {
9090
return trace.setSpan(context, trace.wrapSpanContext(spanContext));
9191
}
9292

93-
fields(): string[] {
93+
public fields(): string[] {
9494
return [AWSXRAY_TRACE_ID_HEADER];
9595
}
9696

0 commit comments

Comments
 (0)