Skip to content

Commit 98d4fa0

Browse files
committed
fix: Lint issues.
1 parent 2ea0514 commit 98d4fa0

File tree

7 files changed

+109
-73
lines changed

7 files changed

+109
-73
lines changed

browser/components/CodeEditor.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const buildEditorContextMenu = require('browser/lib/contextMenuBuilder')
2121
import { createTurndownService } from '../lib/turndown'
2222
import { languageMaps } from '../lib/CMLanguageList'
2323
import snippetManager from '../lib/SnippetManager'
24-
import { gfm } from 'turndown-plugin-gfm'
2524
import { findStorage } from 'browser/lib/findStorage'
2625
import { sendWakatimeHeartBeat } from 'browser/lib/wakatime-plugin'
2726
import {
@@ -120,8 +119,15 @@ export default class CodeEditor extends React.Component {
120119
// wakatime
121120
const { storageKey, noteKey } = this.props
122121
const storage = findStorage(storageKey)
123-
if (storage) sendWakatimeHeartBeat(storage.path, noteKey, storage.name, false, false, true)
124-
122+
if (storage)
123+
sendWakatimeHeartBeat(
124+
storage.path,
125+
noteKey,
126+
storage.name,
127+
false,
128+
false,
129+
true
130+
)
125131
}
126132

127133
handleSearch(msg) {
@@ -807,9 +813,25 @@ export default class CodeEditor extends React.Component {
807813
const storage = findStorage(storageKey)
808814
if (this.props.onChange) {
809815
this.props.onChange(editor)
810-
if (storage) sendWakatimeHeartBeat(storage.path, noteKey, storage.name, true, true, false)
816+
if (storage)
817+
sendWakatimeHeartBeat(
818+
storage.path,
819+
noteKey,
820+
storage.name,
821+
true,
822+
true,
823+
false
824+
)
811825
} else {
812-
if (storage) sendWakatimeHeartBeat(storage.path, noteKey, storage.name, false, false, false)
826+
if (storage)
827+
sendWakatimeHeartBeat(
828+
storage.path,
829+
noteKey,
830+
storage.name,
831+
false,
832+
false,
833+
false
834+
)
813835
}
814836
}
815837

@@ -942,7 +964,15 @@ export default class CodeEditor extends React.Component {
942964
// wakatime
943965
const { storageKey, noteKey } = this.props
944966
const storage = findStorage(storageKey)
945-
if (storage) sendWakatimeHeartBeat(storage.path, noteKey, storage.name, false, false, true)
967+
if (storage)
968+
sendWakatimeHeartBeat(
969+
storage.path,
970+
noteKey,
971+
storage.name,
972+
false,
973+
false,
974+
true
975+
)
946976
}
947977

948978
setValue(value) {

browser/components/MarkdownPreview.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,9 +1299,4 @@ MarkdownPreview.propTypes = {
12991299
breaks: PropTypes.bool
13001300
}
13011301

1302-
export default connect(
1303-
null,
1304-
null,
1305-
null,
1306-
{ forwardRef: true }
1307-
)(MarkdownPreview)
1302+
export default connect(null, null, null, { forwardRef: true })(MarkdownPreview)

browser/lib/markdown.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,7 @@ class Markdown {
278278
flowchart: token => {
279279
return `<pre class="fence" data-line="${token.map[0]}">
280280
<span class="filename">${token.fileName}</span>
281-
<div class="flowchart" data-height="${token.parameters.height}">${
282-
token.content
283-
}</div>
281+
<div class="flowchart" data-height="${token.parameters.height}">${token.content}</div>
284282
</pre>`
285283
},
286284
gallery: token => {
@@ -299,25 +297,19 @@ class Markdown {
299297

300298
return `<pre class="fence" data-line="${token.map[0]}">
301299
<span class="filename">${token.fileName}</span>
302-
<div class="gallery" data-autoplay="${
303-
token.parameters.autoplay
304-
}" data-height="${token.parameters.height}">${content}</div>
300+
<div class="gallery" data-autoplay="${token.parameters.autoplay}" data-height="${token.parameters.height}">${content}</div>
305301
</pre>`
306302
},
307303
mermaid: token => {
308304
return `<pre class="fence" data-line="${token.map[0]}">
309305
<span class="filename">${token.fileName}</span>
310-
<div class="mermaid" data-height="${token.parameters.height}">${
311-
token.content
312-
}</div>
306+
<div class="mermaid" data-height="${token.parameters.height}">${token.content}</div>
313307
</pre>`
314308
},
315309
sequence: token => {
316310
return `<pre class="fence" data-line="${token.map[0]}">
317311
<span class="filename">${token.fileName}</span>
318-
<div class="sequence" data-height="${token.parameters.height}">${
319-
token.content
320-
}</div>
312+
<div class="sequence" data-height="${token.parameters.height}">${token.content}</div>
321313
</pre>`
322314
}
323315
},

browser/lib/wakatime-plugin.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ const exec = require('child_process').exec
33
const path = require('path')
44
let lastHeartbeat = 0
55

6-
function sendWakatimeHeartBeat (storagePath, noteKey, storageName, isWrite, hasFileChanges, isFileChange) {
6+
function sendWakatimeHeartBeat(
7+
storagePath,
8+
noteKey,
9+
storageName,
10+
isWrite,
11+
hasFileChanges,
12+
isFileChange
13+
) {
714
if (new Date().getTime() - lastHeartbeat > 120000 || isFileChange) {
815
const notePath = path.join(storagePath, 'notes', noteKey + '.cson')
916

@@ -14,14 +21,25 @@ function sendWakatimeHeartBeat (storagePath, noteKey, storageName, isWrite, hasF
1421
lastHeartbeat = new Date()
1522
const wakatimeKey = config.get().wakatime.key
1623
if (wakatimeKey) {
17-
exec(`wakatime --file ${notePath} --project '${storageName}' --key ${wakatimeKey} --plugin Boostnote-wakatime`, (error, stdOut, stdErr) => {
18-
if (error) {
19-
console.log(error)
20-
lastHeartbeat = 0
21-
} else {
22-
console.log('wakatime', 'isWrite', isWrite, 'hasChanges', hasFileChanges, 'isFileChange', isFileChange)
24+
exec(
25+
`wakatime --file ${notePath} --project '${storageName}' --key ${wakatimeKey} --plugin Boostnote-wakatime`,
26+
(error, stdOut, stdErr) => {
27+
if (error) {
28+
console.log(error)
29+
lastHeartbeat = 0
30+
} else {
31+
console.log(
32+
'wakatime',
33+
'isWrite',
34+
isWrite,
35+
'hasChanges',
36+
hasFileChanges,
37+
'isFileChange',
38+
isFileChange
39+
)
40+
}
2341
}
24-
})
42+
)
2543
}
2644
}
2745
}

browser/main/modals/PreferencesModal/PluginsTab.js

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,55 @@ const electron = require('electron')
1111
const ipc = electron.ipcRenderer
1212

1313
class PluginsTab extends React.Component {
14-
constructor (props) {
14+
constructor(props) {
1515
super(props)
1616

1717
this.state = {
1818
config: props.config
1919
}
2020
}
2121

22-
componentDidMount () {
22+
componentDidMount() {
2323
this.handleSettingDone = () => {
24-
this.setState({pluginsAlert: {
25-
type: 'success',
26-
message: i18n.__('Successfully applied!')
27-
}})
24+
this.setState({
25+
pluginsAlert: {
26+
type: 'success',
27+
message: i18n.__('Successfully applied!')
28+
}
29+
})
2830
}
29-
this.handleSettingError = (err) => {
31+
this.handleSettingError = err => {
3032
if (
3133
this.state.config.wakatime.key === '' ||
3234
this.state.config.wakatime.key === null
3335
) {
34-
this.setState({pluginsAlert: {
35-
type: 'success',
36-
message: i18n.__('Successfully applied!')
37-
}})
36+
this.setState({
37+
pluginsAlert: {
38+
type: 'success',
39+
message: i18n.__('Successfully applied!')
40+
}
41+
})
3842
} else {
39-
this.setState({pluginsAlert: {
40-
type: 'error',
41-
message: err.message != null ? err.message : i18n.__('An error occurred!')
42-
}})
43+
this.setState({
44+
pluginsAlert: {
45+
type: 'error',
46+
message:
47+
err.message != null ? err.message : i18n.__('An error occurred!')
48+
}
49+
})
4350
}
4451
}
4552
this.oldWakatimekey = this.state.config.wakatime
4653
ipc.addListener('APP_SETTING_DONE', this.handleSettingDone)
4754
ipc.addListener('APP_SETTING_ERROR', this.handleSettingError)
4855
}
4956

50-
componentWillUnmount () {
57+
componentWillUnmount() {
5158
ipc.removeListener('APP_SETTING_DONE', this.handleSettingDone)
5259
ipc.removeListener('APP_SETTING_ERROR', this.handleSettingError)
5360
}
5461

55-
handleSaveButtonClick (e) {
62+
handleSaveButtonClick(e) {
5663
const newConfig = {
5764
wakatime: this.state.config.wakatime
5865
}
@@ -67,7 +74,7 @@ class PluginsTab extends React.Component {
6774
this.props.haveToSave()
6875
}
6976

70-
handleWakatimeKeyChange (e) {
77+
handleWakatimeKeyChange(e) {
7178
const { config } = this.state
7279
config.wakatime = { key: this.refs.key.value }
7380
this.setState({
@@ -84,21 +91,20 @@ class PluginsTab extends React.Component {
8491
}
8592
}
8693

87-
clearMessage () {
94+
clearMessage() {
8895
_.debounce(() => {
8996
this.setState({
9097
pluginsAlert: null
9198
})
9299
}, 2000)()
93100
}
94101

95-
render () {
102+
render() {
96103
const pluginsAlert = this.state.pluginsAlert
97-
const pluginsAlertElement = pluginsAlert != null
98-
? <p className={`alert ${pluginsAlert.type}`}>
99-
{pluginsAlert.message}
100-
</p>
101-
: null
104+
const pluginsAlertElement =
105+
pluginsAlert != null ? (
106+
<p className={`alert ${pluginsAlert.type}`}>{pluginsAlert.message}</p>
107+
) : null
102108
const { config } = this.state
103109

104110
return (
@@ -108,17 +114,21 @@ class PluginsTab extends React.Component {
108114
<div styleName='group-section'>
109115
<div styleName='group-section-label'>{i18n.__('Wakatime key')}</div>
110116
<div styleName='group-section-control'>
111-
<input styleName='group-section-control-input'
112-
onChange={(e) => this.handleWakatimeKeyChange(e)}
117+
<input
118+
styleName='group-section-control-input'
119+
onChange={e => this.handleWakatimeKeyChange(e)}
113120
ref='key'
114121
value={config.wakatime.key}
115122
type='text'
116123
/>
117124
</div>
118125
</div>
119126
<div styleName='group-control'>
120-
<button styleName='group-control-rightButton'
121-
onClick={(e) => this.handleSaveButtonClick(e)}>{i18n.__('Save')}
127+
<button
128+
styleName='group-control-rightButton'
129+
onClick={e => this.handleSaveButtonClick(e)}
130+
>
131+
{i18n.__('Save')}
122132
</button>
123133
{pluginsAlertElement}
124134
</div>

browser/main/modals/PreferencesModal/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,13 @@ class Preferences extends React.Component {
8282
/>
8383
)
8484
case 'SNIPPET':
85-
return (
86-
<SnippetTab
87-
dispatch={dispatch}
88-
config={config}
89-
data={data}
90-
/>
91-
)
85+
return <SnippetTab dispatch={dispatch} config={config} data={data} />
9286
case 'PLUGINS':
9387
return (
9488
<PluginsTab
9589
dispatch={dispatch}
9690
config={config}
97-
haveToSave={alert => this.setState({PluginsAlert: alert})}
91+
haveToSave={alert => this.setState({ PluginsAlert: alert })}
9892
/>
9993
)
10094
case 'STORAGES':

browser/main/store.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,7 @@ const store = createStore(
480480
reducer,
481481
undefined,
482482
process.env.NODE_ENV === 'development'
483-
? compose(
484-
applyMiddleware(routerMiddleware(history)),
485-
DevTools.instrument()
486-
)
483+
? compose(applyMiddleware(routerMiddleware(history)), DevTools.instrument())
487484
: applyMiddleware(routerMiddleware(history))
488485
)
489486

0 commit comments

Comments
 (0)