Skip to content

Commit 4b9cd24

Browse files
committed
chore: lint
1 parent d469aa6 commit 4b9cd24

31 files changed

+250
-260
lines changed

.eslintrc.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

.eslintrc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extends": [
3+
"plugin:putout/recommended"
4+
],
5+
"plugins": [
6+
"putout",
7+
"n"
8+
],
9+
"overrides": [{
10+
"files": ["bin/**/*.js"],
11+
"rules": {
12+
"no-console": 0
13+
},
14+
"extends": [
15+
"plugin:n/recommended"
16+
]
17+
}, {
18+
"files": ["client/**/*.js"],
19+
"env": {
20+
"browser": true
21+
}
22+
}]
23+
}

.github/workflows/nodejs.yml

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
name: Node CI
2-
3-
on: [push, pull_request]
4-
2+
on:
3+
- push
4+
- pull_request
55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
9-
108
strategy:
119
matrix:
12-
node-version: [14.x, 15.x]
13-
10+
node-version:
11+
- 18.x
12+
- 20.x
13+
- 21.x
1414
steps:
15-
- uses: actions/checkout@v1
16-
- name: Use Node.js ${{ matrix.node-version }}
17-
uses: actions/setup-node@v1
18-
with:
19-
node-version: ${{ matrix.node-version }}
20-
21-
- name: Install Redrun
22-
run:
23-
npm i redrun -g
24-
25-
- name: Install
26-
run:
27-
npm install
28-
29-
- name: Bootstrap
30-
run:
31-
redrun bootstrap
32-
33-
- name: Lint
34-
run:
35-
redrun lint
36-
15+
- uses: actions/checkout@v4
16+
- uses: oven-sh/setup-bun@v1
17+
with:
18+
bun-version: latest
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- name: Install Redrun
24+
run: bun i redrun -g --no-save
25+
- name: Install
26+
run: bun i --no-save
27+
- name: Bootstrap
28+
run: redrun bootstrap
29+
- name: Lint
30+
run: redrun lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ yarn-error.log
1010
*.swp.*
1111
*.swp
1212
coverage
13+
.idea

