From efa478629027e43c64c242ec61d4a793fe57de41 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Fri, 14 Oct 2016 01:19:15 +0300 Subject: [PATCH] Fix remaining lint issues --- package.json | 6 +++++- src/make-plural.js | 31 +++++++++++++++++++------------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 2b3d38e..d4d1d24 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,10 @@ "plugins": [ "standard", "promise" - ] + ], + "rules": { + "no-new-func": 0, + "space-before-function-paren": [2, "never"] + } } } diff --git a/src/make-plural.js b/src/make-plural.js index 689c892..8e975f6 100644 --- a/src/make-plural.js +++ b/src/make-plural.js @@ -89,23 +89,30 @@ class Tests { } testCond(n, type, expResult, fn) { - try { var r = (fn || this.obj.fn)(n, (type === 'ordinal')) } - catch (e) { r = e.toString() } - if (r !== expResult) { throw new Error( - 'Locale ' + JSON.stringify(this.obj.lc) + type - + ' rule self-test failed for v = ' + JSON.stringify(n) - + ' (was ' + JSON.stringify(r) + ', expected ' + JSON.stringify(expResult) + ')' - ) } + try { + var r = (fn || this.obj.fn)(n, (type === 'ordinal')) + } catch (e) { + r = e.toString() + } + if (r !== expResult) { + throw new Error( + 'Locale ' + JSON.stringify(this.obj.lc) + type + + ' rule self-test failed for v = ' + JSON.stringify(n) + + ' (was ' + JSON.stringify(r) + ', expected ' + JSON.stringify(expResult) + ')' + ) + } return true } testCat(type, cat, fn) { const data = this[type][cat] - if (!data.values) data.values = data.src.join(' ') - .replace(/^[ ,]+|[ ,…]+$/g, '') - .replace(/(0\.[0-9])~(1\.[1-9])/g, '$1 1.0 $2') - .split(/[ ,~…]+/) - data.values.forEach( n => { + if (!data.values) { + data.values = data.src.join(' ') + .replace(/^[ ,]+|[ ,…]+$/g, '') + .replace(/(0\.[0-9])~(1\.[1-9])/g, '$1 1.0 $2') + .split(/[ ,~…]+/) + } + data.values.forEach(n => { this.testCond(n, type, cat, fn) if (!/\.0+$/.test(n)) this.testCond(Number(n), type, cat, fn) })