Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit 6b80790

Browse files
committed
Eslint
1 parent 818512d commit 6b80790

File tree

10 files changed

+250
-278
lines changed

10 files changed

+250
-278
lines changed

.eslintrc.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
# extends: standard
1+
extends:
2+
- standard
3+
- "plugin:react/recommended"
4+
plugins:
5+
- standard
6+
- promise
7+
- react
8+
env:
9+
node: true
10+
globals:
11+
atom: true
212
parserOptions:
313
ecmaVersion: 8
414
ecmaFeatures:

lib/output-panel/output-panel.js

Lines changed: 81 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
1-
"use babel"
1+
'use babel'
22
/** @jsx etch.dom */
33

44
import etch from 'etch'
5-
import {Emitter, Disposable, CompositeDisposable} from 'atom'
5+
import {Disposable, CompositeDisposable} from 'atom'
66
import {OutputPanelButtons} from './views/output-panel-buttons'
77
import {OutputPanelCheckbox} from './views/output-panel-checkbox'
88
import {ProgressBar} from './views/progress-bar'
99
import {OutputPanelItems} from './views/output-panel-items'
10-
const $ = etch.dom;
10+
const $ = etch.dom
1111

1212
export class OutputPanel {
13-
constructor(state, results) {
13+
constructor (state, results) {
1414
this.state = state || {}
1515
this.results = results
1616

1717
this.hiddenOutput = true
1818

19-
this.elements = new Set
19+
this.elements = new Set()
2020

2121
this.statusMap = new Map
2222

2323
this.disposables = new CompositeDisposable
2424

25-
etch.initialize(this);
25+
etch.initialize(this)
2626

27-
atom.config.observe('ide-haskell.panelPosition',(value) => {
27+
atom.config.observe('ide-haskell.panelPosition', (value) => {
2828
this.pos = value
2929
this.panel = atom.workspace.addPanel(this.pos, {
3030
item: this,
31-
visible: this.state.visibility || true,
31+
visible: this.state.visibility || true
3232
})
33-
if(this.element)
33+
if (this.element) {
3434
this.update()
35+
}
3536
})
3637

3738
this.disposables.add(atom.tooltips.add(this.refs.status, {
@@ -51,34 +52,37 @@ export class OutputPanel {
5152

5253
this.disposables.add(this.results.onDidUpdate(({types}) => {
5354
this.currentResult = null
54-
if(atom.config.get('ide-haskell.autoHideOutput') &&
55-
types.map((type) => this.results.filter({severity: type}).length).every((l) => l == 0))
55+
if (atom.config.get('ide-haskell.autoHideOutput') &&
56+
types.map((type) => this.results.filter({severity: type}).length).every((l) => l === 0)) {
5657
this.buttons.disableAll()
57-
else
58-
if(atom.config.get('ide-haskell.switchTabOnCheck'))
58+
} else {
59+
if (atom.config.get('ide-haskell.switchTabOnCheck')) {
5960
this.activateFirstNonEmptyTab(types)
61+
}
62+
}
6063
this.updateItems()
61-
}));
64+
}))
6265

6366
this.refs.progressBar.setProgress(0)
6467

6568
this.disposables.add(this.refs.buttons.onButtonClicked(() => this.updateItems()))
6669
this.disposables.add(this.refs.checkboxUriFilter.onCheckboxSwitched(() => this.updateItems()))
6770
this.disposables.add(atom.workspace.onDidChangeActivePaneItem(() => {
68-
if(this.refs.checkboxUriFilter.getFileFilter()) this.updateItems() } ))
71+
if (this.refs.checkboxUriFilter.getFileFilter()) this.updateItems()
72+
}))
6973
}
7074

71-
render() {
75+
render () {
7276
let orientMap = {
7377
'top': 'horizontal',
7478
'bottom': 'horizontal',
7579
'left': 'vertical',
76-
'right': 'vertical',
80+
'right': 'vertical'
7781
}
7882
return (
7983
<ide-haskell-panel style={{width: this.state.width, height: this.state.height}}
8084
dataset={{pos: this.pos}}
81-
class={this.hiddenOutput?'hidden-output':''}>
85+
class={this.hiddenOutput ? 'hidden-output' : ''}>
8286
<resize-handle on={{mousedown: this.resizeStart}} />
8387
<ide-haskell-panel-heading ref='heading'>
8488
<ide-haskell-status-icon ref='status' id='status' dataset={{status: 'ready'}}/>
@@ -91,15 +95,15 @@ export class OutputPanel {
9195
</ide-haskell-panel-heading>
9296
<OutputPanelItems model={this.results} ref='items' id='items'/>
9397
</ide-haskell-panel>
94-
);
98+
)
9599
}
96100

97-
resizeStart(e) {
101+
resizeStart (e) {
98102
let varsMap = {
99103
'top': {axis: 'Y', param: 'height', dir: 1},
100104
'bottom': {axis: 'Y', param: 'height', dir: -1},
101105
'left': {axis: 'X', param: 'width', dir: 1},
102-
'right': {axis: 'X', param: 'width', dir: -1},
106+
'right': {axis: 'X', param: 'width', dir: -1}
103107
}
104108

105109
let vars = varsMap[this.pos]
@@ -110,7 +114,7 @@ export class OutputPanel {
110114

111115
let doDrag = (e) => {
112116
this.state[vars.param] =
113-
(startParam + vars.dir * (e[vars.axis] - startAxis)) + 'px';
117+
(startParam + vars.dir * (e[vars.axis] - startAxis)) + 'px'
114118
this.update()
115119
}
116120
let stopDrag = () => {
@@ -122,38 +126,34 @@ export class OutputPanel {
122126
document.documentElement.addEventListener('mouseup', stopDrag)
123127
}
124128

125-
update() {
129+
update () {
126130
return etch.update(this)
127131
}
128132

129-
async destroy() {
133+
async destroy () {
130134
await etch.destroy(this)
131135
this.disposables.dispose()
132136
this.panel.destroy()
133137
this.statusMap.clear()
134138
this.statusMap = null
135139
}
136140

137-
addPanelControl(element, opts) {
138-
if(typeof element == 'string') {
141+
addPanelControl (element, opts) {
142+
if (typeof element === 'string') {
139143
let {events, classes, style, attrs} = opts
140144
let props = {}
141-
if(classes)
142-
props.class = classes.join(' ')
143-
if(style)
144-
props.style = style
145-
if(attrs)
146-
props.attributes=attrs
147-
if(events)
148-
props.on = events
145+
if (classes) props.class = classes.join(' ')
146+
if (style) props.style = style
147+
if (attrs) props.attributes = attrs
148+
if (events) props.on = events
149149

150150
element = $(element, props)
151151
this.elements.add(element)
152-
this.update();
152+
this.update()
153153
return new Disposable(() => {
154154
this.elements.delete(element)
155-
this.update();
156-
});
155+
this.update()
156+
})
157157
} else {
158158
opts.ref = `${opts.pluginName}.${opts.name}.${Date.now()}`
159159
element = $(element, opts)
@@ -163,99 +163,96 @@ export class OutputPanel {
163163
let ref = this.refs[opts.ref]
164164
ref.disposables.add(new Disposable(() => {
165165
this.elements.delete(element)
166-
this.update();
167-
}));
168-
return ref;
166+
this.update()
167+
}))
168+
return ref
169169
})
170170
}
171171
}
172172

173-
setHideParameterValues(value) {
173+
setHideParameterValues (value) {
174174
Array.prototype.slice.call(this.refs.heading.querySelectorAll('ide-haskell-param')).forEach((el) => {
175-
if(value)
176-
el.classList.add('hidden-value')
177-
else
178-
el.classList.remove('hidden-value')
179-
})
175+
if (value) el.classList.add('hidden-value')
176+
else el.classList.remove('hidden-value')
177+
})
180178
}
181179

182-
updateItems() {
183-
activeTab = this.getActiveTab()
180+
updateItems () {
181+
let activeTab = this.getActiveTab()
184182
let uri
185-
if(activeTab) {
183+
if (activeTab) {
186184
this.hiddenOutput = false
187185
let filter = {severity: activeTab}
188-
if(this.refs.checkboxUriFilter.getFileFilter()) {
186+
if (this.refs.checkboxUriFilter.getFileFilter()) {
189187
uri = atom.workspace.getActiveTextEditor().getPath()
190-
if(uri && this.refs.buttons.options(activeTab).uriFilter)
188+
if (uri && this.refs.buttons.options(activeTab).uriFilter) {
191189
filter.uri = uri
190+
}
192191
}
193-
scroll = this.refs.buttons.options(activeTab).autoScroll && this.refs.items.atEnd()
192+
let scroll = this.refs.buttons.options(activeTab).autoScroll && this.refs.items.atEnd()
194193
this.refs.items.filter(filter)
195-
if(scroll) this.refs.items.scrollToEnd()
194+
if (scroll) this.refs.items.scrollToEnd()
196195
} else {
197196
this.hiddenOutput = true
198197
}
199198

200199
this.refs.buttons.buttonNames().forEach((btn) => {
201200
let f = {severity: btn}
202-
if(uri && this.refs.buttons.options(btn).uriFilter)
203-
f.uri = uri
201+
if (uri && this.refs.buttons.options(btn).uriFilter) f.uri = uri
204202
this.refs.buttons.setCount(btn, this.results.filter(f).length)
205203
})
206204
this.update()
207205
}
208206

209-
activateTab(tab) {
207+
activateTab (tab) {
210208
this.refs.buttons.clickButton(tab, true)
211209
}
212210

213-
activateFirstNonEmptyTab(types) {
211+
activateFirstNonEmptyTab (types) {
214212
let names = this.refs.buttons.buttonNames()
215-
for(i in names) {
213+
for (let i in names) {
216214
let name = names[i]
217-
if(! types || types.includes(name)) {
218-
if((this.results.filter({severity: name})).length > 0)
215+
if (!types || types.includes(name)) {
216+
if ((this.results.filter({severity: name})).length > 0) {
219217
this.activateTab(name)
220218
break
219+
}
221220
}
222221
}
223222
}
224223

225-
showItem(item) {
224+
showItem (item) {
226225
this.activateTab(item.severity)
227226
this.refs.items.showItem(item)
228227
}
229228

230-
getActiveTab() {
229+
getActiveTab () {
231230
return this.refs.buttons.getActive()
232231
}
233232

234-
createTab(name, opts) {
235-
if(!this.refs.buttons.buttonNames().includes(name)) {
233+
createTab (name, opts) {
234+
if (!this.refs.buttons.buttonNames().includes(name)) {
236235
this.refs.buttons.createButton(name, opts)
237236
this.activateTab(this.state.activeTab)
238237
}
239238
}
240239

241-
setProgress(progress) {
240+
setProgress (progress) {
242241
this.refs.progressBar.setProgress(progress)
243242
}
244243

245-
toggle() {
246-
if(this.panel.isVisible())
247-
this.panel.hide()
248-
else
249-
this.panel.show()
244+
toggle () {
245+
if (this.panel.isVisible()) this.panel.hide()
246+
else this.panel.show()
250247
}
251248

252-
serialize() {
249+
serialize () {
253250
return {
254251
visibility: this.panel.isVisible(),
255252
height: this.element.style.height,
256253
width: this.element.style.width,
257254
activeTab: this.getActiveTab(),
258-
fileFilter: this.refs.checkboxUriFilter.getFileFilter(),
255+
fileFilter: this.refs.checkboxUriFilter.getFileFilter()
259256
}
260257
}
261258

@@ -274,30 +271,30 @@ export class OutputPanel {
274271
this.setProgress(progress)
275272
}
276273

277-
showNextError() {
274+
showNextError () {
278275
let rs = this.results.resultsWithURI()
279-
if(rs.length == 0) return
276+
if (rs.length === 0) return
280277

281-
if(this.currentResult !== null && this.currentResult !== undefined)
278+
if (this.currentResult !== null && this.currentResult !== undefined) {
282279
this.currentResult++
283-
else
284-
this.currentResult = 0
285-
if(this.currentResult >= rs.length)
280+
} else {
286281
this.currentResult = 0
282+
}
283+
if (this.currentResult >= rs.length) this.currentResult = 0
287284

288285
this.showItem(rs[this.currentResult])
289286
}
290287

291-
showPrevError() {
288+
showPrevError () {
292289
let rs = this.results.resultsWithURI()
293-
if(rs.length == 0) return
290+
if (rs.length === 0) return
294291

295-
if(this.currentResult !== null && this.currentResult !== undefined)
292+
if (this.currentResult !== null && this.currentResult !== undefined) {
296293
this.currentResult--
297-
else
298-
this.currentResult = rs.length - 1
299-
if (this.currentResult < 0)
294+
} else {
300295
this.currentResult = rs.length - 1
296+
}
297+
if (this.currentResult < 0) this.currentResult = rs.length - 1
301298

302299
this.showItem(rs[this.currentResult])
303300
}

0 commit comments

Comments
 (0)