mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
chore: fix leftover eslint exceptions
This commit is contained in:
@@ -20,7 +20,6 @@ function createTestCollection(): TestCollection {
|
||||
function expectInvalidFunctionError(cb: () => unknown, val?: unknown): void {
|
||||
expect(() => {
|
||||
cb();
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
}).toThrowError(new TypeError(`${val} is not a function`));
|
||||
}
|
||||
|
||||
@@ -133,9 +132,9 @@ describe('each() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.each());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.each(123), 123);
|
||||
});
|
||||
|
||||
@@ -154,7 +153,7 @@ describe('each() tests', () => {
|
||||
describe('ensure() tests', () => {
|
||||
test('throws if defaultValueGenerator is not a function', () => {
|
||||
const coll = createTestCollection();
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.ensure('d', 'abc'), 'abc');
|
||||
});
|
||||
|
||||
@@ -178,7 +177,7 @@ describe('equals() tests', () => {
|
||||
const coll2 = createTestCollection();
|
||||
|
||||
test('returns false if no collection is passed', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expect(coll1.equals()).toBeFalsy();
|
||||
});
|
||||
|
||||
@@ -200,9 +199,9 @@ describe('every() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.every());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.every(123), 123);
|
||||
});
|
||||
|
||||
@@ -226,9 +225,9 @@ describe('filter() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.filter());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.filter(123), 123);
|
||||
});
|
||||
|
||||
@@ -253,9 +252,9 @@ describe('find() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => createCollection().find());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => createCollection().find(123), 123);
|
||||
});
|
||||
|
||||
@@ -277,9 +276,9 @@ describe('findKey() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.findKey());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.findKey(123), 123);
|
||||
});
|
||||
|
||||
@@ -508,9 +507,9 @@ describe('map() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.map());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.map(123), 123);
|
||||
});
|
||||
|
||||
@@ -531,9 +530,9 @@ describe('mapValues() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.mapValues());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.mapValues(123), 123);
|
||||
});
|
||||
|
||||
@@ -608,9 +607,9 @@ describe('partition() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.partition());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.partition(123), 123);
|
||||
});
|
||||
|
||||
@@ -692,9 +691,9 @@ describe('reduce() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.reduce());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.reduce(123), 123);
|
||||
});
|
||||
|
||||
@@ -731,9 +730,9 @@ describe('some() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.some());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.some(123), 123);
|
||||
});
|
||||
|
||||
@@ -775,9 +774,9 @@ describe('sweep() test', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.sweep());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.sweep(123), 123);
|
||||
});
|
||||
|
||||
@@ -802,9 +801,9 @@ describe('tap() tests', () => {
|
||||
const coll = createTestCollection();
|
||||
|
||||
test('throws if fn is not a function', () => {
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.tap());
|
||||
// @ts-expect-error: invalid function
|
||||
// @ts-expect-error: Invalid function
|
||||
expectInvalidFunctionError(() => coll.tap(123), 123);
|
||||
});
|
||||
|
||||
|
||||
@@ -85,12 +85,10 @@ export class Collection<K, V> extends Map<K, V> {
|
||||
public first(): V | undefined;
|
||||
public first(amount: number): V[];
|
||||
public first(amount?: number): V | V[] | undefined {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
if (typeof amount === 'undefined') return this.values().next().value;
|
||||
if (amount < 0) return this.last(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.values();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return Array.from({ length: amount }, (): V => iter.next().value);
|
||||
}
|
||||
|
||||
@@ -104,12 +102,10 @@ export class Collection<K, V> extends Map<K, V> {
|
||||
public firstKey(): K | undefined;
|
||||
public firstKey(amount: number): K[];
|
||||
public firstKey(amount?: number): K | K[] | undefined {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
if (typeof amount === 'undefined') return this.keys().next().value;
|
||||
if (amount < 0) return this.lastKey(amount * -1);
|
||||
amount = Math.min(this.size, amount);
|
||||
const iter = this.keys();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return Array.from({ length: amount }, (): K => iter.next().value);
|
||||
}
|
||||
|
||||
@@ -426,9 +422,7 @@ export class Collection<K, V> extends Map<K, V> {
|
||||
if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg);
|
||||
const iter = this.entries();
|
||||
return Array.from({ length: this.size }, (): T => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const [key, value] = iter.next().value;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
return fn(value, key, this);
|
||||
});
|
||||
}
|
||||
@@ -636,7 +630,6 @@ export class Collection<K, V> extends Map<K, V> {
|
||||
* @returns Whether the collections have identical contents
|
||||
*/
|
||||
public equals(collection: ReadonlyCollection<K, V>) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (!collection) return false; // runtime check
|
||||
if (this === collection) return true;
|
||||
if (this.size !== collection.size) return false;
|
||||
|
||||
Reference in New Issue
Block a user