Confiure eslint package and fix lint issues

This commit is contained in:
Jorik Schellekens 2020-07-21 11:30:28 +01:00
parent 6c50aa14ad
commit 9bb1f99bd9
9 changed files with 634 additions and 112 deletions

View file

@ -29,6 +29,7 @@ export default class VectorEmbeddedPage extends EmbeddedPage {
translate(s) {
s = sanitizeHtml(_t(s));
// ugly fix for https://github.com/vector-im/riot-web/issues/4243
// eslint-disable-next-line max-len
s = s.replace(/\[matrix\]/, '<a href="https://matrix.org" target="_blank" rel="noreferrer noopener"><img width="79" height="34" alt="[matrix]" style="padding-left: 1px;vertical-align: middle" src="welcome/images/matrix.svg"/></a>');
return s;
}

View file

@ -52,7 +52,7 @@ export default class Favicon {
private context: CanvasRenderingContext2D;
private icons: HTMLLinkElement[];
private isReady: boolean = false;
private isReady = false;
// callback to run once isReady is asserted, allows for a badge to be queued for when it can be shown
private readyCb = () => {};

View file

@ -18,7 +18,7 @@ import request from 'browser-request';
// Load the config file. First try to load up a domain-specific config of the
// form "config.$domain.json" and if that fails, fall back to config.json.
export async function getVectorConfig(relativeLocation: string='') {
export async function getVectorConfig(relativeLocation='') {
if (relativeLocation !== '' && !relativeLocation.endsWith('/')) relativeLocation += '/';
const specificConfigPromise = getConfig(`${relativeLocation}config.${document.domain}.json`);

View file

@ -175,8 +175,12 @@ async function start() {
if (error.err && error.err instanceof SyntaxError) {
// This uses the default brand since the app config is unavailable.
return showError(_t("Your Element is misconfigured"), [
_t("Your Element configuration contains invalid JSON. Please correct the problem and reload the page."),
_t("The message from the parser is: %(message)s", { message: error.err.message || _t("Invalid JSON")}),
_t("Your Element configuration contains invalid JSON. " +
"Please correct the problem and reload the page."),
_t(
"The message from the parser is: %(message)s",
{ message: error.err.message || _t("Invalid JSON") },
),
]);
}
return showError(_t("Unable to load config file: please refresh the page to try again."));
@ -210,6 +214,7 @@ start().catch(err => {
// with some basic styling to make the iframe full page
delete document.body.style.height;
const iframe = document.createElement("iframe");
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - typescript seems to only like the IE syntax for iframe sandboxing
iframe["sandbox"] = "";
iframe.src = supportedBrowser ? "static/unable-to-load.html" : "static/incompatible-browser.html";

View file

@ -23,7 +23,7 @@ import { Capability, WidgetApi } from "matrix-react-sdk/src/widgets/WidgetApi";
// Dev note: we use raw JS without many dependencies to reduce bundle size.
// We do not need all of React to render a Jitsi conference.
declare var JitsiMeetExternalAPI: any;
declare let JitsiMeetExternalAPI: any;
let inConference = false;
@ -36,7 +36,7 @@ let userId: string;
let widgetApi: WidgetApi;
(async function () {
(async function() {
try {
// The widget's options are encoded into the fragment to avoid leaking info to the server. The widget
// spec on the other hand requires the widgetId and parentUrl to show up in the regular query string.

View file

@ -29,7 +29,7 @@ function renderConfigError(message) {
async function initPage() {
document.getElementById('back_to_element_button').onclick = onBackToElementClick;
let config = await getVectorConfig('..');
const config = await getVectorConfig('..');
// We manually parse the config similar to how validateServerConfig works because
// calling that function pulls in roughly 4mb of JS we don't use.