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

Revert quotes change in ts

This commit is contained in:
Jorik Schellekens
2020-07-28 14:16:40 +01:00
parent 8a974172ab
commit a9c3aee447
6 changed files with 64 additions and 62 deletions

View File

@@ -31,11 +31,12 @@ module.exports = {
"no-async-promise-executor": "off", "no-async-promise-executor": "off",
}, },
overrides: [{ overrides: [{
files: ["src/**/*.{ts, tsx}"], "files": ["src/**/*.{ts, tsx}"],
"extends": ["matrix-org/ts"], "extends": ["matrix-org/ts"],
"rules": { "rules": {
// While we're converting to ts we make heavy use of this // While we're converting to ts we make heavy use of this
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
} "quotes": "off",
},
}], }],
} };

View File

@@ -14,7 +14,7 @@
"build:minify-browser": "terser dist/browser-matrix.js --compress --mangle --source-map --output dist/browser-matrix.min.js", "build:minify-browser": "terser dist/browser-matrix.js --compress --mangle --source-map --output dist/browser-matrix.min.js",
"gendoc": "jsdoc -c jsdoc.json -P package.json", "gendoc": "jsdoc -c jsdoc.json -P package.json",
"lint": "yarn lint:types && yarn lint:js", "lint": "yarn lint:types && yarn lint:js",
"lint:js": "eslint --max-warnings 76 src spec --fix", "lint:js": "eslint --max-warnings 76 src spec",
"lint:types": "tsc --noEmit", "lint:types": "tsc --noEmit",
"test": "jest spec/ --coverage --testEnvironment node", "test": "jest spec/ --coverage --testEnvironment node",
"test:watch": "jest spec/ --coverage --testEnvironment node --watch" "test:watch": "jest spec/ --coverage --testEnvironment node --watch"

View File

@@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import * as matrixcs from './matrix'; import * as matrixcs from "./matrix";
import * as utils from './utils'; import * as utils from "./utils";
import request from 'request'; import request from "request";
matrixcs.request(request); matrixcs.request(request);
utils.runPolyfills(); utils.runPolyfills();
@@ -29,5 +29,5 @@ try {
console.log('nodejs was compiled without crypto support'); console.log('nodejs was compiled without crypto support');
} }
export * from './matrix'; export * from "./matrix";
export default matrixcs; export default matrixcs;

View File

