-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
types: enable @typescripteslint/array-type (#36)
- Loading branch information
Showing
10 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters