mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
DEV: Fix or disable various lint rules (#24630)
A grab bag of smaller issues (constructor-super, no-fallthrough, ember/no-private-routing-service, no-unreachable, no-async-promise-executor)
This commit is contained in:
parent
7cac167928
commit
8cf13977a1
@ -14,21 +14,17 @@ export default Mixin.create({
|
||||
|
||||
@discourseComputed("period")
|
||||
startDate(period) {
|
||||
let fullDay = moment().locale("en").utc().endOf("day");
|
||||
const fullDay = moment().locale("en").utc().endOf("day");
|
||||
|
||||
switch (period) {
|
||||
case "yearly":
|
||||
return fullDay.subtract(1, "year").startOf("day");
|
||||
break;
|
||||
case "quarterly":
|
||||
return fullDay.subtract(3, "month").startOf("day");
|
||||
break;
|
||||
case "weekly":
|
||||
return fullDay.subtract(6, "days").startOf("day");
|
||||
break;
|
||||
case "monthly":
|
||||
return fullDay.subtract(1, "month").startOf("day");
|
||||
break;
|
||||
default:
|
||||
return fullDay.subtract(1, "month").startOf("day");
|
||||
}
|
||||
|
@ -98,13 +98,10 @@ function mustacheValue(node, state) {
|
||||
opts ? argValue(opts) : opts
|
||||
}, ${otherOpts ? argValue(otherOpts) : otherOpts})`;
|
||||
|
||||
break;
|
||||
case "yield":
|
||||
return `this.attrs.contents()`;
|
||||
break;
|
||||
case "i18n":
|
||||
return i18n(node);
|
||||
break;
|
||||
case "avatar":
|
||||
let template = argValue(
|
||||
node.hash.pairs.find((p) => p.key === "template")
|
||||
@ -117,13 +114,10 @@ function mustacheValue(node, state) {
|
||||
state,
|
||||
"avatar"
|
||||
)}(${size}, { template: ${template}, username: ${username} })`;
|
||||
break;
|
||||
case "date":
|
||||
return `${useHelper(state, "dateNode")}(${valueOf(node.params[0])})`;
|
||||
break;
|
||||
case "d-icon":
|
||||
return `${useHelper(state, "iconNode")}(${valueOf(node.params[0])})`;
|
||||
break;
|
||||
default:
|
||||
// Shortcut: If our mustache has hash arguments, we can assume it's attaching.
|
||||
// For example `{{home-logo count=123}}` can become `this.attach('home-logo, { "count": 123 });`
|
||||
@ -146,7 +140,6 @@ function mustacheValue(node, state) {
|
||||
path
|
||||
)} + '</span>'})`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,6 +225,7 @@ class Compiler {
|
||||
switch (node.path.original) {
|
||||
case "unless":
|
||||
negate = "!";
|
||||
// eslint-disable-next-line no-fallthrough
|
||||
case "if":
|
||||
instructions.push(
|
||||
`if (${negate}${resolve(node.params[0].original)}) {`
|
||||
|
@ -30,7 +30,7 @@ export default Component.extend({
|
||||
// text customizations to use those.
|
||||
@discourseComputed("options", "action", "model.tags", "model.category")
|
||||
actionTitle(opts, action) {
|
||||
let result = this.model.customizationFor("actionTitle");
|
||||
const result = this.model.customizationFor("actionTitle");
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@ -39,22 +39,23 @@ export default Component.extend({
|
||||
return I18n.t(TITLES[action]);
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case REPLY:
|
||||
if (opts.userAvatar && opts.userLink) {
|
||||
return this._formatReplyToUserPost(opts.userAvatar, opts.userLink);
|
||||
} else if (opts.topicLink) {
|
||||
return this._formatReplyToTopic(opts.topicLink);
|
||||
}
|
||||
case EDIT:
|
||||
if (opts.userAvatar && opts.userLink && opts.postLink) {
|
||||
return this._formatEditUserPost(
|
||||
opts.userAvatar,
|
||||
opts.userLink,
|
||||
opts.postLink,
|
||||
opts.originalUser
|
||||
);
|
||||
}
|
||||
if (action === REPLY) {
|
||||
if (opts.userAvatar && opts.userLink) {
|
||||
return this._formatReplyToUserPost(opts.userAvatar, opts.userLink);
|
||||
} else if (opts.topicLink) {
|
||||
return this._formatReplyToTopic(opts.topicLink);
|
||||
}
|
||||
}
|
||||
|
||||
if (action === EDIT) {
|
||||
if (opts.userAvatar && opts.userLink && opts.postLink) {
|
||||
return this._formatEditUserPost(
|
||||
opts.userAvatar,
|
||||
opts.userLink,
|
||||
opts.postLink,
|
||||
opts.originalUser
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -26,7 +26,6 @@ export default class extends Component {
|
||||
}
|
||||
|
||||
return hexValues.join(", ");
|
||||
break;
|
||||
default:
|
||||
return this.args.prefixValue;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ export function overrideThrowGjsError(value) {
|
||||
// This patch is not ideal, but Ember does not allow us to change a component template after initial association
|
||||
// https://github.com/glimmerjs/glimmer-vm/blob/03a4b55c03/packages/%40glimmer/manager/lib/public/template.ts#L14-L20
|
||||
const originalGetTemplate = GlimmerManager.getComponentTemplate;
|
||||
// eslint-disable-next-line no-import-assign
|
||||
GlimmerManager.getComponentTemplate = (component) => {
|
||||
return (
|
||||
COLOCATED_TEMPLATE_OVERRIDES.get(component) ??
|
||||
|
@ -9,6 +9,7 @@ import { defaultHomepage } from "discourse/lib/utilities";
|
||||
* When detected, we rewrite the URL to `/` before saving it to the Ember router and the browser.
|
||||
*/
|
||||
export default function applyRouterHomepageOverrides(router) {
|
||||
// eslint-disable-next-line ember/no-private-routing-service
|
||||
const microLib = router._routerMicrolib;
|
||||
|
||||
for (const method of ["updateURL", "replaceURL"]) {
|
||||
|
@ -59,33 +59,28 @@ CategoryList.reopenClass({
|
||||
c.topics = c.topics.map((t) => Topic.create(t));
|
||||
}
|
||||
|
||||
switch (statPeriod) {
|
||||
case "week":
|
||||
case "month":
|
||||
const stat = c[`topics_${statPeriod}`];
|
||||
if (stat > 0) {
|
||||
const unit = I18n.t(`categories.topic_stat_unit.${statPeriod}`);
|
||||
const stat = c[`topics_${statPeriod}`];
|
||||
|
||||
c.stat = I18n.t("categories.topic_stat", {
|
||||
count: stat, // only used to correctly pluralize the string
|
||||
number: `<span class="value">${number(stat)}</span>`,
|
||||
unit: `<span class="unit">${unit}</span>`,
|
||||
});
|
||||
if ((statPeriod === "week" || statPeriod === "month") && stat > 0) {
|
||||
const unit = I18n.t(`categories.topic_stat_unit.${statPeriod}`);
|
||||
|
||||
c.statTitle = I18n.t(`categories.topic_stat_sentence_${statPeriod}`, {
|
||||
count: stat,
|
||||
});
|
||||
c.stat = I18n.t("categories.topic_stat", {
|
||||
count: stat, // only used to correctly pluralize the string
|
||||
number: `<span class="value">${number(stat)}</span>`,
|
||||
unit: `<span class="unit">${unit}</span>`,
|
||||
});
|
||||
|
||||
c.pickAll = false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
c.stat = `<span class="value">${number(c.topics_all_time)}</span>`;
|
||||
c.statTitle = I18n.t("categories.topic_sentence", {
|
||||
count: c.topics_all_time,
|
||||
});
|
||||
c.pickAll = true;
|
||||
break;
|
||||
c.statTitle = I18n.t(`categories.topic_stat_sentence_${statPeriod}`, {
|
||||
count: stat,
|
||||
});
|
||||
|
||||
c.pickAll = false;
|
||||
} else {
|
||||
c.stat = `<span class="value">${number(c.topics_all_time)}</span>`;
|
||||
c.statTitle = I18n.t("categories.topic_sentence", {
|
||||
count: c.topics_all_time,
|
||||
});
|
||||
c.pickAll = true;
|
||||
}
|
||||
|
||||
if (Site.currentProp("mobileView")) {
|
||||
|
@ -53,6 +53,7 @@ export default class MediaOptimizationWorkerService extends Service {
|
||||
}
|
||||
await this.ensureAvailableWorker();
|
||||
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async (resolve) => {
|
||||
this.logIfDebug(`Transforming ${file.name}`);
|
||||
|
||||
|
@ -12,7 +12,7 @@ acceptance("Acceptance | decorateCookedElement", function () {
|
||||
static eventLog = [];
|
||||
constructor() {
|
||||
DemoComponent.eventLog.push("created");
|
||||
return super(...arguments);
|
||||
super(...arguments);
|
||||
}
|
||||
willDestroy() {
|
||||
super.willDestroy(...arguments);
|
||||
|
Loading…
Reference in New Issue
Block a user