Skip to content

Commit f650a15

Browse files
committed
feat(eslint): Make class member accessibility explicit
Add @typescript-eslint/explicit-member-accessibility rule to make sure class members declarations have explicit accessibility (public, private, protected).
1 parent 6c5cd37 commit f650a15

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

packages/browser/src/transports/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class FetchTransport extends BaseTransport {
8181
*/
8282
private _fetch: typeof fetch;
8383

84-
constructor(options: TransportOptions, fetchImpl: FetchImpl = getNativeFetchImplementation()) {
84+
public constructor(options: TransportOptions, fetchImpl: FetchImpl = getNativeFetchImplementation()) {
8585
super(options);
8686
this._fetch = fetchImpl;
8787
}

packages/eslint-config-sdk/src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ module.exports = {
104104
// instead of any. This is especially important for methods that expose a public API, as users
105105
// should know exactly what they have to provide to use those methods. Turned off in tests.
106106
'@typescript-eslint/no-unsafe-member-access': 'error',
107+
108+
// Be explicit about class member accessibility (public, private, protected). Turned off
109+
// on tests for ease of use.
110+
'@typescript-eslint/explicit-member-accessibility': ['error'],
107111
},
108112
},
109113
{
@@ -140,6 +144,7 @@ module.exports = {
140144
'no-unused-expressions': 'off',
141145
'@typescript-eslint/no-unused-expressions': 'off',
142146
'@typescript-eslint/no-unsafe-member-access': 'off',
147+
'@typescript-eslint/explicit-member-accessibility': 'off',
143148
},
144149
},
145150
{

packages/gatsby/test/integration.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { render } from '@testing-library/react';
33
import { useEffect } from 'react';
4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45
import * as React from 'react';
56

67
import { onClientEntry } from '../gatsby-browser';

packages/hub/src/session.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export class Session implements SessionInterface {
1818
public ipAddress?: string;
1919
public init: boolean = true;
2020

21-
constructor(context?: Omit<SessionContext, 'started' | 'status'>) {
21+
public constructor(context?: Omit<SessionContext, 'started' | 'status'>) {
2222
if (context) {
2323
this.update(context);
2424
}
2525
}
2626

2727
/** JSDoc */
2828
// eslint-disable-next-line complexity
29-
update(context: SessionContext = {}): void {
29+
public update(context: SessionContext = {}): void {
3030
if (context.user) {
3131
if (context.user.ip_address) {
3232
this.ipAddress = context.user.ip_address;
@@ -78,7 +78,7 @@ export class Session implements SessionInterface {
7878
}
7979

8080
/** JSDoc */
81-
close(status?: Exclude<SessionStatus, SessionStatus.Ok>): void {
81+
public close(status?: Exclude<SessionStatus, SessionStatus.Ok>): void {
8282
if (status) {
8383
this.update({ status });
8484
} else if (this.status === SessionStatus.Ok) {
@@ -89,7 +89,7 @@ export class Session implements SessionInterface {
8989
}
9090

9191
/** JSDoc */
92-
toJSON(): {
92+
public toJSON(): {
9393
init: boolean;
9494
sid: string;
9595
did?: string;

packages/nextjs/src/utils/metadataBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class MetadataBuilder {
1313
private _options: NextjsOptions;
1414
private _packageNames: string[];
1515

16-
constructor(options: NextjsOptions, packages: string[]) {
16+
public constructor(options: NextjsOptions, packages: string[]) {
1717
this._options = options;
1818
this._packageNames = packages;
1919
}

packages/tracing/test/integrations/mongo.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class Collection {
1010
public namespace: string = 'mockedNamespace';
1111

1212
// Method that can have a callback as last argument, or return a promise otherwise.
13-
insertOne(_doc: unknown, _options: unknown, callback?: () => void) {
13+
public insertOne(_doc: unknown, _options: unknown, callback?: () => void) {
1414
if (typeof callback === 'function') {
1515
callback();
1616
return;
1717
}
1818
return Promise.resolve();
1919
}
2020
// Method that has no callback as last argument, and doesnt return promise.
21-
initializeOrderedBulkOp() {
21+
public initializeOrderedBulkOp() {
2222
return {};
2323
}
2424
}

0 commit comments

Comments
 (0)