Skip to content

Commit

Permalink
Upgrade prettier to v3 (#984)
Browse files Browse the repository at this point in the history
Updated prettier plugins and ran --fix
  • Loading branch information
gilest authored Sep 15, 2023
1 parent b0c604f commit 05e0819
Show file tree
Hide file tree
Showing 27 changed files with 6,260 additions and 1,459 deletions.
4 changes: 2 additions & 2 deletions ember-file-upload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-ember": "^11.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.3.2",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.3",
"release-it": "^15.0.0",
"release-it-lerna-changelog": "^5.0.0",
"rollup": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion ember-file-upload/src/helpers/file-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class FileQueueHelper

compute(
_positional: FileQueueSignature['Args']['Positional'],
named: FileQueueSignature['Args']['Named']
named: FileQueueSignature['Args']['Named'],
) {
this.named = named;
const queue = this.fileQueue.findOrCreate(named.name ?? DEFAULT_QUEUE);
Expand Down
10 changes: 5 additions & 5 deletions ember-file-upload/src/mirage/upload-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ interface FakeRequest {

export function uploadHandler(
fn: (this: void, db: unknown, request: FakeRequest) => void,
options = { network: null, timeout: null }
options = { network: null, timeout: null },
) {
if (
macroCondition(
dependencySatisfies('miragejs', '*') &&
dependencySatisfies('ember-cli-mirage', '*')
dependencySatisfies('ember-cli-mirage', '*'),
)
) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -59,7 +59,7 @@ export function uploadHandler(
lengthComputable: true,
total,
loaded: Math.min(loaded, total),
})
}),
);

const metadata = await extractFileMetadata(file.value);
Expand All @@ -79,7 +79,7 @@ export function uploadHandler(
lengthComputable: true,
total,
loaded,
})
}),
);

