Skip to content

Commit 47d15bd

Browse files
committed
chore: lint
1 parent 0b9fb47 commit 47d15bd

File tree

18 files changed

+106
-96
lines changed

18 files changed

+106
-96
lines changed

.github/workflows/nodejs.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,30 @@ jobs:
88
strategy:
99
matrix:
1010
node-version:
11-
- 16.x
1211
- 18.x
12+
- 20.x
13+
- 21.x
1314
steps:
14-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
16+
- uses: oven-sh/setup-bun@v1
17+
with:
18+
bun-version: latest
1519
- name: Use Node.js ${{ matrix.node-version }}
16-
uses: actions/setup-node@v2
20+
uses: actions/setup-node@v4
1721
with:
1822
node-version: ${{ matrix.node-version }}
1923
- name: Install Redrun
20-
run: npm i redrun -g
24+
run: bun i redrun -g --no-save
2125
- name: Install
22-
run: npm install
26+
run: bun i --no-save
2327
- name: Bootstrap
2428
run: redrun bootstrap
2529
- name: Lint
2630
run: redrun lint
2731
- name: Coverage
2832
run: redrun coverage report
2933
- name: Coveralls
30-
uses: coverallsapp/github-action@master
34+
uses: coverallsapp/github-action@v2
35+
continue-on-error: true
3136
with:
3237
github-token: ${{ secrets.GITHUB_TOKEN }}

.madrun.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
run,
3-
cutEnv,
4-
} from 'madrun';
1+
import {run, cutEnv} from 'madrun';
52

63
const SUPERTAPE_TIMEOUT = 15_000;
74

@@ -36,4 +33,3 @@ export default {
3633
SUPERTAPE_TIMEOUT,
3734
}],
3835
};
39-

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ Start `gritty`, and go to url `http://localhost:1337`
5555
#### gritty(element [, options])
5656

5757
```js
58-
const prefix = '/gritty'; // default
58+
const prefix = '/gritty';
5959
const env = {}; // default
60-
const fontFamily = 'Courier'; // default
60+
const fontFamily = 'Courier';
6161

6262
gritty('body', {
6363
prefix,
@@ -73,7 +73,7 @@ gritty('body', {
7373
`Gritty` could be used as middleware:
7474

7575
```js
76-
const prefix = '/gritty'; // default
76+
const prefix = '/gritty';
7777

