diff --git a/.codeclimate.yml b/.codeclimate.yml index d3c19ad6..53f90d17 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -12,6 +12,7 @@ engines: - javascript eslint: enabled: true + channel: "eslint-3" fixme: enabled: true rubocop: diff --git a/.eslintrc.js b/.eslintrc.js index 26319254..11a46fd1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,165 +1,15 @@ module.exports = { "sourceType": "module", "parser": "babel-eslint", + "extends": "standard", "installedESLint": true, "env": { "es6": true, "node": true }, "plugins": [ + "promise", + "standard", "react" - ], - "globals": { - "document": false, - "navigator": false, - "window": false - }, - "rules": { - "accessor-pairs": 2, - "arrow-spacing": [2, { "before": true, "after": true }], - "block-spacing": [2, "always"], - "brace-style": [2, "1tbs", { "allowSingleLine": true }], - "camelcase": [2, { "properties": "never" }], - "comma-dangle": [2, "never"], - "comma-spacing": [2, { "before": false, "after": true }], - "comma-style": [2, "last"], - "constructor-super": 2, - "curly": [2, "multi-line"], - "dot-location": [2, "property"], - "eol-last": 2, - "eqeqeq": [2, "allow-null"], - // errors on code climate - disable for now - //"func-call-spacing": [2, "never"], - "handle-callback-err": [2, "^(err|error)$" ], - "indent": [2, 2, { "SwitchCase": 1 }], - "key-spacing": [2, { "beforeColon": false, "afterColon": true }], - // errors on code climate - disable for now - //"keyword-spacing": [2, { "before": true, "after": true }], - "new-cap": [2, { "newIsCap": true, "capIsNew": false }], - "new-parens": 2, - "no-array-constructor": 2, - "no-caller": 2, - "no-class-assign": 2, - "no-cond-assign": 2, - "no-const-assign": 2, - // errors on code climate - disable for now - //"no-constant-condition": [2, { "checkLoops": false }], - "no-control-regex": 2, - "no-debugger": 2, - "no-delete-var": 2, - "no-dupe-args": 2, - "no-dupe-class-members": 2, - "no-dupe-keys": 2, - "no-duplicate-case": 2, - // errors on code climate - disable for now - //"no-duplicate-imports": 2, - "no-empty-character-class": 2, - "no-empty-pattern": 2, - "no-eval": 2, - "no-ex-assign": 2, - "no-extend-native": 2, - "no-extra-bind": 2, - "no-extra-boolean-cast": 2, - "no-extra-parens": [2, "functions"], - "no-fallthrough": 2, - "no-floating-decimal": 2, - "no-func-assign": 2, - // errors on code climate - disable for now - //"no-global-assign": 2, - "no-implied-eval": 2, - "no-inner-declarations": [2, "functions"], - "no-invalid-regexp": 2, - "no-irregular-whitespace": 2, - "no-iterator": 2, - "no-label-var": 2, - // errors on code climate - disable for now - //"no-labels": [2, { "allowLoop": false, "allowSwitch": false }], - "no-lone-blocks": 2, - "no-mixed-spaces-and-tabs": 2, - "no-multi-spaces": 2, - "no-multi-str": 2, - "no-multiple-empty-lines": [2, { "max": 1 }], - "no-native-reassign": 2, - "no-negated-in-lhs": 2, - "no-new": 2, - "no-new-func": 2, - "no-new-object": 2, - "no-new-require": 2, - // errors on code climate - disable for now - //"no-new-symbol": 2, - "no-new-wrappers": 2, - "no-obj-calls": 2, - "no-octal": 2, - "no-octal-escape": 2, - "no-path-concat": 2, - "no-proto": 2, - "no-redeclare": 2, - "no-regex-spaces": 2, - "no-return-assign": [2, "except-parens"], - // errors on code climate - disable for now - //"no-self-assign": 2, - "no-self-compare": 2, - "no-sequences": 2, - "no-shadow-restricted-names": 2, - "no-sparse-arrays": 2, - // errors on code climate - disable for now - //"no-tabs": 2, - // errors on code climate - disable for now - //"no-template-curly-in-string": 2, - "no-this-before-super": 2, - "no-throw-literal": 2, - "no-trailing-spaces": 2, - "no-undef": 2, - "no-undef-init": 2, - "no-unexpected-multiline": 2, - // errors on code climate - disable for now - //"no-unmodified-loop-condition": 2, - "no-unneeded-ternary": [2, { "defaultAssignment": false }], - "no-unreachable": 2, - // errors on code climate - disable for now - //"no-unsafe-finally": 2, - // errors on code climate - disable for now - //"no-unsafe-negation": 2, - "no-unused-vars": [2, { "vars": "all", "args": "none" }], - "no-useless-call": 2, - // errors on code climate - disable for now - //"no-useless-computed-key": 2, - // errors on code climate - disable for now - //"no-useless-constructor": 2, - // errors on code climate - disable for now - //"no-useless-escape": 2, - // errors on code climate - disable for now - //"no-useless-rename": 2, - // errors on code climate - disable for now - //"no-whitespace-before-property": 2, - "no-with": 2, - // errors on code climate - disable for now - //"object-property-newline": [2, { "allowMultiplePropertiesPerLine": true }], - "one-var": [2, { "initialized": "never" }], - "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }], - "padded-blocks": [2, "never"], - // errors on code climate - disable for now - //"quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }], - // errors on code climate - disable for now - //"rest-spread-spacing": [2, "never"], - "semi": [2, "never"], - "semi-spacing": [2, { "before": false, "after": true }], - "space-before-blocks": [2, "always"], - "space-before-function-paren": [2, "always"], - "space-in-parens": [2, "never"], - "space-infix-ops": 2, - "space-unary-ops": [2, { "words": true, "nonwords": false }], - // errors on code climate - disable for now - //"spaced-comment": [2, "always", { "line": { "markers": ["*package", "!", ","] }, "block": { "balanced": true, "markers": ["*package", "!", ","], "exceptions": ["*"] } }], - // errors on code climate - disable for now - //"template-curly-spacing": [2, "never"], - // errors on code climate - disable for now - //"unicode-bom": [2, "never"], - "use-isnan": 2, - "valid-typeof": 2, - "wrap-iife": [2, "any"], - // errors on code climate - disable for now - //"yield-star-spacing": [2, "both"], - "yoda": [2, "never"], - } + ] } diff --git a/frontend/src/Metamaps/Create.js b/frontend/src/Metamaps/Create.js index 1fc18b87..5d290fcd 100644 --- a/frontend/src/Metamaps/Create.js +++ b/frontend/src/Metamaps/Create.js @@ -1,4 +1,4 @@ -/* global Metamaps, $ */ +/* global Metamaps, $, Hogan, Bloodhound */ import Mouse from './Mouse' import Selected from './Selected' @@ -54,7 +54,7 @@ const Create = { }, updateMetacodeSet: function (set, index, custom) { if (custom && Create.newSelectedMetacodes.length == 0) { - alert('Please select at least one metacode to use!') + window.alert('Please select at least one metacode to use!') return false } diff --git a/frontend/src/Metamaps/GlobalUI.js b/frontend/src/Metamaps/GlobalUI.js index b24b31c7..7af133de 100644 --- a/frontend/src/Metamaps/GlobalUI.js +++ b/frontend/src/Metamaps/GlobalUI.js @@ -1,3 +1,4 @@ +/* global Metamaps, $, Hogan, Bloodhound */ import Active from './Active' import Create from './Create' import Filter from './Filter' @@ -585,7 +586,6 @@ GlobalUI.Search = { if (["topic", "map", "mapper"].indexOf(datum.rtype) !== -1) { self.close(0, true); - var win; if (datum.rtype == "topic") { Router.topics(datum.id); } else if (datum.rtype == "map") { diff --git a/frontend/src/Metamaps/JIT.js b/frontend/src/Metamaps/JIT.js index 0a75a036..63723dbd 100644 --- a/frontend/src/Metamaps/JIT.js +++ b/frontend/src/Metamaps/JIT.js @@ -1,4 +1,4 @@ -/* global Metamaps, $jit */ +/* global Metamaps, $, Image, CanvasLoader */ import _ from 'lodash' @@ -79,7 +79,6 @@ const JIT = { var jitReady = [] var synapsesToRemove = [] - var topic var mapping var node var nodes = {} @@ -183,8 +182,6 @@ const JIT = { if (!synapse) return // this means there are no corresponding synapses for // this edge, don't render it - var directionCat = synapse.get('category') - // label placement on edges if (canvas.denySelected) { var color = Settings.colors.synapses.normal @@ -282,8 +279,8 @@ const JIT = { if (synapseNum > 1) { var ctx = canvas.getCtx() - var x = (pos.x + posChild.x) / 2 - var y = (pos.y + posChild.y) / 2 + const x = (pos.x + posChild.x) / 2 + const y = (pos.y + posChild.y) / 2 drawSynapseCount(ctx, x, y, synapseNum) } } @@ -847,8 +844,8 @@ const JIT = { // set the draw synapse start positions var l = Selected.Nodes.length if (l > 0) { - for (var i = l - 1; i >= 0; i -= 1) { - var n = Selected.Nodes[i] + for (let i = l - 1; i >= 0; i -= 1) { + const n = Selected.Nodes[i] Mouse.synapseStartCoordinates.push({ x: n.pos.getc().x, y: n.pos.getc().y @@ -1541,8 +1538,6 @@ const JIT = { if (adj.getData('alpha') === 0) return; // don't do anything if the edge is filtered - var authorized - e.preventDefault() e.stopPropagation() @@ -1827,10 +1822,11 @@ const JIT = { width = canvas.getSize().width, maxX, minX, maxY, minY, counter = 0 + let nodes if (!denySelected && Selected.Nodes.length > 0) { - var nodes = Selected.Nodes + nodes = Selected.Nodes } else { - var nodes = _.values(Visualize.mGraph.graph.nodes) + nodes = _.values(Visualize.mGraph.graph.nodes) } if (nodes.length > 1) { diff --git a/frontend/src/Metamaps/Map/InfoBox.js b/frontend/src/Metamaps/Map/InfoBox.js index ec5c1405..c36f70c3 100644 --- a/frontend/src/Metamaps/Map/InfoBox.js +++ b/frontend/src/Metamaps/Map/InfoBox.js @@ -1,4 +1,4 @@ -/* global Metamaps, $ */ +/* global Metamaps, $, Hogan, Bloodhound, Countable */ import Active from '../Active' import GlobalUI from '../GlobalUI' @@ -236,7 +236,7 @@ const InfoBox = { Metamaps.Collaborators.add(mapper) var mapperIds = Metamaps.Collaborators.models.map(function (mapper) { return mapper.id }) $.post('/maps/' + Active.Map.id + '/access', { access: mapperIds }) - var name = Metamaps.Collaborators.get(newCollaboratorId).get('name') + var name = Metamaps.Collaborators.get(newCollaboratorId).get('name') GlobalUI.notifyUser(name + ' will be notified by email') self.updateNumbers() } @@ -349,7 +349,7 @@ const InfoBox = { var confirmString = 'Are you sure you want to delete this map? ' confirmString += 'This action is irreversible. It will not delete the topics and synapses on the map.' - var doIt = confirm(confirmString) + var doIt = window.confirm(confirmString) var map = Active.Map var mapper = Active.Mapper var authorized = map.authorizePermissionChange(mapper) diff --git a/frontend/src/Metamaps/Realtime.js b/frontend/src/Metamaps/Realtime.js index 355e73f8..608523c8 100644 --- a/frontend/src/Metamaps/Realtime.js +++ b/frontend/src/Metamaps/Realtime.js @@ -1,4 +1,4 @@ -/* global Metamaps, $ */ +/* global Metamaps, $, SocketIoConnection, SimpleWebRTC */ import _ from 'lodash' @@ -1106,7 +1106,7 @@ const Realtime = { } }, newSynapse: function (data) { - var topic1, topic2, node1, node2, synapse, mapping, cancel + var topic1, topic2, node1, node2, synapse, mapping, cancel, mapper var self = Realtime var socket = self.socket diff --git a/frontend/src/Metamaps/Views/ChatView.js b/frontend/src/Metamaps/Views/ChatView.js index a49aaa4d..473c6f1e 100644 --- a/frontend/src/Metamaps/Views/ChatView.js +++ b/frontend/src/Metamaps/Views/ChatView.js @@ -1,7 +1,13 @@ -/* global $ */ +/* global Metamaps, $, Howl */ + +/* + * Dependencies: + * Metamaps.Erb + */ import Backbone from 'backbone' import Autolinker from 'autolinker' +import _ from 'lodash' // TODO is this line good or bad // Backbone.$ = window.$ diff --git a/frontend/src/Metamaps/index.js b/frontend/src/Metamaps/index.js index 21a3fb8d..db67409b 100644 --- a/frontend/src/Metamaps/index.js +++ b/frontend/src/Metamaps/index.js @@ -1,4 +1,4 @@ -/* global $ */ +/* global Metamaps */ import Account from './Account' import Active from './Active'