Skip to content

Commit

Permalink
Merge branch 'main' into typescript2
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed May 28, 2024
2 parents 5a9f228 + b147b53 commit ca9081e
Show file tree
Hide file tree
Showing 45 changed files with 1,468 additions and 1,863 deletions.
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

88 changes: 0 additions & 88 deletions .eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.eslintcache
.vscode/settings.json
node_modules
demos/reactnative/.expo
Expand Down
4 changes: 0 additions & 4 deletions .prettierignore

This file was deleted.

8 changes: 0 additions & 8 deletions .prettierrc.json

This file was deleted.

10 changes: 5 additions & 5 deletions .vscode/tus-js-client.code-workspace
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"folders": [
{
"path": "..",
},
"path": ".."
}
],
"settings": {
"workbench.colorCustomizations": {
"titleBar.activeForeground": "#cecece",
"titleBar.activeBackground": "#45b39d",
},
},
"titleBar.activeBackground": "#45b39d"
}
}
}
93 changes: 93 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 100,
"attributePosition": "auto"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"style": {
"noParameterAssign": "warn",
"noDefaultExport": "warn",
"useCollapsedElseIf": "error"
},
"suspicious": {
"noExplicitAny": "warn",
"useAwait": "error"
},
"correctness": {
"noNewSymbol": "error",
"noUndeclaredVariables": "error",
"noUnusedVariables": "error"
}
}
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingComma": "all",
"semicolons": "asNeeded",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
}
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"overrides": [
{
"include": ["lib/node/**"],
"linter": {
"rules": {
"style": {
"noRestrictedGlobals": {
"level": "error",
"options": {
"deniedGlobals": ["__filename", "__dirname", "exports", "module", "require"]
}
}
}
}
}
},
{
"include": ["test/**"],
"javascript": {
"globals": [
"jasmine",
"describe",
"expect",
"expectAsync",
"beforeEach",
"afterEach",
"it",
"spyOn"
]
}
},
{
"include": ["demos/browser/**", "demos/cordova/**"],
"javascript": { "globals": ["tus", "Camera"] }
},

{
"include": ["tsconfig*.json"],
"json": { "parser": { "allowComments": true } }
}
]
}
13 changes: 4 additions & 9 deletions demos/browser/demo.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/* global tus */
/* eslint-disable no-console, no-alert */

'use strict'

let upload = null
let uploadIsRunning = false
const toggleBtn = document.querySelector('#toggle-btn')
Expand Down Expand Up @@ -33,7 +28,7 @@ function askToResumeUpload(previousUploads, currentUpload) {
'\nEnter the corresponding number to resume an upload or press Cancel to start a new upload'

const answer = prompt(text)
const index = parseInt(answer, 10)
const index = Number.parseInt(answer, 10)

if (!Number.isNaN(index) && previousUploads[index]) {
currentUpload.resumeFromPreviousUpload(previousUploads[index])
Expand All @@ -50,12 +45,12 @@ function startUpload() {
}

const endpoint = endpointInput.value
let chunkSize = parseInt(chunkInput.value, 10)
let chunkSize = Number.parseInt(chunkInput.value, 10)
if (Number.isNaN(chunkSize)) {
chunkSize = Infinity
chunkSize = Number.POSITIVE_INFINITY
}

let parallelUploads = parseInt(parallelInput.value, 10)
let parallelUploads = Number.parseInt(parallelInput.value, 10)
if (Number.isNaN(parallelUploads)) {
parallelUploads = 1
}
Expand Down
13 changes: 5 additions & 8 deletions demos/browser/video.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/* global tus */
/* eslint-disable no-console, no-alert */

'use strict'

let stopRecording = null
let upload = null
const recordBtn = document.querySelector('#record-btn')
Expand Down Expand Up @@ -33,9 +28,9 @@ recordBtn.addEventListener('click', (e) => {

function startUpload(file) {
const endpoint = endpointInput.value
let chunkSize = parseInt(chunkInput.value, 10)
let chunkSize = Number.parseInt(chunkInput.value, 10)
if (Number.isNaN(chunkSize)) {
chunkSize = Infinity
chunkSize = Number.POSITIVE_INFINITY
}

const options = {
Expand Down Expand Up @@ -132,7 +127,9 @@ function startStreamUpload() {
startUpload(readableRecorder)

stopRecording = () => {
stream.getTracks().forEach((t) => t.stop())
for (const t of stream.getTracks()) {
t.stop()
}
mr.stop()
stopRecording = null
}
Expand Down
6 changes: 2 additions & 4 deletions demos/cordova/hooks/before_prepare/copy_tus_files.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env node

'use strict'

const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')

const rootDir = path.join(__dirname, '..', '..')
const tusJsPath = path.join(rootDir, '..', '..', 'dist', 'tus.js')
Expand Down
4 changes: 1 addition & 3 deletions demos/cordova/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"cordova-plugin-file": {},
"cordova-plugin-whitelist": {}
},
"platforms": [
"android"
]
"platforms": ["android"]
}
}
5 changes: 0 additions & 5 deletions demos/cordova/www/js/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/* global tus Camera */
/* eslint-disable no-alert */

'use strict'

let upload = null
let uploadIsRunning = false
let file = null
Expand Down
6 changes: 1 addition & 5 deletions demos/nodejs/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/* eslint-disable no-console */

'use strict'

const fs = require('fs')
const fs = require('node:fs')
const tus = require('../..')

const path = `${__dirname}/../../README.md`
Expand Down
6 changes: 2 additions & 4 deletions demos/reactnative/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable no-console */

import React from 'react'
import { StyleSheet, Text, View, Button, Image, Linking } from 'react-native'
import { ImagePicker, Permissions } from 'expo'
import React from 'react'
import { Button, Image, Linking, StyleSheet, Text, View } from 'react-native'
import * as tus from 'tus-js-client'

const styles = StyleSheet.create({
Expand Down
6 changes: 3 additions & 3 deletions lib/browser/fileReader.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import isReactNative from './isReactNative.js'
import uriToBlob from './uriToBlob.js'

import type { FileReader, FileSource } from '../upload.js'
import type { FileSliceTypes, FileTypes, ReactNativeFile } from './index.js'
import BlobFileSource from './sources/FileSource.js'
import StreamSource from './sources/StreamSource.js'
import { FileReader, FileSource } from '../upload.js'
import { FileSliceTypes, FileTypes, ReactNativeFile } from './index.js'

function isReactNativeFile(input: FileTypes): input is ReactNativeFile {
return 'uri' in input && typeof input.uri === 'string'
Expand All @@ -20,7 +20,7 @@ export default class BrowserFileReader implements FileReader<FileTypes, FileSlic
if (isReactNativeFile(input)) {
if (!isReactNative()) {
// TODO
throw new Error(``)
throw new Error('')
}

try {
Expand Down
4 changes: 2 additions & 2 deletions lib/browser/fileSignature.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UploadOptions } from '../upload.js'
import { ReactNativeFile } from './index.js'
import type { UploadOptions } from '../upload.js'
import type { ReactNativeFile } from './index.js'
import isReactNative from './isReactNative.js'

// TODO: Differenciate between input types
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/httpStack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-classes-per-file */

import { HttpProgressHandler, HttpRequest, HttpResponse, HttpStack } from '../upload.js'
import type { HttpProgressHandler, HttpRequest, HttpResponse, HttpStack } from '../upload.js'

export default class XHRHttpStack implements HttpStack<Blob> {
createRequest(method, url) {
Expand Down
Loading

0 comments on commit ca9081e

Please sign in to comment.