Skip to content

Commit 11c3a31

Browse files
committed
chore(dword) lint
1 parent c0dc188 commit 11c3a31

44 files changed

Lines changed: 1239 additions & 361 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/nodejs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ jobs:
88
strategy:
99
matrix:
1010
node-version:
11-
- 14.x
1211
- 16.x
13-
- 17.x
12+
- 18.x
1413
steps:
1514
- uses: actions/checkout@v2
1615
- name: Use Node.js ${{ matrix.node-version }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ modules/execon
2323
package-lock.json
2424

2525
coverage
26+
.idea

.putout.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88
}
99
},
1010
"rules": {
11-
"declare-undefined-variables": ["on", {
12-
"dismiss": [
13-
"join"
14-
]
15-
}]
11+
"nodejs/declare": "off"
1612
},
1713
"ignore": [
18-
"modules"
14+
"modules",
15+
"codemirror"
1916
]
2017
}

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# Dword [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL]
1+
# Dword [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL]
22

33
[NPMIMGURL]: https://img.shields.io/npm/v/dword.svg?style=flat
44
[BuildStatusURL]: https://github.com/cloudcmd/dword/actions?query=workflow%3A%22Node+CI%22 "Build Status"
55
[BuildStatusIMGURL]: https://github.com/cloudcmd/dword/workflows/Node%20CI/badge.svg
6-
[DependencyStatusURL]: https://david-dm.org/coudcmd/dword?path=packages/putout "Dependency Status"
7-
[DependencyStatusIMGURL]: https://david-dm.org/cloudcmd/dword.svg?path=packages/putout
86
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
97
[NPM_INFO_IMG]: https://nodei.co/npm/dword.png?downloads=true&&stars&&downloadRank "npm install dword"
108
[NPMURL]: https://npmjs.org/package/dword "npm"
@@ -29,7 +27,7 @@ Fork of [edward](https://github.com/cloudcmd/edward "Edward").
2927
npm i dword -g
3028
```
3129

32-
![NPM_INFO][NPM_INFO_IMG]
30+
![NPM\_INFO][NPM_INFO_IMG]
3331

3432
## Command line parameters
3533

@@ -67,12 +65,12 @@ const express = require('express');
6765
const app = express();
6866

6967
app.use(dword({
70-
root: '/', // default
71-
online: true, // default
72-
diff: true, // default
73-
zip: true, // default
74-
dropbox: false, // optional
75-
dropboxToken: 'token', // optional
68+
root: '/', // default
69+
online: true, // default
70+
diff: true, // default
71+
zip: true, // default
72+
dropbox: false, // optional
73+
dropboxToken: 'token', // optional
7674
}));
7775

7876
app.listen(31_337);

bin/dword.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ function main(name) {
4141

4242
const {env} = process;
4343

44-
const port = env.PORT || /* c9 */
45-
env.VCAP_APP_PORT || /* cloudfoundry */
46-
1337;
44+
const port = env.PORT /* c9 */
45+
|| env.VCAP_APP_PORT /* cloudfoundry */
46+
|| 1337;
4747

48-
const ip = env.IP || /* c9 */
49-
'0.0.0.0';
48+
const ip = env.IP /* c9 */
49+
|| '0.0.0.0';
5050

5151
app .use(express.static(DIR))
5252
.use(dword({
@@ -57,7 +57,7 @@ function main(name) {
5757

5858
server.listen(port, ip);
5959

60-
const socket = io.listen(server);
60+
const socket = io(server);
6161
const edSocket = dword.listen(socket);
6262

6363
edSocket.on('connection', () => {

client/_clipboard.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ module.exports = (cmd) => {
3333
.then(insert)
3434
.catch(() => {
3535
showMessageOnce('Could not paste from clipboard. Inner buffer used.');
36+
3637
const value = _story.getData(NAME);
38+
3739
insert(value);
3840
});
3941
};

client/_on-save.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ module.exports = function onSave(error, text) {
1414
if (error.message)
1515
msg = error.message + '\n' + msg;
1616
else
17-
msg = 'Can\'t save.' + msg;
17+
msg = `Can't save.` + msg;
1818

1919
const onSave = this._onSave.bind(this);
2020

2121
return confirm(this._TITLE, msg).then(() => {
2222
write(this._FileName, this._Value, onSave);
23-
}).catch(empty).then(() => {
24-
this.focus();
25-
});
23+
})
24+
.catch(empty)
25+
.then(() => {
26+
this.focus();
27+
});
2628
}
2729

2830
this.showMessage(text);

client/codemirror/use-soft-tabs.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
/* global define */
55

66
(function(mod) {
7-
const isFn = (a) => typeof a === 'function';
8-
97
if (typeof exports === 'object' && typeof module === 'object') // CommonJS
108
mod(require('../../lib/codemirror'));
11-
else if (isFn(define) && define.amd) // AMD
9+
else if (typeof define === 'function' && define.amd) // AMD
1210
define(['../../lib/codemirror'], mod);
1311
else // Plain browser env
1412
mod(CodeMirror);

client/dword.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* global CodeMirror, exec, join */
2-
31
'use strict';
42

3+
/* global CodeMirror, exec, join */
4+
55
require('../css/dword.css');
66

77
const restafary = require('restafary/client');
@@ -27,6 +27,7 @@ const _initSocket = require('./_init-socket');
2727

2828
const notGlobal = (name) => !window[name];
2929
const addPrefix = currify((obj, prefix, name) => prefix + obj[name]);
30+
const isString = (a) => typeof a === 'string';
3031

3132
module.exports = Dword;
3233

@@ -43,7 +44,7 @@ function Dword(el, options, callback) {
4344
if (!callback)
4445
callback = options;
4546

46-
if (typeof el === 'string')
47+
if (isString(el))
4748
el = document.querySelector(el);
4849

4950
this._maxSize = options.maxSize || 512_000;
@@ -241,9 +242,11 @@ Dword.prototype.goToLine = function() {
241242
const coords = Ace.charCoords({line, ch}, 'local');
242243

243244
Ace.scrollTo(null, (coords.top + coords.bottom - myHeight) / 2);
244-
}).catch(empty).then(() => {
245-
dword.focus();
246-
});
245+
})
246+
.catch(empty)
247+
.then(() => {
248+
dword.focus();
249+
});
247250

248251
return this;
249252
};
@@ -484,6 +487,7 @@ Dword.prototype._clipboard = _clipboard;
484487
Dword.prototype.sha = function() {
485488
const value = this.getValue();
486489
const shaObj = new jssha('SHA-1', 'TEXT');
490+
487491
shaObj.update(value);
488492

489493
return shaObj.getHash('HEX');

json/modules.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@
1919
"version": "1.0.3",
2020
"local": "/modules/pako/dist/pako.min.js",
2121
"remote": "//cdnjs.cloudflare.com/ajax/libs/pako/{{ version }}/pako.min.js"
22-
2322
}]

0 commit comments

Comments
 (0)