Update linter

This commit is contained in:
Thomas Nordquist
2020-04-16 10:56:46 +02:00
parent 19e8bfdb37
commit 30af13f793
53 changed files with 92 additions and 97 deletions

View File

@@ -44,6 +44,7 @@
"DEVTOOLS", "DEVTOOLS",
"mixins", "mixins",
"Explorerdmg", "Explorerdmg",
"heapsnapshot" "heapsnapshot",
"noconflict"
] ]
} }

View File

@@ -67,7 +67,7 @@ export const addChart = (chartParameters: ChartParameters) => async (
const chartExists = Boolean( const chartExists = Boolean(
getState() getState()
.charts.get('charts') .charts.get('charts')
.find((chart) => chart.topic === chartParameters.topic && chart.dotPath === chartParameters.dotPath) .find(chart => chart.topic === chartParameters.topic && chart.dotPath === chartParameters.dotPath)
) )
if (chartExists) { if (chartExists) {
dispatch(showNotification('Already added')) dispatch(showNotification('Already added'))

View File

@@ -20,7 +20,7 @@ export const connect = (options: MqttOptions, connectionId: string) => (
const event = makeConnectionStateEvent(connectionId) const event = makeConnectionStateEvent(connectionId)
const host = url.parse(options.url).hostname const host = url.parse(options.url).hostname
rendererEvents.subscribe(event, (dataSourceState) => { rendererEvents.subscribe(event, dataSourceState => {
if (dataSourceState.connected) { if (dataSourceState.connected) {
const didReconnect = Boolean(getState().connection.tree) const didReconnect = Boolean(getState().connection.tree)
if (!didReconnect) { if (!didReconnect) {

View File

@@ -146,7 +146,7 @@ export const deleteConnection = (connectionId: string) => (dispatch: Dispatch<an
const connectionIds = Object.keys(getState().connectionManager.connections) const connectionIds = Object.keys(getState().connectionManager.connections)
const connectionIdLocation = connectionIds.indexOf(connectionId) const connectionIdLocation = connectionIds.indexOf(connectionId)
const remainingIds = connectionIds.filter((id) => id !== connectionId) const remainingIds = connectionIds.filter(id => id !== connectionId)
const nextSelectedConnectionIndex = Math.min(remainingIds.length - 1, connectionIdLocation) const nextSelectedConnectionIndex = Math.min(remainingIds.length - 1, connectionIdLocation)
const nextSelectedConnection = remainingIds[nextSelectedConnectionIndex] const nextSelectedConnection = remainingIds[nextSelectedConnectionIndex]

View File

@@ -22,7 +22,7 @@ export const toggleSettingsVisibility = () => (dispatch: Dispatch<any>) => {
} }
export const requestConfirmation = (title: string, inquiry: string) => (dispatch: Dispatch<any>) => { export const requestConfirmation = (title: string, inquiry: string) => (dispatch: Dispatch<any>) => {
return new Promise((resolve) => { return new Promise(resolve => {
const confirmationRequest = { const confirmationRequest = {
title, title,
inquiry, inquiry,

View File

@@ -40,8 +40,8 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => async
const publishEvent = makePublishEvent(connectionId) const publishEvent = makePublishEvent(connectionId)
topicsForPurging topicsForPurging
.filter((t) => t.path() !== '' && t.hasMessage()) .filter(t => t.path() !== '' && t.hasMessage())
.map((t) => t.path()) .map(t => t.path())
.forEach((path, idx) => { .forEach((path, idx) => {
const mqttMessage = { const mqttMessage = {
topic: path, topic: path,

View File

@@ -82,7 +82,7 @@ function findNextNodeUpward(
} }
const neighborNodes = sortedNodes(settings, parent) const neighborNodes = sortedNodes(settings, parent)
const nodeIdx = neighborNodes.findIndex((n) => n.path() === treeNode.path()) const nodeIdx = neighborNodes.findIndex(n => n.path() === treeNode.path())
if (nodeIdx === 0) { if (nodeIdx === 0) {
return parent return parent
} }
@@ -125,7 +125,7 @@ function findNextNodeDownwardNeighbor(
} }
const neighborNodes = sortedNodes(settings, parent).filter(isTreeNodeVisible) const neighborNodes = sortedNodes(settings, parent).filter(isTreeNodeVisible)
const nodeIdx = neighborNodes.findIndex((n) => n.path() === treeNode.path()) const nodeIdx = neighborNodes.findIndex(n => n.path() === treeNode.path())
const downwardNeighbor = neighborNodes[nodeIdx + 1] const downwardNeighbor = neighborNodes[nodeIdx + 1]
if (downwardNeighbor) { if (downwardNeighbor) {
return downwardNeighbor return downwardNeighbor

View File

@@ -28,7 +28,7 @@ export default withTheme(
memo((props: Props) => { memo((props: Props) => {
const [width, setWidth] = React.useState(300) const [width, setWidth] = React.useState(300)
const [tooltip, setTooltip] = React.useState<Tooltip | undefined>() const [tooltip, setTooltip] = React.useState<Tooltip | undefined>()
const detectResize = React.useCallback((newWidth) => setWidth(newWidth), []) const detectResize = React.useCallback(newWidth => setWidth(newWidth), [])
const hintFormatter = React.useCallback( const hintFormatter = React.useCallback(
(point: any) => [ (point: any) => [

View File

@@ -27,7 +27,7 @@ function domainForData(data: Array<Point>): [number, number] {
let max = data[0].y let max = data[0].y
let min = data[0].y let min = data[0].y
data.forEach((d) => { data.forEach(d => {
if (max < d.y) { if (max < d.y) {
max = d.y max = d.y
} }

View File

@@ -31,7 +31,7 @@ function ColorSettings(props: {
) )
const menuItems = React.useMemo(() => { const menuItems = React.useMemo(() => {
return colors.map((color) => ( return colors.map(color => (
<MenuItem <MenuItem
style={{ minWidth: '8em', minHeight: '36px', backgroundColor: color, textAlign: 'center' }} style={{ minWidth: '8em', minHeight: '36px', backgroundColor: color, textAlign: 'center' }}
key={color} key={color}

View File

@@ -38,7 +38,7 @@ function InterpolationSettings(props: {
}, [curves]) }, [curves])
const menuItems = React.useMemo(() => { const menuItems = React.useMemo(() => {
return curves.map((curve) => ( return curves.map(curve => (
<MenuItem key={curve} onClick={callbacks[curve]} selected={props.chart.interpolation === curve}> <MenuItem key={curve} onClick={callbacks[curve]} selected={props.chart.interpolation === curve}>
<Typography variant="inherit">{curve.replace(/_/g, ' ')}</Typography> <Typography variant="inherit">{curve.replace(/_/g, ' ')}</Typography>
</MenuItem> </MenuItem>

View File

@@ -58,7 +58,7 @@ function TimeRangeSettings(props: Props) {
> >
<Typography>Chart data within a time interval</Typography> <Typography>Chart data within a time interval</Typography>
<div style={{ padding: '0 16px', width: '275px', textAlign: 'center' }}> <div style={{ padding: '0 16px', width: '275px', textAlign: 'center' }}>
{ranges.map((r) => { {ranges.map(r => {
return ( return (
<Button <Button
style={{ margin: '4px', textTransform: 'none' }} style={{ margin: '4px', textTransform: 'none' }}

View File

@@ -39,7 +39,7 @@ export function colors() {
indigo, indigo,
yellow, yellow,
] ]
.map((color) => [color[200], color[500], color[700]]) .map(color => [color[200], color[500], color[700]])
.reduce((a, b) => a.concat(b), []) .reduce((a, b) => a.concat(b), [])
.sort((a, b) => colorCompare(a, b)) .sort((a, b) => colorCompare(a, b))
return colors return colors

View File

@@ -63,7 +63,7 @@ function ChartPanel(props: Props) {
} }
}, [chartsInView]) }, [chartsInView])
const charts = props.charts.map((chartParameters) => ( const charts = props.charts.map(chartParameters => (
<CSSTransition <CSSTransition
key={`${chartParameters.topic}-${chartParameters.dotPath || ''}`} key={`${chartParameters.topic}-${chartParameters.dotPath || ''}`}
timeout={{ enter: 500, exit: 500 }} timeout={{ enter: 500, exit: 500 }}

View File

@@ -36,7 +36,7 @@ class ConnectionSettings extends React.Component<Props, State> {
private renderSubscriptions() { private renderSubscriptions() {
const connection = this.props.connection const connection = this.props.connection
return connection.subscriptions.map((subscription) => ( return connection.subscriptions.map(subscription => (
<Subscription <Subscription
deleteAction={() => this.props.managerActions.deleteSubscription(subscription, connection.id)} deleteAction={() => this.props.managerActions.deleteSubscription(subscription, connection.id)}
subscription={subscription} subscription={subscription}

View File

@@ -27,7 +27,7 @@ function ProfileList(props: Props) {
} }
const indexDirection = dir === 'next' ? 1 : -1 const indexDirection = dir === 'next' ? 1 : -1
const connectionArray = Object.values(connections) const connectionArray = Object.values(connections)
const selectedIndex = connectionArray.map((connection) => connection.id).indexOf(selected) const selectedIndex = connectionArray.map(connection => connection.id).indexOf(selected)
const nextConnection = connectionArray[selectedIndex + indexDirection] const nextConnection = connectionArray[selectedIndex + indexDirection]
if (nextConnection) { if (nextConnection) {
actions.selectConnection(nextConnection.id) actions.selectConnection(nextConnection.id)
@@ -48,7 +48,7 @@ function ProfileList(props: Props) {
return ( return (
<List style={{ height: '100%' }} component="nav" subheader={createConnectionButton}> <List style={{ height: '100%' }} component="nav" subheader={createConnectionButton}>
<div className={classes.list}> <div className={classes.list}>
{Object.values(connections).map((connection) => ( {Object.values(connections).map(connection => (
<ConnectionItem connection={connection} key={connection.id} selected={selected === connection.id} /> <ConnectionItem connection={connection} key={connection.id} selected={selected === connection.id} />
))} ))}
</div> </div>

View File

@@ -65,7 +65,7 @@ class Demo extends React.Component<{ classes: any }, State> {
let keys: Array<any> = [] let keys: Array<any> = []
if (this.state.keys.length > 0) { if (this.state.keys.length > 0) {
keys = this.state.keys keys = this.state.keys
.map((key) => [<Key key={key} keyboardKey={key} />]) .map(key => [<Key key={key} keyboardKey={key} />])
.reduce((prev, current) => { .reduce((prev, current) => {
return [prev, '+' as any, current] return [prev, '+' as any, current]
}) })

View File

@@ -25,7 +25,7 @@ function ContentView(props: Props) {
setDetectedHeight(newHeight) setDetectedHeight(newHeight)
}, []) }, [])
const detectSidebarSize = React.useCallback((width) => { const detectSidebarSize = React.useCallback(width => {
setDetectedSidebarWidth(width) setDetectedSidebarWidth(width)
}, []) }, [])

View File

@@ -33,7 +33,7 @@ function SearchBar(props: {
actions.settings.filterTopics(event.target.value) actions.settings.filterTopics(event.target.value)
}, []) }, [])
useGlobalKeyEventHandler(undefined, (event) => { useGlobalKeyEventHandler(undefined, event => {
const isCharacter = event.key.length === 1 const isCharacter = event.key.length === 1
const isModifierKey = event.metaKey || event.ctrlKey const isModifierKey = event.metaKey || event.ctrlKey
const isAllowedControlCharacter = event.keyCode === KeyCodes.backspace || event.keyCode === KeyCodes.delete const isAllowedControlCharacter = event.keyCode === KeyCodes.backspace || event.keyCode === KeyCodes.delete

View File

@@ -143,7 +143,7 @@ class Settings extends React.PureComponent<Props, {}> {
private renderAutoExpand() { private renderAutoExpand() {
const { classes, autoExpandLimit } = this.props const { classes, autoExpandLimit } = this.props
const limits = autoExpandLimitSet.map((limit) => ( const limits = autoExpandLimitSet.map(limit => (
<MenuItem key={limit.limit} value={limit.limit}> <MenuItem key={limit.limit} value={limit.limit}>
{limit.limit < 10000 && limit.limit > 0 ? `${limit.limit} topics` : limit.name} {limit.limit < 10000 && limit.limit > 0 ? `${limit.limit} topics` : limit.name}
</MenuItem> </MenuItem>

View File

@@ -47,7 +47,7 @@ function TimeLocaleSettings(props: Props) {
input={<Input name="time-locale" id="time-locale-label-placeholder" />} input={<Input name="time-locale" id="time-locale-label-placeholder" />}
name="time-locale" name="time-locale"
className={classes.input} className={classes.input}
renderValue={(v) => <span>{String(v)}</span>} renderValue={v => <span>{String(v)}</span>}
style={{ flex: '1' }} style={{ flex: '1' }}
> >
{localeMenuItems} {localeMenuItems}

View File

@@ -9,11 +9,9 @@ interface Props {
} }
function changeAmount(props: Props) { function changeAmount(props: Props) {
const additions = props.changes const additions = props.changes.map(change => (change.added === true ? change.count || 0 : 0)).reduce((a, b) => a + b)
.map((change) => (change.added === true ? change.count || 0 : 0))
.reduce((a, b) => a + b)
const deletions = props.changes const deletions = props.changes
.map((change) => (change.removed === true ? change.count || 0 : 0)) .map(change => (change.removed === true ? change.count || 0 : 0))
.reduce((a, b) => a + b) .reduce((a, b) => a + b)
if (additions === 0 && deletions === 0) { if (additions === 0 && deletions === 0) {
return null return null

View File

@@ -30,7 +30,7 @@ function useHistory(): [Array<Message>, (topic: string, payload?: string) => voi
const amendToHistory = useCallback( const amendToHistory = useCallback(
(topic: string, payload?: string) => { (topic: string, payload?: string) => {
// Remove duplicates // Remove duplicates
let filteredHistory = history.filter((e) => e.payload !== payload || e.topic !== topic) let filteredHistory = history.filter(e => e.payload !== payload || e.topic !== topic)
filteredHistory = filteredHistory.slice(-7) filteredHistory = filteredHistory.slice(-7)
setHistory([...filteredHistory, { topic, payload, sent: new Date() }]) setHistory([...filteredHistory, { topic, payload, sent: new Date() }])
}, },
@@ -157,12 +157,9 @@ const PublishButton = (props: { publish: () => void }) => {
[props.publish] [props.publish]
) )
const onFocus = useCallback( const onFocus = useCallback((e: React.FocusEvent<HTMLElement>) => {
(e: React.FocusEvent<HTMLElement>) => { ;(e.relatedTarget as HTMLElement | null)?.focus()
(e.relatedTarget as HTMLElement|null)?.focus() }, [])
},
[]
)
return useMemo( return useMemo(
() => ( () => (

View File

@@ -18,7 +18,7 @@ function PublishHistory(props: { history: Array<Message>; actions: typeof publis
) )
return useMemo(() => { return useMemo(() => {
const items = [...props.history].reverse().map((message) => ({ const items = [...props.history].reverse().map(message => ({
key: sha1(message.topic + message.payload), key: sha1(message.topic + message.payload),
title: message.topic, title: message.topic,
value: message.payload || '', value: message.payload || '',

View File

@@ -33,9 +33,9 @@ class Topic extends React.PureComponent<Props, {}> {
let key = 0 let key = 0
const breadCrumps = node const breadCrumps = node
.branch() .branch()
.map((node) => node.sourceEdge) .map(node => node.sourceEdge)
.filter((edge) => Boolean(edge)) .filter(edge => Boolean(edge))
.map((edge) => [ .map(edge => [
<Button <Button
onClick={() => this.props.actions.selectTopic(edge!.target)} onClick={() => this.props.actions.selectTopic(edge!.target)}
size="small" size="small"

View File

@@ -19,7 +19,7 @@ interface Props {
function filterUsingTimeRange(startTime: number | undefined, data: Array<q.Message>) { function filterUsingTimeRange(startTime: number | undefined, data: Array<q.Message>) {
if (startTime) { if (startTime) {
const threshold = new Date(Date.now() - startTime) const threshold = new Date(Date.now() - startTime)
return data.filter((d) => d.received >= threshold) return data.filter(d => d.received >= threshold)
} }
return data return data
@@ -31,7 +31,7 @@ function nodeToHistory(startTime: number | undefined, history: q.MessageHistory)
const value = message.value ? toPlottableValue(Base64Message.toUnicodeString(message.value)) : NaN const value = message.value ? toPlottableValue(Base64Message.toUnicodeString(message.value)) : NaN
return { x: message.received.getTime(), y: toPlottableValue(value) } return { x: message.received.getTime(), y: toPlottableValue(value) }
}) })
.filter((data) => !isNaN(data.y as any)) as any .filter(data => !isNaN(data.y as any)) as any
} }
function nodeDotPathToHistory(startTime: number | undefined, history: q.MessageHistory, dotPath: string) { function nodeDotPathToHistory(startTime: number | undefined, history: q.MessageHistory, dotPath: string) {
@@ -46,7 +46,7 @@ function nodeDotPathToHistory(startTime: number | undefined, history: q.MessageH
return { x: message.received.getTime(), y: toPlottableValue(value) } return { x: message.received.getTime(), y: toPlottableValue(value) }
}) })
.filter((data) => !isNaN(data.y as any)) as any .filter(data => !isNaN(data.y as any)) as any
} }
function TopicPlot(props: Props) { function TopicPlot(props: Props) {

View File

@@ -48,7 +48,7 @@ function TreeNodeSubnodes(props: Props) {
return useMemo(() => { return useMemo(() => {
const nodes = sortedNodes(props.settings, props.treeNode).slice(0, alreadyAdded) const nodes = sortedNodes(props.settings, props.treeNode).slice(0, alreadyAdded)
const listItems = nodes.map((node) => { const listItems = nodes.map(node => {
return ( return (
<TreeNode <TreeNode
key={`${node.hash()}-${props.filter}`} key={`${node.hash()}-${props.filter}`}

View File

@@ -51,10 +51,10 @@ class UpdateNotifier extends React.PureComponent<Props, State> {
this.state = { newerVersions: [] } this.state = { newerVersions: [] }
const ownVersion = electron.remote.app.getVersion() const ownVersion = electron.remote.app.getVersion()
this.fetchReleases().then((releases) => { this.fetchReleases().then(releases => {
const newerVersions = releases const newerVersions = releases
.filter((release) => this.allowPrereleaseIfOwnVersionIsBeta(release, ownVersion)) .filter(release => this.allowPrereleaseIfOwnVersionIsBeta(release, ownVersion))
.filter((release) => compareVersions(release.tag_name, ownVersion) > 0) .filter(release => compareVersions(release.tag_name, ownVersion) > 0)
.sort((a, b) => compareVersions(b.tag_name, a.tag_name)) .sort((a, b) => compareVersions(b.tag_name, a.tag_name))
if (newerVersions.length > 0) { if (newerVersions.length > 0) {
@@ -145,7 +145,7 @@ class UpdateNotifier extends React.PureComponent<Props, State> {
return null return null
} }
const releaseNotes = this.state.newerVersions const releaseNotes = this.state.newerVersions
.map((release) => `<p><h3>${release.tag_name}</h3><p/><p>${release.body_html}</p>`) .map(release => `<p><h3>${release.tag_name}</h3><p/><p>${release.body_html}</p>`)
.join('<hr />') .join('<hr />')
return ( return (
@@ -195,7 +195,7 @@ class UpdateNotifier extends React.PureComponent<Props, State> {
return null return null
} }
return latestUpdate.assets.filter(this.assetForCurrentPlatform).map((asset) => ( return latestUpdate.assets.filter(this.assetForCurrentPlatform).map(asset => (
<div> <div>
<Button className={this.props.classes.download} onClick={() => this.openUrl(asset.browser_download_url)}> <Button className={this.props.classes.download} onClick={() => this.openUrl(asset.browser_download_url)}>
<CloudDownload /> <CloudDownload />

View File

@@ -20,7 +20,7 @@ const styles = (theme: Theme) => ({
icon: { icon: {
boxShadow: theme.shadows[2] boxShadow: theme.shadows[2]
.split('),') .split('),')
.map((s) => `inset ${s}`) .map(s => `inset ${s}`)
.join('),'), .join('),'),
padding: '6px', padding: '6px',
borderRadius: '50%', borderRadius: '50%',

View File

@@ -81,7 +81,7 @@ function addChart(state: ChartsState, action: AddChart) {
function moveUp(state: ChartsState, action: MoveUp) { function moveUp(state: ChartsState, action: MoveUp) {
const charts = state.get('charts') const charts = state.get('charts')
const idx = charts.findIndex((chart) => chart.topic === action.topic && chart.dotPath === action.dotPath) const idx = charts.findIndex(chart => chart.topic === action.topic && chart.dotPath === action.dotPath)
const item = charts.get(idx) const item = charts.get(idx)
const previousItem = charts.get(idx - 1) const previousItem = charts.get(idx - 1)
@@ -95,7 +95,7 @@ function moveUp(state: ChartsState, action: MoveUp) {
function updateChart(state: ChartsState, action: UpdateChart) { function updateChart(state: ChartsState, action: UpdateChart) {
const charts = state.get('charts') const charts = state.get('charts')
const chartIdx = charts.findIndex((chart) => chart.topic === action.topic && chart.dotPath === action.dotPath) const chartIdx = charts.findIndex(chart => chart.topic === action.topic && chart.dotPath === action.dotPath)
const chart = charts.get(chartIdx) const chart = charts.get(chartIdx)
return state.set('charts', chart ? charts.set(chartIdx, { ...chart, ...action.parameters }) : charts) return state.set('charts', chart ? charts.set(chartIdx, { ...chart, ...action.parameters }) : charts)
@@ -103,9 +103,7 @@ function updateChart(state: ChartsState, action: UpdateChart) {
function removeChart(state: ChartsState, action: RemoveChart) { function removeChart(state: ChartsState, action: RemoveChart) {
const charts = state.get('charts') const charts = state.get('charts')
const newCharts = charts.filter( const newCharts = charts.filter(chart => chart.topic !== action.chart.topic || chart.dotPath !== action.chart.dotPath)
(chart) => chart.topic !== action.chart.topic || chart.dotPath !== action.chart.dotPath
)
return state.set('charts', newCharts) return state.set('charts', newCharts)
} }

View File

@@ -160,7 +160,7 @@ function addSubscription(state: ConnectionManagerState, action: AddSubscription)
function deleteSubscription(state: ConnectionManagerState, action: AddSubscription): ConnectionManagerState { function deleteSubscription(state: ConnectionManagerState, action: AddSubscription): ConnectionManagerState {
const connection = state.connections[action.connectionId] const connection = state.connections[action.connectionId]
const newSubscriptions = connection.subscriptions.filter((s) => s !== action.subscription) const newSubscriptions = connection.subscriptions.filter(s => s !== action.subscription)
return { return {
...state, ...state,

View File

@@ -90,7 +90,7 @@ export const globalState: Reducer<Record<GlobalStateInterface>, GlobalAction> =
} }
return state.set( return state.set(
'confirmationRequests', 'confirmationRequests',
state.get('confirmationRequests').filter((a) => a !== action.confirmationRequest) state.get('confirmationRequests').filter(a => a !== action.confirmationRequest)
) )
default: default:

View File

@@ -9,7 +9,7 @@ export function sortedNodes(settings: SettingsState, treeNode: q.TreeNode<any>):
if (topicOrder === TopicOrder.abc) { if (topicOrder === TopicOrder.abc) {
edges.sort((a, b) => a.name.localeCompare(b.name)) edges.sort((a, b) => a.name.localeCompare(b.name))
} }
const nodes = edges.map((edge) => edge.target) const nodes = edges.map(edge => edge.target)
if (topicOrder === TopicOrder.messages) { if (topicOrder === TopicOrder.messages) {
nodes.sort((a, b) => b.leafMessageCount() - a.leafMessageCount()) nodes.sort((a, b) => b.leafMessageCount() - a.leafMessageCount())
} }

View File

@@ -32,7 +32,7 @@ export default class ConfigStorage {
} }
public async init() { public async init() {
backendEvents.subscribe(storageStoreEvent, async (event) => { backendEvents.subscribe(storageStoreEvent, async event => {
const ack = makeStorageAcknowledgementEvent(event.transactionId) const ack = makeStorageAcknowledgementEvent(event.transactionId)
try { try {
const db = await this.getDb() const db = await this.getDb()
@@ -48,7 +48,7 @@ export default class ConfigStorage {
} }
}) })
backendEvents.subscribe(storageLoadEvent, async (event) => { backendEvents.subscribe(storageLoadEvent, async event => {
const responseEvent = makeStorageResponseEvent(event.transactionId) const responseEvent = makeStorageResponseEvent(event.transactionId)
try { try {
const db = await this.getDb() const db = await this.getDb()
@@ -68,7 +68,7 @@ export default class ConfigStorage {
} }
}) })
backendEvents.subscribe(storageClearEvent, async (event) => { backendEvents.subscribe(storageClearEvent, async event => {
try { try {
const db = await this.getDb() const db = await this.getDb()
const keys = await db.keys().value() const keys = await db.keys().value()

View File

@@ -73,7 +73,7 @@ export class MqttSource implements DataSource<MqttOptions> {
client.on('connect', () => { client.on('connect', () => {
this.stateMachine.setConnected(true) this.stateMachine.setConnected(true)
options.subscriptions.forEach((subscription) => { options.subscriptions.forEach(subscription => {
client.subscribe(subscription, (err: Error) => { client.subscribe(subscription, (err: Error) => {
if (err) { if (err) {
this.stateMachine.setError(err) this.stateMachine.setError(err)

View File

@@ -70,7 +70,7 @@ function jsonToPropertyPaths(ast: JsonAst, previousPath: Array<string> = []): Ar
} else if (ast.type === 'Array') { } else if (ast.type === 'Array') {
children = ast.children.map((value, idx) => jsonToPropertyPaths(value, previousPath.slice().concat([String(idx)]))) children = ast.children.map((value, idx) => jsonToPropertyPaths(value, previousPath.slice().concat([String(idx)])))
} else if (ast.type === 'Object') { } else if (ast.type === 'Object') {
children = ast.children.map((property) => { children = ast.children.map(property => {
const path = property.key.value.replace('.', '\\.') const path = property.key.value.replace('.', '\\.')
return jsonToPropertyPaths(property.value, previousPath.slice().concat([path])) return jsonToPropertyPaths(property.value, previousPath.slice().concat([path]))

View File

@@ -74,7 +74,7 @@ export class Tree<ViewModel extends Destroyable> extends TreeNode<ViewModel> {
} }
public applyUnmergedChanges() { public applyUnmergedChanges() {
this.unmergedMessages.popAll().forEach((bufferedItem) => { this.unmergedMessages.popAll().forEach(bufferedItem => {
const edges = bufferedItem.message.topic.split('/') const edges = bufferedItem.message.topic.split('/')
const node = TreeNodeFactory.fromEdgesAndValue<ViewModel>( const node = TreeNodeFactory.fromEdgesAndValue<ViewModel>(
edges, edges,

View File

@@ -156,8 +156,8 @@ export class TreeNode<ViewModel extends Destroyable> {
public path(): string { public path(): string {
if (!this.cachedPath) { if (!this.cachedPath) {
return this.branch() return this.branch()
.map((node) => node.sourceEdge && node.sourceEdge.name) .map(node => node.sourceEdge && node.sourceEdge.name)
.filter((name) => name !== undefined) .filter(name => name !== undefined)
.join('/') .join('/')
} }
@@ -214,7 +214,7 @@ export class TreeNode<ViewModel extends Destroyable> {
public leafMessageCount(): number { public leafMessageCount(): number {
if (this.cachedLeafMessageCount === undefined) { if (this.cachedLeafMessageCount === undefined) {
this.cachedLeafMessageCount = this.cachedLeafMessageCount =
this.edgeArray.map((edge) => edge.target.leafMessageCount()).reduce((a, b) => a + b, 0) + this.messages this.edgeArray.map(edge => edge.target.leafMessageCount()).reduce((a, b) => a + b, 0) + this.messages
} }
return this.cachedLeafMessageCount as number return this.cachedLeafMessageCount as number
@@ -223,7 +223,7 @@ export class TreeNode<ViewModel extends Destroyable> {
public childTopicCount(): number { public childTopicCount(): number {
if (this.cachedChildTopicCount === undefined) { if (this.cachedChildTopicCount === undefined) {
this.cachedChildTopicCount = this.edgeArray this.cachedChildTopicCount = this.edgeArray
.map((e) => e.target.childTopicCount()) .map(e => e.target.childTopicCount())
.reduce((a, b) => a + b, this.hasMessage() ? 1 : 0) .reduce((a, b) => a + b, this.hasMessage() ? 1 : 0)
} }
@@ -239,7 +239,7 @@ export class TreeNode<ViewModel extends Destroyable> {
const initialValue = this.message && this.message.value ? [this] : [] const initialValue = this.message && this.message.value ? [this] : []
this.cachedChildTopics = this.edgeArray this.cachedChildTopics = this.edgeArray
.map((e) => e.target.childTopics()) .map(e => e.target.childTopics())
.reduce((a, b) => a.concat(b), initialValue) .reduce((a, b) => a.concat(b), initialValue)
} }

View File

@@ -8,8 +8,8 @@ describe('EventDispatcher', async () => {
this.timeout(300) this.timeout(300)
setTimeout(() => dispatcher.dispatch('hello'), 5) setTimeout(() => dispatcher.dispatch('hello'), 5)
const response = await new Promise((resolve) => { const response = await new Promise(resolve => {
dispatcher.subscribe((msg) => { dispatcher.subscribe(msg => {
resolve(msg) resolve(msg)
}) })
}) })

View File

@@ -27,7 +27,7 @@ export class ConnectionManager {
this.connections[connectionId] = connection this.connections[connectionId] = connection
const connectionStateEvent = makeConnectionStateEvent(connectionId) const connectionStateEvent = makeConnectionStateEvent(connectionId)
connection.stateMachine.onUpdate.subscribe((state) => { connection.stateMachine.onUpdate.subscribe(state => {
backendEvents.emit(connectionStateEvent, state) backendEvents.emit(connectionStateEvent, state)
}) })
@@ -72,6 +72,6 @@ export class ConnectionManager {
} }
public closeAllConnections() { public closeAllConnections() {
Object.keys(this.connections).forEach((connectionId) => this.removeConnection(connectionId)) Object.keys(this.connections).forEach(connectionId => this.removeConnection(connectionId))
} }
} }

View File

@@ -26,13 +26,13 @@ export class EventDispatcher<Message> {
} }
public unsubscribe(callback: (msg: Message) => void) { public unsubscribe(callback: (msg: Message) => void) {
const item = this.callbacks.find((store) => store.callback === callback) const item = this.callbacks.find(store => store.callback === callback)
if (!item) { if (!item) {
return return
} }
this.emitter.removeListener('event', item.wrappedCallback) this.emitter.removeListener('event', item.wrappedCallback)
this.callbacks = this.callbacks.filter((a) => a !== item) this.callbacks = this.callbacks.filter(a => a !== item)
} }
public removeAllListeners() { public removeAllListeners() {

View File

@@ -22,12 +22,12 @@ export class IpcRendererEventBus implements EventBusInterface {
this.ipc.removeAllListeners(event.topic) this.ipc.removeAllListeners(event.topic)
} }
public unsubscribe<MessageType>(event: Event<MessageType>, callback: any) { public unsubscribe<MessageType>(event: Event<MessageType>, callback: any) {
const item = this.callbacks.find((store) => store.callback === callback) const item = this.callbacks.find(store => store.callback === callback)
if (!item) { if (!item) {
return return
} }
this.ipc.removeListener(event.topic, item.wrappedCallback) this.ipc.removeListener(event.topic, item.wrappedCallback)
this.callbacks = this.callbacks.filter((a) => a !== item) this.callbacks = this.callbacks.filter(a => a !== item)
} }
public emit<MessageType>(event: Event<MessageType>, msg: MessageType) { public emit<MessageType>(event: Event<MessageType>, msg: MessageType) {
this.ipc.send(event.topic, msg) this.ipc.send(event.topic, msg)

View File

@@ -90,7 +90,7 @@
"source-map-support": "^0.5.9", "source-map-support": "^0.5.9",
"spectron": "10", "spectron": "10",
"ts-node": "^8.2.0", "ts-node": "^8.2.0",
"tslint": "^5.18.0", "tslint": "6",
"tslint-config-airbnb": "^5.11.1", "tslint-config-airbnb": "^5.11.1",
"tslint-react": "^4.0.0", "tslint-react": "^4.0.0",
"tslint-react-recommended": "^1.0.15", "tslint-react-recommended": "^1.0.15",

View File

@@ -4,4 +4,5 @@ module.exports = {
semi: false, semi: false,
singleQuote: true, singleQuote: true,
printWidth: 120, printWidth: 120,
arrowParens: 'avoid',
}; };

View File

@@ -15,7 +15,7 @@ interface Context {
export default async function (context: Context) { export default async function (context: Context) {
console.log(context) console.log(context)
const isLinux = context.targets.find((target) => target.name === 'appImage') const isLinux = context.targets.find(target => target.name === 'appImage')
if (!isLinux) { if (!isLinux) {
return return
} }

View File

@@ -40,8 +40,8 @@ class TransitionBuilder {
public buildOptions(outputFile: string) { public buildOptions(outputFile: string) {
return { return {
output: outputFile, output: outputFile,
videos: this.scenes.map((s) => `${s}.mp4`), videos: this.scenes.map(s => `${s}.mp4`),
transitions: this.transitions.map((name) => ({ transitions: this.transitions.map(name => ({
name: name !== 'none' ? name : 'fade', name: name !== 'none' ? name : 'fade',
duration: name !== 'none' ? 1000 : 10, duration: name !== 'none' ? 1000 : 10,
})), })),

View File

@@ -23,7 +23,7 @@ function redirectOutputFor(child: ChildProcess) {
} }
async function waitFor(child: ChildProcess) { async function waitFor(child: ChildProcess) {
return new Promise((resolve) => { return new Promise(resolve => {
child.once('close', () => resolve()) child.once('close', () => resolve())
}) })
} }

View File

@@ -16,7 +16,7 @@ export function handleAutoUpdate() {
console.log('There is an update available') console.log('There is an update available')
}) })
autoUpdater.on('error', (error) => { autoUpdater.on('error', error => {
console.error('could not update due to error', error) console.error('could not update due to error', error)
}) })

View File

@@ -11,7 +11,7 @@ export async function waitForDevServer() {
response = await axios.get('http://localhost:8080') response = await axios.get('http://localhost:8080')
} catch { } catch {
console.log('Waiting for dev server') console.log('Waiting for dev server')
await new Promise((resolve) => setTimeout(resolve, 1000)) await new Promise(resolve => setTimeout(resolve, 1000))
} }
} }
} }
@@ -24,9 +24,9 @@ export function loadDevTools() {
} }
export function isDev() { export function isDev() {
return Boolean(process.argv.find((arg) => arg === '--development')) return Boolean(process.argv.find(arg => arg === '--development'))
} }
export function runningUiTestOnCi() { export function runningUiTestOnCi() {
return Boolean(process.argv.find((arg) => arg === '--runningUiTestOnCi')) return Boolean(process.argv.find(arg => arg === '--runningUiTestOnCi'))
} }

View File

@@ -2,7 +2,7 @@ import * as mqtt from 'mqtt'
let mqttClient: mqtt.MqttClient let mqttClient: mqtt.MqttClient
function startServer(): Promise<mqtt.MqttClient> { function startServer(): Promise<mqtt.MqttClient> {
return new Promise(async (resolve) => { return new Promise(async resolve => {
mqttClient = await connectMqtt() mqttClient = await connectMqtt()
generateData(mqttClient) generateData(mqttClient)
resolve(mqttClient) resolve(mqttClient)
@@ -10,7 +10,7 @@ function startServer(): Promise<mqtt.MqttClient> {
} }
function connectMqtt(): Promise<mqtt.MqttClient> { function connectMqtt(): Promise<mqtt.MqttClient> {
return new Promise((resolve) => { return new Promise(resolve => {
const client = mqtt.connect('mqtt://127.0.0.1:1883', { const client = mqtt.connect('mqtt://127.0.0.1:1883', {
username: '', username: '',
password: '', password: '',

View File

@@ -24,6 +24,6 @@ async function topicMatches(topics: Array<string>, browser: Browser) {
} }
function topicSelector(topics: Array<string>) { function topicSelector(topics: Array<string>) {
const suffix = topics.map((topic) => `*[contains(text(), "${topic}")]`).join('/../..//') const suffix = topics.map(topic => `*[contains(text(), "${topic}")]`).join('/../..//')
return `//${suffix}` return `//${suffix}`
} }

View File

@@ -9,7 +9,7 @@ export function setFast() {
} }
export function sleep(ms: number, required = false) { export function sleep(ms: number, required = false) {
return new Promise((resolve) => { return new Promise(resolve => {
if (required) { if (required) {
setTimeout(resolve, ms) setTimeout(resolve, ms)
} else { } else {

View File

@@ -3418,7 +3418,7 @@ mkdirp@0.5.3:
dependencies: dependencies:
minimist "^1.2.5" minimist "^1.2.5"
mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.4, mkdirp@~0.5.1: mkdirp@^0.5.3, mkdirp@^0.5.4, mkdirp@~0.5.1:
version "0.5.5" version "0.5.5"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
@@ -5002,7 +5002,7 @@ tslib@1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
integrity sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ== integrity sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==
tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1: tslib@^1.10.0, tslib@^1.7.1, tslib@^1.8.1:
version "1.11.1" version "1.11.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA== integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==
@@ -5058,10 +5058,10 @@ tslint-strict-null-checks@^1.0.1:
resolved "https://registry.yarnpkg.com/tslint-strict-null-checks/-/tslint-strict-null-checks-1.0.1.tgz#29ad44ed353185f5d7af66a76e29a1bee74d944b" resolved "https://registry.yarnpkg.com/tslint-strict-null-checks/-/tslint-strict-null-checks-1.0.1.tgz#29ad44ed353185f5d7af66a76e29a1bee74d944b"
integrity sha512-W7SzlPqOv7E/UnqrqcbUFXeE5M/YU41GpkHY5nkAyhBW12UJ3Xhh9rLAizw57xFLng4Y400h06udmgDe2cNBCg== integrity sha512-W7SzlPqOv7E/UnqrqcbUFXeE5M/YU41GpkHY5nkAyhBW12UJ3Xhh9rLAizw57xFLng4Y400h06udmgDe2cNBCg==
tslint@^5.18.0: tslint@6:
version "5.20.1" version "6.1.1"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.20.1.tgz#e401e8aeda0152bc44dd07e614034f3f80c67b7d" resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.1.tgz#ac03fbd17f85bfefaae348b353b25a88efe10cde"
integrity sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg== integrity sha512-kd6AQ/IgPRpLn6g5TozqzPdGNZ0q0jtXW4//hRcj10qLYBaa3mTUU2y2MCG+RXZm8Zx+KZi0eA+YCrMyNlF4UA==
dependencies: dependencies:
"@babel/code-frame" "^7.0.0" "@babel/code-frame" "^7.0.0"
builtin-modules "^1.1.1" builtin-modules "^1.1.1"
@@ -5071,10 +5071,10 @@ tslint@^5.18.0:
glob "^7.1.1" glob "^7.1.1"
js-yaml "^3.13.1" js-yaml "^3.13.1"
minimatch "^3.0.4" minimatch "^3.0.4"
mkdirp "^0.5.1" mkdirp "^0.5.3"
resolve "^1.3.2" resolve "^1.3.2"
semver "^5.3.0" semver "^5.3.0"
tslib "^1.8.0" tslib "^1.10.0"
tsutils "^2.29.0" tsutils "^2.29.0"
"tsutils@^2.27.2 <2.29.0": "tsutils@^2.27.2 <2.29.0":