loaded += speed / 20;
Expand All @@ -91,7 +91,7 @@ export function uploadHandler(
};
} else {
throw new Error(
'You must add ember-cli-mirage and miragejs to your app to use this helper.'
'You must add ember-cli-mirage and miragejs to your app to use this helper.',
);
}
}
8 changes: 4 additions & 4 deletions ember-file-upload/src/mirage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function extractFormData(formData: FormData) {
const pipelines = {
async gif(file: File): Promise<AdditionalMetadata> {
const buffer = (await new UploadFileReader().readAsArrayBuffer(
file
file,
)) as ArrayBuffer;
const data = new Uint8Array(buffer);
let duration = 0;
Expand Down Expand Up @@ -105,7 +105,7 @@ const pipelines = {
const videoEl = document.createElement('video');
return new RSVP.Promise(function (resolve: (result: VideoResult) => void) {
videoEl.addEventListener('loadeddata', () =>
resolve({ hasAdditionalMetadata: true, video: videoEl })
resolve({ hasAdditionalMetadata: true, video: videoEl }),
);
videoEl.onerror = () => resolve({ hasAdditionalMetadata: false });
videoEl.src = metadata.url;
Expand All @@ -129,7 +129,7 @@ const pipelines = {
const audioEl = document.createElement('audio');
return new RSVP.Promise(function (resolve: (result: AudioResult) => void) {
audioEl.addEventListener('loadeddata', () =>
resolve({ hasAdditionalMetadata: true, audio: audioEl })
resolve({ hasAdditionalMetadata: true, audio: audioEl }),
);
audioEl.onerror = () => resolve({ hasAdditionalMetadata: false });
audioEl.src = metadata.url;
Expand Down Expand Up @@ -183,7 +183,7 @@ export async function extractFileMetadata(file: File) {
// Collapse state of `hasAdditionalMetadata` from multiple pipelines
// Should be `true` if at least one pipeline succeeded
metadata.hasAdditionalMetadata = additionalMetadata.some(
(data) => data.hasAdditionalMetadata
(data) => data.hasAdditionalMetadata,
);

return metadata;
Expand Down
2 changes: 1 addition & 1 deletion ember-file-upload/src/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,6 @@ export class Queue {
};
},
// used to opt-in to lazy argument handling, which is the default for ember-modifier@^4
{ eager: false }
{ eager: false },
);
}
4 changes: 2 additions & 2 deletions ember-file-upload/src/services/file-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export default class FileQueueService extends Service {
create(name: QueueName): Queue {
assert(
`Queue names are required to be unique. "${String(
name
name,
)}" has already been reserved.`,
!this.#queues.has(name)
!this.#queues.has(name),
);

const queue = new Queue({ name, fileQueue: this });
Expand Down
2 changes: 1 addition & 1 deletion ember-file-upload/src/system/drag-listener-modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class DragListenerModifier extends Modifier<DragListenerModifierS
dragleave,
dragover,
drop,
}: NamedArgs<DragListenerModifierSignature>
}: NamedArgs<DragListenerModifierSignature>,
) {
this.listener = new DragListener(dropzone);

Expand Down
6 changes: 3 additions & 3 deletions ember-file-upload/src/system/drag-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class DragListener {
if (listener) {
assert(
`Cannot add multiple listeners for the same element ${this._dropzone}, ${listener.element}`,
this._dropzone !== listener.element
this._dropzone !== listener.element,
);

if (listener.element.contains(this._dropzone)) {
Expand All @@ -89,7 +89,7 @@ export default class DragListener {

removeEventListeners() {
this._listeners = this._listeners.filter(
(listener) => listener.element !== this._dropzone
(listener) => listener.element !== this._dropzone,
);
if (this._listeners.length === 0) {
this.endListening();
Expand Down Expand Up @@ -193,7 +193,7 @@ export default class DragListener {
scheduleEvent(
eventName: QueuedDragEvent['eventName'],
listener: QueuedDragEvent['listener'],
event: QueuedDragEvent['event']
event: QueuedDragEvent['event'],
) {
const isDuplicate = this._events.find((queuedEvent) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions ember-file-upload/src/system/http-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class HTTPRequest {

constructor(options: HTTPRequestOptions = {}) {
const { resolve, reject, promise } = RSVP.defer(
`ember-file-upload: ${options.label}`
`ember-file-upload: ${options.label}`,
);
this.resolve = resolve;
this.reject = reject;
Expand Down Expand Up @@ -133,7 +133,7 @@ export default class HTTPRequest {
url: string | URL,
_async: boolean,
usename?: string,
password?: string
password?: string,
) {
this.request.open(method, url, true, usename, password);
}
Expand Down
4 changes: 2 additions & 2 deletions ember-file-upload/src/system/upload-file-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class UploadFileReader {

get cancellablePromise() {
const { promise, resolve, reject } = RSVP.defer(
`ember-file-upload: ${this.label}`
`ember-file-upload: ${this.label}`,
);

const cancellable = promise.then(
Expand All @@ -112,7 +112,7 @@ export default class UploadFileReader {
() => {
return RSVP.reject(this.reader.error);
},
`ember-file-upload: Unpack ${this.label}`
`ember-file-upload: Unpack ${this.label}`,
);

let abort: RSVP.Deferred<string> | undefined;
Expand Down
8 changes: 4 additions & 4 deletions ember-file-upload/src/system/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function clone(object: object | undefined) {
function normalizeOptions(
file: UploadFile,
url: string | object | undefined,
options?: UploadOptions
options?: UploadOptions,
) {
if (typeof url === 'object') {
options = url;
Expand Down Expand Up @@ -56,11 +56,11 @@ export function upload(
file: UploadFile,
url: string | object,
opts: UploadOptions | undefined,
uploadFn: (request: HTTPRequest, options: UploadOptions) => Promise<Response>
uploadFn: (request: HTTPRequest, options: UploadOptions) => Promise<Response>,
) {
if (['queued', 'failed', 'timed_out', 'aborted'].indexOf(file.state) === -1) {
assert(
`The file ${file.id} is in the state "${file.state}" and cannot be requeued.`
`The file ${file.id} is in the state "${file.state}" and cannot be requeued.`,
);
}

Expand Down Expand Up @@ -118,6 +118,6 @@ export function upload(
file.queue?.uploadFailed(file, response);
return RSVP.reject(response);
})
.finally(() => file.queue?.flush())
.finally(() => file.queue?.flush()),
);
}
10 changes: 5 additions & 5 deletions ember-file-upload/src/test-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export async function selectFiles(
const input = target instanceof HTMLElement ? target : find(target);
assert(
`Target '${target}' is not an input element.`,
input && input.tagName === 'INPUT'
input && input.tagName === 'INPUT',
);
assert(
'All files must be instances of File/Blob type',
files.every((file) => file instanceof Blob)
files.every((file) => file instanceof Blob),
);

return triggerEvent(input, 'change', { files });
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function dragAndDrop(
assert(`Target '${dropzone}' could not be found.`, dropzone);
assert(
'All files must be instances of File/Blob type',
files.every((file) => file instanceof Blob)
files.every((file) => file instanceof Blob),
);

const dataTransfer = { files };
Expand Down Expand Up @@ -127,7 +127,7 @@ export async function dragEnter(
assert(`Target '${dropzone}' could not be found.`, dropzone);
assert(
'All files must be instances of File/Blob type',
files.every((file) => file instanceof Blob)
files.every((file) => file instanceof Blob),
);

const dataTransfer = { files };
Expand Down Expand Up @@ -171,7 +171,7 @@ export async function dragLeave(
assert(`Target '${dropzone}' could not be found.`, dropzone);
assert(
'All files must be instances of File/Blob type',
files.every((file) => file instanceof Blob)
files.every((file) => file instanceof Blob),
);

const dataTransfer = { files };
Expand Down
2 changes: 1 addition & 1 deletion ember-file-upload/src/upload-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class UploadFile {

this.queue?.uploadStarted(this);
return request.send(form);
}
},
);
}

Expand Down
Loading

0 comments on commit 05e0819

Please sign in to comment.