Fix lint errors in ContentRules.js

Signed-off-by: Aaron Raimist <aaron@raim.ist>
This commit is contained in:
Aaron Raimist 2018-10-11 22:04:53 -05:00
parent fb1deee387
commit 954d49f22e
No known key found for this signature in database
GPG key ID: 37419210002890EF

View file

@ -16,7 +16,7 @@ limitations under the License.
'use strict'; 'use strict';
var PushRuleVectorState = require('./PushRuleVectorState'); const PushRuleVectorState = require('./PushRuleVectorState');
module.exports = { module.exports = {
/** /**
@ -32,7 +32,7 @@ module.exports = {
*/ */
parseContentRules: function(rulesets) { parseContentRules: function(rulesets) {
// first categorise the keyword rules in terms of their actions // first categorise the keyword rules in terms of their actions
var contentRules = this._categoriseContentRules(rulesets); const contentRules = this._categoriseContentRules(rulesets);
// Decide which content rules to display in Vector UI. // Decide which content rules to display in Vector UI.
// Vector displays a single global rule for a list of keywords // Vector displays a single global rule for a list of keywords
@ -54,41 +54,38 @@ module.exports = {
rules: contentRules.loud, rules: contentRules.loud,
externalRules: [].concat(contentRules.loud_but_disabled, contentRules.on, contentRules.on_but_disabled, contentRules.other), externalRules: [].concat(contentRules.loud_but_disabled, contentRules.on, contentRules.on_but_disabled, contentRules.other),
}; };
} } else if (contentRules.loud_but_disabled.length) {
else if (contentRules.loud_but_disabled.length) {
return { return {
vectorState: PushRuleVectorState.OFF, vectorState: PushRuleVectorState.OFF,
rules: contentRules.loud_but_disabled, rules: contentRules.loud_but_disabled,
externalRules: [].concat(contentRules.on, contentRules.on_but_disabled, contentRules.other), externalRules: [].concat(contentRules.on, contentRules.on_but_disabled, contentRules.other),
}; };
} } else if (contentRules.on.length) {
else if (contentRules.on.length) {
return { return {
vectorState: PushRuleVectorState.ON, vectorState: PushRuleVectorState.ON,
rules: contentRules.on, rules: contentRules.on,
externalRules: [].concat(contentRules.on_but_disabled, contentRules.other), externalRules: [].concat(contentRules.on_but_disabled, contentRules.other),
}; };
} } else if (contentRules.on_but_disabled.length) {
else if (contentRules.on_but_disabled.length) {
return { return {
vectorState: PushRuleVectorState.OFF, vectorState: PushRuleVectorState.OFF,
rules: contentRules.on_but_disabled, rules: contentRules.on_but_disabled,
externalRules: contentRules.other, externalRules: contentRules.other,
} };
} else { } else {
return { return {
vectorState: PushRuleVectorState.ON, vectorState: PushRuleVectorState.ON,
rules: [], rules: [],
externalRules: contentRules.other, externalRules: contentRules.other,
} };
} }
}, },
_categoriseContentRules: function(rulesets) { _categoriseContentRules: function(rulesets) {
var contentRules = {on: [], on_but_disabled:[], loud: [], loud_but_disabled: [], other: []}; const contentRules = {on: [], on_but_disabled: [], loud: [], loud_but_disabled: [], other: []};
for (var kind in rulesets.global) { for (const kind in rulesets.global) {
for (var i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) { for (let i = 0; i < Object.keys(rulesets.global[kind]).length; ++i) {
var r = rulesets.global[kind][i]; const r = rulesets.global[kind][i];
// check it's not a default rule // check it's not a default rule
if (r.rule_id[0] === '.' || kind !== 'content') { if (r.rule_id[0] === '.' || kind !== 'content') {
@ -101,16 +98,14 @@ module.exports = {
case PushRuleVectorState.ON: case PushRuleVectorState.ON:
if (r.enabled) { if (r.enabled) {
contentRules.on.push(r); contentRules.on.push(r);
} } else {
else {
contentRules.on_but_disabled.push(r); contentRules.on_but_disabled.push(r);
} }
break; break;
case PushRuleVectorState.LOUD: case PushRuleVectorState.LOUD:
if (r.enabled) { if (r.enabled) {
contentRules.loud.push(r); contentRules.loud.push(r);
} } else {
else {
contentRules.loud_but_disabled.push(r); contentRules.loud_but_disabled.push(r);
} }
break; break;