Skip to content

Commit 7989407

Browse files
author
Petr Pchelko
authored
Merge pull request #140 from wikimedia/updatelint
Update linting packages and release version 0.8.0
2 parents 240c9df + 3b65e54 commit 7989407

File tree

9 files changed

+32
-18
lines changed

9 files changed

+32
-18
lines changed

.eslintrc.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
{
22
"extends": [
3-
"wikimedia/server",
4-
"wikimedia/node",
5-
"wikimedia/language/es2016"
3+
"wikimedia/server"
64
],
75
"plugins": ["json", "jsdoc"],
86
"rules": {
7+
"array-bracket-spacing": "off",
98
"camelcase": [
109
"error",
1110
{
1211
"properties": "never"
1312
}
1413
],
14+
"computed-property-spacing": "off",
1515
"indent": ["off", 4],
16+
"jsdoc/no-undefined-types": "off",
17+
"no-multi-spaces": "off",
18+
"no-shadow": "off",
19+
"no-underscore-dangle": "off",
1620
"no-unused-vars": [
1721
"error",
1822
{
1923
"args": "none"
2024
}
2125
],
22-
"space-in-parens": ["error", "never"],
23-
"computed-property-spacing": "off",
24-
"no-multi-spaces": "off",
25-
"prefer-const": "error",
26-
"no-underscore-dangle": "off",
27-
"array-bracket-spacing": "off"
26+
"space-in-parens": ["error", "never"]
2827
}
2928
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ language: node_js
33
sudo: false
44

55
node_js:
6-
- "6"
76
- "10"
7+
- "node"

app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const path = require('path');
1515

1616
/**
1717
* Creates an express app and initialises it
18+
*
1819
* @param {Object} options the options to initialise the app with
1920
* @return {bluebird} the promise resolving to the app object
2021
*/
@@ -36,7 +37,6 @@ function initApp(options) {
3637
app.conf.compression_level = app.conf.compression_level === undefined ? 3 : app.conf.compression_level;
3738
app.conf.cors = app.conf.cors === undefined ? '*' : app.conf.cors;
3839
if (app.conf.csp === undefined) {
39-
// eslint-disable-next-line max-len
4040
app.conf.csp = "default-src 'self'; object-src 'none'; media-src *; img-src *; style-src *; frame-ancestors 'self'";
4141
}
4242

@@ -134,6 +134,7 @@ function initApp(options) {
134134

135135
/**
136136
* Loads all routes declared in routes/ into the app
137+
*
137138
* @param {Application} app the application object to load routes into
138139
* @param {string} dir routes folder
139140
* @return {bluebird} a promise resolving to the app object
@@ -187,6 +188,7 @@ function loadRoutes(app, dir) {
187188

188189
/**
189190
* Creates and start the service's web server
191+
*
190192
* @param {Application} app the app object to use in the service
191193
* @return {bluebird} a promise creating the web server
192194
*/
@@ -224,6 +226,7 @@ function createServer(app) {
224226
* options and the logger- and metrics-reporting objects from
225227
* service-runner and starts an HTTP server, attaching the application
226228
* object to it.
229+
*
227230
* @param {Object} options the options to initialise the app with
228231
* @return {bluebird} HTTP server
229232
*/

lib/api-util.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const HTTPError = sUtil.HTTPError;
77

88
/**
99
* Calls the MW API with the supplied query as its body
10+
*
1011
* @param {!Object} req the incoming request object
1112
* @param {?Object} query an object with all the query parameters for the MW API
1213
* @param {?Object} headers additional headers to pass to the MW API
@@ -46,6 +47,7 @@ function mwApiGet(req, query, headers) {
4647

4748
/**
4849
* Calls the REST API with the supplied domain, path and request parameters
50+
*
4951
* @param {!Object} req the incoming request object
5052
* @param {?string} path the REST API path to contact without the leading slash
5153
* @param {?Object} [restReq={}] the object containing the REST request details
@@ -87,6 +89,7 @@ function restApiGet(req, path, restReq) {
8789

8890
/**
8991
* Sets up the request templates for MW and RESTBase API requests
92+
*
9093
* @param {!Application} app the application object
9194
*/
9295
function setupApiTemplates(app) {

lib/util.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class HTTPError extends Error {
3737

3838
/**
3939
* Generates an object suitable for logging out of a request object
40+
*
4041
* @param {!Request} req the request
4142
* @param {?RegExp} whitelistRE the RegExp used to filter headers
4243
* @return {!Object} an object containing the key components of the request
@@ -68,6 +69,7 @@ function reqForLog(req, whitelistRE) {
6869

6970
/**
7071
* Serialises an error object in a form suitable for logging.
72+
*
7173
* @param {!Error} err error to serialise
7274
* @return {!Object} the serialised version of the error
7375
*/
@@ -92,6 +94,7 @@ function errForLog(err) {
9294
* promised try blocks so as to allow catching all errors,
9395
* regardless of whether a handler returns/uses promises
9496
* or not.
97+
*
9598
* @param {!Object} route the object containing the router and path to bind it to
9699
* @param {!Application} app the application object
97100
*/
@@ -130,6 +133,7 @@ function wrapRouteHandlers(route, app) {
130133

131134
/**
132135
* Generates an error handler for the given applications and installs it.
136+
*
133137
* @param {!Application} app the application object to add the handler to
134138
*/
135139
function setErrorHandler(app) {
@@ -208,6 +212,7 @@ function setErrorHandler(app) {
208212

209213
/**
210214
* Creates a new router with some default options.
215+
*
211216
* @param {?Object} [opts] additional options to pass to express.Router()
212217
* @return {!Router} a new router object
213218
*/
@@ -227,6 +232,7 @@ function createRouter(opts) {
227232

228233
/**
229234
* Adds logger to the request and logs it.
235+
*
230236
* @param {!*} req request object
231237
* @param {!Application} app application object
232238
*/

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "service-template-node",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"description": "A blueprint for MediaWiki REST API services",
55
"main": "./app.js",
66
"scripts": {
@@ -47,9 +47,9 @@
4747
},
4848
"devDependencies": {
4949
"ajv": "^6.5.4",
50-
"eslint-config-wikimedia": "^0.10.0",
51-
"eslint-plugin-jsdoc": "^4.0.1",
52-
"eslint-plugin-json": "^1.2.1",
50+
"eslint-config-wikimedia": "^0.17.0",
51+
"eslint-plugin-jsdoc": "^30.6.2",
52+
"eslint-plugin-json": "^2.1.2",
5353
"extend": "^3.0.2",
5454
"mocha": "^5.2.0",
5555
"mocha-lcov-reporter": "^1.3.0",
@@ -59,7 +59,7 @@
5959
},
6060
"deploy": {
6161
"target": "debian",
62-
"node": "6.11.1",
62+
"node": "10.15.2",
6363
"dependencies": {
6464
"_all": []
6565
}

routes/v1.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ router.get('/siteinfo/:prop?', (req, res) => {
7474
/**
7575
* A helper function that obtains the Parsoid HTML for a given title and
7676
* loads it into a domino DOM document instance.
77+
*
7778
* @param {!Object} req the incoming request
7879
* @return {Promise} a promise resolving as the HTML element object
7980
*/

test/.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"extends": "../.eslintrc.json",
33
"env": { "mocha": true },
44
"rules": {
5+
"max-len": "off",
56
"no-console": "off",
6-
"no-invalid-this": "off",
7-
"max-len": "off"
7+
"no-invalid-this": "off"
88
}
99
}

test/utils/assert.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function deepEqual(result, expected, message) {
1616

1717
/**
1818
* Asserts whether the return status was as expected
19+
*
1920
* @param {Object} res
2021
* @param {integer} expected
2122
*/
@@ -28,6 +29,7 @@ function status(res, expected) {
2829

2930
/**
3031
* Asserts whether content type was as expected
32+
*
3133
* @param {Object} res
3234
* @param {string} expectedRegexString
3335
*/

0 commit comments

Comments
 (0)