Skip to content

Commit 2c39d2e

Browse files
committed
Implement strict coding conventions using semistandard
1 parent 730a4a8 commit 2c39d2e

File tree

6 files changed

+46
-25
lines changed

6 files changed

+46
-25
lines changed

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
extends: [
7+
'standard'
8+
],
9+
rules: {
10+
},
11+
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ services:
4141
cache: npm
4242

4343
before_install:
44-
- "npm install -g npm@latest"
44+
- npm install -g npm@latest
4545
- npm install -g node-gyp
4646

4747
install:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![Master Build Status](https://travis-ci.com/scala-network/scala-pool.svg?branch=master)](https://travis-ci.com/scala-network/scala-pool?branch=master)
2+
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/standard/semistandard)
23

34
scala-pool
45
======================

lib/web.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* You should have received a copy of the GNU General Public License
2020
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2121
*/
22-
const logSystem = "web";
22+
const logSystem = "web";
2323
const http = require("http"),
2424
url = require("url"),
2525
path = require("path"),

package.json

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,36 @@
2121
"fastify-static": "^3.4.0",
2222
"pm2": "^4.5.4",
2323
"read-package-json": "^2.1.1",
24-
"redis": "*"
24+
"redis": "*",
25+
"semistandard": "^16.0.0"
2526
},
2627
"engines": {
2728
"node": ">=14.0.0 <16.0.0"
2829
},
2930
"devDependencies": {
3031
"ava": "^3.10.1",
31-
"nodemon": "^2.0.7"
32+
"eslint": "^7.13.0",
33+
"eslint-config-standard": "^16.0.2",
34+
"eslint-plugin-html": "^6.1.1",
35+
"eslint-plugin-import": "^2.22.1",
36+
"eslint-plugin-markdown": "^1.0.2",
37+
"eslint-plugin-node": "^11.1.0",
38+
"eslint-plugin-promise": "^4.2.1",
39+
"nodemon": "^2.0.7",
40+
"snazzy": "^9.0.0"
3241
},
3342
"scripts": {
3443
"api": "node init.js --module=api",
3544
"comms": "node init.js --module=comms",
36-
"lint": "npx eslint --config .eslint.js",
3745
"payments": "node init.js --module=payments",
3846
"pool": "node init.js --module=pool",
3947
"remote": "node init.js --module=remote",
40-
"test": "npx ava",
4148
"unlocker": "node init.js --module=unlocker",
4249
"web": "node init.js --module=web --port=80",
43-
"pooldev": "nodemon init.js -a '--module=pool' --watch lib --watch config"
50+
"pooldev": "nodemon init.js -a '--module=pool' --watch lib --watch config",
51+
"test": "npx ava",
52+
"lint": "npx semistandard lib/* --verbose | npx snazzy",
53+
"lint_md": "npx semistandard --plugin markdown '**/*.md' --verbose | npx snazzy",
54+
"lint_html": "npx semistandard --plugin html '**/*.html' --verbose | npx snazzy"
4455
}
4556
}

web.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
const http = require("http"),
2-
url = require("url"),
3-
path = require("path"),
4-
fs = require("fs"),
5-
port = process.argv[2] || 80;
1+
const http = require('http')
2+
const url = require('url')
3+
const path = require('path')
4+
const fs = require('fs')
5+
const port = process.argv[2] || 80
66

77
const fastify = require('fastify')()
88
const fastifyStatic = require('fastify-static')
9-
const fastifyCompress = require('fastify-compress');
10-
9+
const fastifyCompress = require('fastify-compress')
1110

1211
fastify.get('/', async (request, res) => {
13-
return res.sendFile('index.html');
12+
return res.sendFile('index.html')
1413
})
1514

1615
fastify
17-
.register(fastifyCompress, {threshold:0})
18-
.register(fastifyStatic, {
19-
root: path.join(__dirname, 'public')
20-
})
16+
.register(fastifyCompress, { threshold: 0 })
17+
.register(fastifyStatic, {
18+
root: path.join(__dirname, 'public')
19+
})
2120

2221
// this will work with fastify-static and send ./static/index.html
2322
fastify.setNotFoundHandler((req, res) => {
24-
res.sendFile('index.html');
25-
});
23+
res.sendFile('index.html')
24+
})
2625

2726
//
2827

29-
3028
// Run the server!
3129
const start = async () => {
3230
try {
33-
await fastify.listen(port, "0.0.0.0")
31+
await fastify.listen(port, '0.0.0.0')
3432
} catch (err) {
3533
fastddify.log.error(err)
3634

@@ -39,6 +37,6 @@ const start = async () => {
3937
}
4038

4139
console.log(`server listening on ${port}`)
42-
};
40+
}
4341

44-
start();
42+
start()

0 commit comments

Comments
 (0)