Skip to content

Commit bd9ff1a

Browse files
authored
Merge pull request #7 from github/null-entries
Filter out null file entries
2 parents a62bce8 + 35be7e0 commit bd9ff1a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"plugin:github/es6",
55
"plugin:github/typescript"
66
],
7+
"rules": {
8+
"@typescript-eslint/no-explicit-any": "off"
9+
},
710
"globals": {
811
"FileAttachmentElement": "readable"
912
},

src/attachment.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,8 @@ async function traverse(path: string, entries: FileSystemEntry[]): Promise<Attac
136136
const results = []
137137
for (const entry of visible(entries)) {
138138
if (entry.isDirectory) {
139-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
140139
results.push(...(await traverse(entry.fullPath, await getEntries(entry as any))))
141140
} else {
142-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
143141
const file = await getFile(entry as any)
144142
results.push(new Attachment(file, path))
145143
}
@@ -150,7 +148,6 @@ async function traverse(path: string, entries: FileSystemEntry[]): Promise<Attac
150148
function isDirectory(transfer: DataTransfer): boolean {
151149
return (
152150
transfer.items &&
153-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
154151
Array.from(transfer.items).some((item: any) => {
155152
const entry = item.webkitGetAsEntry && item.webkitGetAsEntry()
156153
return entry && entry.isDirectory
@@ -159,6 +156,7 @@ function isDirectory(transfer: DataTransfer): boolean {
159156
}
160157

161158
function roots(transfer: DataTransfer): FileSystemEntry[] {
162-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
163-
return Array.from(transfer.items).map((item: any) => item.webkitGetAsEntry())
159+
return Array.from(transfer.items)
160+
.map((item: any) => item.webkitGetAsEntry())
161+
.filter(entry => entry != null)
164162
}

0 commit comments

Comments
 (0)