From d1f4bc678c15b56f0d3e9ceaf05788a8722fbde0 Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Thu, 11 Apr 2019 19:34:23 +0200 Subject: [PATCH] Fix code-style --- app/src/actions/ConnectionManager.ts | 2 +- app/src/actions/Global.ts | 2 +- app/src/actions/Tree.ts | 3 +- app/src/components/Demo/ShowText.tsx | 6 ++-- .../components/SettingsDrawer/Settings.tsx | 2 +- app/src/components/Sidebar/CodeBlockColors.ts | 2 +- app/src/components/Sidebar/CodeDiff.tsx | 2 +- app/src/components/Sidebar/History.tsx | 2 +- .../components/Sidebar/Publish/Publish.tsx | 5 ++- .../Sidebar/ValueRenderer/ValuePanel.tsx | 2 +- app/src/components/UpdateNotifier.tsx | 33 +++++++++---------- app/src/model/ConnectionOptions.ts | 2 +- app/src/reducers/Global.ts | 2 +- app/src/theme.ts | 4 +-- backend/src/DataSource/MqttSource.ts | 2 +- backend/src/Model/ChangeBuffer.ts | 4 +-- backend/src/Model/RingBuffer.ts | 2 +- backend/src/Model/TreeNode.ts | 2 +- backend/src/Model/TreeNodeFactory.ts | 4 +-- events/EventBus.ts | 2 +- events/EventDispatcher.ts | 2 +- package.ts | 2 +- 22 files changed, 43 insertions(+), 46 deletions(-) diff --git a/app/src/actions/ConnectionManager.ts b/app/src/actions/ConnectionManager.ts index a2bbacb..23b6a7e 100644 --- a/app/src/actions/ConnectionManager.ts +++ b/app/src/actions/ConnectionManager.ts @@ -57,7 +57,7 @@ async function openCertificate(): Promise { } return new Promise((resolve, reject) => { - remote.dialog.showOpenDialog({ properties: ['openFile'], securityScopedBookmarks: true }, (filePaths?: string[]) => { + remote.dialog.showOpenDialog({ properties: ['openFile'], securityScopedBookmarks: true }, (filePaths?: Array) => { const selectedFile = filePaths && filePaths[0] if (!selectedFile) { reject(rejectReasons.noCertificateSelected) diff --git a/app/src/actions/Global.ts b/app/src/actions/Global.ts index 49ee179..c575828 100644 --- a/app/src/actions/Global.ts +++ b/app/src/actions/Global.ts @@ -19,4 +19,4 @@ export const toggleSettingsVisibility = () => (dispatch: Dispatch) => { dispatch({ type: ActionTypes.toggleSettingsVisibility, }) -} \ No newline at end of file +} diff --git a/app/src/actions/Tree.ts b/app/src/actions/Tree.ts index 886699d..78dbed7 100644 --- a/app/src/actions/Tree.ts +++ b/app/src/actions/Tree.ts @@ -5,7 +5,7 @@ import { AppState } from '../reducers' import { batchActions } from 'redux-batched-actions' import { setTopic } from './Publish' import { TopicViewModel } from '../model/TopicViewModel' -import { globalActions } from '.'; +import { globalActions } from '.' const debounce = require('lodash.debounce') export const selectTopic = (topic: q.TreeNode) => (dispatch: Dispatch, getState: () => AppState) => { @@ -80,5 +80,4 @@ export const togglePause = (tree?: q.Tree) => (dispatch: Dispatc type: paused ? ActionTypes.TREE_RESUME_UPDATES : ActionTypes.TREE_PAUSE_UPDATES, }) - } diff --git a/app/src/components/Demo/ShowText.tsx b/app/src/components/Demo/ShowText.tsx index ac90aa1..1f66281 100644 --- a/app/src/components/Demo/ShowText.tsx +++ b/app/src/components/Demo/ShowText.tsx @@ -4,7 +4,7 @@ import Key from './Key' interface State { message?: string - keys: string[] + keys: Array location: string } @@ -20,7 +20,7 @@ class Demo extends React.Component<{classes: any}, State> { } public componentDidMount() { - (window as any).demo.showMessage = (message: string, location: string, duration: number, keys: string[] = []) => { + (window as any).demo.showMessage = (message: string, location: string, duration: number, keys: Array = []) => { this.clearTimer() this.setState({ message, location, keys }) this.timer = setTimeout(() => this.setState({ message: undefined }), duration) @@ -59,7 +59,7 @@ class Demo extends React.Component<{classes: any}, State> { return null } - let keys: any[] = [] + let keys: Array = [] if (this.state.keys.length > 0) { keys = this.state.keys.map(key => []) .reduce((prev, current) => { diff --git a/app/src/components/SettingsDrawer/Settings.tsx b/app/src/components/SettingsDrawer/Settings.tsx index 25bd5c9..3330b29 100644 --- a/app/src/components/SettingsDrawer/Settings.tsx +++ b/app/src/components/SettingsDrawer/Settings.tsx @@ -216,7 +216,7 @@ const mapDispatchToProps = (dispatch: any) => { actions: { settings: bindActionCreators(settingsActions, dispatch), global: bindActionCreators(globalActions, dispatch), - } + }, } } diff --git a/app/src/components/Sidebar/CodeBlockColors.ts b/app/src/components/Sidebar/CodeBlockColors.ts index d451abc..e978163 100644 --- a/app/src/components/Sidebar/CodeBlockColors.ts +++ b/app/src/components/Sidebar/CodeBlockColors.ts @@ -16,4 +16,4 @@ export enum CodeBlockColorsBraceMonokai { string = '#E6DB74', variable = '#A6E22E', gutters = '#2F3129', -} \ No newline at end of file +} diff --git a/app/src/components/Sidebar/CodeDiff.tsx b/app/src/components/Sidebar/CodeDiff.tsx index 5e6eb72..d40df14 100644 --- a/app/src/components/Sidebar/CodeDiff.tsx +++ b/app/src/components/Sidebar/CodeDiff.tsx @@ -19,7 +19,7 @@ class CodeDiff extends React.Component { super(props) } - private renderChangeAmount(changes: Diff.Change[]) { + private renderChangeAmount(changes: Array) { const additions = changes.map(change => (change.added === true) ? (change.count || 0) : 0).reduce((a, b) => a + b) const deletions = changes.map(change => (change.removed === true) ? (change.count || 0) : 0).reduce((a, b) => a + b) if (additions === 0 && deletions === 0) { diff --git a/app/src/components/Sidebar/History.tsx b/app/src/components/Sidebar/History.tsx index 41db15b..85f2a2c 100644 --- a/app/src/components/Sidebar/History.tsx +++ b/app/src/components/Sidebar/History.tsx @@ -10,7 +10,7 @@ interface HistoryItem { } interface Props { - items: HistoryItem[] + items: Array onClick?: (index: number, element: EventTarget) => void classes: any contentTypeIndicator?: JSX.Element diff --git a/app/src/components/Sidebar/Publish/Publish.tsx b/app/src/components/Sidebar/Publish/Publish.tsx index 5ec3211..c6fc64c 100644 --- a/app/src/components/Sidebar/Publish/Publish.tsx +++ b/app/src/components/Sidebar/Publish/Publish.tsx @@ -25,7 +25,6 @@ import { withTheme, } from '@material-ui/core' -// tslint:disable-next-line import { default as AceEditor } from 'react-ace' import { AppState } from '../../../reducers' import History from '../History' @@ -52,7 +51,7 @@ interface Props { } interface State { - history: Message[] + history: Array } class Publish extends React.Component { @@ -97,7 +96,7 @@ class Publish extends React.Component { // Remove duplicates let filteredHistory = this.state.history.filter(e => e.payload !== payload || e.topic !== topic) filteredHistory = filteredHistory.slice(-7) - const history: Message[] = [...filteredHistory, { topic, payload, sent: new Date() }] + const history: Array = [...filteredHistory, { topic, payload, sent: new Date() }] this.setState({ history }) } diff --git a/app/src/components/Sidebar/ValueRenderer/ValuePanel.tsx b/app/src/components/Sidebar/ValueRenderer/ValuePanel.tsx index 0d2497d..344ec1f 100644 --- a/app/src/components/Sidebar/ValueRenderer/ValuePanel.tsx +++ b/app/src/components/Sidebar/ValueRenderer/ValuePanel.tsx @@ -191,7 +191,7 @@ const styles: StyleRulesCallback = (theme: Theme) => { }, toggleButton: { height: '36px', - } + }, } } diff --git a/app/src/components/UpdateNotifier.tsx b/app/src/components/UpdateNotifier.tsx index 1c855ff..b1f4aec 100644 --- a/app/src/components/UpdateNotifier.tsx +++ b/app/src/components/UpdateNotifier.tsx @@ -1,4 +1,16 @@ +import * as compareVersions from 'compare-versions' +import * as electron from 'electron' +import * as os from 'os' import * as React from 'react' +import axios from 'axios' +import Close from '@material-ui/icons/Close' +import CloudDownload from '@material-ui/icons/CloudDownload' +import { AppState } from '../reducers' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import { green } from '@material-ui/core/colors' +import { Theme, withStyles } from '@material-ui/core/styles' +import { updateNotifierActions } from '../actions' import { Button, @@ -9,19 +21,6 @@ import { SnackbarContent, Typography, } from '@material-ui/core' -import { Theme, withStyles } from '@material-ui/core/styles' -import { green } from '@material-ui/core/colors' - -import { AppState } from '../reducers' -import Close from '@material-ui/icons/Close' -import CloudDownload from '@material-ui/icons/CloudDownload' -import { bindActionCreators } from 'redux' -import { connect } from 'react-redux' -import { updateNotifierActions } from '../actions' -import axios from 'axios' -import * as compareVersions from 'compare-versions' -import * as electron from 'electron' -import * as os from 'os' interface Props { showUpdateNotification: boolean @@ -32,7 +31,7 @@ interface Props { interface GithubRelease { url: string, - assets?: GithubAsset[] + assets?: Array published_at: string // "2019-01-25T20:14:39Z" body_html: string body: string @@ -50,7 +49,7 @@ interface GithubAsset { } interface State { - newerVersions: GithubRelease[] + newerVersions: Array } class UpdateNotifier extends React.Component { @@ -78,14 +77,14 @@ class UpdateNotifier extends React.Component { return ownVersionIsBeta || !release.prerelease } - private async fetchReleases(): Promise { + private async fetchReleases(): Promise> { const res = await axios.get('https://api.github.com/repos/thomasnordquist/mqtt-explorer/releases', { headers: { accept: 'application/vnd.github.v3.full+json', }, }) - return res.data as GithubRelease[] + return res.data as Array } private onCloseNotification = (event: React.SyntheticEvent, reason: string) => { diff --git a/app/src/model/ConnectionOptions.ts b/app/src/model/ConnectionOptions.ts index d77a4d6..2fa7f90 100644 --- a/app/src/model/ConnectionOptions.ts +++ b/app/src/model/ConnectionOptions.ts @@ -21,7 +21,7 @@ export interface ConnectionOptions { certValidation: boolean selfSignedCertificate?: CertificateParameters clientId?: string - subscriptions: string[] + subscriptions: Array } export function toMqttConnection(options: ConnectionOptions): MqttOptions | undefined { diff --git a/app/src/reducers/Global.ts b/app/src/reducers/Global.ts index b6ab124..9be153b 100644 --- a/app/src/reducers/Global.ts +++ b/app/src/reducers/Global.ts @@ -68,4 +68,4 @@ export const globalState: Reducer, GlobalAction> = default: return state } -} \ No newline at end of file +} diff --git a/app/src/theme.ts b/app/src/theme.ts index 385973a..a8e27ee 100644 --- a/app/src/theme.ts +++ b/app/src/theme.ts @@ -1,5 +1,5 @@ -import { createMuiTheme } from "@material-ui/core"; -import { amber } from "@material-ui/core/colors"; +import { createMuiTheme } from '@material-ui/core' +import { amber } from '@material-ui/core/colors' const baseTheme = { typography: { diff --git a/backend/src/DataSource/MqttSource.ts b/backend/src/DataSource/MqttSource.ts index 805bebb..2d71922 100644 --- a/backend/src/DataSource/MqttSource.ts +++ b/backend/src/DataSource/MqttSource.ts @@ -12,7 +12,7 @@ export interface MqttOptions { tls: boolean certValidation: boolean clientId?: string - subscriptions: string[] + subscriptions: Array certificateAuthority?: string } diff --git a/backend/src/Model/ChangeBuffer.ts b/backend/src/Model/ChangeBuffer.ts index fa5076a..a0d1051 100644 --- a/backend/src/Model/ChangeBuffer.ts +++ b/backend/src/Model/ChangeBuffer.ts @@ -1,7 +1,7 @@ import { MqttMessage } from '../../../events' export class ChangeBuffer { - private buffer: MqttMessage[] = [] + private buffer: Array = [] private size = 0 private maxSize = 100_000_000 // ~100MB public length = 0 @@ -27,7 +27,7 @@ export class ChangeBuffer { return this.size / this.maxSize } - public popAll(): MqttMessage[] { + public popAll(): Array { const tmpBuffer = this.buffer this.buffer = [] this.size = 0 diff --git a/backend/src/Model/RingBuffer.ts b/backend/src/Model/RingBuffer.ts index f15e4d7..824308d 100644 --- a/backend/src/Model/RingBuffer.ts +++ b/backend/src/Model/RingBuffer.ts @@ -6,7 +6,7 @@ export class RingBuffer { private capacity: number private maxItems: number private usage: number = 0 - private items: T[] = [] + private items: Array = [] private start: number = 0 private end: number = 0 diff --git a/backend/src/Model/TreeNode.ts b/backend/src/Model/TreeNode.ts index 7e55e40..c0a8b9a 100644 --- a/backend/src/Model/TreeNode.ts +++ b/backend/src/Model/TreeNode.ts @@ -67,7 +67,7 @@ export class TreeNode { previous.removeEdge(this.sourceEdge) } - private findChild(edges: string[]): TreeNode | undefined { + private findChild(edges: Array): TreeNode | undefined { if (edges.length === 0) { return this } diff --git a/backend/src/Model/TreeNodeFactory.ts b/backend/src/Model/TreeNodeFactory.ts index 7b47534..9948555 100644 --- a/backend/src/Model/TreeNodeFactory.ts +++ b/backend/src/Model/TreeNodeFactory.ts @@ -6,7 +6,7 @@ interface HasLength { } export abstract class TreeNodeFactory { - public static insertNodeAtPosition(edgeNames: string[], node: TreeNode) { + public static insertNodeAtPosition(edgeNames: Array, node: TreeNode) { let currentNode: TreeNode = new Tree() let edge for (const edgeName of edgeNames) { @@ -19,7 +19,7 @@ export abstract class TreeNodeFactory { node.sourceEdge!.target = node } - public static fromEdgesAndValue(edgeNames: string[], value?: Base64Message | null): TreeNode { + public static fromEdgesAndValue(edgeNames: Array, value?: Base64Message | null): TreeNode { const node = new TreeNode() node.setMessage({ value: value || undefined, diff --git a/events/EventBus.ts b/events/EventBus.ts index 3b0d4ed..2a6c0b2 100644 --- a/events/EventBus.ts +++ b/events/EventBus.ts @@ -47,7 +47,7 @@ class IpcMainEventBus implements EventBusInterface { class IpcRendererEventBus implements EventBusInterface { private ipc: IpcRenderer - private callbacks: CallbackStore[] = [] + private callbacks: Array = [] constructor(ipc: IpcRenderer) { this.ipc = ipc diff --git a/events/EventDispatcher.ts b/events/EventDispatcher.ts index ab94646..6e1097a 100644 --- a/events/EventDispatcher.ts +++ b/events/EventDispatcher.ts @@ -8,7 +8,7 @@ interface CallbackStore { export class EventDispatcher { private emitter = new EventEmitter() private dispatcher: Dispatcher - private callbacks: CallbackStore[] = [] + private callbacks: Array = [] constructor(dispatcher: Dispatcher) { this.dispatcher = dispatcher diff --git a/package.ts b/package.ts index 88dc319..982bc23 100644 --- a/package.ts +++ b/package.ts @@ -84,7 +84,7 @@ export interface BuildInfo { package: Packages } -type Packages = 'portable' | 'nsis' | 'appx' | 'AppImage' | 'snap' | 'dmg' | 'zip' | 'mas' | 'mas-dev' +type Packages = 'portable' | 'nsis' | 'appx' | 'AppImage' | 'snap' | 'dmg' | 'zip' | 'mas' | 'mas-dev' | 'deb' async function buildWithOptions(options: builder.CliOptions, buildInfo: BuildInfo) { fs.writeFileSync(path.join(options.projectDir!, 'buildOptions.json'), JSON.stringify(buildInfo))