Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: enable @typescripteslint/array-type #36

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"root": true,
"ignorePatterns": ["lib", "coverage", "docs/.vitepress/cache", "docs/.vitepress/dist"],
"extends": ["@varlet"]
"extends": ["@varlet"],
"rules": {
"@typescript-eslint/array-type": "error"
}
}
4 changes: 2 additions & 2 deletions src/array/find.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function find<T>(
arr: Array<T>,
fn: (item: T, index: number, array: Array<T>) => any,
arr: T[],
fn: (item: T, index: number, array: T[]) => any,
from: 'start' | 'end' = 'start',
): [T, number] | [null, -1] {
let i = from === 'start' ? 0 : arr.length - 1
Expand Down
2 changes: 1 addition & 1 deletion src/array/removeArrayBlank.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function removeArrayBlank<T>(arr: Array<T | null | undefined>) {
export function removeArrayBlank<T>(arr: (T | null | undefined)[]) {
return arr.filter((item) => item != null) as T[]
}
2 changes: 1 addition & 1 deletion src/array/removeArrayEmpty.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function removeArrayEmpty<T>(arr: Array<T | null | undefined | ''>) {
export function removeArrayEmpty<T>(arr: (T | null | undefined | '')[]) {
return arr.filter((item) => item != null && item !== '') as T[]
}
2 changes: 1 addition & 1 deletion src/array/removeItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function removeItem<T>(arr: Array<T>, item: T) {
export function removeItem<T>(arr: T[], item: T) {
if (arr.length) {
const index: number = arr.indexOf(item)
if (index > -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/array/toggleItem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { removeItem } from './removeItem'

export function toggleItem<T>(arr: Array<T>, item: T) {
export function toggleItem<T>(arr: T[], item: T) {
arr.includes(item) ? removeItem(arr, item) : arr.push(item)
return arr
}
2 changes: 1 addition & 1 deletion src/general/isArray.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function isArray(val: unknown): val is Array<any> {
export function isArray(val: unknown): val is any[] {
return Array.isArray(val)
}
2 changes: 1 addition & 1 deletion src/general/isNonEmptyArray.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isArray } from './isArray'

export function isNonEmptyArray(val: unknown): val is Array<any> {
export function isNonEmptyArray(val: unknown): val is any[] {
return isArray(val) && !!val.length
}
2 changes: 1 addition & 1 deletion src/number/clampArrayRange.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clamp } from './clamp'

export function clampArrayRange(index: number, arr: Array<unknown>) {
export function clampArrayRange(index: number, arr: unknown[]) {
return clamp(index, 0, arr.length - 1)
}
4 changes: 2 additions & 2 deletions src/util/getAllParentScroller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isWindow } from '../general'
import { getParentScroller } from './getParentScroller'

export function getAllParentScroller(el: HTMLElement): Array<HTMLElement | Window> {
const allParentScroller: Array<HTMLElement | Window> = []
export function getAllParentScroller(el: HTMLElement): (HTMLElement | Window)[] {
const allParentScroller: (HTMLElement | Window)[] = []
let element: HTMLElement | Window = el

while (!isWindow(element)) {
Expand Down
Loading