Skip to content

Commit

Permalink
Merge pull request #7 from github/null-entries
Browse files Browse the repository at this point in the history
Filter out null file entries
  • Loading branch information
dgraham committed Mar 31, 2020
2 parents a62bce8 + 35be7e0 commit bd9ff1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"plugin:github/es6",
"plugin:github/typescript"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
},
"globals": {
"FileAttachmentElement": "readable"
},
Expand Down
8 changes: 3 additions & 5 deletions src/attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ async function traverse(path: string, entries: FileSystemEntry[]): Promise<Attac
const results = []
for (const entry of visible(entries)) {
if (entry.isDirectory) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
results.push(...(await traverse(entry.fullPath, await getEntries(entry as any))))
} else {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const file = await getFile(entry as any)
results.push(new Attachment(file, path))
}
Expand All @@ -150,7 +148,6 @@ async function traverse(path: string, entries: FileSystemEntry[]): Promise<Attac
function isDirectory(transfer: DataTransfer): boolean {
return (
transfer.items &&
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Array.from(transfer.items).some((item: any) => {
const entry = item.webkitGetAsEntry && item.webkitGetAsEntry()
return entry && entry.isDirectory
Expand All @@ -159,6 +156,7 @@ function isDirectory(transfer: DataTransfer): boolean {
}

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

0 comments on commit bd9ff1a

Please sign in to comment.