Skip to content

Commit

Permalink
chore: add eslint import order plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Apr 22, 2024
1 parent 72083af commit 24626d8
Show file tree
Hide file tree
Showing 65 changed files with 960 additions and 668 deletions.
15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@
]
}
],
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal"
],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"no-prototype-builtins": "off",
"prefer-const": "error",
"@typescript-eslint/ban-types": "off",
Expand Down
3 changes: 2 additions & 1 deletion client/infrastructure/electron/app_paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {app} from 'electron';
import * as os from 'os';
import * as path from 'path';

import {app} from 'electron';

const isWindows = os.platform() === 'win32';

/**
Expand Down
3 changes: 1 addition & 2 deletions client/src/www/TODO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
// import * as outlineIcons from './ui_components/outline-icons';

import * as clipboard from './app/clipboard';
import * as errorReporter from './shared/error_reporter';
import * as platform from './app/platform';
import * as tunnel from './app/tunnel';
import * as updater from './app/updater';
import * as urlInterceptor from './app/url_interceptor';
import * as vpnInstaller from './app/vpn_installer';

import * as errorReporter from './shared/error_reporter';
import * as aboutView from './ui_components/about-view';
import * as addServerView from './ui_components/add-server-view';
import * as appRoot from './ui_components/app-root.js';
Expand Down
14 changes: 7 additions & 7 deletions client/src/www/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import * as errors from '../model/errors';
import * as events from '../model/events';
import {Server} from '../model/server';
import {OperationTimedOut} from '../../../infrastructure/timeout_promise';
import {ServerListItem, ServerConnectionState} from '../views/servers_view';
import {SERVER_CONNECTION_INDICATOR_DURATION_MS} from '../views/servers_view/server_connection_indicator';

import {Clipboard} from './clipboard';
import {EnvironmentVariables} from './environment';
import {OutlineErrorReporter} from '../shared/error_reporter';
import {OutlineServerRepository} from './outline_server_repository';
import {Settings, SettingsKey} from './settings';
import {Updater} from './updater';
import {UrlInterceptor} from './url_interceptor';
import {VpnInstaller} from './vpn_installer';
import {Localizer} from '../../../infrastructure/i18n';
import {OperationTimedOut} from '../../../infrastructure/timeout_promise';
import * as errors from '../model/errors';
import * as events from '../model/events';
import {Server} from '../model/server';
import {OutlineErrorReporter} from '../shared/error_reporter';
import {ServerListItem, ServerConnectionState} from '../views/servers_view';
import {SERVER_CONNECTION_INDICATOR_DURATION_MS} from '../views/servers_view/server_connection_indicator';

enum OUTLINE_ACCESS_KEY_SCHEME {
STATIC = 'ss',
Expand Down
8 changes: 4 additions & 4 deletions client/src/www/app/cordova_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ import * as Sentry from '@sentry/browser';

import {AbstractClipboard} from './clipboard';
import {EnvironmentVariables} from './environment';
import {SentryErrorReporter, Tags} from '../shared/error_reporter';
import {FakeOutlineTunnel} from './fake_tunnel';
import {main} from './main';
import * as errors from '../model/errors';
import {OutlinePlatform} from './platform';
import {Tunnel, TunnelStatus} from './tunnel';
import {ShadowsocksSessionConfig} from './tunnel';
import {AbstractUpdater} from './updater';
import * as interceptors from './url_interceptor';
import {FakeOutlineTunnel} from './fake_tunnel';
import {ShadowsocksSessionConfig} from './tunnel';
import {NoOpVpnInstaller, VpnInstaller} from './vpn_installer';
import * as errors from '../model/errors';
import {SentryErrorReporter, Tags} from '../shared/error_reporter';

const OUTLINE_PLUGIN_NAME = 'OutlinePlugin';

Expand Down
4 changes: 2 additions & 2 deletions client/src/www/app/electron_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';

import * as Sentry from '@sentry/electron/renderer';

import {ErrorCode, OutlinePluginError} from '../model/errors';

import {AbstractClipboard} from './clipboard';
import {ElectronOutlineTunnel} from './electron_outline_tunnel';
import {getSentryBrowserIntegrations, OutlineErrorReporter, Tags} from '../shared/error_reporter';
import {FakeOutlineTunnel} from './fake_tunnel';
import {getLocalizationFunction, main} from './main';
import {AbstractUpdater} from './updater';
import {UrlInterceptor} from './url_interceptor';
import {VpnInstaller} from './vpn_installer';
import {ErrorCode, OutlinePluginError} from '../model/errors';
import {getSentryBrowserIntegrations, OutlineErrorReporter, Tags} from '../shared/error_reporter';

const isWindows = window.electron.os.platform === 'win32';
const isLinux = window.electron.os.platform === 'linux';
Expand Down
2 changes: 1 addition & 1 deletion client/src/www/app/electron_outline_tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {Tunnel, TunnelStatus, ShadowsocksSessionConfig} from './tunnel';
import * as errors from '../model/errors';

import {Tunnel, TunnelStatus, ShadowsocksSessionConfig} from './tunnel';

export class ElectronOutlineTunnel implements Tunnel {
private statusChangeListener: ((status: TunnelStatus) => void) | null = null;
Expand Down
2 changes: 1 addition & 1 deletion client/src/www/app/fake_tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {Tunnel, TunnelStatus, ShadowsocksSessionConfig} from './tunnel';
import * as errors from '../model/errors';

import {Tunnel, TunnelStatus, ShadowsocksSessionConfig} from './tunnel';

// Fake Tunnel implementation for demoing and testing.
// Note that because this implementation does not emit disconnection events, "switching" between
Expand Down
5 changes: 3 additions & 2 deletions client/src/www/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@

import '../ui_components/app-root.js';

import {EventQueue} from '../model/events';

import {makeConfig, SIP002_URI} from 'ShadowsocksConfig';

import {App} from './app';
import {onceEnvVars} from './environment';
import {OutlineServerRepository} from './outline_server_repository';
import {makeConfig, SIP002_URI} from 'ShadowsocksConfig';
import {OutlinePlatform} from './platform';
import {Settings} from './settings';
import {TunnelFactory} from './tunnel';
import {Localizer} from '../../../infrastructure/i18n.js';
import {EventQueue} from '../model/events';

// Used to determine whether to use Polymer functionality on app initialization failure.
let webComponentsAreReady = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import {SHADOWSOCKS_URI} from 'ShadowsocksConfig';

import * as errors from '../../model/errors';

import {ShadowsocksSessionConfig} from '../tunnel';

// DON'T use these methods outside of this folder!
Expand Down
5 changes: 2 additions & 3 deletions client/src/www/app/outline_server_repository/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
import {makeConfig, SHADOWSOCKS_URI, SIP002_URI} from 'ShadowsocksConfig';
import uuidv4 from 'uuidv4';

import {staticKeyToShadowsocksSessionConfig} from './access_key_serialization';
import {OutlineServer} from './server';
import * as errors from '../../model/errors';
import * as events from '../../model/events';
import {ServerRepository, ServerType} from '../../model/server';

import {TunnelFactory} from '../tunnel';

import {OutlineServer} from './server';
import {staticKeyToShadowsocksSessionConfig} from './access_key_serialization';

// TODO(daniellacosse): write unit tests for these functions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {makeConfig, SIP002_URI} from 'ShadowsocksConfig';

import {OutlineServerRepository, ServersStorageV0, ServersStorageV1, serversStorageV0ConfigToAccessKey} from '.';
import {OutlineServer} from './server';
import {InMemoryStorage} from '../../../../infrastructure/memory_storage';
import {ServerIncompatible, ServerUrlInvalid, ShadowsocksUnsupportedCipher} from '../../model/errors';
import {EventQueue, ServerAdded, ServerForgetUndone, ServerForgotten, ServerRenamed} from '../../model/events';

import {FakeOutlineTunnel} from '../fake_tunnel';

import {OutlineServerRepository, ServersStorageV0, ServersStorageV1, serversStorageV0ConfigToAccessKey} from '.';
import {OutlineServer} from './server';
import {makeConfig, SIP002_URI} from 'ShadowsocksConfig';


// TODO(alalama): unit tests for OutlineServer.

Expand Down
3 changes: 1 addition & 2 deletions client/src/www/app/outline_server_repository/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {fetchShadowsocksSessionConfig, staticKeyToShadowsocksSessionConfig} from './access_key_serialization';
import * as errors from '../../model/errors';
import * as events from '../../model/events';
import {Server, ServerType} from '../../model/server';

import {Tunnel, TunnelStatus, ShadowsocksSessionConfig} from '../tunnel';

import {fetchShadowsocksSessionConfig, staticKeyToShadowsocksSessionConfig} from './access_key_serialization';

// PLEASE DON'T use this class outside of this `outline_server_repository` folder!

Expand Down
2 changes: 1 addition & 1 deletion client/src/www/app/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

import {Clipboard} from './clipboard';
import {EnvironmentVariables} from './environment';
import {OutlineErrorReporter} from '../shared/error_reporter';
import {TunnelFactory} from './tunnel';
import {Updater} from './updater';
import {UrlInterceptor} from './url_interceptor';
import {VpnInstaller} from './vpn_installer';
import {OutlineErrorReporter} from '../shared/error_reporter';

// Provides platform-specific dependencies.
// TODO: Remove one of hasDeviceSupport and getServerFactory; they're almost the same
Expand Down
2 changes: 1 addition & 1 deletion client/src/www/app/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {Settings, SettingsKey} from './settings';
import {InMemoryStorage} from '../../../infrastructure/memory_storage';

import {Settings, SettingsKey} from './settings';

const FAKE_SETTINGS_KEYS = ['key', 'key1', 'key2'];

Expand Down
3 changes: 2 additions & 1 deletion client/src/www/testing/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
limitations under the License.
*/

