Skip to content

Commit

Permalink
Make constructors protected
Browse files Browse the repository at this point in the history
  • Loading branch information
Jym77 committed Dec 18, 2024
1 parent 5b24e4b commit 7a38dd0
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 17 deletions.
10 changes: 10 additions & 0 deletions .changeset/quiet-moles-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@siteimprove/alfa-test-utils": patch
"@siteimprove/alfa-frontier": patch
"@siteimprove/alfa-command": patch
"@siteimprove/alfa-crawler": patch
"@siteimprove/alfa-scraper": patch
"@siteimprove/alfa-assert": patch
---

**hanged:** Classes that do not implement the Singleton pattern now have `protected` constructor and can be extended.
2 changes: 1 addition & 1 deletion packages/alfa-assert/src/asserter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Asserter<I, T extends Hashable, Q extends Question.Metadata, S> {
private readonly _handlers: Array<Handler<I, T, Q, S>>;
private readonly _options: Asserter.Options<I, T, Q, S>;

private constructor(
protected constructor(
rules: Array<Rule<I, T, Q, S>>,
handlers: Array<Handler<I, T, Q, S>>,
options: Asserter.Options<I, T, Q, S>
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-assert/src/assertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Assertion<I, T extends Hashable, Q extends Question.Metadata, S> {
private readonly _handlers: Array<Handler<I, T, Q, S>>;
private readonly _options: Assertion.Options<I, T, Q, S>;

private constructor(
protected constructor(
input: I,
rules: Array<Rule<I, T, Q, S>>,
handlers: Array<Handler<I, T, Q, S>>,
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-command/src/argument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Argument<T = unknown>
private readonly _options: Argument.Options;
private readonly _parse: Argument.Parser<T>;

private constructor(
protected constructor(
name: string,
description: string,
options: Argument.Options,
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-command/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class Command<
private readonly _parent: Option<Command>;
private readonly _run: Command.Runner<F, A>;

private constructor(
protected constructor(
name: string,
version: string,
description: string,
Expand Down
4 changes: 2 additions & 2 deletions packages/alfa-command/src/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Flag<T = unknown> implements Functor<T>, Serializable<Flag.JSON> {
private readonly _options: Flag.Options;
private readonly _parse: Flag.Parser<T, [Predicate<string>]>;

private constructor(
protected constructor(
name: string,
description: string,
options: Flag.Options,
Expand Down Expand Up @@ -393,7 +393,7 @@ export namespace Flag {
private readonly _value: T;
private readonly _parse: Flag.Parser<T>;

private constructor(value: T, parse: Flag.Parser<T>) {
protected constructor(value: T, parse: Flag.Parser<T>) {
this._value = value;
this._parse = parse;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-crawler/src/crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Crawler {

private readonly _scraper: Scraper;

private constructor(scraper: Scraper) {
protected constructor(scraper: Scraper) {
this._scraper = scraper;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/alfa-frontier/src/frontier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Frontier implements Equatable, Serializable {
private readonly _scope: URL;
private readonly _items: Array<Item>;

private constructor(scope: URL, items: Array<Item>) {
protected constructor(scope: URL, items: Array<Item>) {
this._scope = scope;
this._items = items;
}
Expand Down Expand Up @@ -243,7 +243,7 @@ class Item implements Equatable, Serializable {
private readonly _aliases: Array<URL>;
private _state: State;

private constructor(url: URL, aliases: Array<URL>, state: State) {
protected constructor(url: URL, aliases: Array<URL>, state: State) {
this._url = url;
this._aliases = aliases;
this._state = state;
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-scraper/src/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Archive implements Equatable, Serializable {
private readonly _path: string;
private readonly _format: Archive.Format;

private constructor(path: string, format: Archive.Format) {
protected constructor(path: string, format: Archive.Format) {
this._path = path;
this._format = format;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-scraper/src/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Credentials implements Equatable, Serializable {
private readonly _username: string;
private readonly _password: string;

private constructor(username: string, password: string) {
protected constructor(username: string, password: string) {
this._username = username;
this._password = password;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-scraper/src/scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class Scraper {

private readonly _browser: puppeteer.Browser;

private constructor(browser: puppeteer.Browser) {
protected constructor(browser: puppeteer.Browser) {
this._browser = browser;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/alfa-scraper/src/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Screenshot implements Equatable, Serializable {
private readonly _path: string;
private readonly _type: Screenshot.Type;

private constructor(path: string, type: Screenshot.Type) {
protected constructor(path: string, type: Screenshot.Type) {
this._path = path;
this._type = type;
}
Expand Down Expand Up @@ -68,7 +68,7 @@ export namespace Screenshot {

private readonly _background: boolean;

private constructor(background: boolean) {
protected constructor(background: boolean) {
this._background = background;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ export namespace Screenshot {

private readonly _quality: number;

private constructor(quality: number) {
protected constructor(quality: number) {
this._quality = quality;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-test-utils/src/audit/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Audit implements json.Serializable<Audit.JSON> {
private readonly _resultAggregates: Audit.ResultAggregates;
private readonly _durations: Performance.Durations;

private constructor(
protected constructor(
page: Page,
outcomes: Map<string, Sequence<alfaOutcome>>,
resultAggregates: Audit.ResultAggregates,
Expand Down
2 changes: 1 addition & 1 deletion packages/alfa-test-utils/src/report/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Logging implements Equatable, json.Serializable<Logging.JSON> {
private readonly _title: string;
private readonly _logs: Sequence<Logging>;

private constructor(title: string, logs: Sequence<Logging>) {
protected constructor(title: string, logs: Sequence<Logging>) {
this._title = title;
this._logs = logs;
}
Expand Down

0 comments on commit 7a38dd0

Please sign in to comment.