Niedzielski has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/339680 )
Change subject: Hygiene: upgrade to eslint-config-node-services v2.0.1
......................................................................
Hygiene: upgrade to eslint-config-node-services v2.0.1
Upgrade eslint-config-node-services v2.0.1 and eslint v3.11.1 (a
required dependency) and fix offenders.
Change-Id: I9d6466e7869620c98ef5bd7ef26533e77e56a4ee
---
M .eslintrc.yml
M lib/dateUtil.js
M lib/parseSection.js
M lib/parsoid-access.js
M lib/util.js
M package.json
M routes/on-this-day.js
7 files changed, 18 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps
refs/changes/80/339680/1
diff --git a/.eslintrc.yml b/.eslintrc.yml
index a372143..bf9f475 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -1,2 +1 @@
-extends: 'eslint-config-node-services'
-plugins: ['json']
\ No newline at end of file
+extends: node-services
\ No newline at end of file
diff --git a/lib/dateUtil.js b/lib/dateUtil.js
index 3d0c49b..0cf90b4 100644
--- a/lib/dateUtil.js
+++ b/lib/dateUtil.js
@@ -125,9 +125,9 @@
dateUtil.validate = function(dateString) {
try {
const parts = dateString.split("-");
- const year = parseInt(parts[0]);
- const month = parseInt(parts[1]);
- const day = parseInt(parts[2]);
+ const year = parseInt(parts[0], 10);
+ const month = parseInt(parts[1], 10);
+ const day = parseInt(parts[2], 10);
return dateUtil.isValidDate(dateString, year, month, day)
&& dateUtil.isWithinBounds(year);
} catch (error) {
diff --git a/lib/parseSection.js b/lib/parseSection.js
index 687833b..c064fbe 100644
--- a/lib/parseSection.js
+++ b/lib/parseSection.js
@@ -14,7 +14,7 @@
node = nextNode;
continue;
} else {
- nextSection.toclevel = parseInt(node.tagName.charAt(1)) - 1;
+ nextSection.toclevel = parseInt(node.tagName.charAt(1), 10) - 1;
nextSection.line = node.innerHTML.trim();
nextSection.anchor = a.anchorencode(nextSection.line);
node = node.nextSibling;
diff --git a/lib/parsoid-access.js b/lib/parsoid-access.js
index 28b8cdb..8aaaf04 100644
--- a/lib/parsoid-access.js
+++ b/lib/parsoid-access.js
@@ -96,7 +96,7 @@
if (i !== 0) {
const className = currentSectionDiv.className;
- currentSection.toclevel =
parseInt(className.substring('toclevel_'.length));
+ currentSection.toclevel =
parseInt(className.substring('toclevel_'.length), 10);
currentSection.line = currentSectionDiv.title;
currentSection.anchor = a.anchorencode(currentSection.line);
}
diff --git a/lib/util.js b/lib/util.js
index 0fdceeb..dcd1f66 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -83,7 +83,7 @@
ret.detail = err.detail;
// log the stack trace only for 500 errors
- if (Number.parseInt(ret.status) !== 500) {
+ if (Number.parseInt(ret.status, 10) !== 500) {
ret.stack = undefined;
}
@@ -127,7 +127,7 @@
BBPromise.try(() => origHandler(req, res, next))
.catch(next)
.finally(() => {
- let statusCode = parseInt(res.statusCode) || 500;
+ let statusCode = parseInt(res.statusCode, 10) || 500;
if (statusCode < 100 || statusCode > 599) {
statusCode = 500;
}
@@ -204,9 +204,9 @@
errObj.detail = errObj.detail || errObj.message || errObj.description
|| '';
// adjust the log level based on the status code
let level = 'error';
- if (Number.parseInt(errObj.status) < 400) {
+ if (Number.parseInt(errObj.status, 10) < 400) {
level = 'trace';
- } else if (Number.parseInt(errObj.status) < 500) {
+ } else if (Number.parseInt(errObj.status, 10) < 500) {
level = 'info';
}
// log the error
diff --git a/package.json b/package.json
index ffcfcfe..4235e30 100644
--- a/package.json
+++ b/package.json
@@ -59,8 +59,8 @@
"devDependencies": {
"ajv": "^4.7.7",
"csv-parse": "^1.1.7",
- "eslint": "^3.11.0",
- "eslint-config-node-services": "^1.0.6",
+ "eslint": "^3.11.1",
+ "eslint-config-node-services": "^2.0.1",
"eslint-plugin-json": "^1.2.0",
"extend": "^3.0.0",
"istanbul": "^0.4.5",
diff --git a/routes/on-this-day.js b/routes/on-this-day.js
index 691bf03..a9d5fe8 100644
--- a/routes/on-this-day.js
+++ b/routes/on-this-day.js
@@ -20,8 +20,8 @@
* @return {!String} Day page title. Example, inputs ('5',
'20') returns 'May_20'
*/
function titleForDayPageFromMonthDayNumberStrings(monthNumberString,
dayNumberString, lang) {
- const monthName = languages[lang].monthNames[parseInt(monthNumberString) -
1];
- const dayNumber = parseInt(dayNumberString);
+ const monthName = languages[lang].monthNames[parseInt(monthNumberString,
10) - 1];
+ const dayNumber = parseInt(dayNumberString, 10);
return languages[lang].dayPage.nameFormatter(monthName, dayNumber);
}
@@ -47,8 +47,8 @@
* 'Wikipedia:Selected_anniversaries/May_20'
*/
function titleForSelectedPageFromMonthDayNumberStrings(monthNumberString,
dayNumberString, lang) {
- const monthName = languages[lang].monthNames[parseInt(monthNumberString) -
1];
- const dayNumber = parseInt(dayNumberString);
+ const monthName = languages[lang].monthNames[parseInt(monthNumberString,
10) - 1];
+ const dayNumber = parseInt(dayNumberString, 10);
return languages[lang].selectedPage.nameFormatter(monthName, dayNumber);
}
@@ -148,7 +148,7 @@
return null;
}
- let year = parseInt(match[1]);
+ let year = parseInt(match[1], 10);
// Negate BC years so they sort correctly
const isBC = (match[2] !== undefined);
@@ -159,7 +159,7 @@
const textAfterYear = match[3].trim();
function isAnchorNotForYear(anchor) {
- return Math.abs(parseInt(anchor.title)) !== Math.abs(year);
+ return Math.abs(parseInt(anchor.title, 10)) !== Math.abs(year);
}
const pages = Array.from(listElement.querySelectorAll('a'))
--
To view, visit https://gerrit.wikimedia.org/r/339680
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d6466e7869620c98ef5bd7ef26533e77e56a4ee
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits