DEV: prettier 2.2.1 (#11862)

This commit is contained in:
Joffrey JAFFEUX 2021-01-27 12:39:20 +01:00 committed by GitHub
parent 7be556fc19
commit c6a1042950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
117 changed files with 2495 additions and 2433 deletions

View File

@ -1,3 +1,4 @@
app/assets/javascripts/discourse-loader.js
app/assets/javascripts/env.js
app/assets/javascripts/main_include_admin.js
app/assets/javascripts/vendor.js

View File

@ -6,6 +6,7 @@ config/locales/**/*.yml
!config/locales/**/*.en*.yml
script/import_scripts/**/*.yml
app/assets/javascripts/discourse-loader.js
app/assets/javascripts/env.js
app/assets/javascripts/main_include_admin.js
app/assets/javascripts/vendor.js

View File

@ -10,7 +10,7 @@ export default Component.extend({
const model = this.model;
const rawData = this.get("model.data");
var data = {
let data = {
labels: rawData.map((r) => r.x),
datasets: [
{

View File

@ -94,9 +94,9 @@ export default Component.extend({
_splitValues(values, delimiter) {
if (values && values.length) {
const keys = ["key", "secret"];
var res = [];
let res = [];
values.split(delimiter).forEach(function (str) {
var object = {};
let object = {};
str.split("|").forEach(function (a, i) {
object[keys[i]] = a;
});

View File

@ -110,7 +110,7 @@ export default Controller.extend(bufferedProperty("model"), {
const data = {};
const buffered = this.buffered;
fields.forEach(function (field) {
var d = buffered.get(field);
let d = buffered.get(field);
if (boolFields.includes(field)) {
d = !!d;
}

View File

@ -53,9 +53,9 @@ export default Controller.extend({
// Only confirm if we already been saved
if (f.get("id")) {
bootbox.confirm(I18n.t("admin.user_fields.delete_confirm"), function (
result
) {
bootbox.confirm(
I18n.t("admin.user_fields.delete_confirm"),
function (result) {
if (result) {
f.destroyRecord()
.then(function () {
@ -63,7 +63,8 @@ export default Controller.extend({
})
.catch(popupAjaxError);
}
});
}
);
} else {
model.removeObject(f);
}

View File

@ -1,9 +1,9 @@
import { registerUnbound } from "discourse-common/lib/helpers";
registerUnbound("value-at-tl", function (data, params) {
var tl = parseInt(params.level, 10);
let tl = parseInt(params.level, 10);
if (data) {
var item = data.find(function (d) {
let item = data.find(function (d) {
return parseInt(d.x, 10) === tl;
});
if (item) {

View File

@ -14,7 +14,7 @@ export default DiscourseRoute.extend({
Badge.findAll().then(function (badges) {
controller.set("badges", badges);
if (badges.length > 0) {
var grantableBadges = controller.get("grantableBadges");
let grantableBadges = controller.get("grantableBadges");
if (grantableBadges.length > 0) {
controller.set("selectedBadgeId", grantableBadges[0].get("id"));
}

View File

@ -2,10 +2,10 @@
//Copyright (c) 2007-2009, MIT Style License <browser-update.org/LICENSE.txt>
(function () {
var $buo = function () {
let $buo = function () {
// Sometimes we have to resort to parsing the user agent string. :(
if (navigator && navigator.userAgent) {
var ua = navigator.userAgent;
let ua = navigator.userAgent;
// we don't ask Googlebot to update their browser
if (
@ -22,10 +22,10 @@
}
document.getElementsByTagName("body")[0].className += " crawler";
var mainElement = document.getElementById("main");
var noscriptElements = document.getElementsByTagName("noscript");
let mainElement = document.getElementById("main");
let noscriptElements = document.getElementsByTagName("noscript");
// find the element with the "data-path" attribute set
for (var i = 0; i < noscriptElements.length; ++i) {
for (let i = 0; i < noscriptElements.length; ++i) {
if (noscriptElements[i].getAttribute("data-path")) {
// noscriptElements[i].innerHTML contains encoded HTML
if (noscriptElements[i].childNodes.length > 0) {
@ -36,7 +36,7 @@
}
// retrieve localized browser upgrade text
var t = I18n.t("browser_update"); // eslint-disable-line no-undef
let t = I18n.t("browser_update"); // eslint-disable-line no-undef
if (t.indexOf(".browser_update]") !== -1) {
// very old browsers might fail to load even translations
t =
@ -44,13 +44,13 @@
}
// create the notification div HTML
var div = document.createElement("div");
let div = document.createElement("div");
div.className = "buorg";
div.innerHTML = "<div>" + t + "</div>";
// create the notification div stylesheet
var sheet = document.createElement("style");
var style =
let sheet = document.createElement("style");
let style =
".buorg {position:absolute; z-index:111111; width:100%; top:0px; left:0px; background:#FDF2AB; text-align:left; font-family: sans-serif; color:#000; font-size: 14px;} .buorg div {padding: 8px;} .buorg a, .buorg a:visited {color:#E25600; text-decoration: underline;} @media print { .buorg { display: none !important; } }";
// insert the div and stylesheet into the DOM

View File

@ -32,8 +32,8 @@ AttributeHook.prototype.unhook = function (node, prop, next) {
return;
}
var colonPosition = prop.indexOf(":");
var localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop;
let colonPosition = prop.indexOf(":");
let localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop;
node.removeAttributeNS(this.namespace, localName);
};

View File

@ -22,7 +22,7 @@ const _helpers = {};
function rawGet(ctx, property, options) {
if (options.types && options.data.view) {
var view = options.data.view;
let view = options.data.view;
return view.getStream
? view.getStream(property).value()
: view.getAttr(property);

View File

@ -47,7 +47,7 @@ export function deepEqual(obj1, obj2) {
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
return false;
}
for (var prop in obj1) {
for (let prop in obj1) {
if (!deepEqual(obj1[prop], obj2[prop])) {
return false;
}

View File

@ -29,24 +29,22 @@ export function registerRawHelpers(hbs, handlebarsClass) {
};
// #each .. in support (as format is transformed to this)
hbs.registerHelper("each", function (
localName,
inKeyword,
contextName,
options
) {
hbs.registerHelper(
"each",
function (localName, inKeyword, contextName, options) {
if (typeof contextName === "undefined") {
return;
}
var list = get(this, contextName);
var output = [];
for (var i = 0; i < list.length; i++) {
let list = get(this, contextName);
let output = [];
for (let i = 0; i < list.length; i++) {
let innerContext = {};
innerContext[localName] = list[i];
output.push(options.fn(innerContext));
}
return output.join("");
});
}
);
function stringCompatHelper(fn) {
const old = hbs.helpers[fn];

View File

@ -6,7 +6,7 @@ import Handlebars from "handlebars";
const RawHandlebars = Handlebars.create();
function buildPath(blk, args) {
var result = {
let result = {
type: "PathExpression",
data: false,
depth: blk.path.depth,
@ -22,7 +22,7 @@ function buildPath(blk, args) {
}
function replaceGet(ast) {
var visitor = new Handlebars.Visitor();
let visitor = new Handlebars.Visitor();
visitor.mutating = true;
visitor.MustacheStatement = function (mustache) {
@ -42,7 +42,7 @@ function replaceGet(ast) {
// This allows us to use the same syntax in all templates
visitor.BlockStatement = function (block) {
if (block.path.original === "each" && block.params.length === 1) {
var paramName = block.program.blockParams[0];
let paramName = block.program.blockParams[0];
block.params = [
buildPath(block, { original: paramName }),
{ type: "CommentStatement", value: "in" },
@ -74,10 +74,10 @@ if (Handlebars.Compiler) {
RawHandlebars.JavaScriptCompiler.prototype.namespace = "RawHandlebars";
RawHandlebars.precompile = function (value, asObject) {
var ast = Handlebars.parse(value);
let ast = Handlebars.parse(value);
replaceGet(ast);
var options = {
let options = {
knownHelpers: {
get: true,
},
@ -87,7 +87,7 @@ if (Handlebars.Compiler) {
asObject = asObject === undefined ? true : asObject;
var environment = new RawHandlebars.Compiler().compile(ast, options);
let environment = new RawHandlebars.Compiler().compile(ast, options);
return new RawHandlebars.JavaScriptCompiler().compile(
environment,
options,
@ -97,20 +97,20 @@ if (Handlebars.Compiler) {
};
RawHandlebars.compile = function (string) {
var ast = Handlebars.parse(string);
let ast = Handlebars.parse(string);
replaceGet(ast);
// this forces us to rewrite helpers
var options = { data: true, stringParams: true };
var environment = new RawHandlebars.Compiler().compile(ast, options);
var templateSpec = new RawHandlebars.JavaScriptCompiler().compile(
let options = { data: true, stringParams: true };
let environment = new RawHandlebars.Compiler().compile(ast, options);
let templateSpec = new RawHandlebars.JavaScriptCompiler().compile(
environment,
options,
undefined,
true
);
var t = RawHandlebars.template(templateSpec);
let t = RawHandlebars.template(templateSpec);
t.isMethod = false;
return t;

View File

@ -111,7 +111,7 @@ export function buildResolver(baseName) {
);
});
var module;
let module;
if (moduleName) {
module = requirejs(moduleName, null, null, true /* force sync */);
if (module && module["default"]) {
@ -200,7 +200,7 @@ export function buildResolver(baseName) {
findPluginMobileTemplate(parsedName) {
if (_options.mobileView) {
var pluginParsedName = this.parseName(
let pluginParsedName = this.parseName(
parsedName.fullName.replace(
"template:",
"template:javascripts/mobile/"
@ -212,7 +212,7 @@ export function buildResolver(baseName) {
findMobileTemplate(parsedName) {
if (_options.mobileView) {
var mobileParsedName = this.parseName(
let mobileParsedName = this.parseName(
parsedName.fullName.replace("template:", "template:mobile/")
);
return this.findTemplate(mobileParsedName);
@ -241,15 +241,15 @@ export function buildResolver(baseName) {
},
findUnderscoredTemplate(parsedName) {
var decamelized = parsedName.fullNameWithoutType.decamelize();
var underscored = decamelized.replace(/\-/g, "_");
let decamelized = parsedName.fullNameWithoutType.decamelize();
let underscored = decamelized.replace(/\-/g, "_");
return Ember.TEMPLATES[underscored];
},
// Try to find a template within a special admin namespace, e.g. adminEmail => admin/templates/email
// (similar to how discourse lays out templates)
findAdminTemplate(parsedName) {
var decamelized = parsedName.fullNameWithoutType.decamelize();
let decamelized = parsedName.fullNameWithoutType.decamelize();
if (decamelized.indexOf("components") === 0) {
let comPath = `admin/templates/${decamelized}`;
const compTemplate =

View File

@ -12,7 +12,7 @@ export default function decoratorAlias(fn, errorMessage) {
configurable: desc.configurable,
writable: desc.writable,
initializer: function () {
var value = extractValue(desc);
let value = extractValue(desc);
return fn.apply(null, params.concat(value));
},
};

View File

@ -51,7 +51,7 @@ export function readOnly(target, name, desc) {
enumerable: desc.enumerable,
configurable: desc.configurable,
initializer: function () {
var value = extractValue(desc);
let value = extractValue(desc);
return value.readOnly();
},
};

View File

@ -10,7 +10,7 @@ export default function handleDescriptor(target, key, desc, params = []) {
let computedDescriptor;
if (desc.writable) {
var val = extractValue(desc);
let val = extractValue(desc);
if (typeof val === "object") {
let value = {};
if (val.get) {

View File

@ -6,7 +6,7 @@ const Handlebars = require("handlebars");
const RawHandlebars = Handlebars.create();
function buildPath(blk, args) {
var result = {
let result = {
type: "PathExpression",
data: false,
depth: blk.path.depth,
@ -22,7 +22,7 @@ function buildPath(blk, args) {
}
function replaceGet(ast) {
var visitor = new Handlebars.Visitor();
let visitor = new Handlebars.Visitor();
visitor.mutating = true;
visitor.MustacheStatement = function (mustache) {
@ -42,7 +42,7 @@ function replaceGet(ast) {
// This allows us to use the same syntax in all templates
visitor.BlockStatement = function (block) {
if (block.path.original === "each" && block.params.length === 1) {
var paramName = block.program.blockParams[0];
let paramName = block.program.blockParams[0];
block.params = [
buildPath(block, { original: paramName }),
{ type: "CommentStatement", value: "in" },
@ -71,10 +71,10 @@ RawHandlebars.JavaScriptCompiler.prototype.compiler =
RawHandlebars.JavaScriptCompiler.prototype.namespace = "RawHandlebars";
RawHandlebars.precompile = function (value, asObject) {
var ast = Handlebars.parse(value);
let ast = Handlebars.parse(value);
replaceGet(ast);
var options = {
let options = {
knownHelpers: {
get: true,
},
@ -84,7 +84,7 @@ RawHandlebars.precompile = function (value, asObject) {
asObject = asObject === undefined ? true : asObject;
var environment = new RawHandlebars.Compiler().compile(ast, options);
let environment = new RawHandlebars.Compiler().compile(ast, options);
return new RawHandlebars.JavaScriptCompiler().compile(
environment,
options,
@ -94,20 +94,20 @@ RawHandlebars.precompile = function (value, asObject) {
};
RawHandlebars.compile = function (string) {
var ast = Handlebars.parse(string);
let ast = Handlebars.parse(string);
replaceGet(ast);
// this forces us to rewrite helpers
var options = { data: true, stringParams: true };
var environment = new RawHandlebars.Compiler().compile(ast, options);
var templateSpec = new RawHandlebars.JavaScriptCompiler().compile(
let options = { data: true, stringParams: true };
let environment = new RawHandlebars.Compiler().compile(ast, options);
let templateSpec = new RawHandlebars.JavaScriptCompiler().compile(
environment,
options,
undefined,
true
);
var t = RawHandlebars.template(templateSpec);
let t = RawHandlebars.template(templateSpec);
t.isMethod = false;
return t;

View File

@ -5,12 +5,12 @@ import discourseComputed from "discourse-common/utils/decorators";
// https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
function b64EncodeUnicode(str) {
return btoa(
encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(
match,
p1
) {
encodeURIComponent(str).replace(
/%([0-9A-F]{2})/g,
function toSolidBytes(match, p1) {
return String.fromCharCode("0x" + p1);
})
}
)
);
}

View File

@ -10,7 +10,7 @@ export default Component.extend({
@discourseComputed("topicList.loaded")
loaded() {
var topicList = this.topicList;
let topicList = this.topicList;
if (topicList) {
return topicList.get("loaded");
} else {

View File

@ -536,10 +536,10 @@ export default Component.extend({
_warnMentionedGroups($preview) {
schedule("afterRender", () => {
var found = this.warnedGroupMentions || [];
let found = this.warnedGroupMentions || [];
$preview.find(".mention-group.notify").each((idx, e) => {
const $e = $(e);
var name = $e.data("name");
let name = $e.data("name");
if (found.indexOf(name) === -1) {
this.groupsMentioned([
{

View File

@ -184,7 +184,7 @@ class Toolbar {
if (button.shortcut) {
const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
const mod = mac ? "Meta" : "Ctrl";
var shortcutTitle = `${mod}+${button.shortcut}`;
let shortcutTitle = `${mod}+${button.shortcut}`;
// Mac users are used to glyphs for shortcut keys
if (mac) {

View File

@ -28,7 +28,7 @@ export default Component.extend({
@observes("lastShownAt")
bounce() {
if (this.lastShownAt) {
var $elem = $(this.element);
let $elem = $(this.element);
if (!this.animateAttribute) {
this.animateAttribute = $elem.css("left") === "auto" ? "right" : "left";
}
@ -51,7 +51,7 @@ export default Component.extend({
},
bounceLeft($elem) {
for (var i = 0; i < 5; i++) {
for (let i = 0; i < 5; i++) {
$elem
.animate({ left: "+=" + this.bouncePixels }, this.bounceDelay)
.animate({ left: "-=" + this.bouncePixels }, this.bounceDelay);
@ -59,7 +59,7 @@ export default Component.extend({
},
bounceRight($elem) {
for (var i = 0; i < 5; i++) {
for (let i = 0; i < 5; i++) {
$elem
.animate({ right: "-=" + this.bouncePixels }, this.bounceDelay)
.animate({ right: "+=" + this.bouncePixels }, this.bounceDelay);

View File

@ -163,9 +163,9 @@ export default Component.extend(LoadMore, {
},
click(e) {
var self = this;
var onClick = function (sel, callback) {
var target = $(e.target).closest(sel);
let self = this;
let onClick = function (sel, callback) {
let target = $(e.target).closest(sel);
if (target.length === 1) {
callback.apply(self, [target]);

View File

@ -12,7 +12,7 @@ export default Component.extend({
@discourseComputed("badge", "user")
badgeUrl() {
// NOTE: I tried using a link-to helper here but the queryParams mean it fails
var username = this.get("user.username_lower") || "";
let username = this.get("user.username_lower") || "";
username = username !== "" ? "?username=" + username : "";
return this.get("badge.url") + username;
},

View File

@ -727,7 +727,7 @@ export default Controller.extend({
}
}
var staged = false;
let staged = false;
// TODO: This should not happen in model
const imageSizes = {};

View File

@ -77,9 +77,9 @@ export default Controller.extend({
@discourseComputed("context", "context_id")
searchContextDescription(context, id) {
var name = id;
let name = id;
if (context === "category") {
var category = Category.findById(id);
let category = Category.findById(id);
if (!category) {
return;
}
@ -322,7 +322,7 @@ export default Controller.extend({
},
loadMore() {
var page = this.page;
let page = this.page;
if (
this.get("model.grouped_search_result.more_full_page_results") &&
!this.loading &&

View File

@ -17,7 +17,7 @@ import { sanitizeAsync } from "discourse/lib/text";
function customTagArray(fieldName) {
return computed(fieldName, function () {
var val = this.get(fieldName);
let val = this.get(fieldName);
if (!val) {
return val;
}
@ -194,7 +194,7 @@ export default Controller.extend(ModalFunctionality, {
if (displayingInline) {
return this.isEitherRevisionHidden ? "hidden-revision-either" : null;
} else {
var result = [];
let result = [];
if (prevHidden) {
result.push("hidden-revision-previous");
}
@ -227,7 +227,7 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("model.category_id_changes")
previousCategory(changes) {
if (changes) {
var category = Category.findById(changes["previous"]);
let category = Category.findById(changes["previous"]);
return categoryBadgeHTML(category, { allowUncategorized: true });
}
},
@ -235,7 +235,7 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("model.category_id_changes")
currentCategory(changes) {
if (changes) {
var category = Category.findById(changes["current"]);
let category = Category.findById(changes["current"]);
return categoryBadgeHTML(category, { allowUncategorized: true });
}
},

View File

@ -62,7 +62,7 @@ export default Controller.extend({
@discourseComputed()
frequencyEstimate() {
var estimate = this.get("model.mailing_list_posts_per_day");
let estimate = this.get("model.mailing_list_posts_per_day");
if (!estimate || estimate < 2) {
return I18n.t("user.mailing_list_mode.few_per_day");
} else {

View File

@ -72,7 +72,7 @@ export default Controller.extend({
}
const joinedTags = tags.slice(0, displayN).join(", ");
var more = Math.max(0, tags.length - displayN);
let more = Math.max(0, tags.length - displayN);
const tagsString =
more === 0

View File

@ -16,7 +16,7 @@ export default Controller.extend({
@observes("userActionType", "model.stream.itemsLoaded")
_showFooter: function () {
var showFooter;
let showFooter;
if (this.userActionType) {
const stat = (this.get("model.stats") || []).find(
(s) => s.action_type === this.userActionType

View File

@ -40,7 +40,7 @@ export default Controller.extend({
bulkOperation(operation) {
const selected = this.selected;
var params = { type: operation };
let params = { type: operation };
if (this.isGroup) {
params.group = this.groupFilter;
}

View File

@ -16,7 +16,7 @@ export function replaceCategoryLinkRenderer(fn) {
}
function categoryStripe(color, classes) {
var style = color ? "style='background-color: #" + color + ";'" : "";
let style = color ? "style='background-color: #" + color + ";'" : "";
return "<span class='" + classes + "' " + style + "></span>";
}
@ -65,7 +65,7 @@ export function categoryBadgeHTML(category, opts) {
}
export function categoryLinkHTML(category, options) {
var categoryOptions = {};
let categoryOptions = {};
// TODO: This is a compatibility layer with the old helper structure.
// Can be removed once we migrate to `registerUnbound` fully

View File

@ -7,7 +7,7 @@ import { registerUnbound } from "discourse-common/lib/helpers";
update the dates on a regular interval.
**/
registerUnbound("format-date", function (val, params) {
var leaveAgo,
let leaveAgo,
format = "medium",
title = true;
@ -22,7 +22,7 @@ registerUnbound("format-date", function (val, params) {
}
if (val) {
var date = new Date(val);
let date = new Date(val);
return htmlSafe(
autoUpdatingRelativeAge(date, {
format: format,

View File

@ -1,13 +1,13 @@
import { htmlHelper } from "discourse-common/lib/helpers";
function renderSpinner(cssClass) {
var html = "<div class='spinner";
let html = "<div class='spinner";
if (cssClass) {
html += " " + cssClass;
}
return html + "'></div>";
}
var spinnerHTML = renderSpinner();
let spinnerHTML = renderSpinner();
export default htmlHelper((params) => {
const hash = params.hash;

View File

@ -1,7 +1,7 @@
import { registerUnbound } from "discourse-common/lib/helpers";
registerUnbound("shorten-url", function (url) {
var matches = url.match(/\//g);
let matches = url.match(/\//g);
if (matches && matches.length === 3) {
url = url.replace(/\/$/, "");

View File

@ -4,7 +4,7 @@
SO: http://stackoverflow.com/questions/9943435/css3-animation-end-techniques
**/
var dummy = document.createElement("div"),
let dummy = document.createElement("div"),
eventNameHash = {
webkit: "webkitTransitionEnd",
Moz: "transitionend",
@ -12,8 +12,8 @@ var dummy = document.createElement("div"),
ms: "MSTransitionEnd",
};
var transitionEnd = (function () {
var retValue;
let transitionEnd = (function () {
let retValue;
retValue = "transitionend";
Object.keys(eventNameHash).some(function (vendor) {
if (vendor + "TransitionProperty" in dummy.style) {

View File

@ -15,8 +15,8 @@ export function replaceSpan($elem, categorySlug, categoryLink, type) {
export function categoryHashtagTriggerRule(textarea, opts) {
const result = caretRowCol(textarea);
const row = result.rowNum;
var col = result.colNum;
var line = textarea.value.split("\n")[row - 1];
let col = result.colNum;
let line = textarea.value.split("\n")[row - 1];
if (opts && opts.backSpace) {
col = col - 1;

View File

@ -37,7 +37,7 @@ function searchTags(term, categories, limit) {
data: { limit: limit, q },
});
var returnVal = CANCELLED_STATUS;
let returnVal = CANCELLED_STATUS;
oldSearch
.then((r) => {
@ -91,8 +91,8 @@ export function search(term, siteSettings) {
}
const limit = 5;
var categories = Category.search(term, { limit });
var numOfCategories = categories.length;
let categories = Category.search(term, { limit });
let numOfCategories = categories.length;
categories = categories.map((category) => {
return { model: category, text: Category.slugFor(category, SEPARATOR, 2) };

View File

@ -27,7 +27,7 @@ const Mobile = {
localStorage.removeItem("mobileView");
}
if (localStorage.mobileView) {
var savedValue = localStorage.mobileView === "true";
let savedValue = localStorage.mobileView === "true";
if (savedValue !== this.mobileView) {
this.reloadPage(savedValue);
}

View File

@ -1,5 +1,5 @@
// for android we test webkit
var hiddenProperty =
let hiddenProperty =
document.hidden !== undefined
? "hidden"
: document.webkitHidden !== undefined

View File

@ -1227,11 +1227,11 @@ let _pluginv01;
// from http://stackoverflow.com/questions/6832596/how-to-compare-software-version-number-using-js-only-number
function cmpVersions(a, b) {
var i, diff;
var regExStrip0 = /(\.0+)+$/;
var segmentsA = a.replace(regExStrip0, "").split(".");
var segmentsB = b.replace(regExStrip0, "").split(".");
var l = Math.min(segmentsA.length, segmentsB.length);
let i, diff;
let regExStrip0 = /(\.0+)+$/;
let segmentsA = a.replace(regExStrip0, "").split(".");
let segmentsB = b.replace(regExStrip0, "").split(".");
let l = Math.min(segmentsA.length, segmentsB.length);
for (i = 0; i < l; i++) {
diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);

View File

@ -93,7 +93,7 @@ function positioningWorkaround($fixedElement) {
const fixedElement = $fixedElement[0];
const oldHeight = fixedElement.style.height;
var originalScrollTop = 0;
let originalScrollTop = 0;
let lastTouchedElement = null;
positioningWorkaround.blur = function (evt) {
@ -114,7 +114,7 @@ function positioningWorkaround($fixedElement) {
}
};
var blurredNow = function (evt) {
let blurredNow = function (evt) {
// we cannot use evt.relatedTarget to get the last focused element in safari iOS
// document.activeElement is also unreliable (iOS does not mark buttons as focused)
// so instead, we store the last touched element and check against it
@ -145,11 +145,11 @@ function positioningWorkaround($fixedElement) {
positioningWorkaround.blur(evt);
};
var blurred = function (evt) {
let blurred = function (evt) {
discourseDebounce(this, blurredNow, evt, INPUT_DELAY);
};
var positioningHack = function (evt) {
let positioningHack = function (evt) {
let _this = this;
if (evt === undefined) {
@ -203,7 +203,7 @@ function positioningWorkaround($fixedElement) {
}, delay);
};
var lastTouched = function (evt) {
let lastTouched = function (evt) {
if (evt && evt.target) {
lastTouchedElement = evt.target;
}
@ -231,7 +231,7 @@ function positioningWorkaround($fixedElement) {
};
positioningWorkaround.touchstartEvent = function (element) {
var triggerHack = positioningHack.bind(element);
let triggerHack = positioningHack.bind(element);
triggerHack();
};

View File

@ -6,7 +6,7 @@ import { emailValid } from "discourse/lib/utilities";
import { isTesting } from "discourse-common/config/environment";
import { userPath } from "discourse/lib/url";
var cache = {},
let cache = {},
cacheKey,
cacheTime,
currentTerm,
@ -23,7 +23,7 @@ function performSearch(
groupMembersOf,
resultsFn
) {
var cached = cache[term];
let cached = cache[term];
if (cached) {
resultsFn(cached);
return;
@ -52,7 +52,7 @@ function performSearch(
},
});
var returnVal = CANCELLED_STATUS;
let returnVal = CANCELLED_STATUS;
oldSearch
.then(function (r) {
@ -81,7 +81,7 @@ function performSearch(
});
}
var debouncedSearch = function (
let debouncedSearch = function (
term,
topicId,
categoryId,
@ -113,7 +113,7 @@ function organizeResults(r, options) {
return r;
}
var exclude = options.exclude || [],
let exclude = options.exclude || [],
limit = options.limit || 5,
users = [],
emails = [],
@ -182,7 +182,7 @@ export default function userSearch(options) {
options.term = options.term.substring(1);
}
var term = options.term || "",
let term = options.term || "",
includeGroups = options.includeGroups,
includeMentionableGroups = options.includeMentionableGroups,
includeMessageableGroups = options.includeMessageableGroups,

View File

@ -97,7 +97,7 @@ export function tinyAvatar(avatarTemplate, options) {
}
export function postUrl(slug, topicId, postNumber) {
var url = getURL("/t/");
let url = getURL("/t/");
if (slug) {
url += slug + "/";
} else {
@ -190,11 +190,11 @@ export function selectedElement() {
// Determine the row and col of the caret in an element
export function caretRowCol(el) {
var cp = caretPosition(el);
var rows = el.value.slice(0, cp).split("\n");
var rowNum = rows.length;
let cp = caretPosition(el);
let rows = el.value.slice(0, cp).split("\n");
let rowNum = rows.length;
var colNum =
let colNum =
cp -
rows.splice(0, rowNum - 1).reduce(function (sum, row) {
return sum + row.length + 1;
@ -205,7 +205,7 @@ export function caretRowCol(el) {
// Determine the position of the caret in an element
export function caretPosition(el) {
var r, rc, re;
let r, rc, re;
if (el.selectionStart) {
return el.selectionStart;
}
@ -227,7 +227,7 @@ export function caretPosition(el) {
// Set the caret's position
export function setCaretPosition(ctrl, pos) {
var range;
let range;
if (ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos, pos);
@ -421,7 +421,7 @@ export function areCookiesEnabled() {
// see: https://github.com/Modernizr/Modernizr/blob/400db4043c22af98d46e1d2b9cbc5cb062791192/feature-detects/cookies.js
try {
document.cookie = "cookietest=1";
var ret = document.cookie.indexOf("cookietest=") !== -1;
let ret = document.cookie.indexOf("cookietest=") !== -1;
document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
return ret;
} catch (e) {

View File

@ -113,7 +113,7 @@ export function mapRoutes() {
// can define admin routes.
Object.keys(requirejs._eak_seen).forEach(function (key) {
if (/route-map$/.test(key)) {
var module = requirejs(key, null, null, true);
let module = requirejs(key, null, null, true);
if (!module || !module.default) {
throw new Error(key + " must export a route map.");
}

View File

@ -67,7 +67,7 @@ const Singleton = Mixin.create({
// Returns OR sets a property on the singleton instance.
currentProp(property, value) {
var instance = this.current();
let instance = this.current();
if (!instance) {
return;
}

View File

@ -312,7 +312,7 @@ const Category = RestModel.extend({
},
});
var _uncategorized;
let _uncategorized;
Category.reopenClass({
slugEncoded() {
@ -508,7 +508,7 @@ Category.reopenClass({
},
search(term, opts) {
var limit = 5;
let limit = 5;
if (opts) {
if (opts.limit === 0) {
@ -529,8 +529,8 @@ Category.reopenClass({
const categories = Category.listByActivity();
const length = categories.length;
var i;
var data = [];
let i;
let data = [];
const done = () => {
return data.length === limit;

View File

@ -177,7 +177,7 @@ NavItem.reopenClass({
return null;
}
var args = { name: filterType, hasIcon: filterType === "unread" };
let args = { name: filterType, hasIcon: filterType === "unread" };
if (opts.category) {
args.category = opts.category;
}

View File

@ -114,9 +114,9 @@ export default EmberObject.extend({
},
find(type, findArgs, opts) {
var adapter = this.adapterFor(type);
let adapter = this.adapterFor(type);
return adapter.find(this, type, findArgs, opts).then((result) => {
var hydrated = this._hydrateFindResults(result, type, findArgs, opts);
let hydrated = this._hydrateFindResults(result, type, findArgs, opts);
if (result.extras) {
hydrated.set("extras", result.extras);
@ -139,7 +139,7 @@ export default EmberObject.extend({
hydrated.set(
"content",
hydrated.get("content").map((item) => {
var staleItem = stale.content.findBy(primaryKey, item.get(primaryKey));
let staleItem = stale.content.findBy(primaryKey, item.get(primaryKey));
if (staleItem) {
staleItem.setProperties(item);
} else {

View File

@ -291,7 +291,7 @@ const TopicTrackingState = EmberObject.extend({
if (split.length >= 4) {
filter = split[split.length - 1];
// c/cat/subcat/6/l/latest
var category = Category.findSingleBySlug(
let category = Category.findSingleBySlug(
split.splice(1, split.length - 4).join("/")
);
this.set("filterCategory", category);

View File

@ -27,7 +27,7 @@ UserBadge.reopenClass({
if (json.users === undefined) {
json.users = [];
}
var users = {};
let users = {};
json.users.forEach(function (userJson) {
users[userJson.id] = User.create(userJson);
});
@ -36,7 +36,7 @@ UserBadge.reopenClass({
if (json.topics === undefined) {
json.topics = [];
}
var topics = {};
let topics = {};
json.topics.forEach(function (topicJson) {
topics[topicJson.id] = Topic.create(topicJson);
});
@ -45,13 +45,13 @@ UserBadge.reopenClass({
if (json.badges === undefined) {
json.badges = [];
}
var badges = {};
let badges = {};
Badge.createFromJson(json).forEach(function (badge) {
badges[badge.get("id")] = badge;
});
// Create UserBadge object(s).
var userBadges = [];
let userBadges = [];
if ("user_badge" in json) {
userBadges = [json.user_badge];
} else {
@ -61,9 +61,9 @@ UserBadge.reopenClass({
}
userBadges = userBadges.map(function (userBadgeJson) {
var userBadge = UserBadge.create(userBadgeJson);
let userBadge = UserBadge.create(userBadgeJson);
var grantedAtDate = Date.parse(userBadge.get("granted_at"));
let grantedAtDate = Date.parse(userBadge.get("granted_at"));
userBadge.set("grantedAt", grantedAtDate);
userBadge.set("badge", badges[userBadge.get("badge_id")]);
@ -102,7 +102,7 @@ UserBadge.reopenClass({
if (!username) {
return Promise.resolve([]);
}
var url = "/user-badges/" + username + ".json";
let url = "/user-badges/" + username + ".json";
if (options && options.grouped) {
url += "?grouped=true";
}

View File

@ -342,7 +342,7 @@ const User = RestModel.extend({
data[s] = this.get(`user_option.${s}`);
});
var updatedState = {};
let updatedState = {};
["muted", "regular", "watched", "tracked", "watched_first_post"].forEach(
(s) => {

View File

@ -3,8 +3,8 @@ export default {
initialize: function () {
$('script[type="text/x-handlebars"]').each(function () {
var $this = $(this);
var name = $this.attr("name") || $this.data("template-name");
let $this = $(this);
let name = $this.attr("name") || $this.data("template-name");
if (window.console) {
window.console.log(

View File

@ -157,7 +157,7 @@ export default (filterArg, params) => {
canCreateTopic: canCreateTopic,
});
var topicOpts = {
let topicOpts = {
model: topics,
category,
period:

View File

@ -30,7 +30,7 @@ export default DiscourseRoute.extend({
model(params) {
const cached = getTransient("lastSearch");
var args = { q: params.q };
let args = { q: params.q };
if (params.context_id && !args.skip_context) {
args.search_context = {
type: params.context,

View File

@ -5,7 +5,7 @@ const SignupRoute = buildStaticRoute("signup");
SignupRoute.reopen({
beforeModel() {
var canSignUp = this.controllerFor("application").get("canSignUp");
let canSignUp = this.controllerFor("application").get("canSignUp");
if (!this.siteSettings.login_required) {
this.replaceWith("discovery.latest").then((e) => {

View File

@ -29,7 +29,7 @@ createWidget("avatar-flair", {
},
buildAttributes(attrs) {
var style = "";
let style = "";
if (!this.isIcon(attrs)) {
style +=
"background-image: url(" +

View File

@ -12,7 +12,7 @@ export function actionDescriptionHtml(actionCode, createdAt, username) {
const dt = new Date(createdAt);
const when = autoUpdatingRelativeAge(dt, { format: "medium-with-ago" });
var who = "";
let who = "";
if (username) {
if (actionCode === "invited_group" || actionCode === "removed_group") {
who = `<a class="mention-group" href="/g/${username}">@${username}</a>`;

View File

@ -6,9 +6,9 @@ import {
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
acceptance("Opening the hamburger menu with some reviewables", function (
needs
) {
acceptance(
"Opening the hamburger menu with some reviewables",
function (needs) {
needs.user();
needs.pretender((server, helper) => {
server.get("/review/count.json", () => helper.response({ count: 3 }));
@ -24,4 +24,5 @@ acceptance("Opening the hamburger menu with some reviewables", function (
"3"
);
});
});
}
);

View File

@ -290,9 +290,9 @@ acceptance("Second Factor Backups", function (needs) {
});
});
acceptance("Avatar selector when selectable avatars is enabled", function (
needs
) {
acceptance(
"Avatar selector when selectable avatars is enabled",
function (needs) {
needs.user();
needs.settings({ selectable_avatars_enabled: true });
needs.pretender((server, helper) => {
@ -311,7 +311,8 @@ acceptance("Avatar selector when selectable avatars is enabled", function (
exists(".selectable-avatars", "opens the avatar selection modal")
);
});
});
}
);
acceptance("User Preferences when badges are disabled", function (needs) {
needs.user();

View File

@ -1,9 +1,9 @@
import {
acceptance,
exists,
invisible,
queryAll,
updateCurrentUser,
invisible,
} from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit";

View File

@ -6,9 +6,9 @@ import {
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | activation-controls", function (
hooks
) {
discourseModule(
"Integration | Component | activation-controls",
function (hooks) {
setupRenderingTest(hooks);
componentTest("hides change email button", {
@ -22,4 +22,5 @@ discourseModule("Integration | Component | activation-controls", function (
assert.equal(queryAll("button.edit-email").length, 0);
},
});
});
}
);

View File

@ -97,10 +97,9 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
});
}
testCase(`selecting the space before a word`, async function (
assert,
textarea
) {
testCase(
`selecting the space before a word`,
async function (assert, textarea) {
textarea.selectionStart = 5;
textarea.selectionEnd = 7;
@ -109,12 +108,12 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(this.value, `hello **w**orld.`);
assert.equal(textarea.selectionStart, 8);
assert.equal(textarea.selectionEnd, 9);
});
}
);
testCase(`selecting the space after a word`, async function (
assert,
textarea
) {
testCase(
`selecting the space after a word`,
async function (assert, textarea) {
textarea.selectionStart = 0;
textarea.selectionEnd = 6;
@ -123,7 +122,8 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(this.value, `**hello** world.`);
assert.equal(textarea.selectionStart, 2);
assert.equal(textarea.selectionEnd, 7);
});
}
);
testCase(`bold button with no selection`, async function (assert, textarea) {
await click(`button.bold`);
@ -149,10 +149,9 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(textarea.selectionEnd, 11);
});
testCase(`bold with a multiline selection`, async function (
assert,
textarea
) {
testCase(
`bold with a multiline selection`,
async function (assert, textarea) {
this.set("value", "hello\n\nworld\n\ntest.");
textarea.selectionStart = 0;
@ -167,19 +166,20 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(this.value, `hello\n\nworld\n\ntest.`);
assert.equal(textarea.selectionStart, 0);
assert.equal(textarea.selectionEnd, 12);
});
}
);
testCase(`italic button with no selection`, async function (
assert,
textarea
) {
testCase(
`italic button with no selection`,
async function (assert, textarea) {
await click(`button.italic`);
const example = I18n.t(`composer.italic_text`);
assert.equal(this.value, `hello world.*${example}*`);
assert.equal(textarea.selectionStart, 13);
assert.equal(textarea.selectionEnd, 13 + example.length);
});
}
);
testCase(`italic button with a selection`, async function (assert, textarea) {
textarea.selectionStart = 6;
@ -196,10 +196,9 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(textarea.selectionEnd, 11);
});
testCase(`italic with a multiline selection`, async function (
assert,
textarea
) {
testCase(
`italic with a multiline selection`,
async function (assert, textarea) {
this.set("value", "hello\n\nworld\n\ntest.");
textarea.selectionStart = 0;
@ -214,7 +213,8 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
assert.equal(this.value, `hello\n\nworld\n\ntest.`);
assert.equal(textarea.selectionStart, 0);
assert.equal(textarea.selectionEnd, 12);
});
}
);
componentTest("advanced code", {
template: "{{d-editor value=value}}",
@ -508,10 +508,9 @@ third line`
assert.equal(this.value, "hello\n\nwor\n\nld.\n\n> Blockquote");
});
testCase(`bullet button with no selection`, async function (
assert,
textarea
) {
testCase(
`bullet button with no selection`,
async function (assert, textarea) {
const example = I18n.t("composer.list_item");
await click(`button.bullet`);
@ -521,7 +520,8 @@ third line`
await click(`button.bullet`);
assert.equal(this.value, `hello world.\n\n${example}`);
});
}
);
testCase(`bullet button with a selection`, async function (assert, textarea) {
textarea.selectionStart = 6;
@ -538,10 +538,9 @@ third line`
assert.equal(textarea.selectionEnd, 12);
});
testCase(`bullet button with a multiple line selection`, async function (
assert,
textarea
) {
testCase(
`bullet button with a multiple line selection`,
async function (assert, textarea) {
this.set("value", "* Hello\n\nWorld\n\nEvil");
textarea.selectionStart = 0;
@ -556,7 +555,8 @@ third line`
assert.equal(this.value, "* Hello\n\n* World\n\n* Evil");
assert.equal(textarea.selectionStart, 0);
assert.equal(textarea.selectionEnd, 24);
});
}
);
testCase(`list button with no selection`, async function (assert, textarea) {
const example = I18n.t("composer.list_item");
@ -633,10 +633,9 @@ third line`
},
});
testCase(`doesn't jump to bottom with long text`, async function (
assert,
textarea
) {
testCase(
`doesn't jump to bottom with long text`,
async function (assert, textarea) {
let longText = "hello world.";
for (let i = 0; i < 8; i++) {
longText = longText + longText;
@ -649,7 +648,8 @@ third line`
await click("button.bold");
assert.equal($(textarea).scrollTop(), 0, "it stays scrolled up");
});
}
);
componentTest("emoji", {
template: "{{d-editor value=value}}",

View File

@ -24,9 +24,9 @@ function toTimeInput() {
const DEFAULT_DATE_TIME = moment("2019-01-29 14:45");
discourseModule("Integration | Component | date-time-input-range", function (
hooks
) {
discourseModule(
"Integration | Component | date-time-input-range",
function (hooks) {
setupRenderingTest(hooks);
componentTest("default", {
@ -43,4 +43,5 @@ discourseModule("Integration | Component | date-time-input-range", function (
assert.equal(toTimeInput().dataset.name, "--:--");
},
});
});
}
);

View File

@ -8,9 +8,9 @@ import {
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "I18n";
discourseModule("Integration | Component | secret-value-list", function (
hooks
) {
discourseModule(
"Integration | Component | secret-value-list",
function (hooks) {
setupRenderingTest(hooks);
componentTest("adding a value", {
@ -102,4 +102,5 @@ discourseModule("Integration | Component | secret-value-list", function (
);
},
});
});
}
);

View File

@ -47,9 +47,9 @@ function template(options = []) {
`;
}
discourseModule("Integration | Component | select-kit/category-drop", function (
hooks
) {
discourseModule(
"Integration | Component | select-kit/category-drop",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
@ -356,4 +356,5 @@ discourseModule("Integration | Component | select-kit/category-drop", function (
);
},
});
});
}
);

View File

@ -24,9 +24,9 @@ const setDefaultState = (ctx, options) => {
ctx.setProperties(properties);
};
discourseModule("Integration | Component | select-kit/combo-box", function (
hooks
) {
discourseModule(
"Integration | Component | select-kit/combo-box",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
@ -106,4 +106,5 @@ discourseModule("Integration | Component | select-kit/combo-box", function (
);
},
});
});
}
);

View File

@ -16,9 +16,9 @@ function template(options = []) {
`;
}
discourseModule("Integration | Component | select-kit/list-setting", function (
hooks
) {
discourseModule(
"Integration | Component | select-kit/list-setting",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
@ -43,4 +43,5 @@ discourseModule("Integration | Component | select-kit/list-setting", function (
assert.equal(this.subject.rowByIndex(0).value(), "underline");
},
});
});
}
);

View File

@ -33,9 +33,9 @@ const setDefaultState = (ctx, options) => {
ctx.setProperties(properties);
};
discourseModule("Integration | Component | select-kit/multi-select", function (
hooks
) {
discourseModule(
"Integration | Component | select-kit/multi-select",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
@ -71,4 +71,5 @@ discourseModule("Integration | Component | select-kit/multi-select", function (
);
},
});
});
}
);

View File

@ -44,9 +44,9 @@ const setDefaultState = (ctx, options) => {
ctx.setProperties(properties);
};
discourseModule("Integration | Component | select-kit/single-select", function (
hooks
) {
discourseModule(
"Integration | Component | select-kit/single-select",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
@ -121,7 +121,10 @@ discourseModule("Integration | Component | select-kit/single-select", function (
});
componentTest("options.limitMatches", {
template: template(["limitMatches=limitMatches", "filterable=filterable"]),
template: template([
"limitMatches=limitMatches",
"filterable=filterable",
]),
beforeEach() {
setDefaultState(this, { limitMatches: 1, filterable: true });
@ -344,4 +347,5 @@ discourseModule("Integration | Component | select-kit/single-select", function (
);
},
});
});
}
);

View File

@ -36,9 +36,9 @@ function template(options = []) {
`;
}
discourseModule("Integration | Component | select-kit/tag-drop", function (
hooks
) {
discourseModule(
"Integration | Component | select-kit/tag-drop",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
@ -95,4 +95,5 @@ discourseModule("Integration | Component | select-kit/tag-drop", function (
);
},
});
});
}
);

View File

@ -4,9 +4,9 @@ import componentTest, {
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
discourseModule("Integration | Component | select-kit/user-chooser", function (
hooks
) {
discourseModule(
"Integration | Component | select-kit/user-chooser",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
@ -37,4 +37,5 @@ discourseModule("Integration | Component | select-kit/user-chooser", function (
assert.equal(this.subject.header().name(), "martin");
},
});
});
}
);

View File

@ -6,9 +6,9 @@ import {
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | Widget | actions-summary", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | actions-summary",
function (hooks) {
setupRenderingTest(hooks);
componentTest("post deleted", {
@ -31,4 +31,5 @@ discourseModule("Integration | Component | Widget | actions-summary", function (
);
},
});
});
}
);

View File

@ -6,9 +6,9 @@ import {
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | Widget | avatar-flair", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | avatar-flair",
function (hooks) {
setupRenderingTest(hooks);
componentTest("avatar flair with an icon", {
@ -43,4 +43,5 @@ discourseModule("Integration | Component | Widget | avatar-flair", function (
assert.ok(queryAll("svg").length === 0, "it does not have an svg icon");
},
});
});
}
);

View File

@ -12,9 +12,9 @@ let mutedCategoryIds = [];
let unreadCategoryIds = [];
let categoriesByCount = [];
discourseModule("Integration | Component | Widget | hamburger-menu", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | hamburger-menu",
function (hooks) {
setupRenderingTest(hooks);
componentTest("prioritize faq", {
@ -158,7 +158,8 @@ discourseModule("Integration | Component | Widget | hamburger-menu", function (
beforeEach() {
this.siteSettings.header_dropdown_category_count = 8;
maxCategoriesToDisplay = this.siteSettings.header_dropdown_category_count;
maxCategoriesToDisplay = this.siteSettings
.header_dropdown_category_count;
categoriesByCount = this.site.get("categoriesByCount").slice();
categoriesByCount.every((c) => {
if (!topCategoryIds.includes(c.id)) {
@ -207,7 +208,9 @@ discourseModule("Integration | Component | Widget | hamburger-menu", function (
assert.equal(
queryAll(".category-link .category-name").text(),
ids.map((i) => categoriesByCount.find((c) => c.id === i).name).join("")
ids
.map((i) => categoriesByCount.find((c) => c.id === i).name)
.join("")
);
},
});
@ -260,4 +263,5 @@ discourseModule("Integration | Component | Widget | hamburger-menu", function (
assert.ok(queryAll(".keyboard-shortcuts-link").length);
},
});
});
}
);

View File

@ -14,9 +14,9 @@ const darkLogo = "/images/d-logo-sketch.png?dark";
const title = "Cool Forum";
const prefersDark = "(prefers-color-scheme: dark)";
discourseModule("Integration | Component | Widget | home-logo", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | home-logo",
function (hooks) {
setupRenderingTest(hooks);
componentTest("basics", {
@ -250,4 +250,5 @@ discourseModule("Integration | Component | Widget | home-logo", function (
);
},
});
});
}
);

View File

@ -7,9 +7,9 @@ import {
} from "discourse/tests/helpers/qunit-helpers";
import { click } from "@ember/test-helpers";
discourseModule("Integration | Component | Widget | post-links", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | post-links",
function (hooks) {
setupRenderingTest(hooks);
componentTest("duplicate links", {
@ -46,20 +46,52 @@ discourseModule("Integration | Component | Widget | post-links", function (
this.set("args", {
id: 1,
links: [
{ title: "Link 1", url: "http://eviltrout.com?1", reflection: true },
{ title: "Link 2", url: "http://eviltrout.com?2", reflection: true },
{ title: "Link 3", url: "http://eviltrout.com?3", reflection: true },
{ title: "Link 4", url: "http://eviltrout.com?4", reflection: true },
{ title: "Link 5", url: "http://eviltrout.com?5", reflection: true },
{ title: "Link 6", url: "http://eviltrout.com?6", reflection: true },
{ title: "Link 7", url: "http://eviltrout.com?7", reflection: true },
{
title: "Link 1",
url: "http://eviltrout.com?1",
reflection: true,
},
{
title: "Link 2",
url: "http://eviltrout.com?2",
reflection: true,
},
{
title: "Link 3",
url: "http://eviltrout.com?3",
reflection: true,
},
{
title: "Link 4",
url: "http://eviltrout.com?4",
reflection: true,
},
{
title: "Link 5",
url: "http://eviltrout.com?5",
reflection: true,
},
{
title: "Link 6",
url: "http://eviltrout.com?6",
reflection: true,
},
{
title: "Link 7",
url: "http://eviltrout.com?7",
reflection: true,
},
],
});
},
async test(assert) {
assert.ok(queryAll(".expand-links").length === 1, "collapsed by default");
assert.ok(
queryAll(".expand-links").length === 1,
"collapsed by default"
);
await click("a.expand-links");
assert.equal(queryAll(".post-links a.track-link").length, 7);
},
});
});
}
);

View File

@ -7,9 +7,9 @@ import {
} from "discourse/tests/helpers/qunit-helpers";
import { withPluginApi } from "discourse/lib/plugin-api";
discourseModule("Integration | Component | Widget | post-menu", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | post-menu",
function (hooks) {
setupRenderingTest(hooks);
componentTest("add extra button", {
@ -51,4 +51,5 @@ discourseModule("Integration | Component | Widget | post-menu", function (
);
},
});
});
}
);

View File

@ -21,9 +21,9 @@ function postStreamTest(name, attrs) {
});
}
discourseModule("Integration | Component | Widget | post-stream", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | post-stream",
function (hooks) {
setupRenderingTest(hooks);
postStreamTest("basics", {
@ -153,4 +153,5 @@ discourseModule("Integration | Component | Widget | post-stream", function (
);
},
});
});
}
);

View File

@ -6,9 +6,9 @@ import {
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | Widget | poster-name", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | poster-name",
function (hooks) {
setupRenderingTest(hooks);
componentTest("basic rendering", {
@ -76,4 +76,5 @@ discourseModule("Integration | Component | Widget | poster-name", function (
assert.equal(queryAll(".second").length, 0);
},
});
});
}
);

View File

@ -6,9 +6,9 @@ import {
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | Widget | small-user-list", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | small-user-list",
function (hooks) {
setupRenderingTest(hooks);
componentTest("renders avatars and support for unknown", {
@ -27,4 +27,5 @@ discourseModule("Integration | Component | Widget | small-user-list", function (
assert.ok(queryAll(".unknown").length, "includes unkown user");
},
});
});
}
);

View File

@ -7,9 +7,9 @@ import {
} from "discourse/tests/helpers/qunit-helpers";
import TopicStatusIcons from "discourse/helpers/topic-status-icons";
discourseModule("Integration | Component | Widget | topic-status", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | topic-status",
function (hooks) {
setupRenderingTest(hooks);
componentTest("basics", {
@ -44,4 +44,5 @@ discourseModule("Integration | Component | Widget | topic-status", function (
assert.ok(queryAll(".topic-status .d-icon-far-check-square").length);
},
});
});
}
);

View File

@ -10,9 +10,9 @@ import I18n from "I18n";
import { click } from "@ember/test-helpers";
import sinon from "sinon";
discourseModule("Integration | Component | Widget | user-menu", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | user-menu",
function (hooks) {
setupRenderingTest(hooks);
componentTest("basics", {
@ -232,4 +232,5 @@ discourseModule("Integration | Component | Widget | user-menu", function (
assert.notOk(this.anonymous);
},
});
});
}
);

View File

@ -60,9 +60,9 @@ const TEMPLATE = `
)
}}`;
discourseModule("Integration | Component | Widget | widget-dropdown", function (
hooks
) {
discourseModule(
"Integration | Component | Widget | widget-dropdown",
function (hooks) {
setupRenderingTest(hooks);
componentTest("dropdown id", {
@ -345,4 +345,5 @@ discourseModule("Integration | Component | Widget | widget-dropdown", function (
);
},
});
});
}
);

View File

@ -33,9 +33,9 @@ const Modal = Plugin.Constructor;
function AcceptanceModal(option, _relatedTarget) {
return this.each(function () {
var $this = $(this);
var data = $this.data("bs.modal");
var options = $.extend(
let $this = $(this);
let data = $this.data("bs.modal");
let options = $.extend(
{},
Modal.DEFAULTS,
$this.data(),
@ -202,8 +202,8 @@ export default function setupTests(app, container) {
// Load ES6 tests
function getUrlParameter(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
let regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
let results = regex.exec(location.search);
return results === null
? ""
: decodeURIComponent(results[1].replace(/\+/g, " "));

View File

@ -5,8 +5,8 @@ let originalTemplates;
let resolver;
function lookupTemplate(assert, name, expectedTemplate, message) {
var parseName = resolver.parseName(name);
var result = resolver.resolveTemplate(parseName);
let parseName = resolver.parseName(name);
let result = resolver.resolveTemplate(parseName);
assert.equal(result, expectedTemplate, message);
}

View File

@ -154,7 +154,7 @@ module("Unit | Utility | click-track", function (hooks) {
assert.notOk(track(generateClickEventOn("a")));
var $link = fixture("a").first();
let $link = fixture("a").first();
assert.ok($link.hasClass("no-href"));
assert.equal($link.data("href"), "http://www.google.com/");
assert.blank($link.attr("href"));
@ -178,7 +178,7 @@ module("Unit | Utility | click-track", function (hooks) {
function badgeClickCount(assert, id, expected) {
track(generateClickEventOn("#" + id));
var $badge = $("span.badge", fixture("#" + id).first());
let $badge = $("span.badge", fixture("#" + id).first());
assert.equal(parseInt($badge.html(), 10), expected);
}
@ -200,7 +200,7 @@ module("Unit | Utility | click-track", function (hooks) {
function testOpenInANewTab(description, clickEventModifier) {
test(description, async function (assert) {
var clickEvent = generateClickEventOn("a");
let clickEvent = generateClickEventOn("a");
clickEventModifier(clickEvent);
assert.ok(track(clickEvent));
assert.notOk(clickEvent.defaultPrevented);

View File

@ -45,7 +45,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
});
test("propertyEqual", function (assert) {
var t = EmberObject.extend({
let t = EmberObject.extend({
same: propertyEqual("cookies", "biscuits"),
}).create({
cookies: 10,
@ -58,7 +58,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
});
test("propertyNotEqual", function (assert) {
var t = EmberObject.extend({
let t = EmberObject.extend({
diff: propertyNotEqual("cookies", "biscuits"),
}).create({
cookies: 10,
@ -71,7 +71,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
});
test("fmt", function (assert) {
var t = EmberObject.extend({
let t = EmberObject.extend({
exclaimyUsername: fmt("username", "!!! %@ !!!"),
multiple: fmt("username", "mood", "%@ is %@"),
}).create({
@ -105,7 +105,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
});
test("i18n", function (assert) {
var t = EmberObject.extend({
let t = EmberObject.extend({
exclaimyUsername: i18n("username", "!!! %@ !!!"),
multiple: i18n("username", "mood", "%@ is %@"),
}).create({
@ -139,7 +139,7 @@ discourseModule("Unit | Utility | computed", function (hooks) {
});
test("url", function (assert) {
var t, testClass;
let t, testClass;
testClass = EmberObject.extend({
userUrl: url("username", "/u/%@"),

View File

@ -159,7 +159,7 @@ discourseModule("Unit | Utility | formatter", function (hooks) {
assert.equal(formatDays(-500), shortDateYear(-500));
assert.equal(formatDays(-365 * 2 - 1), shortDateYear(-365 * 2 - 1)); // one leap year
var originalValue = this.siteSettings.relative_date_duration;
let originalValue = this.siteSettings.relative_date_duration;
this.siteSettings.relative_date_duration = 7;
assert.equal(formatDays(7), "7d");
assert.equal(formatDays(8), shortDate(8));
@ -203,9 +203,9 @@ discourseModule("Unit | Utility | formatter", function (hooks) {
});
test("autoUpdatingRelativeAge", function (assert) {
var d = moment().subtract(1, "day").toDate();
let d = moment().subtract(1, "day").toDate();
var $elem = $(autoUpdatingRelativeAge(d));
let $elem = $(autoUpdatingRelativeAge(d));
assert.equal($elem.data("format"), "tiny");
assert.equal($elem.data("time"), d.getTime());
assert.equal($elem.attr("title"), undefined);
@ -233,8 +233,8 @@ discourseModule("Unit | Utility | formatter", function (hooks) {
});
test("updateRelativeAge", function (assert) {
var d = new Date();
var $elem = $(autoUpdatingRelativeAge(d));
let d = new Date();
let $elem = $(autoUpdatingRelativeAge(d));
$elem.data("time", d.getTime() - 2 * 60 * 1000);
updateRelativeAge($elem);

View File

@ -194,7 +194,7 @@ discourseModule("Unit | Utility | uploads", function () {
test("isImage", function (assert) {
["png", "webp", "jpg", "jpeg", "gif", "ico"].forEach((extension) => {
var image = "image." + extension;
let image = "image." + extension;
assert.ok(isImage(image), image + " is recognized as an image");
assert.ok(
isImage("http://foo.bar/path/to/" + image),

View File

@ -71,7 +71,7 @@ discourseModule("Unit | Utilities", function () {
});
test("avatarUrl", function (assert) {
var rawSize = getRawSize;
let rawSize = getRawSize;
assert.blank(avatarUrl("", "tiny"), "no template returns blank");
assert.equal(
avatarUrl("/fake/template/{size}.png", "tiny"),
@ -85,7 +85,7 @@ discourseModule("Unit | Utilities", function () {
);
});
var setDevicePixelRatio = function (value) {
let setDevicePixelRatio = function (value) {
if (Object.defineProperty && !window.hasOwnProperty("devicePixelRatio")) {
Object.defineProperty(window, "devicePixelRatio", { value: 2 });
} else {
@ -94,10 +94,10 @@ discourseModule("Unit | Utilities", function () {
};
test("avatarImg", function (assert) {
var oldRatio = window.devicePixelRatio;
let oldRatio = window.devicePixelRatio;
setDevicePixelRatio(2);
var avatarTemplate = "/path/to/avatar/{size}.png";
let avatarTemplate = "/path/to/avatar/{size}.png";
assert.equal(
avatarImg({ avatarTemplate: avatarTemplate, size: "tiny" }),
"<img alt='' width='20' height='20' src='/path/to/avatar/40.png' class='avatar'>",
@ -164,7 +164,7 @@ discourseModule("Unit | Utilities", function () {
});
test("caretRowCol", function (assert) {
var textarea = document.createElement("textarea");
let textarea = document.createElement("textarea");
const content = document.createTextNode("01234\n56789\n012345");
textarea.appendChild(content);
document.body.appendChild(textarea);

View File

@ -4,10 +4,10 @@ import Singleton from "discourse/mixins/singleton";
module("Unit | Mixin | singleton", function () {
test("current", function (assert) {
var DummyModel = EmberObject.extend({});
let DummyModel = EmberObject.extend({});
DummyModel.reopenClass(Singleton);
var current = DummyModel.current();
let current = DummyModel.current();
assert.present(current, "current returns the current instance");
assert.equal(
current,
@ -22,9 +22,9 @@ module("Unit | Mixin | singleton", function () {
});
test("currentProp reading", function (assert) {
var DummyModel = EmberObject.extend({});
let DummyModel = EmberObject.extend({});
DummyModel.reopenClass(Singleton);
var current = DummyModel.current();
let current = DummyModel.current();
assert.blank(
DummyModel.currentProp("evil"),
@ -39,14 +39,14 @@ module("Unit | Mixin | singleton", function () {
});
test("currentProp writing", function (assert) {
var DummyModel = EmberObject.extend({});
let DummyModel = EmberObject.extend({});
DummyModel.reopenClass(Singleton);
assert.blank(
DummyModel.currentProp("adventure"),
"by default attributes are blank"
);
var result = DummyModel.currentProp("adventure", "time");
let result = DummyModel.currentProp("adventure", "time");
assert.equal(result, "time", "it returns the new value");
assert.equal(
DummyModel.currentProp("adventure"),
@ -70,7 +70,7 @@ module("Unit | Mixin | singleton", function () {
});
test("createCurrent", function (assert) {
var Shoe = EmberObject.extend({});
let Shoe = EmberObject.extend({});
Shoe.reopenClass(Singleton, {
createCurrent: function () {
return Shoe.create({ toes: 5 });
@ -85,7 +85,7 @@ module("Unit | Mixin | singleton", function () {
});
test("createCurrent that returns null", function (assert) {
var Missing = EmberObject.extend({});
let Missing = EmberObject.extend({});
Missing.reopenClass(Singleton, {
createCurrent: function () {
return null;

View File

@ -18,13 +18,13 @@ function buildPost(args) {
module("Unit | Model | post", function () {
test("defaults", function (assert) {
var post = Post.create({ id: 1 });
let post = Post.create({ id: 1 });
assert.blank(post.get("deleted_at"), "it has no deleted_at by default");
assert.blank(post.get("deleted_by"), "there is no deleted_by by default");
});
test("new_user", function (assert) {
var post = Post.create({ trust_level: 0 });
let post = Post.create({ trust_level: 0 });
assert.ok(post.get("new_user"), "post is from a new user");
post.set("trust_level", 1);
@ -32,7 +32,7 @@ module("Unit | Model | post", function () {
});
test("firstPost", function (assert) {
var post = Post.create({ post_number: 1 });
let post = Post.create({ post_number: 1 });
assert.ok(post.get("firstPost"), "it's the first post");
post.set("post_number", 10);
@ -40,7 +40,7 @@ module("Unit | Model | post", function () {
});
test("updateFromPost", function (assert) {
var post = Post.create({
let post = Post.create({
post_number: 1,
raw: "hello world",
});

View File

@ -15,7 +15,7 @@ module("Unit | Model | rest-model", function () {
},
});
var g = Grape.create({ store, percent: 0.4 });
let g = Grape.create({ store, percent: 0.4 });
assert.equal(g.get("inverse"), 0.6, "it runs `munge` on `create`");
});

View File

@ -9,13 +9,13 @@ function buildDetails(id) {
module("Unit | Model | topic-details", function () {
test("defaults", function (assert) {
var details = buildDetails(1234);
let details = buildDetails(1234);
assert.present(details, "the details are present by default");
assert.ok(!details.get("loaded"), "details are not loaded by default");
});
test("updateFromJson", function (assert) {
var details = buildDetails(1234);
let details = buildDetails(1234);
details.updateFromJson({
allowed_users: [{ username: "eviltrout" }],

View File

@ -3,7 +3,7 @@ import UserAction from "discourse/models/user-action";
module("Unit | Model | user-action", function () {
test("collapsing likes", function (assert) {
var actions = UserAction.collapseStream([
let actions = UserAction.collapseStream([
UserAction.create({
action_type: UserAction.TYPES.likes_given,
topic_id: 1,

View File

@ -4,8 +4,8 @@ import UserAction from "discourse/models/user-action";
module("Unit | Model | user-stream", function () {
test("basics", function (assert) {
var user = User.create({ id: 1, username: "eviltrout" });
var stream = user.get("stream");
let user = User.create({ id: 1, username: "eviltrout" });
let stream = user.get("stream");
assert.present(stream, "a user has a stream by default");
assert.equal(
stream.get("user"),
@ -25,8 +25,8 @@ module("Unit | Model | user-stream", function () {
});
test("filterParam", function (assert) {
var user = User.create({ id: 1, username: "eviltrout" });
var stream = user.get("stream");
let user = User.create({ id: 1, username: "eviltrout" });
let stream = user.get("stream");
// defaults to posts/topics
assert.equal(stream.get("filterParam"), "4,5");

View File

@ -7,7 +7,7 @@ import sinon from "sinon";
module("Unit | Model | user", function () {
test("staff", function (assert) {
var user = User.create({ id: 1, username: "eviltrout" });
let user = User.create({ id: 1, username: "eviltrout" });
assert.ok(!user.get("staff"), "user is not staff");
@ -19,7 +19,7 @@ module("Unit | Model | user", function () {
});
test("searchContext", function (assert) {
var user = User.create({ id: 1, username: "EvilTrout" });
let user = User.create({ id: 1, username: "EvilTrout" });
assert.deepEqual(
user.get("searchContext"),
@ -29,7 +29,7 @@ module("Unit | Model | user", function () {
});
test("isAllowedToUploadAFile", function (assert) {
var user = User.create({ trust_level: 0, admin: true });
let user = User.create({ trust_level: 0, admin: true });
assert.ok(
user.isAllowedToUploadAFile("image"),
"admin can always upload a file"

Some files were not shown because too many files have changed in this diff Show More