Skip to content

Commit

Permalink
Merge pull request #1020 from NullVoxPopuli/fix-ci
Browse files Browse the repository at this point in the history
lint:fix
  • Loading branch information
NullVoxPopuli authored Oct 20, 2023
2 parents d919158 + ebfdb00 commit 1c1ad1c
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 60 deletions.
6 changes: 3 additions & 3 deletions ember-resources/src/core/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ReadonlyCell<Value> implements Reactive<Value> {

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',
);
}

Expand All @@ -32,7 +32,7 @@ export class Cell<Value = unknown> implements Reactive<Value> {

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',
);
}

Expand All @@ -51,7 +51,7 @@ export class Cell<Value = unknown> implements Reactive<Value> {
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;
Expand Down
10 changes: 5 additions & 5 deletions ember-resources/src/core/class-based/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class Resource<Args = unknown> {
*/
static from<SomeResource extends Resource<any>>(
this: Constructor<SomeResource>,
thunk: AsThunk<ArgsFrom<SomeResource>>
thunk: AsThunk<ArgsFrom<SomeResource>>,
): SomeResource;

/**
Expand Down Expand Up @@ -241,13 +241,13 @@ export class Resource<Args = unknown> {
static from<SomeResource extends Resource<any>>(
this: Constructor<SomeResource>,
context: unknown,
thunk: AsThunk<ArgsFrom<SomeResource>>
thunk: AsThunk<ArgsFrom<SomeResource>>,
): SomeResource;

static from<SomeResource extends Resource<any>>(
this: Constructor<SomeResource>,
contextOrThunk: unknown | AsThunk<ArgsFrom<SomeResource>>,
thunkOrUndefined?: undefined | AsThunk<ArgsFrom<SomeResource>>
thunkOrUndefined?: undefined | AsThunk<ArgsFrom<SomeResource>>,
): SomeResource {
/**
* This first branch is for
Expand Down Expand Up @@ -338,12 +338,12 @@ export class Resource<Args = unknown> {
function resourceOf<SomeResource extends Resource<unknown>>(
context: unknown,
klass: Constructor<SomeResource>,
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<SomeResource>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ResourceInvokerManager {
* ```
*/
export function resourceFactory<Value = unknown, Args extends any[] = any[]>(
wrapperFn: (...args: Args) => ReturnType<typeof resource<Value>>
wrapperFn: (...args: Args) => ReturnType<typeof resource<Value>>,
/**
* This is a bonkers return type.
* Here are the scenarios:
Expand Down
6 changes: 3 additions & 3 deletions ember-resources/src/core/function-based/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions ember-resources/src/core/function-based/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ export function resource<Value>(context: object, setup: ResourceFunction<Value>)
*/
export function resource<Value>(
context: object | ResourceFunction<Value>,
setup?: ResourceFunction<Value>
setup?: ResourceFunction<Value>,
): Value | InternalFunctionResourceConfig<Value> | ResourceFn<Value> {
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<Value> = {
Expand Down Expand Up @@ -204,12 +204,12 @@ export function resource<Value>(
`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<Value> = {
Expand Down
2 changes: 1 addition & 1 deletion ember-resources/src/core/function-based/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { InternalFunctionResourceConfig } from './types';
*/
export function wrapForPlainUsage<Value>(
context: object,
setup: InternalFunctionResourceConfig<Value>
setup: InternalFunctionResourceConfig<Value>,
) {
let cache: Cache;

Expand Down
2 changes: 1 addition & 1 deletion ember-resources/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface Stage1DecoratorDescriptor {
export type Stage1Decorator = (
prototype: object,
key: string | symbol,
descriptor?: Stage1DecoratorDescriptor
descriptor?: Stage1DecoratorDescriptor,
) => any;

export interface ClassResourceConfig {
Expand Down
16 changes: 8 additions & 8 deletions ember-resources/src/core/use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function use<Value>(definition: Value | (() => Value)): PropertyDecorator
export function use<Prototype, Key>(
prototype: NonInstanceType<Prototype>,
key: DecoratorKey<Key>,
descriptor?: Stage1DecoratorDescriptor
descriptor?: Stage1DecoratorDescriptor,
): void;

/**
Expand All @@ -78,7 +78,7 @@ export function use<Prototype, Key>(
export function use<Value>(
parent: object,
definition: Value | (() => Value),
_?: never
_?: never,
): Reactive<Value extends Reactive<any> ? Value['current'] : Value>;

export function use(
Expand Down Expand Up @@ -117,7 +117,7 @@ function getCurrentValue<Value>(value: Value | Reactive<Value>): Value {

function classContextLink<Value>(
context: object,
definition: Value | (() => Value)
definition: Value | (() => Value),
): Reactive<Value> {
let cache: ReturnType<typeof invokeHelper>;

Expand All @@ -138,7 +138,7 @@ function argumentToDecorator<Value>(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;
Expand All @@ -148,7 +148,7 @@ function argumentToDecorator<Value>(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);
Expand All @@ -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') {
Expand Down Expand Up @@ -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;
Expand All @@ -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 */;
Expand Down
4 changes: 2 additions & 2 deletions ember-resources/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function linkDecorator(
_prototype: object,
key: string | Symbol,
descriptor: Stage1DecoratorDescriptor | undefined,
explicitChild?: Class<unknown>
explicitChild?: Class<unknown>,
): 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');
Expand All @@ -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<object, any>();
Expand Down
10 changes: 5 additions & 5 deletions ember-resources/src/modifier/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type ArgsForFn<S> = S extends { Args?: object }
*
*/
export function modifier<El extends Element, Args extends unknown[] = unknown[]>(
fn: (element: El, ...args: Args) => void
fn: (element: El, ...args: Args) => void,
): ModifierLike<{
Element: El;
Args: {
Expand Down Expand Up @@ -112,7 +112,7 @@ export function modifier<El extends Element, Args extends unknown[] = unknown[]>
*
*/
export function modifier<S extends { Element?: Element }>(
fn: (element: ElementFor<S>, ...args: ArgsForFn<S>) => ReturnType<typeof resource>
fn: (element: ElementFor<S>, ...args: ArgsForFn<S>) => ReturnType<typeof resource>,
): ModifierLike<S>;
/**
* A resource-based API for building modifiers.
Expand Down Expand Up @@ -153,7 +153,7 @@ export function modifier<S extends { Element?: Element }>(
*
*/
export function modifier<S extends { Args?: object }>(
fn: (element: ElementFor<S>, ...args: ArgsForFn<S>) => ReturnType<typeof resource>
fn: (element: ElementFor<S>, ...args: ArgsForFn<S>) => ReturnType<typeof resource>,
): ModifierLike<S>;
/**
* A resource-based API for building modifiers.
Expand Down Expand Up @@ -194,7 +194,7 @@ export function modifier<S extends { Args?: object }>(
*
*/
export function modifier<S extends { Element?: Element; Args?: object }>(
fn: (element: ElementFor<S>, ...args: ArgsForFn<S>) => ReturnType<typeof resource>
fn: (element: ElementFor<S>, ...args: ArgsForFn<S>) => ReturnType<typeof resource>,
): ModifierLike<S>;

export function modifier(fn: (element: Element, ...args: unknown[]) => void): ModifierLike<{
Expand Down Expand Up @@ -223,5 +223,5 @@ export function modifier(fn: (element: Element, ...args: unknown[]) => void): Mo
export type FunctionBasedModifierDefinition<S> = (
element: ElementFor<S>,
positional: PositionalArgs<S>,
named: NamedArgs<S>
named: NamedArgs<S>,
) => void;
16 changes: 8 additions & 8 deletions ember-resources/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function service(resource: unknown) {
return function legacyServiceDecorator(
_prototype: object,
key: string,
descriptor?: Stage1DecoratorDescriptor
descriptor?: Stage1DecoratorDescriptor,
) {
if (!descriptor) return;

Expand All @@ -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 {
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -180,15 +180,15 @@ 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,
);

/**
* We do a lot of lying internally to make TypeScript nice for consumers.
* 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);
Expand Down Expand Up @@ -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.',
);
}

Expand Down
8 changes: 4 additions & 4 deletions ember-resources/src/util/ember-concurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import type { Cache } from '../core/types';
export function task<
Return = unknown,
Args extends unknown[] = unknown[],
LocalTask extends TaskIsh<Args, Return> = TaskIsh<Args, Return>
LocalTask extends TaskIsh<Args, Return> = TaskIsh<Args, Return>,
>(context: object, task: LocalTask, thunk?: () => Args) {
assert(`Task does not have a perform method. Is it actually a task?`, 'perform' in task);

Expand All @@ -85,7 +85,7 @@ const TASK_CACHE = new WeakMap<object, any>();
function buildUnproxiedTaskResource<
ArgsList extends any[],
Return,
LocalTask extends TaskIsh<ArgsList, Return> = TaskIsh<ArgsList, Return>
LocalTask extends TaskIsh<ArgsList, Return> = TaskIsh<ArgsList, Return>,
>(context: object, task: LocalTask, thunk: () => ArgsList) {
type LocalResource = TaskResource<ArgsList, Return, LocalTask>;
type Klass = new (...args: unknown[]) => LocalResource;
Expand Down Expand Up @@ -128,7 +128,7 @@ export function proxyClass<
ArgsList,
Return,
LocalTask
>
>,
>(target: { value: Instance }) {
/*
* This proxy defaults to returning the underlying data on
Expand Down Expand Up @@ -216,7 +216,7 @@ export const TASK = Symbol('TASK');
export class TaskResource<
Args extends any[],
Return,
LocalTask extends TaskIsh<Args, Return>
LocalTask extends TaskIsh<Args, Return>,
> extends Resource<{
positional: Args;
}> {
Expand Down
2 changes: 1 addition & 1 deletion ember-resources/src/util/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Get<T, K, Otherwise = unknown> = K extends keyof T ? T[K] : Otherwise;
export function helper<T = unknown, S = InferSignature<T>, Return = Get<S, 'Return'>>(
context: object,
helper: T,
thunk: Thunk = DEFAULT_THUNK
thunk: Thunk = DEFAULT_THUNK,
): { value: Return } {
let resource: Cache<unknown>;

Expand Down
Loading

0 comments on commit 1c1ad1c

Please sign in to comment.