Skip to content

Commit

Permalink
fix: eslint issues
Browse files Browse the repository at this point in the history
It looks like there were two actual bugs, related to an
earlier switch from using lodash to using individual
lodash functions. One in Restore and the other in SourcePriorities.
Not going to dig into those deeper at this time, as the fixes
seem to be straightforward.
  • Loading branch information
tkurki committed Apr 27, 2024
1 parent abc05c1 commit 9108bc0
Show file tree
Hide file tree
Showing 34 changed files with 72 additions and 138 deletions.
1 change: 1 addition & 0 deletions packages/server-admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"lodash.get": "^4.4.2",
"lodash.remove": "^4.7.0",
"lodash.set": "^4.3.2",
"lodash.uniq": "^4.5.0",
"moment": "^2.29.1",
"node-sass": "^8.0.0",
"prettier": "^2.3.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/server-admin-ui/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function logout() {
}
return response
})
.then((response) => {
.then(() => {
dispatch({
type: 'LOGOUT_SUCCESS',
})
Expand Down Expand Up @@ -180,7 +180,7 @@ export function openServerEventsConnection(dispatch, isReconnect) {
type: 'WEBSOCKET_CLOSE',
})
}
ws.onerror = (error) => {
ws.onerror = () => {
dispatch({
type: 'WEBSOCKET_ERROR',
})
Expand Down
10 changes: 6 additions & 4 deletions packages/server-admin-ui/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const state = {

let store = createStore(
(state, action) => {
let newState = {}
if (action.type === 'RECEIVE_PLUGIN_LIST') {
return {
...state,
Expand Down Expand Up @@ -257,9 +256,10 @@ let store = createStore(
}
if (action.type === 'SOURCEPRIORITIES') {
const sourcePrioritiesMap = action.data
const sourcePriorities = Object.keys(sourcePrioritiesMap).map(
(key, i) => ({ path: key, priorities: sourcePrioritiesMap[key] })
)
const sourcePriorities = Object.keys(sourcePrioritiesMap).map((key) => ({
path: key,
priorities: sourcePrioritiesMap[key],
}))
sourcePriorities.state = {}

return {
Expand Down Expand Up @@ -297,8 +297,10 @@ function nameCollator(left, right) {

window.serverRoutesPrefix = '/skServer'

// eslint-disable-next-line no-undef
__webpack_init_sharing__('default')

// eslint-disable-next-line react/no-deprecated
ReactDOM.render(
<HashRouter>
<Switch>
Expand Down
11 changes: 0 additions & 11 deletions packages/server-admin-ui/src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,4 @@ const mapStateToProps = (state) => {
return result
}

const pluginMenuItems = (plugins) => {
return plugins
? plugins.map((pluginData) => {
return {
name: pluginData.name,
url: `/plugins/${pluginData.id}`,
}
})
: []
}

export default connect(mapStateToProps)(Sidebar)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import { Component } from 'react'

class SidebarFooter extends Component {
render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import { Component } from 'react'

class SidebarForm extends Component {
render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react'
import { Component } from 'react'

class SidebarHeader extends Component {
render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SidebarMinimizer extends Component {
<button
className="sidebar-minimizer"
type="button"
onClick={(event) => {
onClick={() => {
this.sidebarMinimize()
this.brandMinimize()
}}
Expand Down
12 changes: 3 additions & 9 deletions packages/server-admin-ui/src/containers/Full/Full.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { Switch, Route, Redirect, withRouter, History } from 'react-router-dom'
import { Switch, Route, Redirect, withRouter } from 'react-router-dom'
import { Container } from 'reactstrap'
import { connect } from 'react-redux'

Expand All @@ -21,19 +21,13 @@ import Users from '../../views/security/Users'
import Devices from '../../views/security/Devices'
import Register from '../../views/security/Register'
import AccessRequests from '../../views/security/AccessRequests'
import VesselConfiguration from '../../views/ServerConfig/VesselConfiguration'
import ProvidersConfiguration from '../../views/ServerConfig/ProvidersConfiguration'
import Settings from '../../views/ServerConfig/Settings'
import BackupRestore from '../../views/ServerConfig/BackupRestore'
import Logging from '../../views/ServerConfig/Logging'
import ServerLog from '../../views/ServerConfig/ServerLog'
import ServerUpdate from '../../views/ServerConfig/ServerUpdate'

import {
fetchLoginStatus,
fetchAllData,
openServerEventsConnection,
} from '../../actions'
import { fetchAllData, openServerEventsConnection } from '../../actions'

class Full extends Component {
componentDidMount() {
Expand Down Expand Up @@ -148,7 +142,7 @@ const loginOrOriginal = (BaseComponent, componentSupportsReadOnly) => {
this.state = { hasError: false }
}

static getDerivedStateFromError(error) {
static getDerivedStateFromError() {
return { hasError: true }
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from 'react'
import PluginConfigurationForm from './../ServerConfig/PluginConfigurationForm'
import {
Alert,
Button,
Card,
CardBody,
Expand Down Expand Up @@ -234,7 +233,7 @@ class PluginCard extends Component {
type="checkbox"
name="enabled"
className="switch-input"
onChange={(e) => {
onChange={() => {
this.props.saveData({
...this.props.plugin.data,
enabled: !this.props.plugin.data.enabled,
Expand All @@ -260,7 +259,7 @@ class PluginCard extends Component {
type="checkbox"
name="enableLogging"
className="switch-input"
onChange={(e) => {
onChange={() => {
this.props.saveData({
...this.props.plugin.data,
enableLogging:
Expand All @@ -287,7 +286,7 @@ class PluginCard extends Component {
type="checkbox"
name="enableDebug"
className="switch-input "
onChange={(e) => {
onChange={() => {
this.props.saveData({
...this.props.plugin.data,
enableDebug: !this.props.plugin.data.enableDebug,
Expand Down
8 changes: 0 additions & 8 deletions packages/server-admin-ui/src/views/DataBrowser.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import React, { Component } from 'react'
import { connect } from 'react-redux'
import get from 'lodash.get'
import JSONTree from 'react-json-tree'
import {
Badge,
Button,
Card,
CardHeader,
CardBody,
CardFooter,
InputGroup,
InputGroupAddon,
Input,
Form,
Col,
Label,
FormGroup,
FormText,
Table,
} from 'reactstrap'
import moment from 'moment'
Expand Down Expand Up @@ -357,7 +350,6 @@ class DataBrowser extends Component {
const meta =
this.state.meta[this.state.context][data.path]
const units = meta && meta.units ? meta.units : ''
const path = key.substring(0, key.lastIndexOf('.'))

return (
<tr key={key}>
Expand Down
14 changes: 5 additions & 9 deletions packages/server-admin-ui/src/views/Playground.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import React, { Component, useState } from 'react'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import {
Badge,
Button,
Card,
CardHeader,
CardBody,
CardFooter,
InputGroup,
InputGroupAddon,
Input,
Form,
Col,
Label,
FormGroup,
FormText,
Table,
Expand Down Expand Up @@ -77,7 +73,7 @@ class Playground extends Component {
}, 500)
}

handleExecute(event) {
handleExecute() {
this.send(true)
}

Expand All @@ -99,7 +95,6 @@ class Playground extends Component {
deltas: [],
putResults: [],
n2kJson: [],
jsonError: null,
error: 'invalid json',
jsonError: error.message,
activeTab: LINT_ERROR_TAB_ID,
Expand Down Expand Up @@ -416,7 +411,6 @@ class Playground extends Component {
? 2
: 0
)
const path = data.path
const key = `${data.path}${data.context}`

return (
Expand Down Expand Up @@ -509,7 +503,9 @@ function isJson(input) {
try {
JSON.parse(input)
inputIsJson = true
} catch (e) {}
} catch (e) {
/* empty */
}
return inputIsJson
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BackupRestore extends Component {
this.cancelRestore = this.cancelRestore.bind(this)
}

cancelRestore(event) {
cancelRestore() {
this.setState({ restoreState: RESTORE_NONE })
}

Expand Down Expand Up @@ -229,7 +229,7 @@ class BackupRestore extends Component {
{this.state.restoreState === RESTORE_CONFIRM && (
<FormGroup check>
<Col xs="12" md={fieldColWidthMd}>
{_.keys(this.state.restoreContents).map((name) => {
{Object.keys(this.state.restoreContents).map((name) => {
return (
<div key={name}>
<Label className="switch switch-text switch-primary">
Expand Down
13 changes: 6 additions & 7 deletions packages/server-admin-ui/src/views/ServerConfig/BasicProvider.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Input, FormGroup, FormText, Col, Label } from 'reactstrap'
import N2KFilters from './N2KFilters'

class BasicProvider extends Component {
constructor(props) {
constructor() {
super()
this.state = {
hasAnalyzer: false,
Expand Down Expand Up @@ -177,7 +176,7 @@ class TextAreaInput extends Component {
}

class DeviceInput extends Component {
constructor(props) {
constructor() {
super()
this.state = {
devices: {},
Expand Down Expand Up @@ -852,7 +851,7 @@ const NMEA0183 = (props) => {
{props.value.options.type === 'serial' && (
<Col xs="12" md="6">
Serial ports are bidirectional. Input from the connection is parsed
as NMEA0183. Configure Output Events below to connect server's
as NMEA0183. Configure Output Events below to connect server&apos;s
NMEA0183 data for output.
</Col>
)}
Expand Down Expand Up @@ -988,7 +987,7 @@ const SignalK = (props) => {
{!props.value.options.useDiscovery && (
<FormGroup row>
<Col md="3">
<Label htmlFor="options.type">'self' handling</Label>
<Label htmlFor="options.type">&apos;self&apos; handling</Label>
</Col>
<Col xs="12" md="3">
<Input
Expand All @@ -998,10 +997,10 @@ const SignalK = (props) => {
onChange={(event) => props.onChange(event)}
>
<option value="useRemoteSelf">
Map remote 'self' to local 'self'
Map remote &apos;self&apos; to local &apos;self&apos;
</option>
<option value="manualSelf">Manual mapping</option>
<option value="noSelf">No 'self' mapping</option>
<option value="noSelf">No &apos;self&apos; mapping</option>
</Input>
</Col>
</FormGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import React, { Component } from 'react'
import { connect } from 'react-redux'
import {
Table,
Input,
Button,
Card,
CardBody,
CardHeader,
FormText,
Label,
} from 'reactstrap'

class N2KFilters extends Component {
constructor(props) {
constructor() {
super()

this.handleAddFilter = this.handleAddFilter.bind(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import React from 'react'
import Form from 'react-jsonschema-form-bs4'

// eslint-disable-next-line react/display-name
export default ({ plugin, onSubmit }) => {
const schema = JSON.parse(JSON.stringify(plugin.schema))
var uiSchema = {}
Expand All @@ -16,7 +17,6 @@ export default ({ plugin, onSubmit }) => {
type: 'object',
title: ' ',
description: schema.description,
type: 'object',
properties: schema.properties,
},
},
Expand Down
Loading

0 comments on commit 9108bc0

Please sign in to comment.