Skip to content

Commit

Permalink
fix: eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uwla committed Feb 25, 2025
1 parent 83208f9 commit 3f62795
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default typescriptEslint.config(
"**/dist",
"assets/",
"src/dev.ts",
"tests/**/*",
],
},
{
Expand All @@ -28,7 +29,7 @@ export default typescriptEslint.config(
parserOptions: { parser: typescriptEslint.parser },
},
rules: {
"@typescript-eslint/no-explicit-any": "off", // Allow the use of `any`
"@typescript-eslint/no-explicit-any": "warn", // Allow the use of `any`
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down
17 changes: 10 additions & 7 deletions src/components/DataTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default defineComponent({

data: () => {
return reactive({
dataFetched: [] as Column[],
dataFetched: [] as Data,
dataFetchedLinks: [] as any[],
currentPage: 1,
currentPerPage: 10,
Expand Down Expand Up @@ -182,7 +182,10 @@ export default defineComponent({
return data
}

return sortDataByColumns(data as Data, columnsBeingSorted)
return sortDataByColumns(
data as unknown as Data,
columnsBeingSorted
)
},

/**
Expand Down Expand Up @@ -532,7 +535,7 @@ export default defineComponent({
/**
* Indicates if a page is valid
*/
isValidPage(page: any): boolean {
isValidPage(page: number | string): boolean {
return (
typeof page === "number" &&
page <= this.numberOfPages &&
Expand Down Expand Up @@ -586,15 +589,15 @@ export default defineComponent({
// so, mark it as sorted in ascending mode
if (column.sortingMode === SORTING_MODE.NONE) {
column.sortingMode = SORTING_MODE.ASC
this.columnsBeingSorted = [column] as any
this.columnsBeingSorted = [column]
return
}

// the column is being sorted in ascending mode
// so, mark it as sorted in descending mode
if (column.sortingMode === SORTING_MODE.ASC) {
column.sortingMode = SORTING_MODE.DESC
this.columnsBeingSorted = [column] as any
this.columnsBeingSorted = [column]
return
}

Expand Down Expand Up @@ -654,11 +657,11 @@ export default defineComponent({
/**
* Set the current page being displayed
*/
setPage(value: any) {
setPage(value: number | string) {
if (!this.isValidPage(value)) {
return
}
this.currentPage = value
this.currentPage = Number(value)
this.updateData()
},

Expand Down
6 changes: 3 additions & 3 deletions src/components/Table/Table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export default defineComponent({
name: "VdtTable",
props: {
tableClass: String,
columns: Array as () => any,
columns: Array as () => any[],
data: Array,
dataDisplayed: Array as () => any,
dataFiltered: Array as () => any,
dataDisplayed: Array as () => any[],
dataFiltered: Array as () => any[],
emptyTableText: String,
footerComponent: [Object, String],
isEmpty: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<!-- NON-EMPTY BODY -->
<tr
v-for="data in dataDisplayed"
:key="data._key"
:key="(data._key)"
>
<td
v-for="(column, j) in columns"
Expand Down
2 changes: 1 addition & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ export type LanguageDictVal = string
export type LanguageDict = Record<LanguageDictKey, LanguageDictVal>
export type Translation = Record<LanguageName, LanguageDict>

export type Cell = { [key: string]: any }
export type Cell = { [key: string]: [String, Number, Array, Object] }
export type Data = Cell[]
7 changes: 4 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function toTitleCase(str: string): string {
export function stringReplaceFromArray(
target: string,
searchValues: string[],
replacements: any[]
replacements: (string | number)[]
): string {
for (let i = 0; i < searchValues.length; i++) {
target = target.replace(searchValues[i], replacements[i])
target = target.replace(searchValues[i], "" + replacements[i])
}
return target
}
Expand Down Expand Up @@ -147,7 +147,8 @@ export function searchStringColumn(
search: string,
key: string
): boolean {
return (data[key] || "").toLowerCase().includes(search.toLowerCase())
return ((data[key] || "") as unknown as string)
.toLowerCase().includes(search.toLowerCase())
}

// Performs search on numeric values
Expand Down

0 comments on commit 3f62795

Please sign in to comment.