1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

Auto-fix lint errors

This commit is contained in:
J. Ryan Stinnett
2021-06-29 13:11:58 +01:00
parent 4c5720a573
commit ae0a8b8da4
625 changed files with 3170 additions and 3232 deletions

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {TextEncoder} from "util";
import { TextEncoder } from "util";
import nodeCrypto from "crypto";
import { Crypto } from "@peculiar/webcrypto";
@@ -144,7 +144,7 @@ cissyYBxjsfsAn
const password = 'my super secret passphrase';
return MegolmExportEncryption.encryptMegolmKeyFile(
input, password, {kdf_rounds: 1000},
input, password, { kdf_rounds: 1000 },
).then((ciphertext) => {
return MegolmExportEncryption.decryptMegolmKeyFile(
ciphertext, password,

View File

@@ -54,7 +54,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
const client = mkClient(trusted);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@FF1:h", "@FF2:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@FF1:h", "@FF2:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual("normal");
@@ -67,7 +67,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
const client = mkClient(trusted);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@TT2:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@TT2:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);
@@ -80,7 +80,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
const client = mkClient(trusted);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@FF2:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@FF2:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);
@@ -93,7 +93,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
const client = mkClient(trusted);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);
@@ -106,7 +106,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
const client = mkClient(trusted);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@TT:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@TT:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);
@@ -119,7 +119,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
const client = mkClient(trusted);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);
@@ -139,7 +139,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
const client = mkClient(true);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);
@@ -151,7 +151,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
const client = mkClient(true);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h", "@TT:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h", "@TT:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);
@@ -163,7 +163,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
const client = mkClient(true);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h", "@FT:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h", "@FT:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);
@@ -175,7 +175,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
const client = mkClient(true);
const room = {
roomId: dm ? "DM" : "other",
getEncryptionTargetMembers: () => ["@self:localhost", "@WF:h", "@FT:h"].map((userId) => ({userId})),
getEncryptionTargetMembers: () => ["@self:localhost", "@WF:h", "@FT:h"].map((userId) => ({ userId })),
};
const status = await shieldStatusForRoom(client, room);
expect(status).toEqual(result);

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {Singleflight} from "../../src/utils/Singleflight";
import { Singleflight } from "../../src/utils/Singleflight";
describe('Singleflight', () => {
afterEach(() => {

View File

@@ -29,7 +29,7 @@ import {
ArrayUtil,
GroupedArray,
} from "../../src/utils/arrays";
import {objectFromEntries} from "../../src/utils/objects";
import { objectFromEntries } from "../../src/utils/objects";
function expectSample(i: number, input: number[], expected: number[], smooth = false) {
console.log(`Resample case index: ${i}`); // for debugging test failures
@@ -43,26 +43,26 @@ describe('arrays', () => {
describe('arrayFastResample', () => {
it('should downsample', () => {
[
{input: [1, 2, 3, 4, 5], output: [1, 4]}, // Odd -> Even
{input: [1, 2, 3, 4, 5], output: [1, 3, 5]}, // Odd -> Odd
{input: [1, 2, 3, 4], output: [1, 2, 3]}, // Even -> Odd
{input: [1, 2, 3, 4], output: [1, 3]}, // Even -> Even
{ input: [1, 2, 3, 4, 5], output: [1, 4] }, // Odd -> Even
{ input: [1, 2, 3, 4, 5], output: [1, 3, 5] }, // Odd -> Odd
{ input: [1, 2, 3, 4], output: [1, 2, 3] }, // Even -> Odd
{ input: [1, 2, 3, 4], output: [1, 3] }, // Even -> Even
].forEach((c, i) => expectSample(i, c.input, c.output));
});
it('should upsample', () => {
[
{input: [1, 2, 3], output: [1, 1, 2, 2, 3, 3]}, // Odd -> Even
{input: [1, 2, 3], output: [1, 1, 2, 2, 3]}, // Odd -> Odd
{input: [1, 2], output: [1, 1, 1, 2, 2]}, // Even -> Odd
{input: [1, 2], output: [1, 1, 1, 2, 2, 2]}, // Even -> Even
{ input: [1, 2, 3], output: [1, 1, 2, 2, 3, 3] }, // Odd -> Even
{ input: [1, 2, 3], output: [1, 1, 2, 2, 3] }, // Odd -> Odd
{ input: [1, 2], output: [1, 1, 1, 2, 2] }, // Even -> Odd
{ input: [1, 2], output: [1, 1, 1, 2, 2, 2] }, // Even -> Even
].forEach((c, i) => expectSample(i, c.input, c.output));
});
it('should maintain sample', () => {
[
{input: [1, 2, 3], output: [1, 2, 3]}, // Odd
{input: [1, 2], output: [1, 2]}, // Even
{ input: [1, 2, 3], output: [1, 2, 3] }, // Odd
{ input: [1, 2], output: [1, 2] }, // Even
].forEach((c, i) => expectSample(i, c.input, c.output));
});
});
@@ -73,26 +73,26 @@ describe('arrays', () => {
// we'd be feeding a thousand values in and seeing what a curve of 250 values looks like,
// but that's not really feasible to manually verify accuracy.
[
{input: [4, 4, 1, 4, 4, 1, 4, 4, 1], output: [3, 3, 3, 3]}, // Odd -> Even
{input: [4, 4, 1, 4, 4, 1, 4, 4, 1], output: [3, 3, 3]}, // Odd -> Odd
{input: [4, 4, 1, 4, 4, 1, 4, 4], output: [3, 3, 3]}, // Even -> Odd
{input: [4, 4, 1, 4, 4, 1, 4, 4], output: [3, 3]}, // Even -> Even
{ input: [4, 4, 1, 4, 4, 1, 4, 4, 1], output: [3, 3, 3, 3] }, // Odd -> Even
{ input: [4, 4, 1, 4, 4, 1, 4, 4, 1], output: [3, 3, 3] }, // Odd -> Odd
{ input: [4, 4, 1, 4, 4, 1, 4, 4], output: [3, 3, 3] }, // Even -> Odd
{ input: [4, 4, 1, 4, 4, 1, 4, 4], output: [3, 3] }, // Even -> Even
].forEach((c, i) => expectSample(i, c.input, c.output, true));
});
it('should upsample', () => {
[
{input: [2, 0, 2], output: [2, 2, 0, 0, 2, 2]}, // Odd -> Even
{input: [2, 0, 2], output: [2, 2, 0, 0, 2]}, // Odd -> Odd
{input: [2, 0], output: [2, 2, 2, 0, 0]}, // Even -> Odd
{input: [2, 0], output: [2, 2, 2, 0, 0, 0]}, // Even -> Even
{ input: [2, 0, 2], output: [2, 2, 0, 0, 2, 2] }, // Odd -> Even
{ input: [2, 0, 2], output: [2, 2, 0, 0, 2] }, // Odd -> Odd
{ input: [2, 0], output: [2, 2, 2, 0, 0] }, // Even -> Odd
{ input: [2, 0], output: [2, 2, 2, 0, 0, 0] }, // Even -> Even
].forEach((c, i) => expectSample(i, c.input, c.output, true));
});
it('should maintain sample', () => {
[
{input: [2, 0, 2], output: [2, 0, 2]}, // Odd
{input: [2, 0], output: [2, 0]}, // Even
{ input: [2, 0, 2], output: [2, 0, 2] }, // Odd
{ input: [2, 0], output: [2, 0] }, // Even
].forEach((c, i) => expectSample(i, c.input, c.output, true));
});
});

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {getEnumValues, isEnumValue} from "../../src/utils/enums";
import { getEnumValues, isEnumValue } from "../../src/utils/enums";
enum TestStringEnum {
First = "__first__",

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {iterableDiff, iterableUnion} from "../../src/utils/iterables";
import { iterableDiff, iterableUnion } from "../../src/utils/iterables";
describe('iterables', () => {
describe('iterableUnion', () => {

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {EnhancedMap, mapDiff, mapKeyChanges} from "../../src/utils/maps";
import { EnhancedMap, mapDiff, mapKeyChanges } from "../../src/utils/maps";
describe('maps', () => {
describe('mapDiff', () => {
@@ -187,7 +187,7 @@ describe('maps', () => {
});
it('should use the provided entries', () => {
const obj = {a: 1, b: 2};
const obj = { a: 1, b: 2 };
const result = new EnhancedMap(Object.entries(obj));
expect(result.size).toBe(2);
expect(result.get('a')).toBe(1);

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {clamp, defaultNumber, percentageOf, percentageWithin, sum} from "../../src/utils/numbers";
import { clamp, defaultNumber, percentageOf, percentageWithin, sum } from "../../src/utils/numbers";
describe('numbers', () => {
describe('defaultNumber', () => {

View File

@@ -28,8 +28,8 @@ import {
describe('objects', () => {
describe('objectExcluding', () => {
it('should exclude the given properties', () => {
const input = {hello: "world", test: true};
const output = {hello: "world"};
const input = { hello: "world", test: true };
const output = { hello: "world" };
const props = ["test", "doesnotexist"]; // we also make sure it doesn't explode on missing props
const result = objectExcluding(input, <any>props); // any is to test the missing prop
expect(result).toBeDefined();
@@ -39,8 +39,8 @@ describe('objects', () => {
describe('objectWithOnly', () => {
it('should exclusively use the given properties', () => {
const input = {hello: "world", test: true};
const output = {hello: "world"};
const input = { hello: "world", test: true };
const output = { hello: "world" };
const props = ["hello", "doesnotexist"]; // we also make sure it doesn't explode on missing props
const result = objectWithOnly(input, <any>props); // any is to test the missing prop
expect(result).toBeDefined();
@@ -50,7 +50,7 @@ describe('objects', () => {
describe('objectShallowClone', () => {
it('should create a new object', () => {
const input = {test: 1};
const input = { test: 1 };
const result = objectShallowClone(input);
expect(result).toBeDefined();
expect(result).not.toBe(input);
@@ -58,7 +58,7 @@ describe('objects', () => {
});
it('should only clone the top level properties', () => {
const input = {a: 1, b: {c: 2}};
const input = { a: 1, b: { c: 2 } };
const result = objectShallowClone(input);
expect(result).toBeDefined();
expect(result).toMatchObject(input);
@@ -66,8 +66,8 @@ describe('objects', () => {
});
it('should support custom clone functions', () => {
const input = {a: 1, b: 2};
const output = {a: 4, b: 8};
const input = { a: 1, b: 2 };
const output = { a: 4, b: 8 };
const result = objectShallowClone(input, (k, v) => {
// XXX: inverted expectation for ease of assertion
expect(Object.keys(input)).toContain(k);
@@ -87,29 +87,29 @@ describe('objects', () => {
});
it('should return true if keys for A > keys for B', () => {
const a = {a: 1, b: 2};
const b = {a: 1};
const a = { a: 1, b: 2 };
const b = { a: 1 };
const result = objectHasDiff(a, b);
expect(result).toBe(true);
});
it('should return true if keys for A < keys for B', () => {
const a = {a: 1};
const b = {a: 1, b: 2};
const a = { a: 1 };
const b = { a: 1, b: 2 };
const result = objectHasDiff(a, b);
expect(result).toBe(true);
});
it('should return false if the objects are the same but different pointers', () => {
const a = {a: 1, b: 2};
const b = {a: 1, b: 2};
const a = { a: 1, b: 2 };
const b = { a: 1, b: 2 };
const result = objectHasDiff(a, b);
expect(result).toBe(false);
});
it('should consider pointers when testing values', () => {
const a = {a: {}, b: 2}; // `{}` is shorthand for `new Object()`
const b = {a: {}, b: 2};
const a = { a: {}, b: 2 }; // `{}` is shorthand for `new Object()`
const b = { a: {}, b: 2 };
const result = objectHasDiff(a, b);
expect(result).toBe(true); // even though the keys are the same, the value pointers vary
});
@@ -117,8 +117,8 @@ describe('objects', () => {
describe('objectDiff', () => {
it('should return empty sets for the same object', () => {
const a = {a: 1, b: 2};
const b = {a: 1, b: 2};
const a = { a: 1, b: 2 };
const b = { a: 1, b: 2 };
const result = objectDiff(a, b);
expect(result).toBeDefined();
expect(result.changed).toBeDefined();
@@ -130,7 +130,7 @@ describe('objects', () => {
});
it('should return empty sets for the same object pointer', () => {
const a = {a: 1, b: 2};
const a = { a: 1, b: 2 };
const result = objectDiff(a, a);
expect(result).toBeDefined();
expect(result.changed).toBeDefined();
@@ -142,8 +142,8 @@ describe('objects', () => {
});
it('should indicate when property changes are made', () => {
const a = {a: 1, b: 2};
const b = {a: 11, b: 2};
const a = { a: 1, b: 2 };
const b = { a: 11, b: 2 };
const result = objectDiff(a, b);
expect(result.changed).toBeDefined();
expect(result.added).toBeDefined();
@@ -155,8 +155,8 @@ describe('objects', () => {
});
it('should indicate when properties are added', () => {
const a = {a: 1, b: 2};
const b = {a: 1, b: 2, c: 3};
const a = { a: 1, b: 2 };
const b = { a: 1, b: 2, c: 3 };
const result = objectDiff(a, b);
expect(result.changed).toBeDefined();
expect(result.added).toBeDefined();
@@ -168,8 +168,8 @@ describe('objects', () => {
});
it('should indicate when properties are removed', () => {
const a = {a: 1, b: 2};
const b = {a: 1};
const a = { a: 1, b: 2 };
const b = { a: 1 };
const result = objectDiff(a, b);
expect(result.changed).toBeDefined();
expect(result.added).toBeDefined();
@@ -181,8 +181,8 @@ describe('objects', () => {
});
it('should indicate when multiple aspects change', () => {
const a = {a: 1, b: 2, c: 3};
const b: (typeof a | {d: number}) = {a: 1, b: 22, d: 4};
const a = { a: 1, b: 2, c: 3 };
const b: (typeof a | {d: number}) = { a: 1, b: 22, d: 4 };
const result = objectDiff(a, b);
expect(result.changed).toBeDefined();
expect(result.added).toBeDefined();
@@ -198,23 +198,23 @@ describe('objects', () => {
describe('objectKeyChanges', () => {
it('should return an empty set if no properties changed', () => {
const a = {a: 1, b: 2};
const b = {a: 1, b: 2};
const a = { a: 1, b: 2 };
const b = { a: 1, b: 2 };
const result = objectKeyChanges(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(0);
});
it('should return an empty set if no properties changed for the same pointer', () => {
const a = {a: 1, b: 2};
const a = { a: 1, b: 2 };
const result = objectKeyChanges(a, a);
expect(result).toBeDefined();
expect(result).toHaveLength(0);
});
it('should return properties which were changed, added, or removed', () => {
const a = {a: 1, b: 2, c: 3};
const b: (typeof a | {d: number}) = {a: 1, b: 22, d: 4};
const a = { a: 1, b: 2, c: 3 };
const b: (typeof a | {d: number}) = { a: 1, b: 22, d: 4 };
const result = objectKeyChanges(a, b);
expect(result).toBeDefined();
expect(result).toHaveLength(3);
@@ -245,14 +245,14 @@ describe('objects', () => {
describe('objectFromEntries', () => {
it('should create an object from an array of entries', () => {
const output = {a: 1, b: 2, c: 3};
const output = { a: 1, b: 2, c: 3 };
const result = objectFromEntries(Object.entries(output));
expect(result).toBeDefined();
expect(result).toMatchObject(output);
});
it('should maintain pointers in values', () => {
const output = {a: {}, b: 2, c: 3};
const output = { a: {}, b: 2, c: 3 };
const result = objectFromEntries(Object.entries(output));
expect(result).toBeDefined();
expect(result).toMatchObject(output);

View File

@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {MatrixClientPeg as peg} from '../../../src/MatrixClientPeg';
import { MatrixClientPeg as peg } from '../../../src/MatrixClientPeg';
import {
makeGroupPermalink,
makeRoomPermalink,
@@ -48,7 +48,7 @@ function mockRoom(roomId, members, serverACL) {
content = serverACL;
break;
case "m.room.power_levels":
content = {users: powerLevelsUsers, users_default: 0};
content = { users: powerLevelsUsers, users_default: 0 };
break;
}
if (content) {

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {setHasDiff} from "../../src/utils/sets";
import { setHasDiff } from "../../src/utils/sets";
describe('sets', () => {
describe('setHasDiff', () => {