eslint commands and apply some style fixes (#1021)
* auto eslint and add commands for eslint * eslint the entire frontend folder
This commit is contained in:
parent
8b738f3d28
commit
25b4d388de
18 changed files with 61 additions and 86 deletions
frontend/src
package.json
|
@ -1,5 +1,7 @@
|
||||||
/* global $, ActionCable */
|
/* global $, ActionCable */
|
||||||
|
|
||||||
|
import { indexOf } from 'lodash'
|
||||||
|
|
||||||
import Active from './Active'
|
import Active from './Active'
|
||||||
import Control from './Control'
|
import Control from './Control'
|
||||||
import DataModel from './DataModel'
|
import DataModel from './DataModel'
|
||||||
|
@ -43,7 +45,7 @@ const Cable = {
|
||||||
// refactor the heck outta this, its adding wicked wait time
|
// refactor the heck outta this, its adding wicked wait time
|
||||||
var topic1, topic2, node1, node2, synapse, mapping, cancel, mapper
|
var topic1, topic2, node1, node2, synapse, mapping, cancel, mapper
|
||||||
|
|
||||||
function waitThenRenderSynapse() {
|
const waitThenRenderSynapse = () => {
|
||||||
if (synapse && mapping && mapper) {
|
if (synapse && mapping && mapper) {
|
||||||
topic1 = synapse.getTopic1()
|
topic1 = synapse.getTopic1()
|
||||||
node1 = topic1.get('node')
|
node1 = topic1.get('node')
|
||||||
|
@ -130,7 +132,7 @@ const Cable = {
|
||||||
// refactor the heck outta this, its adding wicked wait time
|
// refactor the heck outta this, its adding wicked wait time
|
||||||
var topic, mapping, mapper, cancel
|
var topic, mapping, mapper, cancel
|
||||||
|
|
||||||
function waitThenRenderTopic() {
|
const waitThenRenderTopic = () => {
|
||||||
if (topic && mapping && mapper) {
|
if (topic && mapping && mapper) {
|
||||||
Topic.renderTopic(mapping, topic, false, false)
|
Topic.renderTopic(mapping, topic, false, false)
|
||||||
} else if (!cancel) {
|
} else if (!cancel) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
/* global $ */
|
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import outdent from 'outdent'
|
import outdent from 'outdent'
|
||||||
|
|
||||||
|
@ -7,7 +5,6 @@ import Active from './Active'
|
||||||
import DataModel from './DataModel'
|
import DataModel from './DataModel'
|
||||||
import Filter from './Filter'
|
import Filter from './Filter'
|
||||||
import GlobalUI from './GlobalUI'
|
import GlobalUI from './GlobalUI'
|
||||||
import JIT from './JIT'
|
|
||||||
import Mouse from './Mouse'
|
import Mouse from './Mouse'
|
||||||
import Selected from './Selected'
|
import Selected from './Selected'
|
||||||
import Settings from './Settings'
|
import Settings from './Settings'
|
||||||
|
@ -98,7 +95,6 @@ const Control = {
|
||||||
|
|
||||||
var permToDelete = Active.Mapper.id === topic.get('user_id') || Active.Mapper.get('admin')
|
var permToDelete = Active.Mapper.id === topic.get('user_id') || Active.Mapper.get('admin')
|
||||||
if (permToDelete) {
|
if (permToDelete) {
|
||||||
var mappableid = topic.id
|
|
||||||
var mapping = node.getData('mapping')
|
var mapping = node.getData('mapping')
|
||||||
topic.destroy()
|
topic.destroy()
|
||||||
DataModel.Mappings.remove(mapping)
|
DataModel.Mappings.remove(mapping)
|
||||||
|
@ -148,7 +144,6 @@ const Control = {
|
||||||
}
|
}
|
||||||
|
|
||||||
var topic = node.getData('topic')
|
var topic = node.getData('topic')
|
||||||
var mappableid = topic.id
|
|
||||||
var mapping = node.getData('mapping')
|
var mapping = node.getData('mapping')
|
||||||
mapping.destroy()
|
mapping.destroy()
|
||||||
DataModel.Topics.remove(topic)
|
DataModel.Topics.remove(topic)
|
||||||
|
@ -267,7 +262,6 @@ const Control = {
|
||||||
if (edge.getData('synapses').length - 1 === 0) {
|
if (edge.getData('synapses').length - 1 === 0) {
|
||||||
Control.hideEdge(edge)
|
Control.hideEdge(edge)
|
||||||
}
|
}
|
||||||
var mappableid = synapse.id
|
|
||||||
synapse.destroy()
|
synapse.destroy()
|
||||||
|
|
||||||
// the server will destroy the mapping, we just need to remove it here
|
// the server will destroy the mapping, we just need to remove it here
|
||||||
|
@ -318,7 +312,6 @@ const Control = {
|
||||||
|
|
||||||
var synapse = edge.getData('synapses')[index]
|
var synapse = edge.getData('synapses')[index]
|
||||||
var mapping = edge.getData('mappings')[index]
|
var mapping = edge.getData('mappings')[index]
|
||||||
var mappableid = synapse.id
|
|
||||||
mapping.destroy()
|
mapping.destroy()
|
||||||
|
|
||||||
DataModel.Synapses.remove(synapse)
|
DataModel.Synapses.remove(synapse)
|
||||||
|
|
|
@ -291,18 +291,18 @@ const Create = {
|
||||||
},
|
},
|
||||||
source: synapseBloodhound
|
source: synapseBloodhound
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'existing_synapses',
|
name: 'existing_synapses',
|
||||||
limit: 50,
|
limit: 50,
|
||||||
display: function(s) { return s.label },
|
display: function(s) { return s.label },
|
||||||
templates: {
|
templates: {
|
||||||
suggestion: function(s) {
|
suggestion: function(s) {
|
||||||
return Hogan.compile($('#synapseAutocompleteTemplate').html()).render(s)
|
return Hogan.compile($('#synapseAutocompleteTemplate').html()).render(s)
|
||||||
},
|
|
||||||
header: '<h3>Existing synapses</h3>'
|
|
||||||
},
|
},
|
||||||
source: existingSynapseBloodhound
|
header: '<h3>Existing synapses</h3>'
|
||||||
}]
|
},
|
||||||
|
source: existingSynapseBloodhound
|
||||||
|
}]
|
||||||
)
|
)
|
||||||
|
|
||||||
$('#synapse_desc').keyup(function(e) {
|
$('#synapse_desc').keyup(function(e) {
|
||||||
|
|
|
@ -7,7 +7,6 @@ try { Backbone.$ = window.$ } catch (err) {}
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
import InfoBox from '../Map/InfoBox'
|
import InfoBox from '../Map/InfoBox'
|
||||||
import Mapper from '../Mapper'
|
import Mapper from '../Mapper'
|
||||||
import Realtime from '../Realtime'
|
|
||||||
|
|
||||||
const Map = Backbone.Model.extend({
|
const Map = Backbone.Model.extend({
|
||||||
urlRoot: '/maps',
|
urlRoot: '/maps',
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
/* global $ */
|
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import outdent from 'outdent'
|
import outdent from 'outdent'
|
||||||
import Backbone from 'backbone'
|
import Backbone from 'backbone'
|
||||||
|
@ -7,8 +5,6 @@ try { Backbone.$ = window.$ } catch (err) {}
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
import Filter from '../Filter'
|
import Filter from '../Filter'
|
||||||
import JIT from '../JIT'
|
|
||||||
import Realtime from '../Realtime'
|
|
||||||
import SynapseCard from '../SynapseCard'
|
import SynapseCard from '../SynapseCard'
|
||||||
import Visualize from '../Visualize'
|
import Visualize from '../Visualize'
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
/* global $ */
|
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import Backbone from 'backbone'
|
import Backbone from 'backbone'
|
||||||
try { Backbone.$ = window.$ } catch (err) {}
|
try { Backbone.$ = window.$ } catch (err) {}
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
import Filter from '../Filter'
|
import Filter from '../Filter'
|
||||||
import JIT from '../JIT'
|
|
||||||
import Realtime from '../Realtime'
|
|
||||||
import TopicCard from '../TopicCard'
|
import TopicCard from '../TopicCard'
|
||||||
import Visualize from '../Visualize'
|
import Visualize from '../Visualize'
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import Visualize from './Visualize'
|
||||||
|
|
||||||
const PasteInput = {
|
const PasteInput = {
|
||||||
// thanks to https://github.com/kevva/url-regex
|
// thanks to https://github.com/kevva/url-regex
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
URL_REGEX: new RegExp('^(?:(?:(?:[a-z]+:)?//)|www\.)(?:\S+(?::\S*)?@)?(?:localhost|(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#][^\s"]*)?$'),
|
URL_REGEX: new RegExp('^(?:(?:(?:[a-z]+:)?//)|www\.)(?:\S+(?::\S*)?@)?(?:localhost|(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#][^\s"]*)?$'),
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports = {
|
||||||
SEND_COORDS: 'SEND_COORDS',
|
SEND_COORDS: 'SEND_COORDS',
|
||||||
DRAG_TOPIC: 'DRAG_TOPIC',
|
DRAG_TOPIC: 'DRAG_TOPIC',
|
||||||
|
|
||||||
/* EVENTS RECEIVABLE FROM NODE SERVER*/
|
/* EVENTS RECEIVABLE FROM NODE SERVER */
|
||||||
JUNTO_UPDATED: 'JUNTO_UPDATED',
|
JUNTO_UPDATED: 'JUNTO_UPDATED',
|
||||||
INVITED_TO_CALL: 'INVITED_TO_CALL',
|
INVITED_TO_CALL: 'INVITED_TO_CALL',
|
||||||
INVITED_TO_JOIN: 'INVITED_TO_JOIN',
|
INVITED_TO_JOIN: 'INVITED_TO_JOIN',
|
||||||
|
@ -29,5 +29,5 @@ module.exports = {
|
||||||
NEW_MAPPER: 'NEW_MAPPER',
|
NEW_MAPPER: 'NEW_MAPPER',
|
||||||
LOST_MAPPER: 'LOST_MAPPER',
|
LOST_MAPPER: 'LOST_MAPPER',
|
||||||
TOPIC_DRAGGED: 'TOPIC_DRAGGED',
|
TOPIC_DRAGGED: 'TOPIC_DRAGGED',
|
||||||
PEER_COORDS_UPDATED: 'PEER_COORDS_UPDATED',
|
PEER_COORDS_UPDATED: 'PEER_COORDS_UPDATED'
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,7 @@ import Cable from '../Cable'
|
||||||
import DataModel from '../DataModel'
|
import DataModel from '../DataModel'
|
||||||
import JIT from '../JIT'
|
import JIT from '../JIT'
|
||||||
import Util from '../Util'
|
import Util from '../Util'
|
||||||
import Views from '../Views'
|
import Views, { ChatView } from '../Views'
|
||||||
import { ChatView } from '../Views'
|
|
||||||
import Visualize from '../Visualize'
|
import Visualize from '../Visualize'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -4,18 +4,12 @@
|
||||||
everthing in this file happens as a result of websocket events
|
everthing in this file happens as a result of websocket events
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { indexOf } from 'lodash'
|
|
||||||
|
|
||||||
import { JUNTO_UPDATED } from './events'
|
import { JUNTO_UPDATED } from './events'
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
import { ChatView } from '../Views'
|
import { ChatView } from '../Views'
|
||||||
import DataModel from '../DataModel'
|
import DataModel from '../DataModel'
|
||||||
import GlobalUI from '../GlobalUI'
|
import GlobalUI from '../GlobalUI'
|
||||||
import Control from '../Control'
|
|
||||||
import Mapper from '../Mapper'
|
|
||||||
import Topic from '../Topic'
|
|
||||||
import Synapse from '../Synapse'
|
|
||||||
import Util from '../Util'
|
import Util from '../Util'
|
||||||
import Visualize from '../Visualize'
|
import Visualize from '../Visualize'
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import Active from './Active'
|
||||||
import Control from './Control'
|
import Control from './Control'
|
||||||
import Create from './Create'
|
import Create from './Create'
|
||||||
import DataModel from './DataModel'
|
import DataModel from './DataModel'
|
||||||
import JIT from './JIT'
|
|
||||||
import Map from './Map'
|
import Map from './Map'
|
||||||
import Selected from './Selected'
|
import Selected from './Selected'
|
||||||
import Settings from './Settings'
|
import Settings from './Settings'
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
/* global $ */
|
/* global $ */
|
||||||
|
|
||||||
import Backbone from 'backbone'
|
|
||||||
import attachMediaStream from 'attachmediastream'
|
import attachMediaStream from 'attachmediastream'
|
||||||
|
|
||||||
// TODO is this line good or bad
|
|
||||||
// Backbone.$ = window.$
|
|
||||||
|
|
||||||
import Active from '../Active'
|
|
||||||
import DataModel from '../DataModel'
|
|
||||||
import Realtime from '../Realtime'
|
import Realtime from '../Realtime'
|
||||||
import VideoView from './VideoView'
|
import VideoView from './VideoView'
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { JUNTO_UPDATED } from '../Realtime/events'
|
||||||
const Views = {
|
const Views = {
|
||||||
init: (serverData) => {
|
init: (serverData) => {
|
||||||
$(document).on(JUNTO_UPDATED, () => ExploreMaps.render())
|
$(document).on(JUNTO_UPDATED, () => ExploreMaps.render())
|
||||||
ChatView.init([serverData['sounds/MM_sounds.mp3'],serverData['sounds/MM_sounds.ogg']])
|
ChatView.init([serverData['sounds/MM_sounds.mp3'], serverData['sounds/MM_sounds.ogg']])
|
||||||
},
|
},
|
||||||
ExploreMaps,
|
ExploreMaps,
|
||||||
ChatView,
|
ChatView,
|
||||||
|
|
|
@ -11,25 +11,25 @@ function addZero(i) {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(created_at) {
|
function formatDate(createdAt) {
|
||||||
let date = new Date(created_at)
|
let date = new Date(createdAt)
|
||||||
let formatted = (date.getMonth() + 1) + '/' + date.getDate()
|
let formatted = (date.getMonth() + 1) + '/' + date.getDate()
|
||||||
formatted += ' ' + addZero(date.getHours()) + ':' + addZero(date.getMinutes())
|
formatted += ' ' + addZero(date.getHours()) + ':' + addZero(date.getMinutes())
|
||||||
return formatted
|
return formatted
|
||||||
}
|
}
|
||||||
|
|
||||||
const Message = props => {
|
const Message = props => {
|
||||||
const { user_image, user_name, message, created_at, heading } = props
|
const { user_image: userImage, user_name: userName, message, created_at: createdAt, heading } = props
|
||||||
const messageHtml = {__html: linker.link(Util.addEmoji(message, { emoticons: false }))}
|
const messageHtml = {__html: linker.link(Util.addEmoji(message, { emoticons: false }))}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="chat-message">
|
<div className="chat-message">
|
||||||
<div className="chat-message-user">
|
<div className="chat-message-user">
|
||||||
{heading && <img src={user_image} />}
|
{heading && <img src={userImage} />}
|
||||||
</div>
|
</div>
|
||||||
{heading && <div className="chat-message-meta">
|
{heading && <div className="chat-message-meta">
|
||||||
<span className='chat-message-username'>{user_name}</span>
|
<span className='chat-message-username'>{userName}</span>
|
||||||
<span className='chat-message-time'>{formatDate(created_at)}</span>
|
<span className='chat-message-time'>{formatDate(createdAt)}</span>
|
||||||
</div>}
|
</div>}
|
||||||
<div className="chat-message-text" dangerouslySetInnerHTML={messageHtml}></div>
|
<div className="chat-message-text" dangerouslySetInnerHTML={messageHtml}></div>
|
||||||
<div className="clearfloat"></div>
|
<div className="clearfloat"></div>
|
||||||
|
|
|
@ -2,28 +2,28 @@ import React, { PropTypes, Component } from 'react'
|
||||||
|
|
||||||
class Participant extends Component {
|
class Participant extends Component {
|
||||||
render() {
|
render() {
|
||||||
const { conversationLive, mapperIsLive, isParticipating, isPending, id, self, image, username, selfName, color } = this.props
|
const { conversationLive, mapperIsLive, isParticipating, isPending, id, self, image, username, color } = this.props
|
||||||
return (
|
return (
|
||||||
<div className={`participant participant-${id} ${self ? 'is-self' : ''}`}>
|
<div className={`participant participant-${id} ${self ? 'is-self' : ''}`}>
|
||||||
<div className="chat-participant-image">
|
<div className="chat-participant-image">
|
||||||
<img src={image} style={{ border: `2px solid ${color}`}} />
|
<img src={image} style={{ border: `2px solid ${color}` }} />
|
||||||
</div>
|
</div>
|
||||||
<div className="chat-participant-name">
|
<div className="chat-participant-name">
|
||||||
{username} {self ? '(me)' : ''}
|
{username} {self ? '(me)' : ''}
|
||||||
</div>
|
</div>
|
||||||
{!self && !conversationLive && <button
|
{!self && !conversationLive && <button
|
||||||
className={`button chat-participant-invite-call ${isPending ? 'pending' : ''}`}
|
className={`button chat-participant-invite-call ${isPending ? 'pending' : ''}`}
|
||||||
onClick={() => !isPending && this.props.inviteACall(id)} // Realtime.inviteACall(id)
|
onClick={() => !isPending && this.props.inviteACall(id)} // Realtime.inviteACall(id)
|
||||||
/>}
|
/>}
|
||||||
{!self && mapperIsLive && !isParticipating && <button
|
{!self && mapperIsLive && !isParticipating && <button
|
||||||
className={`button chat-participant-invite-join ${isPending ? 'pending' : ''}`}
|
className={`button chat-participant-invite-join ${isPending ? 'pending' : ''}`}
|
||||||
onClick={() => !isPending && this.props.inviteToJoin(id)} // Realtime.inviteToJoin(id)
|
onClick={() => !isPending && this.props.inviteToJoin(id)} // Realtime.inviteToJoin(id)
|
||||||
/>}
|
/>}
|
||||||
{isParticipating && <span className="chat-participant-participating">
|
{isParticipating && <span className="chat-participant-participating">
|
||||||
<div className="green-dot"></div>
|
<div className="green-dot"></div>
|
||||||
</span>}
|
</span>}
|
||||||
<div className="clearfloat"></div>
|
<div className="clearfloat"></div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"build:watch": "webpack --watch",
|
"build:watch": "webpack --watch",
|
||||||
"test": "mocha --compilers js:babel-core/register frontend/test"
|
"test": "mocha --compilers js:babel-core/register frontend/test",
|
||||||
|
"eslint": "eslint frontend",
|
||||||
|
"eslint:fix": "eslint --fix frontend"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Loading…
Reference in a new issue