xo: Enable import/no-mutable-exports.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-04-25 17:39:44 -07:00
committed by Anders Kaseorg
parent 9f3b4ff408
commit a46f2ed618
4 changed files with 12 additions and 11 deletions

View File

@@ -141,7 +141,7 @@ class ServerManagerView {
this.initDefaultSettings(); this.initDefaultSettings();
this.initSidebar(); this.initSidebar();
this.removeUAfromDisk(); this.removeUAfromDisk();
if (EnterpriseUtil.configFile) { if (EnterpriseUtil.hasConfigFile()) {
await this.initPresetOrgs(); await this.initPresetOrgs();
} }
@@ -946,8 +946,7 @@ class ServerManagerView {
this.tabs[index].webview.props.name = realmName; this.tabs[index].webview.props.name = realmName;
domain.alias = escape(realmName); domain.alias = escape(realmName);
DomainUtil.db.push(`/domains[${index}]`, domain, true); DomainUtil.updateDomain(index, domain);
DomainUtil.reloadDB();
// Update the realm name also on the Window menu // Update the realm name also on the Window menu
ipcRenderer.send('update-menu', { ipcRenderer.send('update-menu', {
tabs: this.tabsForIpc, tabs: this.tabsForIpc,
@@ -968,8 +967,7 @@ class ServerManagerView {
const serverImgs: NodeListOf<HTMLImageElement> = document.querySelectorAll(serverImgsSelector); const serverImgs: NodeListOf<HTMLImageElement> = document.querySelectorAll(serverImgsSelector);
serverImgs[index].src = localIconUrl; serverImgs[index].src = localIconUrl;
domain.icon = localIconUrl; domain.icon = localIconUrl;
DomainUtil.db.push(`/domains[${index}]`, domain, true); DomainUtil.updateDomain(index, domain);
DomainUtil.reloadDB();
} }
}); });
}); });

View File

@@ -27,7 +27,7 @@ const logger = new Logger({
const defaultIconUrl = '../renderer/img/icon.png'; const defaultIconUrl = '../renderer/img/icon.png';
export let db: JsonDB; let db: JsonDB;
reloadDB(); reloadDB();
// Migrate from old schema // Migrate from old schema
@@ -66,7 +66,7 @@ export function shouldIgnoreCerts(url: string): boolean {
return null; return null;
} }
function updateDomain(index: number, server: ServerConf): void { export function updateDomain(index: number, server: ServerConf): void {
reloadDB(); reloadDB();
db.push(`/domains[${index}]`, server, true); db.push(`/domains[${index}]`, server, true);
} }
@@ -267,7 +267,7 @@ export async function updateSavedServer(url: string, index: number): Promise<voi
} }
} }
export function reloadDB(): void { function reloadDB(): void {
const domainJsonPath = path.join(app.getPath('userData'), 'config/domain.json'); const domainJsonPath = path.join(app.getPath('userData'), 'config/domain.json');
try { try {
const file = fs.readFileSync(domainJsonPath, 'utf8'); const file = fs.readFileSync(domainJsonPath, 'utf8');

View File

@@ -9,8 +9,8 @@ const logger = new Logger({
}); });
// 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; let enterpriseSettings: any;
export let configFile: boolean; let configFile: boolean;
reloadDB(); reloadDB();
@@ -35,6 +35,10 @@ function reloadDB(): void {
} }
} }
export function hasConfigFile(): boolean {
return configFile;
}
export function getConfigItem(key: string, defaultValue?: any): any { export function getConfigItem(key: string, defaultValue?: any): any {
reloadDB(); reloadDB();
if (!configFile) { if (!configFile) {

View File

@@ -204,7 +204,6 @@
"rules": { "rules": {
"@typescript-eslint/no-dynamic-delete": "off", "@typescript-eslint/no-dynamic-delete": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off", "@typescript-eslint/prefer-readonly-parameter-types": "off",
"import/no-mutable-exports": "off",
"import/unambiguous": "error", "import/unambiguous": "error",
"max-lines": [ "max-lines": [
"warn", "warn",