Update to eslint-plugin-matrix-org 0.8 (#23825)

* Update to eslint-plugin-matrix-org 0.8

* Exclude some eslint rules for specs

* Fix eslint tests path
This commit is contained in:
Michael Weimann
2022-11-23 17:24:36 +01:00
committed by GitHub
parent c1d4abbeb0
commit cbf5c43ae7
20 changed files with 104 additions and 95 deletions

View File

@@ -17,13 +17,14 @@ limitations under the License.
// Parse the given window.location and return parameters that can be used when calling
// MatrixChat.showScreen(screen, params)
import { logger } from "matrix-js-sdk/src/logger";
import { QueryDict } from "matrix-js-sdk/src/utils";
import MatrixChatType from "matrix-react-sdk/src/components/structures/MatrixChat";
import { parseQsFromFragment } from "./url_utils";
let lastLocationHashSet: string = null;
export function getScreenFromLocation(location: Location) {
export function getScreenFromLocation(location: Location): { screen: string, params: QueryDict } {
const fragparts = parseQsFromFragment(location);
return {
screen: fragparts.location.substring(1),
@@ -33,7 +34,7 @@ export function getScreenFromLocation(location: Location) {
// Here, we do some crude URL analysis to allow
// deep-linking.
function routeUrl(location: Location) {
function routeUrl(location: Location): void {
if (!window.matrixChat) return;
logger.log("Routing URL ", location.href);
@@ -41,7 +42,7 @@ function routeUrl(location: Location) {
(window.matrixChat as MatrixChatType).showScreen(s.screen, s.params);
}
function onHashChange() {
function onHashChange(): void {
if (decodeURIComponent(window.location.hash) === lastLocationHashSet) {
// we just set this: no need to route it!
return;
@@ -51,7 +52,7 @@ function onHashChange() {
// This will be called whenever the SDK changes screens,
// so a web page can update the URL bar appropriately.
export function onNewScreen(screen: string, replaceLast = false) {
export function onNewScreen(screen: string, replaceLast = false): void {
logger.log("newscreen " + screen);
const hash = '#/' + screen;
lastLocationHashSet = hash;
@@ -71,6 +72,6 @@ export function onNewScreen(screen: string, replaceLast = false) {
}
}
export function init() {
export function init(): void {
window.addEventListener('hashchange', onHashChange);
}