Skip to content

Commit

Permalink
style: Fix style for some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
raon0211 committed Sep 14, 2024
1 parent 8b07ec7 commit a010748
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 10 deletions.
1 change: 1 addition & 0 deletions .scripts/docs/formatters/nodes/decorator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DecoratorDef } from "@deno/doc";
import { FormatOption } from "../options.ts";

// eslint-disable-next-line
export function formatDecorator(node: DecoratorDef, _: FormatOption) {
let result = "";

Expand Down
1 change: 1 addition & 0 deletions .scripts/docs/generate-docs.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { DocumentationItem } from "./types/DocumentationItem.ts";
import { Locale } from "./types/Locale.ts";
import { RenderOptions } from "./operations/render/types.ts";

// eslint-disable-next-line
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const basePath = path.resolve(__dirname, "..", "..", "src");
Expand Down
2 changes: 1 addition & 1 deletion src/array/unzip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* const result = unzip(zipped);
* // result will be [['a', 'b'], [true, false], [1, 2]]
*/
export function unzip<T extends unknown[]>(zipped: readonly [...T][]): Unzip<T> {
export function unzip<T extends unknown[]>(zipped: ReadonlyArray<[...T]>): Unzip<T> {
// For performance reasons, use this implementation instead of
// const maxLen = Math.max(...zipped.map(arr => arr.length));
let maxLen = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/compat/array/findLastIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export function findLastIndex<T>(arr: readonly T[], propertyToCheck: string, fro
* @template T
* @param {readonly T[]} arr - The array to search through.
* @param {string} propertyToCheck - The property name to check.
* @param source
* @param doesMatch
* @param {number} [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.
* @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.
*
Expand Down
1 change: 1 addition & 0 deletions src/compat/array/some.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('some', () => {
});

it('should use `_.identity` when `predicate` is nullish', () => {
// eslint-disable-next-line
const values = [, null, undefined];
let expected = values.map(stubFalse);

Expand Down
1 change: 1 addition & 0 deletions src/compat/array/some.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export function some<T>(
* @param {T[]} arr The array to iterate over.
* @param {((item: T, index: number, arr: any) => unknown) | Partial<T> | [keyof T, unknown] | string} [predicate=identity] The function invoked per iteration.
* If a property name or an object is provided it will be used to create a predicate function.
* @param guard
* @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.
*
* @example
Expand Down
2 changes: 1 addition & 1 deletion src/compat/math/parseInt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* ['6', '08', '10'].map(parseInt); // => [6, 8, 10]
*/
export function parseInt(string: string, radix: number = 0, guard?: unknown): number {
export function parseInt(string: string, radix = 0, guard?: unknown): number {
if (guard) {
radix = 0;
}
Expand Down
14 changes: 10 additions & 4 deletions src/compat/object/omit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ export function omit<T extends Record<string, any>, K extends keyof T>(obj: T, k
* @param {...(PropertyKey | PropertyKey[] | PropertyKey[][]} keys - A variable number of keys to be omitted from the object.
* @returns {Partial<T>} A new object with the specified keys omitted.
*/
export function omit<T extends {}>(
export function omit<
// eslint-disable-next-line
T extends {},
>(
obj: T | null | undefined,
...keys: Array<PropertyKey | readonly PropertyKey[] | readonly (readonly PropertyKey[])[]>
...keys: Array<PropertyKey | readonly PropertyKey[] | ReadonlyArray<readonly PropertyKey[]>>
): Partial<T>;

/**
Expand All @@ -51,9 +54,12 @@ export function omit<T extends {}>(
* @param {...(PropertyKey | PropertyKey[] | PropertyKey[][])} keysArr - A variable number of keys to be omitted from the object.
* @returns {Partial<T>} A new object with the specified keys omitted.
*/
export function omit<T extends {}>(
export function omit<
// eslint-disable-next-line
T extends {},
>(
obj: T | null | undefined,
...keysArr: Array<PropertyKey | readonly PropertyKey[] | readonly (readonly PropertyKey[])[]>
...keysArr: Array<PropertyKey | readonly PropertyKey[] | ReadonlyArray<readonly PropertyKey[]>>
): Partial<T> {
if (obj == null) {
return {};
Expand Down
16 changes: 12 additions & 4 deletions src/compat/object/pick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function pick<T extends Record<string, any>, K extends keyof T>(obj: T, k
*
* @template T - The type of object.
* @param {T | null | undefined} obj - The object to pick keys from.
* @param {...any} keys
* @param {PropertyKey | PropertyKey[] | ProperyKey[][]}} keys - An array of keys to be picked from the object. received keysgoes through a flattening process before being used.
* @returns {Partial<T, K>} A new object with the specified keys picked.
*
Expand All @@ -46,9 +47,12 @@ export function pick<T extends Record<string, any>, K extends keyof T>(obj: T, k
* const result = pick(obj, 'a.b');
* // result will be { 'a.b': 1 }
*/
export function pick<T extends {}>(
export function pick<
// eslint-disable-next-line
T extends {},
>(
obj: T | null | undefined,
...keys: Array<PropertyKey | readonly PropertyKey[] | readonly (readonly PropertyKey[])[]>
...keys: Array<PropertyKey | readonly PropertyKey[] | ReadonlyArray<readonly PropertyKey[]>>
): Partial<T>;

/**
Expand All @@ -59,6 +63,7 @@ export function pick<T extends {}>(
*
* @template T - The type of object.
* @param {T | null | undefined} obj - The object to pick keys from.
* @param {...any} keysArr
* @param {PropertyKey | PropertyKey[] | ProperyKey[][]}} keys - An array of keys to be picked from the object. received keysgoes through a flattening process before being used.
* @returns {Partial<T, K>} A new object with the specified keys picked.
*
Expand All @@ -76,9 +81,12 @@ export function pick<T extends {}>(
* const result = pick(obj, 'a.b');
* // result will be { 'a.b': 1 }
*/
export function pick<T extends {}>(
export function pick<
// eslint-disable-next-line
T extends {},
>(
obj: T | null | undefined,
...keysArr: Array<PropertyKey | readonly PropertyKey[] | readonly (readonly PropertyKey[])[]>
...keysArr: Array<PropertyKey | readonly PropertyKey[] | ReadonlyArray<readonly PropertyKey[]>>
): Partial<T> {
if (isNil(obj)) {
return {};
Expand Down
2 changes: 2 additions & 0 deletions src/compat/predicate/conforms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('conforms', () => {
});

it(`\`conforms\` should return \`false\` when \`object\` is nullish`, () => {
// eslint-disable-next-line
const values = [, null, undefined];
const expected = values.map(() => false);

Expand All @@ -124,6 +125,7 @@ describe('conforms', () => {
});

it(`\`conforms\` should return \`true\` when comparing an empty \`source\` to a nullish \`object\``, () => {
// eslint-disable-next-line
const values = [, null, undefined];
const expected = values.map(() => true);
const par = conforms({});
Expand Down
2 changes: 2 additions & 0 deletions src/compat/predicate/conformsTo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ describe('conformsTo', () => {
});

it(`\`conformsTo\` should return \`false\` when \`object\` is nullish`, () => {
// eslint-disable-next-line
const values = [, null, undefined];
const expected = values.map(() => false);

Expand All @@ -130,6 +131,7 @@ describe('conformsTo', () => {
});

it(`\`conformsTo\` should return \`true\` when comparing an empty \`source\` to a nullish \`object\``, () => {
// eslint-disable-next-line
const values = [, null, undefined];
const expected = values.map(() => true);
const par = conforms({});
Expand Down
2 changes: 2 additions & 0 deletions src/compat/string/trim.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('trim', () => {
};
const expected = `a b c`;

// eslint-disable-next-line
// @ts-ignore
expect(func(object)).toBe(expected);
});
Expand All @@ -35,6 +36,7 @@ describe('trim', () => {
const string = '-_-a-b-c-_-';
const expected = `a-b-c`;

// eslint-disable-next-line
// @ts-ignore
expect(func(string, object)).toBe(expected);
});
Expand Down
1 change: 1 addition & 0 deletions src/compat/string/trim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { trim as trimToolkit } from '../../string/trim.ts';
*
* @param {string} str - The string from which leading and trailing characters will be trimmed.
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
* @param guard
* @returns {string} - The resulting string after the specified leading and trailing characters have been removed.
*
* @example
Expand Down
2 changes: 2 additions & 0 deletions src/compat/string/trimEnd.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('trimEnd', () => {
};
const expected = `${whitespace}a b c`;

// eslint-disable-next-line
// @ts-ignore
expect(func(object)).toBe(expected);
});
Expand All @@ -35,6 +36,7 @@ describe('trimEnd', () => {
const string = '-_-a-b-c-_-';
const expected = `${'-_-'}a-b-c`;

// eslint-disable-next-line
// @ts-ignore
expect(func(string, object)).toBe(expected);
});
Expand Down
1 change: 1 addition & 0 deletions src/compat/string/trimEnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { trimEnd as trimEndToolkit } from '../../string/trimEnd.ts';
*
* @param {string} str - The string from which trailing characters will be trimmed.
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
* @param guard
* @returns {string} - The resulting string after the specified trailing character has been removed.
*
* @example
Expand Down
2 changes: 2 additions & 0 deletions src/compat/string/trimStart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('trimStart', () => {
};
const expected = `a b c${whitespace}`;

// eslint-disable-next-line
// @ts-ignore
expect(func(object)).toBe(expected);
});
Expand All @@ -34,6 +35,7 @@ describe('trimStart', () => {
const string = '-_-a-b-c-_-';
const expected = `a-b-c${'-_-'}`;

// eslint-disable-next-line
// @ts-ignore
expect(func(string, object)).toBe(expected);
});
Expand Down
1 change: 1 addition & 0 deletions src/compat/string/trimStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { trimStart as trimStartToolkit } from '../../string/trimStart.ts';
*
* @param {string} str - The string from which leading characters will be trimmed.
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
* @param guard
* @returns {string} - The resulting string after the specified leading character has been removed.
*
* @example
Expand Down

0 comments on commit a010748

Please sign in to comment.