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