DEV: enforces eslint’s curly rule to the codebase (#10720)

eslint --fix is capable of fix it automatically for you, ensure prettier is run after eslint as eslint --fix could leave the code in an invalid prettier state.
This commit is contained in:
Joffrey JAFFEUX
2020-09-22 16:28:28 +02:00
committed by GitHub
parent c86538097d
commit 530d9ab071
179 changed files with 1246 additions and 434 deletions
@@ -126,12 +126,16 @@ export default Controller.extend({
@discourseComputed("pollOptions")
pollOptionsCount(pollOptions) {
if (pollOptions.length === 0) return 0;
if (pollOptions.length === 0) {
return 0;
}
let length = 0;
pollOptions.split("\n").forEach((option) => {
if (option.length !== 0) length += 1;
if (option.length !== 0) {
length += 1;
}
});
return length;
@@ -141,7 +145,9 @@ export default Controller.extend({
_setPollMax() {
const isMultiple = this.isMultiple;
const isNumber = this.isNumber;
if (!isMultiple && !isNumber) return;
if (!isMultiple && !isNumber) {
return;
}
if (isMultiple) {
this.set("pollMax", this.pollOptionsCount);
@@ -152,7 +158,9 @@ export default Controller.extend({
@discourseComputed("isRegular", "isMultiple", "isNumber", "pollOptionsCount")
pollMinOptions(isRegular, isMultiple, isNumber, count) {
if (isRegular) return;
if (isRegular) {
return;
}
if (isMultiple) {
return this._comboboxOptions(1, count + 1);
@@ -173,7 +181,9 @@ export default Controller.extend({
"pollStep"
)
pollMaxOptions(isRegular, isMultiple, isNumber, count, pollMin, pollStep) {
if (isRegular) return;
if (isRegular) {
return;
}
const pollMinInt = parseInt(pollMin, 10) || 1;
if (isMultiple) {
@@ -192,7 +202,9 @@ export default Controller.extend({
@discourseComputed("isNumber", "pollMax")
pollStepOptions(isNumber, pollMax) {
if (!isNumber) return;
if (!isNumber) {
return;
}
return this._comboboxOptions(1, (parseInt(pollMax, 10) || 1) + 1);
},
@@ -244,14 +256,27 @@ export default Controller.extend({
step = 1;
}
if (pollType) pollHeader += ` type=${pollType}`;
if (pollResult) pollHeader += ` results=${pollResult}`;
if (pollMin && showMinMax) pollHeader += ` min=${pollMin}`;
if (pollMax) pollHeader += ` max=${pollMax}`;
if (isNumber) pollHeader += ` step=${step}`;
if (publicPoll) pollHeader += ` public=true`;
if (chartType && pollType !== "number")
if (pollType) {
pollHeader += ` type=${pollType}`;
}
if (pollResult) {
pollHeader += ` results=${pollResult}`;
}
if (pollMin && showMinMax) {
pollHeader += ` min=${pollMin}`;
}
if (pollMax) {
pollHeader += ` max=${pollMax}`;
}
if (isNumber) {
pollHeader += ` step=${step}`;
}
if (publicPoll) {
pollHeader += ` public=true`;
}
if (chartType && pollType !== "number") {
pollHeader += ` chartType=${chartType}`;
}
if (pollGroups && pollGroups.length > 0) {
pollHeader += ` groups=${pollGroups}`;
}
@@ -260,7 +285,9 @@ export default Controller.extend({
date + " " + time,
"YYYY-MM-DD HH:mm"
).toISOString();
if (closeDate) pollHeader += ` close=${closeDate}`;
if (closeDate) {
pollHeader += ` close=${closeDate}`;
}
}
pollHeader += "]";
@@ -268,7 +295,9 @@ export default Controller.extend({
if (pollOptions.length > 0 && !isNumber) {
pollOptions.split("\n").forEach((option) => {
if (option.length !== 0) output += `* ${option}\n`;
if (option.length !== 0) {
output += `* ${option}\n`;
}
});
}
@@ -378,12 +378,15 @@ function md51(s) {
}
s = s.substring(i - 64);
var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
for (i = 0; i < s.length; i++)
for (i = 0; i < s.length; i++) {
tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3);
}
tail[i >> 2] |= 0x80 << (i % 4 << 3);
if (i > 55) {
md5cycle(state, tail);
for (i = 0; i < 16; i++) tail[i] = 0;
for (i = 0; i < 16; i++) {
tail[i] = 0;
}
}
tail[14] = n * 8;
md5cycle(state, tail);
@@ -409,13 +412,16 @@ var hex_chr = "0123456789abcdef".split("");
function rhex(n) {
var s = "",
j = 0;
for (; j < 4; j++)
for (; j < 4; j++) {
s += hex_chr[(n >> (j * 8 + 4)) & 0x0f] + hex_chr[(n >> (j * 8)) & 0x0f];
}
return s;
}
function hex(x) {
for (var i = 0; i < x.length; i++) x[i] = rhex(x[i]);
for (var i = 0; i < x.length; i++) {
x[i] = rhex(x[i]);
}
return x.join("");
}
@@ -21,7 +21,9 @@ export default function (percentages) {
++percentages[index];
decimals[index] = 0;
// quit early when there is a rounding issue
if (sumsUpTo100(percentages)) break;
if (sumsUpTo100(percentages)) {
break;
}
}
return percentages.map((p) => Math.floor(p));
@@ -102,7 +102,9 @@ createWidget("discourse-poll-load-more", {
click() {
const { state } = this;
if (state.loading) return;
if (state.loading) {
return;
}
state.loading = true;
return this.sendWidgetAction("loadMore").finally(
@@ -126,7 +128,9 @@ createWidget("discourse-poll-voters", {
fetchVoters() {
const { attrs, state } = this;
if (state.loaded === "loading") return;
if (state.loaded === "loading") {
return;
}
state.loaded = "loading";
return _fetchVoters({
@@ -691,7 +695,9 @@ export default createWidget("discourse-poll", {
buildAttributes(attrs) {
let cssClasses = "poll";
if (attrs.poll.chart_type === PIE_CHART_TYPE) cssClasses += " pie";
if (attrs.poll.chart_type === PIE_CHART_TYPE) {
cssClasses += " pie";
}
return {
class: cssClasses,
"data-poll-name": attrs.poll.get("name"),
@@ -900,9 +906,15 @@ export default createWidget("discourse-poll", {
toggleOption(option) {
const { attrs } = this;
if (this.isClosed()) return;
if (!this.currentUser) return this.showLogin();
if (!checkUserGroups(this.currentUser, this.attrs.poll)) return;
if (this.isClosed()) {
return;
}
if (!this.currentUser) {
return this.showLogin();
}
if (!checkUserGroups(this.currentUser, this.attrs.poll)) {
return;
}
const { vote } = attrs;
if (!this.isMultiple()) {
@@ -916,8 +928,12 @@ export default createWidget("discourse-poll", {
},
castVotes() {
if (!this.canCastVotes()) return;
if (!this.currentUser) return this.showLogin();
if (!this.canCastVotes()) {
return;
}
if (!this.currentUser) {
return this.showLogin();
}
const { attrs, state } = this;