Skip to content

Commit

Permalink
eslint: enforce class member accessibility (#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener authored Nov 25, 2024
1 parent d005d11 commit aa6cff1
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 17 deletions.
5 changes: 5 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export default [
*/
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error",

/**
* Enforces explicit class-member accessibility.
*/
"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "explicit" }],
},
languageOptions: {
globals: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const constructorMock = vi.fn().mockReturnValue(browserWindowMock);
vi.mock("electron", () => {
return {
BrowserWindow: class {
constructor(options: BrowserWindowConstructorOptions) {
public constructor(options: BrowserWindowConstructorOptions) {
constructorMock(options);
return browserWindowMock;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/Core/PowershellUtility/PowershellUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { join } from "path";
import type { PowershellUtility as PowershellUtilityInterface } from "./Contract";

export class PowershellUtility implements PowershellUtilityInterface {
static PowershellPath = `C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
public static PowershellPath = `C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;

private readonly byteOrderMark: string = "\ufeff";

Expand Down
2 changes: 1 addition & 1 deletion src/main/Core/TrayIcon/TrayCreator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dummyTrayConstructor = vi.fn().mockReturnValue(dummyTray);
vi.mock("electron", () => {
return {
Tray: class {
constructor(iconFilePath: string) {
public constructor(iconFilePath: string) {
return dummyTrayConstructor(iconFilePath);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ColorConverterExtension implements Extension {
private readonly colorConverter: ColorConverter,
) {}

async getSearchResultItems(): Promise<SearchResultItem[]> {
public async getSearchResultItems(): Promise<SearchResultItem[]> {
return [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class CustomWebSearchExtension implements Extension {
private readonly urlImageGenerator: UrlImageGenerator,
) {}

async getSearchResultItems(): Promise<SearchResultItem[]> {
public async getSearchResultItems(): Promise<SearchResultItem[]> {
// Custom search engines do not have static search results
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ export class JetBrainsToolboxExtension implements Extension {
githubUserName: "scomans",
};

readonly toolboxPaths = {
private readonly toolboxPaths = {
Windows: process.env.LOCALAPPDATA + "/JetBrains/Toolbox/",
macOS: process.env.HOME + "/Library/Application Support/JetBrains/Toolbox/",
Linux: process.env.HOME + "/.local/share/JetBrains/Toolbox/",
};

readonly configPaths = {
private readonly configPaths = {
Windows: process.env.APPDATA + "/JetBrains/",
macOS: process.env.HOME + "/Library/Application Support/JetBrains/",
Linux: process.env.HOME + "/.config/JetBrains/",
};

recents: SearchResultItem[] = [];
private recents: SearchResultItem[] = [];

public constructor(
private readonly operatingSystem: OperatingSystem,
Expand All @@ -74,7 +74,7 @@ export class JetBrainsToolboxExtension implements Extension {
private readonly translator: Translator,
) {}

async getSearchResultItems(): Promise<SearchResultItem[]> {
public async getSearchResultItems(): Promise<SearchResultItem[]> {
const recentPaths = await this.getRecents();

this.recents = await Promise.all(
Expand Down Expand Up @@ -177,7 +177,7 @@ export class JetBrainsToolboxExtension implements Extension {
return recents;
}

async getSearchItem(recent: JetBrainsToolboxRecent): Promise<SearchResultItem> {
private async getSearchItem(recent: JetBrainsToolboxRecent): Promise<SearchResultItem> {
const { t } = this.translator.createT(this.getI18nResources());
const img = await this.getProjectImage(recent);
const path = recent.path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class TerminalLauncherExtension implements Extension {
private readonly terminalRegistry: TerminalRegistry,
) {}

async getSearchResultItems(): Promise<SearchResultItem[]> {
public async getSearchResultItems(): Promise<SearchResultItem[]> {
return [];
}

Expand Down
13 changes: 7 additions & 6 deletions src/main/Extensions/VSCode/VSCodeExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ export class VSCodeExtension implements Extension {
githubUserName: "IrishBruse",
};

readonly stateDatabasePaths = {
private readonly stateDatabasePaths = {
Windows: process.env.APPDATA + "/Code/User/globalStorage/state.vscdb",
macOS: process.env.HOME + "/Library/Application Support/Code/User/globalStorage/state.vscdb",
Linux: process.env.HOME + "/.config/Code/User/globalStorage/state.vscdb",
};

recents: SearchResultItem[] = [];
private recents: SearchResultItem[] = [];

public constructor(
private readonly operatingSystem: OperatingSystem,
Expand All @@ -52,7 +52,7 @@ export class VSCodeExtension implements Extension {
private readonly fileImageGenerator: FileImageGenerator,
) {}

async getSearchResultItems(): Promise<SearchResultItem[]> {
public async getSearchResultItems(): Promise<SearchResultItem[]> {
const searchResults: SearchResultItem[] = [];

for (const recent of this.getRecents()) {
Expand Down Expand Up @@ -82,7 +82,7 @@ export class VSCodeExtension implements Extension {
);
}

getUri = (recent: VscodeRecent) => {
private getUri = (recent: VscodeRecent) => {
if (recent.fileUri) {
return recent.fileUri;
}
Expand All @@ -97,7 +97,8 @@ export class VSCodeExtension implements Extension {

throw new Error("Unknown file type");
};
getPath = (uri: string) => {

private getPath = (uri: string) => {
const decodedUri = decodeURIComponent(uri);
if (uri.startsWith("file://")) {
const url = new URL(decodedUri);
Expand Down Expand Up @@ -146,7 +147,7 @@ export class VSCodeExtension implements Extension {
return this.getImage();
}

async getSearchItem(recent: VscodeRecent): Promise<SearchResultItem> {
private async getSearchItem(recent: VscodeRecent): Promise<SearchResultItem> {
const uri = this.getUri(recent);
const fileType = this.getFileType(recent, uri);
const commandArg = this.getCommandArg(recent);
Expand Down

0 comments on commit aa6cff1

Please sign in to comment.