DEV: Update JS class sorting to match new lint rule

This commit is contained in:
David Taylor 2022-08-14 12:07:44 +01:00
parent b362e614e4
commit 6cac35ca29
8 changed files with 99 additions and 99 deletions

View File

@ -17,8 +17,8 @@ const ICON = "icon";
export default class AdminBadgesShowController extends Controller.extend(
bufferedProperty("model")
) {
@controller adminBadges;
@service router;
@controller adminBadges;
@tracked saving = false;
@tracked savingStatus = "";

View File

@ -7,9 +7,10 @@ import { bind } from "discourse-common/utils/decorators";
import Component from "@glimmer/component";
export default class SidebarMoreSectionLinks extends Component {
@service router;
@tracked shouldDisplaySectionLinks = false;
@tracked activeSectionLink;
@service router;
#allLinks = [...this.args.sectionLinks, ...this.args.secondarySectionLinks];

View File

@ -5,16 +5,16 @@ import { headerOffset } from "discourse/lib/offset-calculator";
import { schedule } from "@ember/runloop";
export default class StickyAvatars {
static init(container) {
return new this(container).init();
}
stickyClass = "sticky-avatar";
topicPostSelector = "#topic .post-stream .topic-post";
intersectionObserver = null;
direction = "⬇️";
prevOffset = -1;
static init(container) {
return new this(container).init();
}
constructor(container) {
this.container = container;
}

View File

@ -82,50 +82,6 @@ export class Tag {
return klass;
}
constructor(prefix = "", suffix = "", inline = false) {
this.prefix = prefix;
this.suffix = suffix;
this.inline = inline;
}
decorate(text) {
for (const callback of tagDecorateCallbacks) {
const result = callback.call(this, text);
if (typeof result !== "undefined") {
text = result;
}
}
if (this.prefix || this.suffix) {
text = [this.prefix, text, this.suffix].join("");
}
if (this.inline) {
const { prev, next } = this.element;
if (prev && prev.name !== "#text") {
text = " " + text;
}
if (next && next.name !== "#text") {
text = text + " ";
}
}
return text;
}
toMarkdown() {
const text = this.element.innerMarkdown();
if (text?.trim()) {
return this.decorate(text);
}
return text;
}
static blocks() {
return [
"address",
@ -643,6 +599,50 @@ export class Tag {
}
};
}
constructor(prefix = "", suffix = "", inline = false) {
this.prefix = prefix;
this.suffix = suffix;
this.inline = inline;
}
decorate(text) {
for (const callback of tagDecorateCallbacks) {
const result = callback.call(this, text);
if (typeof result !== "undefined") {
text = result;
}
}
if (this.prefix || this.suffix) {
text = [this.prefix, text, this.suffix].join("");
}
if (this.inline) {
const { prev, next } = this.element;
if (prev && prev.name !== "#text") {
text = " " + text;
}
if (next && next.name !== "#text") {
text = text + " ";
}
}
return text;
}
toMarkdown() {
const text = this.element.innerMarkdown();
if (text?.trim()) {
return this.decorate(text);
}
return text;
}
}
let tagsMap;
@ -684,6 +684,34 @@ function tagByName(name) {
}
class Element {
static toMarkdown(element, parent, prev, next, metadata) {
return new Element(element, parent, prev, next, metadata).toMarkdown();
}
static parseChildren(parent) {
return Element.parse(parent.children, parent);
}
static parse(elements, parent = null) {
if (elements) {
let result = [];
let metadata = {};
for (let i = 0; i < elements.length; i++) {
const prev = i === 0 ? null : elements[i - 1];
const next = i === elements.length ? null : elements[i + 1];
result.push(
Element.toMarkdown(elements[i], parent, prev, next, metadata)
);
}
return result.join("");
}
return "";
}
constructor(element, parent, previous, next, metadata) {
this.name = element.name;
this.data = element.data;
@ -762,34 +790,6 @@ class Element {
filterParentNames(names) {
return this.parentNames.filter((p) => names.includes(p));
}
static toMarkdown(element, parent, prev, next, metadata) {
return new Element(element, parent, prev, next, metadata).toMarkdown();
}
static parseChildren(parent) {
return Element.parse(parent.children, parent);
}
static parse(elements, parent = null) {
if (elements) {
let result = [];
let metadata = {};
for (let i = 0; i < elements.length; i++) {
const prev = i === 0 ? null : elements[i - 1];
const next = i === elements.length ? null : elements[i + 1];
result.push(
Element.toMarkdown(elements[i], parent, prev, next, metadata)
);
}
return result.join("");
}
return "";
}
}
function trimUnwanted(html) {

View File

@ -2,10 +2,6 @@ import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
export default class GroupsIndexRoute extends DiscourseRoute {
titleToken() {
return I18n.t("groups.index.title");
}
queryParams = {
order: { refreshModel: true, replace: true },
asc: { refreshModel: true, replace: true },
@ -14,6 +10,10 @@ export default class GroupsIndexRoute extends DiscourseRoute {
username: { refreshModel: true },
};
titleToken() {
return I18n.t("groups.index.title");
}
model(params) {
return params;
}

View File

@ -2,12 +2,12 @@ const TapReporter = require("testem/lib/reporters/tap_reporter");
const { shouldLoadPluginTestJs } = require("discourse/lib/plugin-js");
class Reporter {
failReports = [];
constructor() {
this._tapReporter = new TapReporter(...arguments);
}
failReports = [];
reportMetadata(tag, metadata) {
if (tag === "summary-line") {
process.stdout.write(`\n${metadata.message}\n`);

View File

@ -42,6 +42,7 @@ class DemoWidget extends Widget {
class DemoComponent extends ClassicComponent {
static eventLog = [];
classNames = ["demo-component"];
layout = hbs`<DButton class="component-action-button" @label="component_action" @action={{@action}} />`;
init() {
DemoComponent.eventLog.push("init");
@ -63,8 +64,6 @@ class DemoComponent extends ClassicComponent {
willDestroy() {
DemoComponent.eventLog.push("willDestroy");
}
layout = hbs`<DButton class="component-action-button" @label="component_action" @action={{@action}} />`;
}
module("Integration | Component | Widget | render-glimmer", function (hooks) {

View File

@ -14,6 +14,19 @@ import { getProperties } from "@ember/object";
duration between two dates, eg for duration: "1.weeks", "2.months"...
*/
export default class DateWithZoneHelper {
static fromDatetime(datetime, timezone, localTimezone) {
return new DateWithZoneHelper({
year: datetime.year(),
month: datetime.month(),
day: datetime.date(),
hour: datetime.hour(),
minute: datetime.minute(),
second: datetime.second(),
timezone,
localTimezone,
});
}
constructor(params = {}) {
this.timezone = params.timezone || "UTC";
this.localTimezone = params.localTimezone || moment.tz.guess();
@ -77,19 +90,6 @@ export default class DateWithZoneHelper {
return this.datetime.tz(this.localTimezone).toISOString(true);
}
static fromDatetime(datetime, timezone, localTimezone) {
return new DateWithZoneHelper({
year: datetime.year(),
month: datetime.month(),
day: datetime.date(),
hour: datetime.hour(),
minute: datetime.minute(),
second: datetime.second(),
timezone,
localTimezone,
});
}
_fromDatetime(datetime, timezone, localTimezone) {
return DateWithZoneHelper.fromDatetime(datetime, timezone, localTimezone);
}