Skip to content

Commit ab0095e

Browse files
crisbetommalerba
authored andcommitted
build: member naming rule not catching private readonly (#17515)
Fixes the rule that validates member naming not picking up class properties declared through the constructor as `private readonly` (e.g. `constructor(private readonly something: any)`.
1 parent 049da95 commit ab0095e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/google-maps/map-info-window/map-info-window.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ export class MapInfoWindow implements OnInit, OnDestroy {
8686

8787
private _infoWindow?: google.maps.InfoWindow;
8888

89-
constructor(private readonly googleMap: GoogleMap, private _elementRef: ElementRef<HTMLElement>) {
90-
}
89+
constructor(private readonly _googleMap: GoogleMap,
90+
private _elementRef: ElementRef<HTMLElement>) {}
9191

9292
ngOnInit() {
9393
this._combineOptions().pipe(takeUntil(this._destroy)).subscribe(options => {
@@ -149,9 +149,9 @@ export class MapInfoWindow implements OnInit, OnDestroy {
149149
*/
150150
open(anchor?: MapMarker) {
151151
const marker = anchor ? anchor._marker : undefined;
152-
if (this.googleMap._googleMap) {
152+
if (this._googleMap._googleMap) {
153153
this._elementRef.nativeElement.style.display = '';
154-
this._infoWindow!.open(this.googleMap._googleMap, marker);
154+
this._infoWindow!.open(this._googleMap._googleMap, marker);
155155
}
156156
}
157157

src/google-maps/map-marker/map-marker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ export class MapMarker implements OnInit, OnDestroy {
209209

210210
_marker?: google.maps.Marker;
211211

212-
constructor(private readonly googleMap: GoogleMap) {}
212+
constructor(private readonly _googleMap: GoogleMap) {}
213213

214214
ngOnInit() {
215215
const combinedOptionsChanges = this._combineOptions();
216216

217217
combinedOptionsChanges.pipe(take(1)).subscribe(options => {
218218
this._marker = new google.maps.Marker(options);
219-
this._marker.setMap(this.googleMap._googleMap);
219+
this._marker.setMap(this._googleMap._googleMap);
220220
this._initializeEventHandlers();
221221
});
222222

@@ -343,7 +343,7 @@ export class MapMarker implements OnInit, OnDestroy {
343343
position: position || options.position,
344344
label: label || options.label,
345345
clickable: clickable !== undefined ? clickable : options.clickable,
346-
map: this.googleMap._googleMap || null,
346+
map: this._googleMap._googleMap || null,
347347
};
348348
return combinedOptions;
349349
}));

tools/tslint-rules/memberNamingRule.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ class Walker extends Lint.RuleWalker {
5757
// Check class members that were declared via the constructor
5858
// (e.g. `constructor(private _something: number)`. These nodes don't
5959
// show up under `ClassDeclaration.members`.
60-
if (tsutils.hasModifier(modifiers, ts.SyntaxKind.ReadonlyKeyword) ||
61-
tsutils.hasModifier(modifiers, ts.SyntaxKind.PublicKeyword)) {
62-
this._validateNode(param, 'public');
63-
} else if (tsutils.hasModifier(modifiers, ts.SyntaxKind.PrivateKeyword)) {
60+
if (tsutils.hasModifier(modifiers, ts.SyntaxKind.PrivateKeyword)) {
6461
this._validateNode(param, 'private');
6562
} else if (tsutils.hasModifier(modifiers, ts.SyntaxKind.ProtectedKeyword)) {
6663
this._validateNode(param, 'protected');
64+
} else if (tsutils.hasModifier(modifiers, ts.SyntaxKind.ReadonlyKeyword) ||
65+
tsutils.hasModifier(modifiers, ts.SyntaxKind.PublicKeyword)) {
66+
this._validateNode(param, 'public');
6767
}
6868
});
6969

0 commit comments

Comments
 (0)