Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: convert JSDoc comments to TSDoc #1629

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const config = {
'plugin:import/recommended', // Used along with eslint-plugin-import to sort imports with recommended standards
'plugin:import/typescript', // To handle import order cases for typescript files
],
plugins: ['import'],
plugins: ['import', 'eslint-plugin-tsdoc'],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
Expand Down Expand Up @@ -76,7 +76,16 @@ const config = {
pathGroupsExcludedImportTypes: ['react'],
},
],
'tsdoc/syntax': 'error',
},
overrides: [
{
files: ['rtl-spec/**', 'tests/**'],
rules: {
'tsdoc/syntax': 'off',
},
},
],
// the static folder is linted by standard
ignorePatterns: ['/out', '/.webpack', '/coverage', '/static'],
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-tsdoc": "^0.3.0",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"husky": "^9.0.11",
"jest": "^29.6.2",
Expand Down
2 changes: 0 additions & 2 deletions src/main/about-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import contributorsJSON from '../../static/contributors.json';

/**
* Sets Fiddle's About panel options on Linux and macOS
*
* @returns
*/
export function setupAboutPanel(): void {
const contributors: Array<string> = [];
Expand Down
12 changes: 4 additions & 8 deletions src/main/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const TEST_TEMPLATE_BRANCH = 'test-template';
* Ensure we have a fiddle for the specified Electron branch.
* If we don't have it already, download it from electron-quick-start.
*
* @param {string} branch - Electron branchname, e.g. `12-x-y` or `main`
* @returns {Promise<string>} Path to the folder where the fiddle is kept
* @param branch - Electron branchname, e.g. `12-x-y` or `main`
* @returns Path to the folder where the fiddle is kept
*/
async function prepareTemplate(branch: string): Promise<string> {
let folder = path.join(TEMPLATES_DIR, `electron-quick-start-${branch}`);
Expand Down Expand Up @@ -69,8 +69,7 @@ const templateCache: Record<string, Promise<EditorValues>> = {};
/**
* Get a cached copy of the Electron branch's fiddle.
*
* @param {string} branch - Electron branchname, e.g. `12-x-y` or `main`
* @returns {Promise<EditorValues>}
* @param branch - Electron branchname, e.g. `12-x-y` or `main`
*/
function getQuickStart(branch: string): Promise<EditorValues> {
// Load the template for that branch.
Expand All @@ -86,8 +85,6 @@ function getQuickStart(branch: string): Promise<EditorValues> {

/**
* Get a cached copy of the Electron Test fiddle.
*
* @returns {Promise<EditorValues>}
*/
export function getTestTemplate(): Promise<EditorValues> {
return getQuickStart(TEST_TEMPLATE_BRANCH);
Expand All @@ -96,8 +93,7 @@ export function getTestTemplate(): Promise<EditorValues> {
/**
* Get a cached copy of the fiddle for the specified Electron version.
*
* @param {string} version - Electron version, e.g. 12.0.0
* @returns {Promise<EditorValues>}
* @param version - Electron version, e.g. 12.0.0
*/
export function getTemplate(version: string): Promise<EditorValues> {
const major = Number.parseInt(version);
Expand Down
11 changes: 0 additions & 11 deletions src/main/context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { IpcEvents } from '../ipc-events';

/**
* Returns items related to running the current fiddle.
*
* @returns {Array<MenuItemConstructorOptions>}
*/
export function getRunItems(): Array<MenuItemConstructorOptions> {
return [
Expand All @@ -36,9 +34,6 @@ export function getRunItems(): Array<MenuItemConstructorOptions> {
* Possibly returns items interacting with the Monaco editor.
* Our check for "are we in the Monaco editor" is pretty crude -
* we just assume that we are if we can paste text.
*
* @param {ContextMenuParams} { pageURL, editFlags }
* @returns {Array<MenuItemConstructorOptions>}
*/
export function getMonacoItems({
pageURL,
Expand Down Expand Up @@ -105,10 +100,6 @@ export function getMonacoItems({

/**
* Possibly returns the `Inspect Element` item.
*
* @param {BrowserWindow} browserWindow
* @param {ContextMenuParams} { x, y }
* @returns {Array<MenuItemConstructorOptions>}
*/
export function getInspectItems(
browserWindow: BrowserWindow,
Expand Down Expand Up @@ -137,8 +128,6 @@ export function getInspectItems(

/**
* Creates a context menu for a given BrowserWindow
*
* @param {BrowserWindow} browserWindow
*/
export function createContextMenu(browserWindow: BrowserWindow) {
browserWindow.webContents.on('context-menu', (_event, props) => {
Expand Down
3 changes: 0 additions & 3 deletions src/main/devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { isDevMode } from './utils/devmode';

/**
* Installs developer tools if we're in dev mode.
*
* @export
* @returns {Promise<void>}
*/
export async function setupDevTools(): Promise<void> {
if (!isDevMode()) return;
Expand Down
11 changes: 1 addition & 10 deletions src/main/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { IpcEvents } from '../ipc-events';
/**
* Build a default name for a local Electron version
* from its dirname.
*
* @param {string} folderPath
* @return {string} human-readable local build name
* @returns human-readable local build name
*/
function makeLocalName(folderPath: string): string {
// take a dirname like '/home/username/electron/gn/main/src/out/testing'
Expand All @@ -35,9 +33,6 @@ function makeLocalName(folderPath: string): string {

/**
* Verifies if the local electron path is valid
*
* @param {string} folderPath
* @return {boolean}
*/
function isValidElectronPath(folderPath: string): boolean {
const execPath = Installer.getExecPath(folderPath);
Expand All @@ -46,8 +41,6 @@ function isValidElectronPath(folderPath: string): boolean {

/**
* Listens to IPC events related to dialogs and message boxes
*
* @export
*/
export function setupDialogs() {
ipcMainManager.on(IpcEvents.SHOW_WARNING_DIALOG, (event, args) => {
Expand Down Expand Up @@ -77,8 +70,6 @@ export function setupDialogs() {

/**
* Shows a warning dialog
*
* @param {Electron.MessageBoxOptions} args
*/
function showWarningDialog(
window: BrowserWindow,
Expand Down
6 changes: 0 additions & 6 deletions src/main/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ export async function showSaveDialog(

/**
* Confirm it's OK to save files in `folder`
*
* @param {string} filePath
* @returns {Promise<boolean>}
*/
async function isOkToSaveAt(filePath: string): Promise<boolean> {
return (
Expand All @@ -96,9 +93,6 @@ async function isOkToSaveAt(filePath: string): Promise<boolean> {
/**
* Pops open a confirmation dialog, asking the user if they really
* want to overwrite an existing file
*
* @param {string} filePath
* @returns {Promise<boolean>}
*/
async function confirmFileOverwrite(filePath: string): Promise<boolean> {
try {
Expand Down
7 changes: 0 additions & 7 deletions src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import {
* The main purpose of this class is to be the central
* gathering place for IPC calls the main process sends
* or listens to.
*
* @class IpcManager
* @extends {EventEmitter}
*/
class IpcMainManager extends EventEmitter {
public readyWebContents = new WeakSet<Electron.WebContents>();
Expand Down Expand Up @@ -50,10 +47,6 @@ class IpcMainManager extends EventEmitter {
/**
* Send an IPC message to an instance of Electron.WebContents.
* If none is specified, we'll automatically go with the main window.
*
* @param {IpcEvents} channel
* @param {Array<any>} [args]
* @param {Electron.WebContents} [target]
*/
public send(
channel: IpcEvents,
Expand Down
2 changes: 0 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ export async function onReady() {

/**
* Handle the "before-quit" event
*
* @export
*/
export function onBeforeQuit() {
ipcMainManager.send(IpcEvents.BEFORE_QUIT);
Expand Down
13 changes: 0 additions & 13 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import { SHOW_ME_TEMPLATES } from '../templates';

/**
* Is the passed object a constructor for an Electron Menu?
*
* @param {(Array<Electron.MenuItemConstructorOptions> | Electron.Menu)} [submenu]
* @returns {submenu is Array<Electron.MenuItemConstructorOptions>}
*/
function isSubmenu(
submenu?: Array<MenuItemConstructorOptions> | Menu,
Expand All @@ -37,8 +34,6 @@ function isSubmenu(

/**
* Returns additional items for the help menu
*
* @returns {Array<Electron.MenuItemConstructorOptions>}
*/
function getHelpItems(): Array<MenuItemConstructorOptions> {
const items: MenuItemConstructorOptions[] = [];
Expand Down Expand Up @@ -112,8 +107,6 @@ function getHelpItems(): Array<MenuItemConstructorOptions> {
/**
* Depending on the OS, the `Preferences` either go into the `Fiddle`
* menu (macOS) or under `File` (Linux, Windows)
*
* @returns {Array<Electron.MenuItemConstructorOptions>}
*/
function getPreferencesItems(): Array<MenuItemConstructorOptions> {
return [
Expand All @@ -135,8 +128,6 @@ function getPreferencesItems(): Array<MenuItemConstructorOptions> {

/**
* Returns the Exit items
*
* @returns {Array<Electron.MenuItemConstructorOptions>}
*/
function getQuitItems(): Array<MenuItemConstructorOptions> {
return [
Expand All @@ -151,8 +142,6 @@ function getQuitItems(): Array<MenuItemConstructorOptions> {

/**
* Returns the top-level "File" menu
*
* @returns {Array<Electron.MenuItemConstructorOptions>}
*/
function getTasksMenu(): MenuItemConstructorOptions {
const tasksMenu: Array<MenuItemConstructorOptions> = [
Expand Down Expand Up @@ -219,8 +208,6 @@ function getShowMeMenu(

/**
* Returns the top-level "File" menu
*
* @returns {Array<Electron.MenuItemConstructorOptions>}
*/
function getFileMenu(
acceleratorsToBlock: BlockableAccelerator[] = [],
Expand Down
10 changes: 1 addition & 9 deletions src/main/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ export async function getIsPackageManagerInstalled(

/**
* Installs given modules to a given folder.
*
* @param {PMOperationOptions} { dir, packageManager }
* @param {...Array<string>} names
* @returns {Promise<string>}
*/
export async function addModules(
{ dir, packageManager }: PMOperationOptions,
Expand All @@ -73,11 +69,7 @@ export async function addModules(
}

/**
* Execute an "{packageManager} run" command
*
* @param {PMOperationOptions} { dir, packageManager }
* @param {string} command
* @returns {Promise<string>}
* Execute an "\{packageManager\} run" command
*/
export async function packageRun(
{ dir, packageManager }: PMOperationOptions,
Expand Down
3 changes: 0 additions & 3 deletions src/main/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { IpcEvents } from '../ipc-events';

/**
* Returns expected content for a given name.
*
* @param {string} name
* @returns {Promise<EditorValues>}
*/
export function getTemplateValues(name: string): Promise<EditorValues> {
const templatePath = path.join(STATIC_DIR, 'show-me', name.toLowerCase());
Expand Down
10 changes: 0 additions & 10 deletions src/main/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export const THEMES_PATH = path.join(CONFIG_PATH, 'themes');

/**
* Read in a theme file.
*
* @export
* @param {string} [name]
* @returns {Promise<FiddleTheme | null>}
*/
export async function readThemeFile(
name?: string,
Expand All @@ -48,10 +44,6 @@ export async function readThemeFile(

/**
* Create theme file and show in folder.
*
* @param {FiddleTheme} theme
* @param {string} [name]
* @returns {Promise<LoadedFiddleTheme>}
*/
export async function createThemeFile(
theme: FiddleTheme | LoadedFiddleTheme,
Expand Down Expand Up @@ -87,8 +79,6 @@ export async function createThemeFile(

/**
* Reads and then returns all available themes.
*
* @returns {Promise<Array<LoadedFiddleTheme>>}
*/
export async function getAvailableThemes(): Promise<Array<LoadedFiddleTheme>> {
const themes: Array<LoadedFiddleTheme> = [defaultDark, defaultLight];
Expand Down
2 changes: 0 additions & 2 deletions src/main/utils/check-first-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const getConfigPath = () => {
/**
* Whether or not the app is being run for
* the first time
*
* @returns {boolean}
*/
export function isFirstRun(): boolean {
const configPath = getConfigPath();
Expand Down
2 changes: 0 additions & 2 deletions src/main/utils/devmode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Are we currently running in development mode?
*
* @returns {boolean}
*/
export function isDevMode(): boolean {
return !!process.defaultApp;
Expand Down
6 changes: 0 additions & 6 deletions src/main/utils/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import shellEnv from 'shell-env';
/**
* On macOS & Linux, we need to fix the $PATH environment variable
* so that we can call `npm`.
*
* @returns {Promise<void>}
*/
export const maybeFixPath = (() => {
// Singleton: We don't want to do this more than once.
Expand All @@ -31,10 +29,6 @@ export const maybeFixPath = (() => {

/**
* Execute a command in a directory.
*
* @param {string} dir
* @param {string} cliArgs
* @returns {Promise<string>}
*/
export async function exec(dir: string, cliArgs: string): Promise<string> {
await maybeFixPath();
Expand Down
3 changes: 0 additions & 3 deletions src/main/utils/get-project-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import * as namor from 'namor';

/**
* Returns a name for this project
*
* @param {string} [localPath]
* @returns {string}
*/
export function getProjectName(localPath?: string): string {
if (localPath) {
Expand Down
3 changes: 0 additions & 3 deletions src/main/utils/get-username.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import * as os from 'node:os';

/**
* Returns the current username
*
* @export
* @returns {string}
*/
export const getUsername = (() => {
let username = '';
Expand Down
Loading