import IntlMessageFormat from 'intl-messageformat';

import type {FormattableMessage, Localizer} from '../../../infrastructure/i18n';
import englishMessages from '../messages/en.json';
import IntlMessageFormat from 'intl-messageformat';

export const localize: Localizer = (messageID: string, ...formatKeyValueList: FormattableMessage[]): string => {
const message = (englishMessages as {[messageID: string]: string})[messageID];
Expand Down
9 changes: 5 additions & 4 deletions client/src/www/views/contact_view/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
* limitations under the License.
*/

import {ContactView} from './index';

import {ListItemBase} from '@material/mwc-list/mwc-list-item-base';
import {Select} from '@material/mwc-select';
import {fixture, html, nextFrame, oneEvent} from '@open-wc/testing';

import {ContactView} from './index';
import {SupportForm} from './support_form';
import {OutlineErrorReporter, SentryErrorReporter} from '../../shared/error_reporter';
import {localize} from '../../testing/localize';
import {ListItemBase} from '@material/mwc-list/mwc-list-item-base';
import {Select} from '@material/mwc-select';


describe('ContactView client variant', () => {
let el: ContactView;
Expand Down
4 changes: 2 additions & 2 deletions client/src/www/views/contact_view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import {Radio} from '@material/mwc-radio';
import {SingleSelectedEvent} from '@material/mwc-list/mwc-list';

import './support_form';
import {IssueType, UNSUPPORTED_ISSUE_TYPE_HELPPAGES} from './issue_type';
import {AppType} from './app_type';
import {IssueType, UNSUPPORTED_ISSUE_TYPE_HELPPAGES} from './issue_type';
import {FormValues, SupportForm, ValidFormValues} from './support_form';
import {OutlineErrorReporter} from '../../shared/error_reporter';
import {Localizer} from '../../../../infrastructure/i18n';
import {OutlineErrorReporter} from '../../shared/error_reporter';

/** The possible steps in the stepper. Only one step is shown at a time. */
enum Step {
Expand Down
3 changes: 2 additions & 1 deletion client/src/www/views/contact_view/support_form/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/

import {TextField} from '@material/mwc-textfield';
import {fixture, html, nextFrame, oneEvent, triggerBlurFor, triggerFocusFor} from '@open-wc/testing';

import {FormValues, SupportForm} from './index';

import {fixture, html, nextFrame, oneEvent, triggerBlurFor, triggerFocusFor} from '@open-wc/testing';

async function setValue(el: TextField, value: string) {
await triggerFocusFor(el);
Expand Down
8 changes: 5 additions & 3 deletions client/src/www/views/contact_view/support_form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
*/

import {html, css, LitElement, TemplateResult, nothing, PropertyValues} from 'lit';
import {createRef, Ref, ref} from 'lit/directives/ref.js';
import {live} from 'lit/directives/live.js';
import {customElement, property, state} from 'lit/decorators.js';
import {live} from 'lit/directives/live.js';
import {createRef, Ref, ref} from 'lit/directives/ref.js';

import '@material/mwc-button';
import '@material/mwc-select';
import '@material/mwc-textarea';
import '@material/mwc-textfield';
import {Localizer} from '../../../../../infrastructure/i18n';
import {AppType} from '../app_type';

import {TextField} from '@material/mwc-textfield';
import {SelectedDetail} from '@material/mwc-menu/mwc-menu-base';
import {Localizer} from '../../../../../infrastructure/i18n';

type FormControl = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;

Expand Down
2 changes: 1 addition & 1 deletion client/src/www/views/contact_view/support_form/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import {html} from 'lit';

import './index';
import {AppType} from '../app_type';
import {FormValues} from './index';
import {localize} from '../../../testing/localize';
import {AppType} from '../app_type';

export default {
title: 'Contact View/Support Form',
Expand Down
4 changes: 2 additions & 2 deletions client/src/www/views/servers_view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@

import {css, html, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';
import { DirectiveResult } from 'lit/directive';
import {unsafeHTML, UnsafeHTMLDirective} from 'lit/directives/unsafe-html.js';

import '@material/mwc-button';
import './server_connection_indicator';
import './server_list';

import {ServerListItem as _ServerListItem} from './server_list_item';
import {ServerConnectionState as _ServerConnectionState} from './server_connection_indicator';
import {ServerListItem as _ServerListItem} from './server_list_item';
import { Localizer } from '../../../../infrastructure/i18n';

export type ServerListItem = _ServerListItem;

// (This value is used: it's exported.)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export import ServerConnectionState = _ServerConnectionState;
import { DirectiveResult } from 'lit/directive';

@customElement('servers-view')
export class ServerList extends LitElement {
Expand Down
2 changes: 1 addition & 1 deletion client/src/www/views/servers_view/server_list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {css, html, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';

import '../server_list_item/server_card';
import {ServerListItem} from '../server_list_item';
import {Localizer} from '../../../../../infrastructure/i18n';
import {ServerListItem} from '../server_list_item';

@customElement('server-list')
export class ServerList extends LitElement {
Expand Down
2 changes: 1 addition & 1 deletion client/src/www/views/servers_view/server_list/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import './index';

import {html} from 'lit';

import {localize} from '../../../testing/localize';
import {ServerList} from './index';
import {localize} from '../../../testing/localize';
import {ServerConnectionState} from '../server_connection_indicator';

export default {
Expand Down
5 changes: 3 additions & 2 deletions client/src/www/views/servers_view/server_list_item/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
limitations under the License.
*/

import {Ref} from 'lit/directives/ref';
import {Menu} from '@material/mwc-menu';
import {ServerConnectionState} from '../server_connection_indicator';
import {Ref} from 'lit/directives/ref';

import {Localizer} from '../../../../../infrastructure/i18n';
import {ServerConnectionState} from '../server_connection_indicator';

export enum ServerListItemEvent {
CONNECT = 'ConnectPressed',
Expand Down
Loading

0 comments on commit 24626d8

Please sign in to comment.