js: Declare 'use strict' on all scripts and no modules.

And enable the import/unambiguous ESLint rule as a check on our
partition between scripts and modules.  After this commit, if you add
a new file and get this error:

  ✖  1:1  This module could be parsed as a valid script.  import/unambiguous

* For a module, add an `import` or `export` declaration to make the
  file unambiguously a module (the empty `export {};` declaration
  suffices).
* For a script, add the file to the xo overrides section of
  package.json that marks it "sourceType": "script", and add a 'use
  strict' declaration.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-03-09 19:45:00 -07:00
parent 01f6e77237
commit 9d2739f050
43 changed files with 20 additions and 63 deletions

View File

@@ -1,4 +1,3 @@
'use strict';
import { app, dialog, shell } from 'electron';
import { autoUpdater } from 'electron-updater';
import { linuxUpdateNotification } from './linuxupdater'; // Required only in case of linux

View File

@@ -1,4 +1,3 @@
'use strict';
import { sentryInit } from '../renderer/js/utils/sentry-util';
import { appUpdater } from './autoupdater';
import { setAutoLaunch } from './startup';

View File

@@ -1,4 +1,3 @@
'use strict';
import { app, shell, BrowserWindow, Menu, dialog } from 'electron';
import { appUpdater } from './autoupdater';

View File

@@ -1,4 +1,3 @@
'use strict';
import { app } from 'electron';
import AutoLaunch from 'auto-launch';

View File

@@ -1,5 +1,3 @@
'use strict';
export default class BaseComponent {
generateNodeFromTemplate(template: string): Element | null {
const wrapper = document.createElement('div');

View File

@@ -1,5 +1,3 @@
'use strict';
import Tab from './tab';
export default class FunctionalTab extends Tab {

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer } from 'electron';
import Tab from './tab';

View File

@@ -1,5 +1,3 @@
'use strict';
import WebView from './webview';
import BaseComponent from './base';

View File

@@ -1,4 +1,3 @@
'use strict';
import { remote } from 'electron';
import path from 'path';

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer, remote, clipboard, shell } from 'electron';
import { feedbackHolder } from './feedback';

View File

@@ -1,4 +1,3 @@
'use strict';
import { ipcRenderer } from 'electron';
import {
appId, customReply, focusCurrentServer, parseReply, setupReply

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer } from 'electron';
import { focusCurrentServer } from './helpers';

View File

@@ -1,5 +1,3 @@
'use strict';
import { remote } from 'electron';
import * as params from '../utils/params-util';
import { appId, loadBots } from './helpers';

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer } from 'electron';
export function init($reconnectButton: Element, $settingsButton: Element): void {

View File

@@ -1,4 +1,3 @@
'use strict';
import electron, { app } from 'electron';
import * as ConfigUtil from '../../utils/config-util';

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer } from 'electron';
import BaseComponent from '../../components/base';

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer } from 'electron';
import BaseSection from './base-section';

View File

@@ -1,4 +1,3 @@
'use strict';
import { ipcRenderer, remote, OpenDialogOptions } from 'electron';
import path from 'path';

View File

@@ -1,5 +1,3 @@
'use strict';
import BaseComponent from '../../components/base';
import * as t from '../../utils/translation-util';

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer } from 'electron';
import BaseSection from './base-section';

View File

@@ -1,5 +1,3 @@
'use strict';
import { shell, ipcRenderer } from 'electron';
import BaseComponent from '../../components/base';

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer } from 'electron';
import BaseComponent from '../../components/base';

View File

@@ -1,5 +1,3 @@
'use strict';
import { remote, ipcRenderer } from 'electron';
import BaseComponent from '../../components/base';

View File

@@ -1,5 +1,3 @@
'use strict';
import BaseSection from './base-section';
import NewServerForm from './new-server-form';
import * as t from '../../utils/translation-util';

View File

@@ -1,5 +1,3 @@
'use strict';
import { shell } from 'electron';
import BaseSection from './base-section';

View File

@@ -1,5 +1,3 @@
'use strict';
import { ipcRenderer, shell } from 'electron';
import * as SetupSpellChecker from './spellchecker';

View File

@@ -1,5 +1,3 @@
'use strict';
import type { Subject } from 'rxjs';
import { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker';

View File

@@ -1,4 +1,3 @@
'use strict';
import { ipcRenderer, remote, WebviewTag, NativeImage } from 'electron';
import path from 'path';

View File

@@ -1,5 +1,3 @@
'use strict';
import { remote } from 'electron';
import { JsonDB } from 'node-json-db';
import { initSetUp } from './default-util';

View File

@@ -1,5 +1,3 @@
'use strict';
// unescape already encoded/escaped strings
export function decodeString(stringInput: string): string {
const parser = new DOMParser();

View File

@@ -1,4 +1,3 @@
'use strict';
import { JsonDB } from 'node-json-db';
import fs from 'fs';

View File

@@ -1,5 +1,3 @@
'use strict';
import * as ConfigUtil from './config-util';
// TODO: TypeScript - add to Setting interface

View File

@@ -1,4 +1,3 @@
'use strict';
import { JsonDB } from 'node-json-db';
import escape from 'escape-html';

View File

@@ -1,5 +1,3 @@
'use strict';
// TODO: TypeScript - Add @types/
import wurl from 'wurl';

View File

@@ -1,4 +1,3 @@
'use strict';
import { JsonDB } from 'node-json-db';
import fs from 'fs';

View File

@@ -1,5 +1,3 @@
'use strict';
import * as ConfigUtil from './config-util';
export interface ProxyRule {

View File

@@ -1,4 +1,3 @@
'use strict';
import { remote } from 'electron';
import os from 'os';

View File

@@ -1,5 +1,3 @@
'use strict';
import path from 'path';
import electron from 'electron';
import i18n from 'i18n';

View File

@@ -219,6 +219,7 @@
"@typescript-eslint/restrict-template-expressions": "off",
"capitalized-comments": "off",
"import/no-mutable-exports": "off",
"import/unambiguous": "error",
"max-lines": [
"warn",
{
@@ -232,11 +233,26 @@
"no-warning-comments": "off",
"object-curly-spacing": "off",
"padding-line-between-statements": "off",
"strict": "error",
"unicorn/catch-error-name": "off"
},
"envs": [
"node",
"browser"
],
"overrides": [
{
"files": [
"gulpfile.js",
"scripts/notarize.js",
"tools/locale-helper/index.js",
"tools/reinstall-node-modules.js",
"typings.d.ts"
],
"parserOptions": {
"sourceType": "script"
}
}
]
}
}

View File

@@ -1,3 +1,4 @@
'use strict';
const path = require('path');
const dotenv = require('dotenv');

View File

@@ -1,3 +1,4 @@
'use strict';
const translate = require('@vitalets/google-translate-api');
const path = require('path');
const fs = require('fs');

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env node
'use strict';
const {exec} = require('child_process');
const path = require('path');

1
typings.d.ts vendored
View File

@@ -1,3 +1,4 @@
'use strict';
declare module '@electron-elements/send-feedback';
declare module 'node-mac-notifier';
declare module 'wurl';