1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Update eslint-plugin-matrix-org and improve visibilities & types (#2887)

This commit is contained in:
Michael Telatynski
2022-11-18 09:20:53 +00:00
committed by GitHub
parent e085609572
commit c0f7df8c3b
88 changed files with 486 additions and 456 deletions

View File

@@ -178,7 +178,7 @@ export function removeElement<T>(
* @param {*} value The thing to check.
* @return {boolean} True if it is a function.
*/
export function isFunction(value: any) {
export function isFunction(value: any): boolean {
return Object.prototype.toString.call(value) === "[object Function]";
}
@@ -189,7 +189,7 @@ export function isFunction(value: any) {
* @throws If the object is missing keys.
*/
// note using 'keys' here would shadow the 'keys' function defined above
export function checkObjectHasKeys(obj: object, keys: string[]) {
export function checkObjectHasKeys(obj: object, keys: string[]): void {
for (const key of keys) {
if (!obj.hasOwnProperty(key)) {
throw new Error("Missing required key: " + key);
@@ -383,7 +383,7 @@ export function globToRegexp(glob: string, extended = false): string {
if (!extended) {
replacements.push([
/\\\[(!|)(.*)\\]/g,
(_match: string, neg: string, pat: string) => [
(_match: string, neg: string, pat: string): string => [
'[',
neg ? '^' : '',
pat.replace(/\\-/, '-'),
@@ -490,7 +490,7 @@ export function simpleRetryOperation<T>(promiseFn: (attempt: number) => Promise<
* The default alphabet used by string averaging in this SDK. This matches
* all usefully printable ASCII characters (0x20-0x7E, inclusive).
*/
export const DEFAULT_ALPHABET = (() => {
export const DEFAULT_ALPHABET = ((): string => {
let str = "";
for (let c = 0x20; c <= 0x7E; c++) {
str += String.fromCharCode(c);