Skip to content

Commit 800f909

Browse files
authored
Merge pull request #224 from ZahraTee/fix-lint-errors
(209) Fix ESLint errors
2 parents c45b4ac + e832ce5 commit 800f909

File tree

8 files changed

+32
-31
lines changed

8 files changed

+32
-31
lines changed

static/.eslintrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
2-
"globals": {},
2+
"globals": {
3+
"CONFIG": true,
4+
"CHAR_WIDTH": true
5+
},
36
"env": {
47
"browser": true,
58
"jquery": true
69
},
710
"rules": {
8-
"react/prop-types": 0
11+
"react/prop-types": 0,
12+
"no-console": 0
913
},
1014
"plugins": [
1115
"react",

static/app.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import React from 'react';
1010
import ReactDOM from 'react-dom';
11-
import { BrowserRouter, Route, Switch } from 'react-router-dom';
11+
import { BrowserRouter, Route } from 'react-router-dom';
1212

13-
import * as utils from './utils';
13+
import { request } from './utils';
1414
import { Sidebar } from './sidebar';
1515
import { makeTreeData } from './symbolPanel';
1616
import { ContentPanel, Page } from './contentPanel';
@@ -38,7 +38,7 @@ export class RustwApp extends React.Component {
3838

3939
loadFileTreeData() {
4040
let self = this;
41-
utils.request(
41+
request(
4242
'tree/' + CONFIG.workspace_root.replace('\\', '/'),
4343
function(json) {
4444
if (json.Directory) {
@@ -55,7 +55,7 @@ export class RustwApp extends React.Component {
5555

5656
loadSymbols() {
5757
const self = this;
58-
utils.request(
58+
request(
5959
'symbol_roots',
6060
function(json) {
6161
self.setState({ symbols: makeTreeData(json) });
@@ -67,7 +67,7 @@ export class RustwApp extends React.Component {
6767

6868
refreshStatus() {
6969
const self = this;
70-
utils.request(
70+
request(
7171
"status",
7272
function (data) {
7373
self.setState({ status: data.status });
@@ -80,7 +80,7 @@ export class RustwApp extends React.Component {
8080

8181
getSearch(needle) {
8282
const self = this;
83-
return utils.request(
83+
return request(
8484
'search?needle=' + needle,
8585
function(json) {
8686
self.refreshStatus();
@@ -93,7 +93,7 @@ export class RustwApp extends React.Component {
9393

9494
getUses(needle) {
9595
const self = this;
96-
return utils.request(
96+
return request(
9797
'search?id=' + needle,
9898
function(json) {
9999
self.refreshStatus();
@@ -106,7 +106,7 @@ export class RustwApp extends React.Component {
106106

107107
getImpls(needle) {
108108
const self = this;
109-
return utils.request(
109+
return request(
110110
'find?impls=' + needle,
111111
function(json) {
112112
self.refreshStatus();

static/contentPanel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import React from 'react';
1010

1111
import { DirView } from './dirView';
1212
import { SourceView } from './srcView';
13-
const utils = require('./utils');
13+
import { request } from './utils';
1414

1515
export const Page = {
1616
START: 'START',
@@ -51,7 +51,7 @@ export class ContentPanel extends React.Component {
5151
const app = this.props.app;
5252
const self = this;
5353

54-
utils.request(
54+
request(
5555
'src/' + path,
5656
function(json) {
5757
if (json.Directory) {

static/menus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class MenuHost extends React.Component {
7474

7575
render() {
7676
let menu = null;
77-
if (!!this.state.menuOpen) {
77+
if (this.state.menuOpen) {
7878
const onClose = () => this.setState({ menuOpen: null});
7979
menu = React.createElement(this.menuFn, { location: this.state.menuOpen, onClose: onClose, target: this.state.menuOpen.target, callbacks: this.props.callbacks });
8080
}

static/search.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
// except according to those terms.
88

99
import React from 'react';
10-
11-
const utils = require('./utils');
10+
import { highlight_spans } from './utils';
1211

1312
class ResultSet extends React.Component {
1413
componentDidMount() {
@@ -157,7 +156,7 @@ function highlight_needle(results, tag) {
157156
results.map((file, index) => {
158157
file.lines.map((line) => {
159158
line.line_end = line.line_start;
160-
utils.highlight_spans(line,
159+
highlight_spans(line,
161160
null,
162161
`snippet_line_${tag}_${index}_`,
163162
"selected_search");

static/srcView.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// except according to those terms.
88

99
import React from 'react';
10-
import ReactDOM from 'react-dom';
1110

1211
import * as utils from './utils';
1312
import { BreadCrumbs } from './breadCrumbs';
@@ -91,7 +90,7 @@ function view_in_vcs(target) {
9190
function edit(target) {
9291
utils.request(
9392
'edit?file=' + target.dataset.link,
94-
function(json) {
93+
function() {
9594
console.log("edit - success");
9695
},
9796
"Error with search edit",
@@ -113,7 +112,7 @@ export class SourceView extends React.Component {
113112

114113
componentDidUpdate() {
115114
if (this.props.highlight) {
116-
utils.highlight_spans(this.props.highlight, "src_line_number_", "src_line_", "selected", ReactDOM.findDOMNode(this));
115+
utils.highlight_spans(this.props.highlight, "src_line_number_", "src_line_", "selected", this.node);
117116
}
118117

119118
// Make source links active.
@@ -161,15 +160,15 @@ export class SourceView extends React.Component {
161160
});
162161

163162
let refMenu = null;
164-
if (!!this.state.refMenu) {
163+
if (this.state.refMenu) {
165164
const onClose = () => {
166165
return this.setState({ refMenu: null });
167166
};
168167

169168
refMenu = <RefMenu app={this.props.app} location={this.state.refMenu} onClose={onClose} target={this.state.refMenu.target} id={this.state.refMenu.id} />;
170169
}
171170

172-
return <div id="src">
171+
return <div id="src" ref={node => this.node = node}>
173172
<BreadCrumbs app={this.props.app} path={this.props.path} />
174173
<div id="div_src_view">
175174
<div id="div_src_contents">

static/symbolPanel.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
import React from 'react';
1010
import { Treebeard } from 'react-treebeard';
11-
12-
const utils = require('./utils');
11+
import { request } from './utils';
1312

1413
// FIXME share code with treePanel
1514

@@ -46,7 +45,7 @@ export class SymbolPanel extends React.Component {
4645

4746
// Get any children from the server and add them to the tree.
4847
if (node.symId && (!node.children || node.children.length == 0)) {
49-
utils.request(
48+
request(
5049
'symbol_children?id=' + node.symId,
5150
function(json) {
5251
// FIXME? We are mutating the state of app here, I'm pretty sure this is bad practice.

static/utils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function highlight_spans(highlight, line_number_prefix, src_line_prefix,
2424
}
2525

2626
if (line_number_prefix) {
27-
for (var i = highlight.line_start; i <= highlight.line_end; ++i) {
27+
for (let i = highlight.line_start; i <= highlight.line_end; ++i) {
2828
$("#" + line_number_prefix + i).addClass(css_class);
2929
}
3030
}
@@ -34,7 +34,7 @@ export function highlight_spans(highlight, line_number_prefix, src_line_prefix,
3434
}
3535

3636
// Highlight all of the middle lines.
37-
for (var i = highlight.line_start + 1; i <= highlight.line_end - 1; ++i) {
37+
for (let i = highlight.line_start + 1; i <= highlight.line_end - 1; ++i) {
3838
$("#" + src_line_prefix + i).addClass(css_class);
3939
}
4040

@@ -45,8 +45,8 @@ export function highlight_spans(highlight, line_number_prefix, src_line_prefix,
4545
$("#" + src_line_prefix + highlight.line_end).addClass(css_class);
4646
} else {
4747
// First line
48-
var lhs = (highlight.column_start - 1);
49-
var rhs = 0;
48+
const lhs = (highlight.column_start - 1);
49+
let rhs = 0;
5050
if (highlight.line_end === highlight.line_start && highlight.column_end > 0) {
5151
// If we're only highlighting one line, then the highlight must stop
5252
// before the end of the line.
@@ -56,7 +56,7 @@ export function highlight_spans(highlight, line_number_prefix, src_line_prefix,
5656

5757
// Last line
5858
if (highlight.line_end > highlight.line_start) {
59-
var rhs = 0;
59+
rhs = 0;
6060
if (highlight.column_end > 0) {
6161
rhs = (highlight.column_end - 1);
6262
}
@@ -80,12 +80,12 @@ export function request(urlStr, success, errStr, app) {
8080
console.log(errStr);
8181
console.log("error: " + errorThrown + "; status: " + status);
8282

83-
if (!!app) {
83+
if (app) {
8484
app.showError();
8585
}
8686
});
8787

88-
if (!!app) {
88+
if (app) {
8989
app.showLoading();
9090
}
9191
}

0 commit comments

Comments
 (0)