@@ -16,49 +16,49 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import type Request from 'request'; import type Request from "request";
import {MemoryCryptoStore} from './crypto/store/memory-crypto-store'; import {MemoryCryptoStore} from "./crypto/store/memory-crypto-store";
import {LocalStorageCryptoStore} from './crypto/store/localStorage-crypto-store'; import {LocalStorageCryptoStore} from "./crypto/store/localStorage-crypto-store";
import {IndexedDBCryptoStore} from './crypto/store/indexeddb-crypto-store'; import {IndexedDBCryptoStore} from "./crypto/store/indexeddb-crypto-store";
import {MemoryStore} from './store/memory'; import {MemoryStore} from "./store/memory";
import {StubStore} from './store/stub'; import {StubStore} from "./store/stub";
import {LocalIndexedDBStoreBackend} from './store/indexeddb-local-backend'; import {LocalIndexedDBStoreBackend} from "./store/indexeddb-local-backend";
import {RemoteIndexedDBStoreBackend} from './store/indexeddb-remote-backend'; import {RemoteIndexedDBStoreBackend} from "./store/indexeddb-remote-backend";
import {MatrixScheduler} from './scheduler'; import {MatrixScheduler} from "./scheduler";
import {MatrixClient} from './client'; import {MatrixClient} from "./client";
export * from './client'; export * from "./client";
export * from './http-api'; export * from "./http-api";
export * from './autodiscovery'; export * from "./autodiscovery";
export * from './sync-accumulator'; export * from "./sync-accumulator";
export * from './errors'; export * from "./errors";
export * from './models/event'; export * from "./models/event";
export * from './models/room'; export * from "./models/room";
export * from './models/group'; export * from "./models/group";
export * from './models/event-timeline'; export * from "./models/event-timeline";
export * from './models/event-timeline-set'; export * from "./models/event-timeline-set";
export * from './models/room-member'; export * from "./models/room-member";
export * from './models/room-state'; export * from "./models/room-state";
export * from './models/user'; export * from "./models/user";
export * from './scheduler'; export * from "./scheduler";
export * from './filter'; export * from "./filter";
export * from './timeline-window'; export * from "./timeline-window";
export * from './interactive-auth'; export * from "./interactive-auth";
export * from './service-types'; export * from "./service-types";
export * from './store/memory'; export * from "./store/memory";
export * from './store/indexeddb'; export * from "./store/indexeddb";
export * from './store/session/webstorage'; export * from "./store/session/webstorage";
export * from './crypto/store/memory-crypto-store'; export * from "./crypto/store/memory-crypto-store";
export * from './crypto/store/indexeddb-crypto-store'; export * from "./crypto/store/indexeddb-crypto-store";
export * from './content-repo'; export * from "./content-repo";
export const ContentHelpers = import('./content-helpers'); export const ContentHelpers = import("./content-helpers");
export { export {
createNewMatrixCall, createNewMatrixCall,
setAudioOutput as setMatrixCallAudioOutput, setAudioOutput as setMatrixCallAudioOutput,
setAudioInput as setMatrixCallAudioInput, setAudioInput as setMatrixCallAudioInput,
setVideoInput as setMatrixCallVideoInput, setVideoInput as setMatrixCallVideoInput,
} from './webrtc/call'; } from "./webrtc/call";
// expose the underlying request object so different environments can use // expose the underlying request object so different environments can use
@@ -146,9 +146,9 @@ interface ICreateClientOpts {
* <code>opts</code>. * <code>opts</code>.
*/ */
export function createClient(opts: ICreateClientOpts | string) { export function createClient(opts: ICreateClientOpts | string) {
if (typeof opts === 'string') { if (typeof opts === "string") {
opts = { opts = {
'baseUrl': opts as string, "baseUrl": opts as string,
}; };
} }
opts.request = opts.request || requestInstance; opts.request = opts.request || requestInstance;

View File

@@ -16,8 +16,8 @@ limitations under the License.
*/ */
export function randomString(len: number): string { export function randomString(len: number): string {
let ret = ''; let ret = "";
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < len; ++i) { for (let i = 0; i < len; ++i) {
ret += chars.charAt(Math.floor(Math.random() * chars.length)); ret += chars.charAt(Math.floor(Math.random() * chars.length));

View File

@@ -20,9 +20,6 @@ limitations under the License.
* @module utils * @module utils
*/ */
// We do some funky stuff in this module
/* eslint-disable no-extend-native */
import unhomoglyph from 'unhomoglyph'; import unhomoglyph from 'unhomoglyph';
/** /**
@@ -32,12 +29,12 @@ import unhomoglyph from 'unhomoglyph';
* @return {string} The encoded string e.g. foo=bar&baz=taz * @return {string} The encoded string e.g. foo=bar&baz=taz
*/ */
export function encodeParams(params: Record<string, string>): string { export function encodeParams(params: Record<string, string>): string {
let qs = ''; let qs = "";
for (const key in params) { for (const key in params) {
if (!params.hasOwnProperty(key)) { if (!params.hasOwnProperty(key)) {
continue; continue;
} }
qs += '&' + encodeURIComponent(key) + '=' + qs += "&" + encodeURIComponent(key) + "=" +
encodeURIComponent(params[key]); encodeURIComponent(params[key]);
} }
return qs.substring(1); return qs.substring(1);
@@ -217,7 +214,7 @@ export function removeElement<T>(
* @return {boolean} True if it is a function. * @return {boolean} True if it is a function.
*/ */
export function isFunction(value: any) { export function isFunction(value: any) {
return Object.prototype.toString.call(value) === '[object Function]'; return Object.prototype.toString.call(value) === "[object Function]";
} }
/** /**
@@ -240,7 +237,7 @@ export function isArray(value: any) {
export function checkObjectHasKeys(obj: object, keys_: string[]) { export function checkObjectHasKeys(obj: object, keys_: string[]) {
for (let i = 0; i < keys_.length; i++) { for (let i = 0; i < keys_.length; i++) {
if (!obj.hasOwnProperty(keys_[i])) { if (!obj.hasOwnProperty(keys_[i])) {
throw new Error('Missing required key: ' + keys_[i]); throw new Error("Missing required key: " + keys_[i]);
} }
} }
} }
@@ -257,7 +254,7 @@ export function checkObjectHasNoAdditionalKeys(obj: object, allowedKeys: string[
continue; continue;
} }
if (allowedKeys.indexOf(key) === -1) { if (allowedKeys.indexOf(key) === -1) {
throw new Error('Unknown key: ' + key); throw new Error("Unknown key: " + key);
} }
} }
} }
@@ -392,6 +389,7 @@ export function runPolyfills() {
// SOURCE: // SOURCE:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
if (!Array.prototype.filter) { if (!Array.prototype.filter) {
// eslint-disable-next-line no-extend-native
Array.prototype.filter = function(fun: Function/*, thisArg*/, ...restProps) { Array.prototype.filter = function(fun: Function/*, thisArg*/, ...restProps) {
if (this === void 0 || this === null) { if (this === void 0 || this === null) {
throw new TypeError(); throw new TypeError();
@@ -419,7 +417,6 @@ export function runPolyfills() {
} }
} }
} }
return res; return res;
}; };
} }
@@ -431,8 +428,10 @@ export function runPolyfills() {
// Production steps of ECMA-262, Edition 5, 15.4.4.19 // Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.io/#x15.4.4.19 // Reference: http://es5.github.io/#x15.4.4.19
if (!Array.prototype.map) { if (!Array.prototype.map) {
// eslint-disable-next-line no-extend-native
Array.prototype.map = function(callback, thisArg) { Array.prototype.map = function(callback, thisArg) {
let T; let k; let T;
let k;
if (this === null || this === undefined) { if (this === null || this === undefined) {
throw new TypeError(' this is null or not defined'); throw new TypeError(' this is null or not defined');
@@ -521,8 +520,10 @@ export function runPolyfills() {
// Production steps of ECMA-262, Edition 5, 15.4.4.18 // Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18 // Reference: http://es5.github.io/#x15.4.4.18
if (!Array.prototype.forEach) { if (!Array.prototype.forEach) {
// eslint-disable-next-line no-extend-native
Array.prototype.forEach = function(callback, thisArg) { Array.prototype.forEach = function(callback, thisArg) {
let T; let k; let T;
let k;
if (this === null || this === undefined) { if (this === null || this === undefined) {
throw new TypeError(' this is null or not defined'); throw new TypeError(' this is null or not defined');
@@ -539,7 +540,7 @@ export function runPolyfills() {
// 4. If IsCallable(callback) is false, throw a TypeError exception. // 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11 // See: http://es5.github.com/#x9.11
if (typeof callback !== 'function') { if (typeof callback !== "function") {
throw new TypeError(callback + ' is not a function'); throw new TypeError(callback + ' is not a function');
} }
@@ -673,7 +674,7 @@ export function removeHiddenChars(str: string): string {
const removeHiddenCharsRegex = /[\u2000-\u200F\u202A-\u202F\u0300-\u036f\uFEFF\s]/g; const removeHiddenCharsRegex = /[\u2000-\u200F\u202A-\u202F\u0300-\u036f\uFEFF\s]/g;
export function escapeRegExp(string: string): string { export function escapeRegExp(string: string): string {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
} }
export function globToRegexp(glob: string, extended: any): string { export function globToRegexp(glob: string, extended: any): string {
@@ -696,7 +697,7 @@ export function globToRegexp(glob: string, extended: any): string {
} }
export function ensureNoTrailingSlash(url: string): string { export function ensureNoTrailingSlash(url: string): string {
if (url && url.endsWith('/')) { if (url && url.endsWith("/")) {
return url.substr(0, url.length - 1); return url.substr(0, url.length - 1);
} else { } else {
return url; return url;