Skip to content

Commit

Permalink
eslint checks added; refactored to comply with eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
olsender committed May 17, 2019
1 parent 9aff184 commit 53d888e
Show file tree
Hide file tree
Showing 43 changed files with 523 additions and 619 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
env:
browser: true
node: true
commonjs: true
es6: true
extends: 'eslint:recommended'
globals:
Atomics: readonly
SharedArrayBuffer: readonly
parserOptions:
ecmaFeatures:
jsx: true
ecmaVersion: 2018
plugins:
- react
rules:
"react/jsx-uses-vars": "error"
"no-console": 0
5 changes: 3 additions & 2 deletions css/tabs.css
Original file line number Diff line number Diff line change
Expand Up @@ -454,16 +454,17 @@ body{
border-bottom-style: solid;
border-bottom-color: black;
border-bottom-width: 1px;
padding-bottom: 5px;
}

.project-toolbar{
position: relative;
padding-top: 10px;
width: 100%;
text-align: left;
margin-left: 20px;
padding-left: 20px;
line-height: 200%;
border-top: solid 1px;
margin-top: 5px;
}

.project-button{
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</head>
<body>
<div id="root" style="display: flex; flex-direction: column; height: 100%; min-height: 100%;"></div>
<script src="build/index.js"></script>
<script> require("./build/index.js") </script>
</body>
</html>

4 changes: 2 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

if (process.platform == 'linux'){
mkdirp = require('mkdirp');
var mkdirp = require('mkdirp');
mkdirp(process.env.HOME+'/.local/share/icons', function(err){console.log(err)});
mkdirp(process.env.HOME+'/.local/share/applications');
var fs = require('fs');
Expand Down Expand Up @@ -69,7 +69,7 @@ app.on('ready', function() {
createWindow();
if (files2open.length != 0){
var contents = mainWindow.webContents;
for (i in files2open){
for (var i in files2open){
var path = files2open[i];
var getEmitter = function(contents, path){
return function(){
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"firebase": "^5.9.1",
"firebase-admin": "^7.1.1",
"flux": "2.0.1",
"grpc": "^1.19.0",
"grpc": "^1.20.3",
"jquery": "^3.3.1",
"lowdb": "0.7.2",
"marked": "^0.3.3",
Expand All @@ -49,6 +49,8 @@
"electron": "^4.1.0",
"electron-packager": "^13.1.1",
"electron-reload": "^1.4.0",
"eslint": "^5.16.0",
"eslint-plugin-react": "^7.13.0",
"uglify-es": "^3.3.9"
},
"optionalDependencies": {
Expand All @@ -57,9 +59,10 @@
"scripts": {
"postinstall": "npm install grpc --runtime=electron --target=4.1.0; rm -r node_modules/c3/node_modules; babel --plugins transform-react-jsx --out-dir=build src/;",
"start": "electron ./",
"build": "eslint main.js src/ && babel --plugins transform-react-jsx --out-dir=build src/",
"build:mac": "./mac_build.sh",
"build:win": "./win_build.sh",
"build:linux": "./linux_build.sh",
"build:watch": "babel --plugins transform-react-jsx --out-dir=build src/ --watch"
"build:watch": "eslint main.js src/ && babel --plugins transform-react-jsx --out-dir=build src/ --watch"
}
}
2 changes: 0 additions & 2 deletions src/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
*/

var React = require('react');
var ReactDOM = require('react-dom');
var Modal = require('react-bootstrap').Modal;
var Button = require('react-bootstrap').Button;
var OverlayMixin = require('react-bootstrap').OverlayMixin;
var TabsStore = require('./TabsStore');
var Shell = require('electron').shell;

Expand Down
4 changes: 2 additions & 2 deletions src/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ var Actions = {
},

close: function(id){
close = () => Dialog.showMessageBox({
var closeDialog = () => Dialog.showMessageBox({
buttons: ["No", "Yes"],
defaultId: 1,
message: "Do you really want to close the tab?"
});

if (typeof id !== 'undefined' || close()) {
if (typeof id !== 'undefined' || closeDialog()) {
AppDispatcher.dispatch({
eventName: 'close-tab',
key: id,
Expand Down
5 changes: 3 additions & 2 deletions src/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
var React = require('react');
var ReactDOM = require('react-dom');
var c3 = require('c3');
var $ = require('jquery');

var Chart = React.createClass({

componentDidMount: function(){

var fields = this.props.dataset.fields.map(function(field, i){
var fields = this.props.dataset.fields.map(function(field){
return field.name;
});
this.props.dataset.data.unshift(fields);
Expand Down Expand Up @@ -58,7 +59,7 @@ var Chart = React.createClass({
return;
}

var chart = c3.generate({
c3.generate({
bindto: ReactDOM.findDOMNode(this),
data: data,
});
Expand Down
7 changes: 4 additions & 3 deletions src/ClickButton.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/*
Copyright (C) 2015 Aliaksandr Aliashkevich
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

var React = require('react');
var Button = require('react-bootstrap').Button;

var ClickButton = React.createClass({
Expand Down
4 changes: 2 additions & 2 deletions src/Cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ var request = require('request');
var CryptoJS = require("crypto-js");

if (typeof(DEVMODE) == 'undefined'){
DEVMODE = true;
var DEVMODE = true;
}

Cloud = {
const Cloud = {

share: function(target_server, encrypt, encryptionKey, data, callback, err_callback){
if (target_server.indexOf('http://') == -1 && target_server.indexOf('https://') == -1){
Expand Down
6 changes: 2 additions & 4 deletions src/CloudMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var React = require('react');
var ReactDOM = require('react-dom');
var Modal = require('react-bootstrap').Modal;
var Button = require('react-bootstrap').Button;
var OverlayMixin = require('react-bootstrap').OverlayMixin;
var TabsStore = require('./TabsStore');
var Actions = require('./Actions');
var Shell = require('electron').shell;
Expand Down Expand Up @@ -91,10 +90,9 @@ var CloudMessage = React.createClass({

open: function(){
var docid = TabsStore.getCloudDoc();
var target_server = this.target_server;
if (this.target_server.indexOf("http://") == -1 && this.target_server.indexOf('https://') == -1){
var target_server = "https://"+this.target_server;
} else {
var target_server = this.target_server;
target_server = "https://"+this.target_server;
}
Shell.openExternal(target_server+'/api/1.0/docs/'+docid);
this.hide();
Expand Down
2 changes: 1 addition & 1 deletion src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var Conf = {
return "share.sqltabs.com";
} else {
return config.sharing_server;
};
}
},

saveSharingServer: function(server){
Expand Down
48 changes: 24 additions & 24 deletions src/ConnInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ var ConnInput = React.createClass({
this.setState({connstr: e.target.value});
},

focusHandler: function(e){
focusHandler: function(){
this.setState({active: true});
},

unfocusHandler: function(e){
unfocusHandler: function(){
this.setState({
active: false,
hilight: -1,
Expand Down Expand Up @@ -110,8 +110,11 @@ var ConnInput = React.createClass({
if (TabsStore.connectionHistory.length == 0 || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey){
return;
}

var hilight;
var connstr;
if (e.keyCode == 40){ // down
var hilight = (this.state.hilight < history_length - 1 ) ? this.state.hilight+1 : 0;
hilight = (this.state.hilight < history_length - 1 ) ? this.state.hilight+1 : 0;
this.setState({
active: true,
hilight: hilight,
Expand All @@ -120,7 +123,7 @@ var ConnInput = React.createClass({
e.preventDefault();
e.stopPropagation();
} else if (e.keyCode == 38) { // up
var hilight = (this.state.hilight == 0 ) ? history_length-1 : this.state.hilight-1;
hilight = (this.state.hilight == 0 ) ? history_length-1 : this.state.hilight-1;
this.setState({
active: true,
hilight: hilight,
Expand All @@ -137,9 +140,9 @@ var ConnInput = React.createClass({
e.stopPropagation();
} else if (e.keyCode == 13) { // enter
if (this.state.hilight > -1){
var connstr = TabsStore.connectionHistory[this.state.hilight]
connstr = TabsStore.connectionHistory[this.state.hilight]
} else {
var connstr = this.state.connstr;
connstr = this.state.connstr;
}
this.setState({
active: false,
Expand All @@ -160,35 +163,33 @@ var ConnInput = React.createClass({

var history = this.state.history.map(function(item, i){

var meta_start = -1;
if (item != null){
var meta_start = item.indexOf('---'); // extension of connect string: user:port@db --- alias of connect string
} else {
var meta_start = -1;
meta_start = item.indexOf('---'); // extension of connect string: user:port@db --- alias of connect string
}

var conn_str = item;
var alias = null;
if (meta_start != -1){
var conn_str = item.substr(0, meta_start);
var alias = item.match(/---\s*(.*)/)[1]+':';
} else {
var conn_str = item;
var alias = null;
conn_str = item.substr(0, meta_start);
alias = item.match(/---\s*(.*)/)[1]+':';
}

var highlighted = '';
var remove_item = '';
if (i == self.state.hilight) {
var highlighted = ' conn_history_item_active'
var remove_item = <span
highlighted = ' conn_history_item_active'
remove_item = <span
data-idx={i}
key={"remove_connstr_"+i}
onClick={self.removeHandler}
className="conn_item_remove glyphicon glyphicon-minus-sign"></span>
} else {
var highlighted = '';
var remove_item = '';
}

if (alias){
var alias = <span data-idx={i} className="conn_item_alias">{alias}</span>
alias = <span data-idx={i} className="conn_item_alias">{alias}</span>
} else {
var alias = '';
alias = '';
}

var connectionColor = TabsStore.getConnectionColor(item);
Expand All @@ -206,10 +207,9 @@ var ConnInput = React.createClass({
</li>;
});

var visibility = "conn_history_hidden"
if (this.state.active && TabsStore.connectionHistory.length > 0){
var visibility = "conn_history_visisble"
} else {
var visibility = "conn_history_hidden"
visibility = "conn_history_visisble"
}

var history_div =
Expand Down
11 changes: 7 additions & 4 deletions src/Dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

var React = require('react');
var Dispatcher = require('flux').Dispatcher;
var TabsStore = require('./TabsStore');
var Executor = require('./Executor');
Expand Down Expand Up @@ -69,11 +68,14 @@ SignalsDispatcher.register(function(payload){
TabsStore.setCloudError(payload.error);
TabsStore.trigger('cloud-message');
break;
};
}
return true;
});

AppDispatcher.register( function(payload) {
var tab;
var connstr;
var password;
switch( payload.eventName ) {
case 'show-settings':
// Only one settings tab open at the time, so firstly search the open one
Expand Down Expand Up @@ -131,7 +133,7 @@ AppDispatcher.register( function(payload) {
document.getElementById("theme_stylesheet").href = "css/bootstrap.dark.css";
document.getElementById("theme_tabs_stylesheet").href = "css/tabs.dark.css";
}
};
}

TabsStore.setTheme(payload.key);
Config.saveTheme(TabsStore.theme);
Expand Down Expand Up @@ -247,6 +249,7 @@ AppDispatcher.register( function(payload) {
TabsStore.closeFile();
TabsStore.trigger('close-file-'+TabsStore.selectedTab);
TabsStore.trigger('change');
break;

case 'goto-connstr':
TabsStore.trigger('goto-connstr-'+TabsStore.selectedTab);
Expand Down Expand Up @@ -377,7 +380,7 @@ var wordsUpdateInProgress = false;
var updateCompletionWords = function(){
if (!wordsUpdateInProgress){
wordsUpdateInProgress = true;
for (tab in TabsStore.tabs){
for (var tab in TabsStore.tabs){
var connstr = TabsStore.getConnstr(tab);
Executor.getCompletionWords(connstr, function(words){
TabsStore.updateCompletionWords(words);
Expand Down
Loading

0 comments on commit 53d888e

Please sign in to comment.