xo: Enable capitalized-comments.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-04-25 17:22:22 -07:00
committed by Anders Kaseorg
parent 4bfa7c9265
commit e49a880ed6
27 changed files with 61 additions and 63 deletions

View File

@@ -96,7 +96,7 @@ export function appUpdater(updateFromMenu = false): void {
if (response === 0) {
setTimeout(() => {
autoUpdater.quitAndInstall();
// force app to quit. This is just a workaround, ideally autoUpdater.quitAndInstall() should relaunch the app.
// Force app to quit. This is just a workaround, ideally autoUpdater.quitAndInstall() should relaunch the app.
app.quit();
}, 1000);
}

View File

@@ -48,7 +48,7 @@ const iconPath = (): string => {
return APP_ICON + (process.platform === 'win32' ? '.ico' : '.png');
};
// toggle the app window
// Toggle the app window
const toggleApp = (): void => {
if (!mainWindow.isVisible() || mainWindow.isMinimized()) {
mainWindow.show();
@@ -148,10 +148,10 @@ app.on('certificate-error', (event: Event, _webContents: Electron.WebContents, _
callback(true);
});
// this event is only available on macOS. Triggers when you click on the dock icon.
// This event is only available on macOS. Triggers when you click on the dock icon.
app.on('activate', () => {
if (mainWindow) {
// if there is already a window show it
// If there is already a window show it
mainWindow.show();
} else {
mainWindow = createMainWindow();

View File

@@ -220,7 +220,7 @@ function getHelpSubmenu(): Electron.MenuItemConstructorOptions[] {
{
label: t.__('Report an Issue'),
click() {
// the goal is to notify the main.html BrowserWindow
// The goal is to notify the main.html BrowserWindow
// which may not be the focused window.
BrowserWindow.getAllWindows().forEach(window => {
window.webContents.send('open-feedback-modal');

View File

@@ -12,7 +12,7 @@ export const setAutoLaunch = async (AutoLaunchValue: boolean): Promise<void> =>
const autoLaunchOption = ConfigUtil.getConfigItem('startAtLogin', AutoLaunchValue);
// setLoginItemSettings doesn't support linux
// `setLoginItemSettings` doesn't support linux
if (process.platform === 'linux') {
const ZulipAutoLauncher = new AutoLaunch({
name: 'Zulip',

View File

@@ -113,7 +113,7 @@ export default class WebView extends BaseComponent {
if (favicons[0].indexOf('favicon-pms') > 0 && process.platform === 'darwin') {
// This api is only supported on macOS
app.dock.setBadge('●');
// bounce the dock
// Bounce the dock
if (ConfigUtil.getConfigItem('dockBouncing')) {
app.dock.bounce();
}
@@ -192,7 +192,7 @@ export default class WebView extends BaseComponent {
// Injecting preload css in webview to override some css rules
(async () => this.$el.insertCSS(fs.readFileSync(path.join(__dirname, '/../../css/preload.css'), 'utf8')))();
// get customCSS again from config util to avoid warning user again
// Get customCSS again from config util to avoid warning user again
this.customCSS = ConfigUtil.getConfigItem('customCSS');
if (this.customCSS) {
if (!fs.existsSync(this.customCSS)) {
@@ -209,7 +209,7 @@ export default class WebView extends BaseComponent {
}
focus(): void {
// focus Webview and it's contents when Window regain focus.
// Focus Webview and it's contents when Window regain focus.
const webContents = this.$el.getWebContents();
// HACK: webContents.isFocused() seems to be true even without the element
// being in focus. So, we check against `document.activeElement`.

View File

@@ -69,7 +69,7 @@ electron_bridge.on('realm_icon_url', (iconURL: unknown) => {
ipcRenderer.send('realm-icon-changed', serverURL, iconURL);
});
// this follows node's idiomatic implementation of event
// This follows node's idiomatic implementation of event
// emitters to make event handling more simpler instead of using
// functions zulip side will emit event using ElectronBrigde.send_event
// which is alias of .emit and on this side we can handle the data by adding

View File

@@ -12,7 +12,7 @@ interface SendFeedback extends HTMLElement {
type SendFeedbackType = SendFeedback;
// make the button color match zulip app's theme
// Make the button color match zulip app's theme
SendFeedback.customStyles = `
button:hover, button:focus {
border-color: #4EBFAC;
@@ -62,7 +62,7 @@ sendFeedback.useReporter('emailReporter', {
});
feedbackHolder.addEventListener('click', (event: Event) => {
// only remove the class if the grey out faded
// Only remove the class if the grey out faded
// part is clicked and not the feedback element itself
if (event.target === event.currentTarget) {
feedbackHolder.classList.remove('show');

View File

@@ -228,7 +228,7 @@ class ServerManagerView {
}
for (const [setting, value] of Object.entries(settingOptions)) {
// give preference to defaults defined in global_config.json
// Give preference to defaults defined in global_config.json
if (EnterpriseUtil.configItemExists(setting)) {
ConfigUtil.setConfigItem(setting, EnterpriseUtil.getConfigItem(setting), true);
} else if (ConfigUtil.getConfigItem(setting) === null) {
@@ -249,7 +249,7 @@ class ServerManagerView {
}
async queueDomain(domain: string): Promise<boolean> {
// allows us to start adding multiple domains to the app simultaneously
// Allows us to start adding multiple domains to the app simultaneously
// promise of addition resolves in both cases, but we consider it rejected
// if the resolved value is false
try {
@@ -264,11 +264,11 @@ class ServerManagerView {
}
async initPresetOrgs(): Promise<void> {
// read preset organizations from global_config.json and queues them
// Read preset organizations from global_config.json and queues them
// for addition to the app's domains
const preAddedDomains = DomainUtil.getDomains();
this.presetOrgs = EnterpriseUtil.getConfigItem('presetOrganizations', []);
// set to true if at least one new domain is added
// Set to true if at least one new domain is added
const domainPromises = [];
for (const url of this.presetOrgs) {
if (DomainUtil.duplicateDomain(url)) {
@@ -280,9 +280,9 @@ class ServerManagerView {
const domainsAdded = await Promise.all(domainPromises);
if (domainsAdded.includes(true)) {
// at least one domain was resolved
// At least one domain was resolved
if (preAddedDomains.length > 0) {
// user already has servers added
// User already has servers added
// ask them before reloading the app
const { response } = await dialog.showMessageBox({
type: 'question',
@@ -297,7 +297,7 @@ class ServerManagerView {
ipcRenderer.send('reload-full-app');
}
} else if (domainsAdded.length > 0) {
// find all orgs that failed
// Find all orgs that failed
const failedDomains: string[] = [];
for (const org of this.presetOrgs) {
if (DomainUtil.duplicateDomain(org)) {
@@ -310,7 +310,7 @@ class ServerManagerView {
const { title, content } = Messages.enterpriseOrgError(domainsAdded.length, failedDomains);
dialog.showErrorBox(title, content);
if (DomainUtil.getDomains().length === 0) {
// no orgs present, stop showing loading gif
// No orgs present, stop showing loading gif
await this.openSettings('AddServer');
}
}
@@ -329,11 +329,11 @@ class ServerManagerView {
lastActiveTab = 0;
}
// checkDomain() and webview.load() for lastActiveTab before the others
// `checkDomain()` and `webview.load()` for lastActiveTab before the others
await DomainUtil.updateSavedServer(servers[lastActiveTab].url, lastActiveTab);
this.activateTab(lastActiveTab);
await Promise.all(servers.map(async (server, i) => {
// after the lastActiveTab is activated, we load the others in the background
// After the lastActiveTab is activated, we load the others in the background
// without activating them, to prevent flashing of server icons
if (i === lastActiveTab) {
return;
@@ -345,7 +345,7 @@ class ServerManagerView {
// Remove focus from the settings icon at sidebar bottom
this.$settingsButton.classList.remove('active');
} else if (this.presetOrgs.length === 0) {
// not attempting to add organisations in the background
// Not attempting to add organisations in the background
await this.openSettings('AddServer');
} else {
this.showLoading(true);
@@ -456,10 +456,9 @@ class ServerManagerView {
}
displayInitialCharLogo($img: HTMLImageElement, index: number): void {
/*
index parameter needed because webview[data-tab-id] can increment
beyond size of sidebar org array and throw error
*/
// The index parameter is needed because webview[data-tab-id] can
// increment beyond the size of the sidebar org array and throw an
// error
const $altIcon = document.createElement('div');
const $parent = $img.parentElement;
@@ -501,7 +500,7 @@ class ServerManagerView {
}
onHover(index: number): void {
// this.$serverIconTooltip[index].innerHTML already has realm name, so we are just
// `this.$serverIconTooltip[index].innerHTML` already has realm name, so we are just
// removing the style.
this.$serverIconTooltip[index].removeAttribute('style');
// To handle position of servers' tooltip due to scrolling of list of organizations
@@ -599,7 +598,7 @@ class ServerManagerView {
ipcRenderer.send('save-last-tab', index);
}
// returns this.tabs in an way that does
// Returns this.tabs in an way that does
// not crash app when this.tabs is passed into
// ipcRenderer. Something about webview, and props.webview
// properties in ServerTab causes the app to crash.
@@ -787,7 +786,7 @@ class ServerManagerView {
label: 'Notification settings',
enabled: this.isLoggedIn(index),
click: () => {
// switch to tab whose icon was right-clicked
// Switch to tab whose icon was right-clicked
this.activateTab(index);
this.tabs[index].webview.showNotificationSettings();
}
@@ -910,7 +909,7 @@ class ServerManagerView {
try {
webview.setAudioMuted(state);
} catch (error) {
// webview is not ready yet
// Webview is not ready yet
webview.addEventListener('dom-ready', () => {
webview.setAudioMuted(state);
});
@@ -1065,7 +1064,7 @@ class ServerManagerView {
}
window.addEventListener('load', async () => {
// only start electron-connect (auto reload on change) when its ran
// Only start electron-connect (auto reload on change) when its ran
// from `npm run dev` or `gulp dev` and not from `npm start` when
// app is started `npm start` main process's proces.argv will have
// `--no-electron-connect`

View File

@@ -33,7 +33,7 @@ class DarwinNotification {
}));
notification.addEventListener('click', () => {
// focus to the server who sent the
// Focus to the server who sent the
// notification if not focused already
if (clickHandler) {
clickHandler();
@@ -71,7 +71,7 @@ class DarwinNotification {
clickHandler = handler;
}
// not something that is common or
// Not something that is common or
// used by zulip server but added to be
// future proff.
addEventListener(event: string, handler: ClickHandler | ReplyHandler): void {
@@ -101,7 +101,7 @@ class DarwinNotification {
customReply(response);
}
// method specific to notification api
// Method specific to notification api
// used by zulip
close(): void {
return; // eslint-disable-line no-useless-return

View File

@@ -10,7 +10,7 @@ export default class BaseNotification extends NativeNotification {
super(title, options);
this.addEventListener('click', () => {
// focus to the server who sent the
// Focus to the server who sent the
// notification if not focused already
focusCurrentServer();
ipcRenderer.send('focus-app');

View File

@@ -14,7 +14,7 @@ export type BotListItem = [string, string];
const botsList: BotListItem[] = [];
let botsListLoaded = false;
// this function load list of bots from the server
// This function load list of bots from the server
// in case botsList isn't already completely loaded when required in parseRely
export async function loadBots(): Promise<void> {
botsList.length = 0;
@@ -46,14 +46,14 @@ export function checkElements(...elements: any[]): boolean {
}
export function customReply(reply: string): void {
// server does not support notification reply yet.
// Server does not support notification reply yet.
const buttonSelector = '.messagebox #send_controls button[type=submit]';
const messageboxSelector = '.selected_message .messagebox .messagebox-border .messagebox-content';
const textarea: HTMLInputElement = document.querySelector('#compose-textarea');
const messagebox: HTMLButtonElement = document.querySelector(messageboxSelector);
const sendButton: HTMLButtonElement = document.querySelector(buttonSelector);
// sanity check for old server versions
// Sanity check for old server versions
const elementsExists = checkElements(textarea, messagebox, sendButton);
if (!elementsExists) {
return;
@@ -68,13 +68,13 @@ const currentWindow = remote.getCurrentWindow();
const webContents = remote.getCurrentWebContents();
const webContentsId = webContents.id;
// this function will focus the server that sent
// This function will focus the server that sent
// the notification. Main function implemented in main.js
export function focusCurrentServer(): void {
currentWindow.webContents.send('focus-webview-with-id', webContentsId);
}
// this function parses the reply from to notification
// This function parses the reply from to notification
// making it easier to reply from notification eg
// @username in reply will be converted to @**username**
// #stream in reply will be converted to #**stream**

View File

@@ -47,7 +47,7 @@ export default class BaseSection extends BaseComponent {
`;
}
/* a method that in future can be used to create dropdown menus using <select> <option> tags.
/* A method that in future can be used to create dropdown menus using <select> <option> tags.
it needs an object which has ``key: value`` pairs and will return a string that can be appended to HTML
*/
generateSelectTemplate(options: {[key: string]: string}, className?: string, idName?: string): string {

View File

@@ -415,7 +415,7 @@ export default class GeneralSection extends BaseSection {
// This path is for the JSON file that stores key: value pairs for supported locales
const langList = this.generateSelectTemplate(supportedLocales, 'lang-menu');
langDiv.innerHTML += langList;
// langMenu is the select-option dropdown menu formed after executing the previous command
// `langMenu` is the select-option dropdown menu formed after executing the previous command
const langMenu: HTMLSelectElement = document.querySelector('.lang-menu');
// The next three lines set the selected language visible on the dropdown button

View File

@@ -104,7 +104,7 @@ export default class NewServerForm extends BaseComponent {
await this.submitFormHandler();
}
});
// open create new org link in default browser
// Open create new org link in default browser
this.openCreateNewOrgExternalLink();
this.networkSettingsLink();
}

View File

@@ -48,7 +48,7 @@ ipcRenderer.on('show-notification-settings', () => {
const notificationItem: NodeListOf<HTMLElement> = document.querySelectorAll('.normal-settings-list li div');
// wait until the notification dom element shows up
// Wait until the notification dom element shows up
setTimeout(() => {
notificationItem[2].click();
}, 100);
@@ -61,7 +61,7 @@ electron_bridge.once('zulip-loaded', ({ serverLanguage }) => {
SetupSpellChecker.init(serverLanguage);
}
// redirect users to network troubleshooting page
// Redirect users to network troubleshooting page
const getRestartButton = document.querySelector('.restart_get_events_button');
if (getRestartButton) {
getRestartButton.addEventListener('click', () => {
@@ -86,7 +86,7 @@ window.addEventListener('load', (event: any): void => {
NetworkError.init($reconnectButton, $settingsButton);
});
// electron's globalShortcut can cause unexpected results
// Electron's globalShortcut can cause unexpected results
// so adding the reload shortcut in the old-school way
// Zoom from numpad keys is not supported by electron, so adding it through listeners.
document.addEventListener('keydown', event => {

View File

@@ -7,7 +7,7 @@ const { Tray, Menu, nativeImage, BrowserWindow, nativeTheme } = remote;
let tray: Electron.Tray;
// get the theme on macOS
// Get the theme on macOS
const theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
const ICON_DIR = process.platform === 'darwin' ? `../../resources/tray/${theme}` : '../../resources/tray';

View File

@@ -1,4 +1,4 @@
// unescape already encoded/escaped strings
// Unescape already encoded/escaped strings
export function decodeString(stringInput: string): string {
const parser = new DOMParser();
const dom = parser.parseFromString(

View File

@@ -70,7 +70,7 @@ export function isConfigItemExists(key: string): boolean {
export function setConfigItem(key: string, value: any, override? : boolean): void {
if (EnterpriseUtil.configItemExists(key) && !override) {
// if item is in global config and we're not trying to override
// If item is in global config and we're not trying to override
return;
}

View File

@@ -14,7 +14,7 @@ const logDir = `${zulipDir}/Logs/`;
const certificatesDir = `${zulipDir}/certificates/`;
const configDir = `${zulipDir}/config/`;
export const initSetUp = (): void => {
// if it is the first time the app is running
// If it is the first time the app is running
// create zulip dir in userData folder to
// avoid errors
if (!setupCompleted) {
@@ -63,7 +63,7 @@ export const initSetUp = (): void => {
fs.unlinkSync(data.path);
}
});
// window-state.json is only deleted not moved, as the electron-window-state
// `window-state.json` is only deleted not moved, as the electron-window-state
// package will recreate the file in the config folder.
if (fs.existsSync(windowStateJson)) {
fs.unlinkSync(windowStateJson);

View File

@@ -108,7 +108,7 @@ export function duplicateDomain(domain: string): boolean {
async function checkCertError(domain: string, serverConf: ServerConf, error: string, silent: boolean): Promise<ServerConf> {
if (silent) {
// since getting server settings has already failed
// Since getting server settings has already failed
return serverConf;
}
@@ -126,7 +126,7 @@ async function checkCertError(domain: string, serverConf: ServerConf, error: str
detail: certErrorDetail
});
if (response === 0) {
// set ignoreCerts parameter to true in case user responds with yes
// Set ignoreCerts parameter to true in case user responds with yes
serverConf.ignoreCerts = true;
try {
return await getServerSettings(domain, serverConf.ignoreCerts);

View File

@@ -8,7 +8,7 @@ const logger = new Logger({
timestamp: true
});
// todo: replace enterpriseSettings type with an interface once settings are final
// TODO: replace enterpriseSettings type with an interface once settings are final
export let enterpriseSettings: any;
export let configFile: boolean;

View File

@@ -6,7 +6,7 @@ import fs from 'fs';
import os from 'os';
import isDev from 'electron-is-dev';
import electron from 'electron';
// this interface adds [key: string]: any so
// This interface adds [key: string]: any so
// we can do console[type] later on in the code
interface PatchedConsole extends Console {
[key: string]: any;

View File

@@ -55,7 +55,7 @@ export async function resolveSystemProxy(mainWindow: Electron.BrowserWindow): Pr
const proxy = await ses.resolveProxy('http://' + resolveProxyUrl);
let httpString = '';
if (proxy !== 'DIRECT') {
// in case of proxy HTTPS url:port, windows gives first word as HTTPS while linux gives PROXY
// In case of proxy HTTPS url:port, windows gives first word as HTTPS while linux gives PROXY
// for all other HTTP or direct url:port both uses PROXY
if (proxy.includes('PROXY') || proxy.includes('HTTPS')) {
httpString = 'http=' + proxy.split('PROXY')[1] + ';';
@@ -69,7 +69,7 @@ export async function resolveSystemProxy(mainWindow: Electron.BrowserWindow): Pr
const proxy = await ses.resolveProxy('https://' + resolveProxyUrl);
let httpsString = '';
if (proxy !== 'DIRECT' || proxy.includes('HTTPS')) {
// in case of proxy HTTPS url:port, windows gives first word as HTTPS while linux gives PROXY
// In case of proxy HTTPS url:port, windows gives first word as HTTPS while linux gives PROXY
// for all other HTTP or direct url:port both uses PROXY
if (proxy.includes('PROXY') || proxy.includes('HTTPS')) {
httpsString += 'https=' + proxy.split('PROXY')[1] + ';';

View File

@@ -33,7 +33,7 @@ export function requestOptions(domain: string, ignoreCerts: boolean): RequestUti
let certificateFile = null;
if (certificate?.includes('/')) {
// certificate saved using old app version
// Certificate saved using old app version
certificateFile = certificate;
} else if (certificate) {
certificateFile = path.join(`${app.getPath('userData')}/certificates`, certificate);

View File

@@ -10,7 +10,7 @@ export const sentryInit = (): void => {
// This error mainly comes from the console logs.
// This is a temp solution until Sentry supports disabling the console logs
ignoreErrors: ['does not appear to be a valid Zulip server']
// sendTimeout: 30 // wait 30 seconds before considering the sending capture to have failed, default is 1 second
/// sendTimeout: 30 // wait 30 seconds before considering the sending capture to have failed, default is 1 second
});
}
};

View File

@@ -6,10 +6,10 @@ i18n.configure({
directory: path.join(__dirname, '../../../translations/')
});
/* fetches the current appLocale from settings.json */
/* Fetches the current appLocale from settings.json */
const appLocale = ConfigUtil.getConfigItem('appLanguage');
/* if no locale present in the json, en is set default */
/* If no locale present in the json, en is set default */
export function __(phrase: string): string {
return i18n.__({ phrase, locale: appLocale ? appLocale : 'en' });
}

View File

@@ -205,7 +205,6 @@
"@typescript-eslint/no-dynamic-delete": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"capitalized-comments": "off",
"import/no-mutable-exports": "off",
"import/unambiguous": "error",
"max-lines": [