7878
const auth = (accept, reject) => (username, password) => {
7979
accept();
@@ -90,7 +90,7 @@ gritty.listen(socket, {
9090
Middleware function:
9191

9292
```js
93-
const prefix = '/gritty'; // default
93+
const prefix = '/gritty';
9494

9595
gritty({
9696
prefix,
@@ -107,7 +107,6 @@ And use it this way:
107107

108108
```js
109109
// server.js
110-
111110
const gritty = require('gritty');
112111
const http = require('http');
113112
const express = require('express');

bin/gritty.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22

33
'use strict';
44

5+
const {join} = require('node:path');
6+
const process = require('node:process');
57
const args = require('yargs-parser')(process.argv.slice(2), {
68
boolean: [
79
'version',
810
'help',
911
'auto-restart',
1012
'path',
1113
],
12-
number: [
13-
'port',
14-
],
15-
string: [
16-
'command',
17-
],
14+
number: ['port'],
15+
string: ['command'],
1816
alias: {
1917
help: 'h',
2018
version: 'v',
@@ -47,7 +45,6 @@ function main(args) {
4745
}
4846

4947
function path() {
50-
const {join} = require('path');
5148
console.log(join(__dirname, '..'));
5249
}
5350

@@ -62,7 +59,7 @@ function start(options) {
6259

6360
check(port);
6461

65-
const DIR = __dirname + '/../';
62+
const DIR = `${__dirname}/../`;
6663

6764
const gritty = require('../');
6865
const http = require('http');
@@ -73,10 +70,11 @@ function start(options) {
7370
const app = express();
7471
const server = http.createServer(app);
7572

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

79-
app.use(gritty())
76+
app
77+
.use(gritty())
8078
.use(express.static(DIR));
8179

8280
const socket = io(server);
@@ -86,7 +84,8 @@ function start(options) {
8684
autoRestart,
8785
});
8886

89-
server.listen(port, ip)
87+
server
88+
.listen(port, ip)
9089
.on('error', squad(exit, getMessage));
9190

9291
console.log(`url: http://localhost:${port}`);
@@ -118,4 +117,3 @@ function exit(msg) {
118117
console.error(msg);
119118
process.exit(-1);
120119
}
121-

client/get-el.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ module.exports = (el) => {
88

99
return el;
1010
};
11-

client/get-env.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ function getValue(value) {
1818

1919
return value;
2020
}
21-

client/get-host.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
module.exports = () => {
44
const l = location;
5-
const href = l.origin || l.protocol + '//' + l.host;
65

7-
return href;
6+
return l.origin || l.protocol + '//' + l.host;
87
};
9-

client/gritty.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports._onTermData = _onTermData;
3232
module.exports._onWindowResize = _onWindowResize;
3333

3434
const defaultFontFamily = 'Menlo, Consolas, "Liberation Mono", Monaco, "Lucida Console", monospace';
35+
3536
module.exports._defaultFontFamily = defaultFontFamily;
3637

3738
function gritty(element, options = {}) {
@@ -83,7 +84,14 @@ function createTerminal(terminalContainer, {env, cwd, command, autoRestart, sock
8384

8485
const {cols, rows} = terminal;
8586

86-
socket.on('accept', onConnect(socket, fitAddon, {env, cwd, cols, rows, command, autoRestart}));
87+
socket.on('accept', onConnect(socket, fitAddon, {
88+
env,
89+
cwd,
90+
cols,
91+
rows,
92+
command,
93+
autoRestart,
94+
}));
8795
socket.on('disconnect', onDisconnect(terminal));
8896
socket.on('data', onData(terminal));
8997

@@ -94,8 +102,18 @@ function createTerminal(terminalContainer, {env, cwd, command, autoRestart, sock
94102
}
95103

96104
function _onConnect(socket, fitAddon, {env, cwd, cols, rows, command, autoRestart}) {
97-
socket.emit('terminal', {env, cwd, cols, rows, command, autoRestart});
98-
socket.emit('resize', {cols, rows});
105+
socket.emit('terminal', {
106+
env,
107+
cwd,
108+
cols,
109+
rows,
110+
command,
111+
autoRestart,
112+
});
113+
socket.emit('resize', {
114+
cols,
115+
rows,
116+
});
99117
fitAddon.fit();
100118
}
101119

@@ -108,7 +126,10 @@ function _onData(terminal, data) {
108126
}
109127

110128
function _onTermResize(socket, {cols, rows}) {
111-
socket.emit('resize', {cols, rows});
129+
socket.emit('resize', {
130+
cols,
131+
rows,
132+
});
112133
}
113134

114135
function _onTermData(socket, data) {
@@ -126,7 +147,7 @@ function connect(prefix, socketPath) {
126147
const href = getHost();
127148
const FIVE_SECONDS = 5000;
128149

129-
const path = socketPath + '/socket.io';
150+
const path = `${socketPath}/socket.io`;
130151
const socket = io.connect(href + prefix, {
131152
'max reconnection attempts': 2 ** 32,
132153
'reconnection limit': FIVE_SECONDS,
@@ -135,4 +156,3 @@ function connect(prefix, socketPath) {
135156

136157
return socket;
137158
}
138-

css/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ html {
22
height: 100%;
33
}
44

5-
body, .gritty {
5+
body,
6+
.gritty {
67
height: 100%;
78
margin: 0;
89
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"type": "commonjs",
55
"author": "coderaiser <[email protected]> (https://github.com/coderaiser)",
66
"description": "Web terminal emulator",
7-
"commitType": "colon",
87
"bin": {
98
"gritty": "bin/gritty.js"
109
},

0 commit comments

Comments
 (0)