Skip to content

Commit 7d11a3e

Browse files
committed
chore: gritty: lint
1 parent 6c86060 commit 7d11a3e

File tree

12 files changed

+50
-33
lines changed

12 files changed

+50
-33
lines changed

.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
@@ -10,3 +10,4 @@ dist-dev
1010

1111
*.swp
1212

13+
.idea

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# Gritty [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
1+
# Gritty [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
22

33
[NPMIMGURL]: https://img.shields.io/npm/v/gritty.svg?style=flat&longCache=true
44
[BuildStatusURL]: https://github.com/cloudcmd/gritty/actions?query=workflow%3A%22Node+CI%22 "Build Status"
55
[BuildStatusIMGURL]: https://github.com/cloudcmd/gritty/workflows/Node%20CI/badge.svg
6-
[DependencyStatusURL]: https://david-dm.org/cloudcmd/gritty "Dependency Status"
7-
[DependencyStatusIMGURL]: https://img.shields.io/david/cloudcmd/gritty.svg?style=flat&longCache=true
86
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat&longCache=true
97
[NPM_INFO_IMG]: https://nodei.co/npm/cloudcmd.png
108
[NPMURL]: https://npmjs.org/package/cloudcmd "npm"
@@ -161,4 +159,3 @@ server.listen(port, ip);
161159
## License
162160

163161
MIT
164-

bin/gritty.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ function start(options) {
7373
const app = express();
7474
const server = http.createServer(app);
7575

76-
const ip = process.env.IP || /* c9 */
77-
'0.0.0.0';
76+
const ip = process.env.IP /* c9 */
77+
|| '0.0.0.0';
7878

7979
app.use(gritty())
8080
.use(express.static(DIR));

client/get-el.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

3+
const isString = (a) => typeof a === 'string';
4+
35
module.exports = (el) => {
4-
if (typeof el === 'string')
6+
if (isString(el))
57
return document.querySelector(el);
68

79
return el;

client/get-env.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const isFn = (a) => typeof a === 'function';
4+
35
module.exports = (env) => {
46
const obj = {};
57

@@ -11,7 +13,7 @@ module.exports = (env) => {
1113
};
1214

1315
function getValue(value) {
14-
if (typeof value === 'function')
16+
if (isFn(value))
1517
return value();
1618

1719
return value;

client/gritty.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ const getHost = require('./get-host');
1212
const getEnv = require('./get-env');
1313
const wrap = require('wraptile');
1414

15-
const onConnect = wrap(_onConnect);
16-
const onDisconnect = wrap(_onDisconnect);
17-
const onData = currify(_onData);
18-
const onTermResize = currify(_onTermResize);
19-
const onTermData = currify(_onTermData);
15+
const {io} = require('socket.io-client');
16+
const {Terminal} = require('xterm');
2017
const onWindowResize = wrap(_onWindowResize);
18+
const onTermData = currify(_onTermData);
19+
const onTermResize = currify(_onTermResize);
20+
const onData = currify(_onData);
2121

22-
const {io} = require('socket.io-client');
22+
const onDisconnect = wrap(_onDisconnect);
2323

24-
const {Terminal} = require('xterm');
24+
const onConnect = wrap(_onConnect);
2525

2626
module.exports = gritty;
2727
module.exports._onConnect = _onConnect;

server/gritty.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const DIR_ROOT = __dirname + '/..';
3+
const isBool = (a) => typeof a === 'boolean';
44

55
const path = require('path');
66
const log = require('debug')('gritty');
@@ -11,6 +11,8 @@ const wraptile = require('wraptile');
1111
const pty = require('node-pty');
1212
const stringArgv = require('string-to-argv');
1313

14+
const DIR_ROOT = __dirname + '/..';
15+
1416
const terminalFn = currify(_terminalFn);
1517
const connectionWraped = wraptile(connection);
1618

@@ -25,10 +27,10 @@ const getDist = () => {
2527
};
2628

2729
const choose = (a, b, options) => {
28-
if (typeof a === 'boolean')
30+
if (isBool(a))
2931
return a;
3032

31-
if (typeof b === 'boolean')
33+
if (isBool(b))
3234
return b;
3335

3436
return options.default;

test/before.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const isFn = (a) => typeof a === 'function';
4+
35
const http = require('http');
46
const {promisify} = require('util');
57

@@ -11,7 +13,7 @@ const gritty = require('..');
1113
module.exports = before;
1214

1315
function before(options, fn = options) {
14-
if (typeof options === 'function')
16+
if (isFn(options))
1517
options = {};
1618

1719
const app = express();

test/client/get-el.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

3-
const test = require('supertape');
4-
const stub = require('@cloudcmd/stub');
3+
const {
4+
test,
5+
stub,
6+
} = require('supertape');
57

68
const getEl = require('../../client/get-el');
79

0 commit comments

Comments
 (0)