From 554075b312108c334819e9dc0ae541cc89cce3d9 Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Fri, 17 Feb 2017 22:31:05 -0700
Subject: [PATCH] ESlint no-continue
---
.eslintrc | 2 +-
public/src/client/category.js | 13 ++++++-------
public/src/utils.js | 19 +++++++------------
3 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index 96041347bc..0664b80eae 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -109,7 +109,7 @@
"newline-per-chained-call": "off",
"array-bracket-spacing": "off",
"object-property-newline": "off",
- "no-continue": "off",
+ // "no-continue": "off",
// "no-extra-semi": "off",
// "no-spaced-func": "off",
// "no-useless-return": "off"
diff --git a/public/src/client/category.js b/public/src/client/category.js
index f394ee0a88..173b141a96 100644
--- a/public/src/client/category.js
+++ b/public/src/client/category.js
@@ -228,14 +228,13 @@ define('forum/category', [
if (numTopics > 0) {
for (var x = 0; x < numTopics; x++) {
var pinned = $(topics[x]).hasClass('pinned');
- if (pinned) {
- if(x === numTopics - 1) {
- topic.insertAfter(topics[x]);
- }
- continue;
+ if (!pinned) {
+ topic.insertBefore(topics[x]);
+ break;
+ }
+ if(x === numTopics - 1) {
+ topic.insertAfter(topics[x]);
}
- topic.insertBefore(topics[x]);
- break;
}
} else {
container.append(topic);
diff --git a/public/src/utils.js b/public/src/utils.js
index 6a2e444438..485ab05fdd 100644
--- a/public/src/utils.js
+++ b/public/src/utils.js
@@ -447,33 +447,28 @@
},
};
- if (typeof String.prototype.startsWith != 'function') {
+ if (typeof String.prototype.startsWith !== 'function') {
String.prototype.startsWith = function (prefix) {
if (this.length < prefix.length) {
return false;
}
- for (var i = prefix.length - 1; (i >= 0) && (this[i] === prefix[i]); --i) {
- continue;
- }
- return i < 0;
+ return this.slice(0, prefix.length) === prefix;
};
}
- if (typeof String.prototype.endsWith != 'function') {
+ if (typeof String.prototype.endsWith !== 'function') {
String.prototype.endsWith = function (suffix) {
if (this.length < suffix.length) {
return false;
}
- var len = this.length;
- var suffixLen = suffix.length;
- for (var i = 1; (i <= suffixLen && this[len - i] === suffix[suffixLen - i]); ++i) {
- continue;
+ if (suffix.length === 0) {
+ return true;
}
- return i > suffixLen;
+ return this.slice(-suffix.length) === suffix;
};
}
- if (typeof String.prototype.rtrim != 'function') {
+ if (typeof String.prototype.rtrim !== 'function') {
String.prototype.rtrim = function () {
return this.replace(/\s+$/g, '');
};