From ebfdb0081e11ee250a158c76d7f9eaa3c286939a Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 19 Oct 2023 22:16:00 -0600 Subject: [PATCH] lint:fix --- ember-resources/src/core/cell.ts | 6 +++--- ember-resources/src/core/class-based/resource.ts | 10 +++++----- .../core/function-based/immediate-invocation.ts | 2 +- .../src/core/function-based/manager.ts | 6 +++--- .../src/core/function-based/resource.ts | 8 ++++---- ember-resources/src/core/function-based/utils.ts | 2 +- ember-resources/src/core/types.ts | 2 +- ember-resources/src/core/use.ts | 16 ++++++++-------- ember-resources/src/link.ts | 4 ++-- ember-resources/src/modifier/index.ts | 10 +++++----- ember-resources/src/service.ts | 16 ++++++++-------- ember-resources/src/util/ember-concurrency.ts | 8 ++++---- ember-resources/src/util/helper.ts | 2 +- ember-resources/src/util/map.ts | 6 +++--- ember-resources/src/util/remote-data.ts | 6 +++--- test-app-ember-concurrency-2/app/index.html | 2 +- test-app-ember-concurrency-2/tests/index.html | 2 +- .../types/ember-app/index.d.ts | 4 ++-- test-app-ember-concurrency-3/app/index.html | 2 +- test-app-ember-concurrency-3/tests/index.html | 2 +- .../types/ember-app/index.d.ts | 4 ++-- 21 files changed, 60 insertions(+), 60 deletions(-) diff --git a/ember-resources/src/core/cell.ts b/ember-resources/src/core/cell.ts index 18990cf6f..53b4a6f18 100644 --- a/ember-resources/src/core/cell.ts +++ b/ember-resources/src/core/cell.ts @@ -10,7 +10,7 @@ export class ReadonlyCell implements Reactive { toHTML(): string { assert( - 'Not a valid API. Please access either .current or .read() if the value of this Cell is needed' + 'Not a valid API. Please access either .current or .read() if the value of this Cell is needed', ); } @@ -32,7 +32,7 @@ export class Cell implements Reactive { toHTML(): string { assert( - 'Not a valid API. Please access either .current or .read() if the value of this Cell is needed' + 'Not a valid API. Please access either .current or .read() if the value of this Cell is needed', ); } @@ -51,7 +51,7 @@ export class Cell implements Reactive { toggle = () => { assert( `toggle can only be used when 'current' is a boolean type`, - typeof this.current === 'boolean' || this.current === undefined + typeof this.current === 'boolean' || this.current === undefined, ); (this.current as boolean) = !this.current; diff --git a/ember-resources/src/core/class-based/resource.ts b/ember-resources/src/core/class-based/resource.ts index 3ae0ef7ec..d26c05798 100644 --- a/ember-resources/src/core/class-based/resource.ts +++ b/ember-resources/src/core/class-based/resource.ts @@ -192,7 +192,7 @@ export class Resource { */ static from>( this: Constructor, - thunk: AsThunk> + thunk: AsThunk>, ): SomeResource; /** @@ -241,13 +241,13 @@ export class Resource { static from>( this: Constructor, context: unknown, - thunk: AsThunk> + thunk: AsThunk>, ): SomeResource; static from>( this: Constructor, contextOrThunk: unknown | AsThunk>, - thunkOrUndefined?: undefined | AsThunk> + thunkOrUndefined?: undefined | AsThunk>, ): SomeResource { /** * This first branch is for @@ -338,12 +338,12 @@ export class Resource { function resourceOf>( context: unknown, klass: Constructor, - thunk?: Thunk + thunk?: Thunk, ): SomeResource { assert( `Expected second argument, klass, to be a Resource. ` + `Instead, received some ${typeof klass}, ${klass.name}`, - klass.prototype instanceof Resource + klass.prototype instanceof Resource, ); let cache: Cache; diff --git a/ember-resources/src/core/function-based/immediate-invocation.ts b/ember-resources/src/core/function-based/immediate-invocation.ts index 6d7ab7f02..aacde0eda 100644 --- a/ember-resources/src/core/function-based/immediate-invocation.ts +++ b/ember-resources/src/core/function-based/immediate-invocation.ts @@ -130,7 +130,7 @@ class ResourceInvokerManager { * ``` */ export function resourceFactory( - wrapperFn: (...args: Args) => ReturnType> + wrapperFn: (...args: Args) => ReturnType>, /** * This is a bonkers return type. * Here are the scenarios: diff --git a/ember-resources/src/core/function-based/manager.ts b/ember-resources/src/core/function-based/manager.ts index 9c7252c1b..f44bf8286 100644 --- a/ember-resources/src/core/function-based/manager.ts +++ b/ember-resources/src/core/function-based/manager.ts @@ -79,15 +79,15 @@ class FunctionResourceManager { const use: ResourceAPI['use'] = (usable) => { assert( `Expected the resource's \`use(...)\` utility to have been passed an object, but a \`${typeof usable}\` was passed.`, - typeof usable === 'object' + typeof usable === 'object', ); assert( `Expected the resource's \`use(...)\` utility to have been passed a truthy value, instead was passed: ${usable}.`, - usable + usable, ); assert( `Expected the resource's \`use(...)\` utility to have been passed another resource, but something else was passed.`, - INTERNAL in usable + INTERNAL in usable, ); let previousCache = usableCache.get(usable); diff --git a/ember-resources/src/core/function-based/resource.ts b/ember-resources/src/core/function-based/resource.ts index 9c9eb9c29..6196333bb 100644 --- a/ember-resources/src/core/function-based/resource.ts +++ b/ember-resources/src/core/function-based/resource.ts @@ -166,14 +166,14 @@ export function resource(context: object, setup: ResourceFunction) */ export function resource( context: object | ResourceFunction, - setup?: ResourceFunction + setup?: ResourceFunction, ): Value | InternalFunctionResourceConfig | ResourceFn { if (!setup) { assert( `When using \`resource\` with @use, ` + `the first argument to \`resource\` must be a function. ` + `Instead, a ${typeof context} was received.`, - typeof context === 'function' + typeof context === 'function', ); let internalConfig: InternalFunctionResourceConfig = { @@ -204,12 +204,12 @@ export function resource( `Mismatched argument types passed to \`resource\`. ` + `Expected the first arg, the context, to be a type of object. This is usually the \`this\`. ` + `Received ${typeof context} instead.`, - typeof context === 'object' + typeof context === 'object', ); assert( `Mismatched argument type passed to \`resource\`. ` + `Expected the second arg to be a function but instead received ${typeof setup}.`, - typeof setup === 'function' + typeof setup === 'function', ); let internalConfig: InternalFunctionResourceConfig = { diff --git a/ember-resources/src/core/function-based/utils.ts b/ember-resources/src/core/function-based/utils.ts index 3256dcc4e..e19e34053 100644 --- a/ember-resources/src/core/function-based/utils.ts +++ b/ember-resources/src/core/function-based/utils.ts @@ -16,7 +16,7 @@ import type { InternalFunctionResourceConfig } from './types'; */ export function wrapForPlainUsage( context: object, - setup: InternalFunctionResourceConfig + setup: InternalFunctionResourceConfig, ) { let cache: Cache; diff --git a/ember-resources/src/core/types.ts b/ember-resources/src/core/types.ts index 753d6d8ef..e8ddb1262 100644 --- a/ember-resources/src/core/types.ts +++ b/ember-resources/src/core/types.ts @@ -26,7 +26,7 @@ export interface Stage1DecoratorDescriptor { export type Stage1Decorator = ( prototype: object, key: string | symbol, - descriptor?: Stage1DecoratorDescriptor + descriptor?: Stage1DecoratorDescriptor, ) => any; export interface ClassResourceConfig { diff --git a/ember-resources/src/core/use.ts b/ember-resources/src/core/use.ts index 783ec7a17..436269b99 100644 --- a/ember-resources/src/core/use.ts +++ b/ember-resources/src/core/use.ts @@ -54,7 +54,7 @@ export function use(definition: Value | (() => Value)): PropertyDecorator export function use( prototype: NonInstanceType, key: DecoratorKey, - descriptor?: Stage1DecoratorDescriptor + descriptor?: Stage1DecoratorDescriptor, ): void; /** @@ -78,7 +78,7 @@ export function use( export function use( parent: object, definition: Value | (() => Value), - _?: never + _?: never, ): Reactive ? Value['current'] : Value>; export function use( @@ -117,7 +117,7 @@ function getCurrentValue(value: Value | Reactive): Value { function classContextLink( context: object, - definition: Value | (() => Value) + definition: Value | (() => Value), ): Reactive { let cache: ReturnType; @@ -138,7 +138,7 @@ function argumentToDecorator(definition: Value | (() => Value)): Property return ( _prototype: object, key: string | symbol, - descriptor?: Stage1DecoratorDescriptor + descriptor?: Stage1DecoratorDescriptor, ): void => { // TS's types for decorators use the Stage2 implementation, even though Babel uses Stage 1 if (!descriptor) return; @@ -148,7 +148,7 @@ function argumentToDecorator(definition: Value | (() => Value)): Property assert( `When @use(...) is passed a resource, an initialized value is not allowed. ` + `\`@use(Clock) time;`, - !descriptor.initializer + !descriptor.initializer, ); let newDescriptor = descriptorGetter(definition); @@ -171,7 +171,7 @@ function descriptorGetter(initializer: unknown | (() => unknown)) { assert( `Expected initialized value under @use to have used either the \`resource\` wrapper function, or a \`Resource.from\` call`, - INTERNAL in config + INTERNAL in config, ); if (config.type === 'function-based') { @@ -199,7 +199,7 @@ function descriptorGetter(initializer: unknown | (() => unknown)) { function initializerDecorator( _prototype: object, key: string | symbol, - descriptor?: Stage1DecoratorDescriptor + descriptor?: Stage1DecoratorDescriptor, ): void { // TS's types for decorators use the Stage2 implementation, even though Babel uses Stage 1 if (!descriptor) return; @@ -212,7 +212,7 @@ function initializerDecorator( `@use may only be used on initialized properties. For example, ` + `\`@use foo = resource(() => { ... })\` or ` + `\`@use foo = SomeResource.from(() => { ... });\``, - initializer + initializer, ); return descriptorGetter(initializer) as unknown as void /* Thanks, TS and Stage 2 Decorators */; diff --git a/ember-resources/src/link.ts b/ember-resources/src/link.ts index e3eed81cb..bca46b913 100644 --- a/ember-resources/src/link.ts +++ b/ember-resources/src/link.ts @@ -140,7 +140,7 @@ function linkDecorator( _prototype: object, key: string | Symbol, descriptor: Stage1DecoratorDescriptor | undefined, - explicitChild?: Class + explicitChild?: Class, ): void { assert(`@link is a stage 1 decorator, and requires a descriptor`, descriptor); assert(`@link can only be used with string-keys`, typeof key === 'string'); @@ -150,7 +150,7 @@ function linkDecorator( assert( `@link requires an initializer or be used as a decorator factory (\`@link(...))\`). For example, ` + `\`@link foo = new MyClass();\` or \`@link(MyClass) foo;\``, - initializer || explicitChild + initializer || explicitChild, ); let caches = new WeakMap(); diff --git a/ember-resources/src/modifier/index.ts b/ember-resources/src/modifier/index.ts index aad61c782..df9ba7bbc 100644 --- a/ember-resources/src/modifier/index.ts +++ b/ember-resources/src/modifier/index.ts @@ -64,7 +64,7 @@ type ArgsForFn = S extends { Args?: object } * */ export function modifier( - fn: (element: El, ...args: Args) => void + fn: (element: El, ...args: Args) => void, ): ModifierLike<{ Element: El; Args: { @@ -112,7 +112,7 @@ export function modifier * */ export function modifier( - fn: (element: ElementFor, ...args: ArgsForFn) => ReturnType + fn: (element: ElementFor, ...args: ArgsForFn) => ReturnType, ): ModifierLike; /** * A resource-based API for building modifiers. @@ -153,7 +153,7 @@ export function modifier( * */ export function modifier( - fn: (element: ElementFor, ...args: ArgsForFn) => ReturnType + fn: (element: ElementFor, ...args: ArgsForFn) => ReturnType, ): ModifierLike; /** * A resource-based API for building modifiers. @@ -194,7 +194,7 @@ export function modifier( * */ export function modifier( - fn: (element: ElementFor, ...args: ArgsForFn) => ReturnType + fn: (element: ElementFor, ...args: ArgsForFn) => ReturnType, ): ModifierLike; export function modifier(fn: (element: Element, ...args: unknown[]) => void): ModifierLike<{ @@ -223,5 +223,5 @@ export function modifier(fn: (element: Element, ...args: unknown[]) => void): Mo export type FunctionBasedModifierDefinition = ( element: ElementFor, positional: PositionalArgs, - named: NamedArgs + named: NamedArgs, ) => void; diff --git a/ember-resources/src/service.ts b/ember-resources/src/service.ts index 92e97f5ed..c40af1ca8 100644 --- a/ember-resources/src/service.ts +++ b/ember-resources/src/service.ts @@ -121,7 +121,7 @@ export function service(resource: unknown) { return function legacyServiceDecorator( _prototype: object, key: string, - descriptor?: Stage1DecoratorDescriptor + descriptor?: Stage1DecoratorDescriptor, ) { if (!descriptor) return; @@ -130,12 +130,12 @@ export function service(resource: unknown) { assert( `@service(...) may not be used with an initializer. For example, ` + `\`@service(MyService) property;\``, - !descriptor.initializer + !descriptor.initializer, ); assert( `Expected passed resource to be a valid resource definition.`, - typeof resource === 'function' || (typeof resource === 'object' && resource !== null) + typeof resource === 'function' || (typeof resource === 'object' && resource !== null), ); return { @@ -146,7 +146,7 @@ export function service(resource: unknown) { `owner was not found on instance of ${this.constructor.name}. ` + `Has it been linked up correctly with setOwner?` + `If this error has occured in a framework-controlled class, something has gone wrong.`, - owner + owner, ); assert(`Resource definition is invalid`, isResourceType(resource)); @@ -171,7 +171,7 @@ export function service(resource: unknown) { assert( `When using resources with @service(...), do not call .from() on class-based resources. ` + `Resources used as services may not take arguments.`, - resource.type === 'function-based' + resource.type === 'function-based', ); cache = invokeHelper(owner, resource); @@ -180,7 +180,7 @@ export function service(resource: unknown) { } else if ((resource as any).prototype instanceof Resource) { assert( `The .from() method on a type of Resource has been removed or altered. This is not allowed.`, - 'from' in resource && resource.from === Resource.from + 'from' in resource && resource.from === Resource.from, ); /** @@ -188,7 +188,7 @@ export function service(resource: unknown) { * But it does mean that we have to cast in our own code. */ let { definition } = (resource as typeof Resource).from( - () => [] + () => [], ) as unknown as ClassResourceConfig; cache = invokeHelper(owner, definition); @@ -238,7 +238,7 @@ interface RegisterOptions { export function serviceOverride(owner: Owner, { original, replacement }: RegisterOptions) { if (macroCondition(!isTesting() && !isDevelopingApp())) { throw new Error( - '@service is experimental and `serviceOverride` is not available in production builds.' + '@service is experimental and `serviceOverride` is not available in production builds.', ); } diff --git a/ember-resources/src/util/ember-concurrency.ts b/ember-resources/src/util/ember-concurrency.ts index e7aee04bd..150ee3b0e 100644 --- a/ember-resources/src/util/ember-concurrency.ts +++ b/ember-resources/src/util/ember-concurrency.ts @@ -68,7 +68,7 @@ import type { Cache } from '../core/types'; export function task< Return = unknown, Args extends unknown[] = unknown[], - LocalTask extends TaskIsh = TaskIsh + LocalTask extends TaskIsh = TaskIsh, >(context: object, task: LocalTask, thunk?: () => Args) { assert(`Task does not have a perform method. Is it actually a task?`, 'perform' in task); @@ -85,7 +85,7 @@ const TASK_CACHE = new WeakMap(); function buildUnproxiedTaskResource< ArgsList extends any[], Return, - LocalTask extends TaskIsh = TaskIsh + LocalTask extends TaskIsh = TaskIsh, >(context: object, task: LocalTask, thunk: () => ArgsList) { type LocalResource = TaskResource; type Klass = new (...args: unknown[]) => LocalResource; @@ -128,7 +128,7 @@ export function proxyClass< ArgsList, Return, LocalTask - > + >, >(target: { value: Instance }) { /* * This proxy defaults to returning the underlying data on @@ -216,7 +216,7 @@ export const TASK = Symbol('TASK'); export class TaskResource< Args extends any[], Return, - LocalTask extends TaskIsh + LocalTask extends TaskIsh, > extends Resource<{ positional: Args; }> { diff --git a/ember-resources/src/util/helper.ts b/ember-resources/src/util/helper.ts index 873f7e3e7..bb957330a 100644 --- a/ember-resources/src/util/helper.ts +++ b/ember-resources/src/util/helper.ts @@ -64,7 +64,7 @@ type Get = K extends keyof T ? T[K] : Otherwise; export function helper, Return = Get>( context: object, helper: T, - thunk: Thunk = DEFAULT_THUNK + thunk: Thunk = DEFAULT_THUNK, ): { value: Return } { let resource: Cache; diff --git a/ember-resources/src/util/map.ts b/ember-resources/src/util/map.ts index 191bb8fbd..4d6710cb5 100644 --- a/ember-resources/src/util/map.ts +++ b/ember-resources/src/util/map.ts @@ -184,7 +184,7 @@ export function map( * - if not iterating, map will only be called for the elements observed. */ map: (element: Elements[number]) => MapTo; - } + }, ) { let { data, map } = options; @@ -247,7 +247,7 @@ export class TrackedArrayMap modify([data]: Positional>, { map }: Named>) { assert( `Every entry in the data passed to \`map\` must be an object.`, - data.every((datum) => typeof datum === 'object') + data.every((datum) => typeof datum === 'object'), ); this._records = data as Array; this._map = map; @@ -294,7 +294,7 @@ export class TrackedArrayMap `The array item is expected to exist, because the map utility resource lazily iterates along the indices of the original array passed as data. ` + `This error could happen if the data array passed to map has been mutated while iterating. ` + `To resolve this error, do not mutate arrays while iteration occurs.`, - record + record, ); let value = this.#map.get(record); diff --git a/ember-resources/src/util/remote-data.ts b/ember-resources/src/util/remote-data.ts index 6327bb5bf..60ecfb0f9 100644 --- a/ember-resources/src/util/remote-data.ts +++ b/ember-resources/src/util/remote-data.ts @@ -125,7 +125,7 @@ export class State { export function remoteData( { on }: ResourceAPI, url: string, - options: FetchOptions = {} + options: FetchOptions = {}, ): State { let state = new State(); let controller = new AbortController(); @@ -150,7 +150,7 @@ export function remoteData( .catch((error) => { state.isRejected = true; state.error = error; - }) + }), ); return state; @@ -258,7 +258,7 @@ export function RemoteData(options: () => { url: string } & FetchOp */ export function RemoteData( url: string | (() => string) | (() => { url: string } & FetchOptions), - opts?: FetchOptions + opts?: FetchOptions, ) { return resource((hooks) => { let result = typeof url === 'string' ? url : url(); diff --git a/test-app-ember-concurrency-2/app/index.html b/test-app-ember-concurrency-2/app/index.html index 861578847..6d826d9ca 100644 --- a/test-app-ember-concurrency-2/app/index.html +++ b/test-app-ember-concurrency-2/app/index.html @@ -1,4 +1,4 @@ - + diff --git a/test-app-ember-concurrency-2/tests/index.html b/test-app-ember-concurrency-2/tests/index.html index f5c81fb72..d2b32cc28 100644 --- a/test-app-ember-concurrency-2/tests/index.html +++ b/test-app-ember-concurrency-2/tests/index.html @@ -1,4 +1,4 @@ - + diff --git a/test-app-ember-concurrency-2/types/ember-app/index.d.ts b/test-app-ember-concurrency-2/types/ember-app/index.d.ts index 2bd8e618c..a771725fa 100644 --- a/test-app-ember-concurrency-2/types/ember-app/index.d.ts +++ b/test-app-ember-concurrency-2/types/ember-app/index.d.ts @@ -56,7 +56,7 @@ declare module '@ember/component' { export function setComponentTemplate< Klass extends abstract new (owner: Owner, args: any) => Instance, Instance = InstanceType, - S = InferSignature + S = InferSignature, >(template: abstract new () => HasContext>, klass: Klass): Klass; export function capabilities( @@ -65,6 +65,6 @@ declare module '@ember/component' { destructor?: boolean; asyncLifecycleCallbacks?: boolean; updateHook?: boolean; - } + }, ): any; } diff --git a/test-app-ember-concurrency-3/app/index.html b/test-app-ember-concurrency-3/app/index.html index 861578847..6d826d9ca 100644 --- a/test-app-ember-concurrency-3/app/index.html +++ b/test-app-ember-concurrency-3/app/index.html @@ -1,4 +1,4 @@ - + diff --git a/test-app-ember-concurrency-3/tests/index.html b/test-app-ember-concurrency-3/tests/index.html index f5c81fb72..d2b32cc28 100644 --- a/test-app-ember-concurrency-3/tests/index.html +++ b/test-app-ember-concurrency-3/tests/index.html @@ -1,4 +1,4 @@ - + diff --git a/test-app-ember-concurrency-3/types/ember-app/index.d.ts b/test-app-ember-concurrency-3/types/ember-app/index.d.ts index 2bd8e618c..a771725fa 100644 --- a/test-app-ember-concurrency-3/types/ember-app/index.d.ts +++ b/test-app-ember-concurrency-3/types/ember-app/index.d.ts @@ -56,7 +56,7 @@ declare module '@ember/component' { export function setComponentTemplate< Klass extends abstract new (owner: Owner, args: any) => Instance, Instance = InstanceType, - S = InferSignature + S = InferSignature, >(template: abstract new () => HasContext>, klass: Klass): Klass; export function capabilities( @@ -65,6 +65,6 @@ declare module '@ember/component' { destructor?: boolean; asyncLifecycleCallbacks?: boolean; updateHook?: boolean; - } + }, ): any; }