.madrun.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {run} from 'madrun';
33
export default {
44
'start': () => 'bin/deepword.js package.json',
55
'start:dev': () => 'NODE_ENV=development npm start',
6-
'test': () => 'tape \'{client,common,server}/**/*.spec.js\'',
6+
'test': () => `tape '{client,common,server}/**/*.spec.js'`,
77
'coverage': () => 'c8 npm test',
88
'report': () => 'c8 report --reporter=lcov',
99
'watcher:test': () => 'nodemon -e spec.js -w client -w server -w common -x ',
@@ -12,7 +12,12 @@ export default {
1212
'fresh:lint': () => run('lint', '--fresh'),
1313
'lint:fresh': () => run('lint', '--fresh'),
1414
'wisdom': () => run('build'),
15-
'build': () => run(['clean', 'mkdir', 'build:client*', 'cp:*']),
15+
'build': () => run([
16+
'clean',
17+
'mkdir',
18+
'build:client*',
19+
'cp:*',
20+
]),
1621
'cp:socket.io:dist': () => 'cp node_modules/socket.io-client/dist/socket.io.js dist/socket.io.js',
1722
'cp:socket.io:dist-dev': () => 'cp node_modules/socket.io-client/dist/socket.io.js dist-dev/socket.io.js',
1823
'cp:socket.io.map:dist': () => 'cp node_modules/socket.io-client/dist/socket.io.js.map dist/socket.io.js.map',
@@ -27,4 +32,3 @@ export default {
2732
'mkdir': () => 'mkdirp dist dist-dev',
2833
'clean': () => 'rimraf dist dist-dev',
2934
};
30-

README.md

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

33
Web editor used in [Cloud Commander](http://cloudcmd.io) based on [Monaco](https://microsoft.github.io/monaco-editor/ "Monaco").
44

@@ -15,7 +15,7 @@ Web editor used in [Cloud Commander](http://cloudcmd.io) based on [Monaco](https
1515
npm i deepword -g
1616
```
1717

18-
![NPM_INFO][NPM_INFO_IMG]
18+
![NPM\_INFO][NPM_INFO_IMG]
1919

2020
## Command line parameters
2121

@@ -66,11 +66,11 @@ const express = require('express');
6666
const app = express();
6767

6868
app.use(deepword({
69-
root: '/', // default
70-
diff: true, // default
71-
zip: true, // default
72-
dropbox: false, // optional
73-
dropboxToken: 'token', // optional
69+
root: '/', // default
70+
diff: true, // default
71+
zip: true, // default
72+
dropbox: false, // optional
73+
dropboxToken: 'token', // optional
7474
}));
7575

7676
app.listen(31_337);
@@ -86,7 +86,8 @@ const socket = io.listen(server);
8686

8787
deepword.listen(socket, {
8888
prefixSocket: '/deepword', // optional
89-
auth: (accept, reject) => (username, password) => { // optional
89+
auth: (accept, reject) => (username, password) => {
90+
// optional
9091
accept();
9192
},
9293
});
@@ -142,13 +143,11 @@ For more information you could always look into `html` and `bin` directory.
142143
MIT
143144

144145
[NPMIMGURL]: https://img.shields.io/npm/v/deepword.svg?style=flat
145-
[DependencyStatusIMGURL]: https://img.shields.io/david/cloudcmd/deepword.svg?style=flat
146146
[BuildStatusURL]: https://github.com/cloudcmd/deepword/actions?query=workflow%3A%22Node+CI%22 "Build Status"
147147
[BuildStatusIMGURL]: https://github.com/cloudcmd/deepword/workflows/Node%20CI/badge.svg
148148
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
149149
[NPM_INFO_IMG]: https://nodei.co/npm/deepword.png?downloads=true&&stars&&downloadRank "npm install deepword"
150150
[NPMURL]: https://npmjs.org/package/deepword "npm"
151-
[DependencyStatusURL]: https://david-dm.org/cloudcmd/deepword "Dependency Status"
152151
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
153152
[CoverageURL]: https://coveralls.io/github/cloudcmd/deepword?branch=master
154153
[CoverageIMGURL]: https://coveralls.io/repos/cloudcmd/deepword/badge.svg?branch=master&service=github

bin/deepword.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/usr/bin/env node
22

3-
'use strict';
3+
import {createRequire} from 'node:module';
4+
import {dirname} from 'node:path';
5+
import process from 'node:process';
6+
import fs from 'node:fs';
7+
import {fileURLToPath} from 'node:url';
8+
import http from 'node:http';
49

5-
const fs = require('fs');
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = dirname(__filename);
12+
const require = createRequire(import.meta.url);
613
const [name] = process.argv.slice(2);
714

815
if (!name)
@@ -12,9 +19,9 @@ else if (/^(-v|--v)$/.test(name))
1219
else if (/^(-h|--help)$/.test(name))
1320
help();
1421
else
15-
checkFile(name, (error) => {
22+
checkFile(name, async (error) => {
1623
if (!error)
17-
return main(name);
24+
return await main(name);
1825

1926
console.error(error.message);
2027
});
@@ -28,27 +35,22 @@ function getPath(name) {
2835
return name;
2936
}
3037

31-
function main(name) {
38+
async function main(name) {
3239
const filename = getPath(name);
33-
const DIR = __dirname + '/../html/';
34-
const deepword = require('..');
35-
const http = require('http');
36-
const express = require('express');
40+
const DIR = `${__dirname}/../html/`;
41+
const {default: deepword} = await import('../server/index.cjs');
42+
const {default: express} = await import('express');
3743
const io = require('socket.io');
3844

3945
const app = express();
4046
const server = http.createServer(app);
4147

4248
const {env} = process;
49+
const port = env.PORT || 1337;
50+
const ip = env.IP || '0.0.0.0';
4351

44-
const port = env.PORT || /* c9 */
45-
env.app_port || /* nodester */
46-
env.VCAP_APP_PORT || /* cloudfoundry */
47-
1337;
48-
const ip = env.IP || /* c9 */
49-
'0.0.0.0';
50-
51-
app .use(express.static(DIR))
52+
app
53+
.use(express.static(DIR))
5254
.use(deepword({
5355
diff: true,
5456
zip: true,

client/api/_add-commands.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const addId = (a) => {
44
};
55

66
export default function _addCommands() {
7-
debugger;
87
const {_monaco, _eddy} = this;
98
const {KeyCode, KeyMod} = _monaco;
109

@@ -21,10 +20,7 @@ export default function _addCommands() {
2120
KeyS,
2221
} = KeyCode;
2322

24-
const {
25-
CtrlCmd,
26-
WinCtrl,
27-
} = KeyMod;
23+
const {CtrlCmd, WinCtrl} = KeyMod;
2824

2925
const actions = [{
3026
id: 'evaluate',
@@ -47,4 +43,3 @@ export default function _addCommands() {
4743
.map(addId)
4844
.forEach(addAction);
4945
}
50-

client/api/_init-socket.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/* global io*/
22
import {alert} from 'smalltalk';
33
import {applyPatch} from 'daffy';
4-
54
import {promisify} from 'es6-promisify';
65

76
const getHost = () => {
87
const l = location;
9-
const href = l.origin || l.protocol + '//' + l.host;
108

11-
return href;
9+
return l.origin || l.protocol + '//' + l.host;
1210
};
1311

1412
export default function _initSocket(prefix = '', socketPath = '') {
@@ -26,7 +24,7 @@ export default function _initSocket(prefix = '', socketPath = '') {
2624
const socket = io.connect(href, {
2725
'max reconnection attempts': 2 ** 32,
2826
'reconnection limit': FIVE_SECONDS,
29-
'path': socketPath + '/socket.io',
27+
'path': `${socketPath}/socket.io`,
3028
});
3129

3230
socket.on('reject', () => {
@@ -86,4 +84,3 @@ export default function _initSocket(prefix = '', socketPath = '') {
8684
alert(this._TITLE, error);
8785
});
8886
}
89-

client/api/_on-save.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@ export default 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

19-
confirm(this._TITLE, msg).then(() => {
20-
write(_filename, _value, onSave);
21-
}).catch(empty).then(() => {
22-
this.focus();
23-
});
19+
confirm(this._TITLE, msg)
20+
.then(() => {
21+
write(_filename, _value, onSave);
22+
})
23+
.catch(empty)
24+
.then(() => {
25+
this.focus();
26+
});
2427
} else {
2528
this.showMessage(text);
2629

27-
this._story.setData(_filename, _value)
30+
this
31+
._story
32+
.setData(_filename, _value)
2833
.setHash(_filename, this.sha());
2934

3035
this.emit('save', _value.length);
3136
}
3237
}
33-

0 commit comments

Comments
 (0)