Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wszgrcy committed Mar 23, 2024
1 parent 65ed88e commit d8431c8
Show file tree
Hide file tree
Showing 48 changed files with 490 additions and 460 deletions.
8 changes: 4 additions & 4 deletions src/import/di/create_injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export function createInjector(
defType: /* InjectorType<any> */ any,
parent: Injector | null = null,
additionalProviders: Array<Provider | StaticProvider> | null = null,
name?: string
name?: string,
): Injector {
const injector = createInjectorWithoutInjectorInstances(
defType,
parent,
additionalProviders,
name
name,
);
injector.resolveInjectorInitializers();
return injector;
Expand All @@ -44,7 +44,7 @@ export function createInjectorWithoutInjectorInstances(
parent: Injector | null = null,
additionalProviders: Array<Provider | StaticProvider> | null = null,
name?: string,
scopes = new Set<InjectorScope>()
scopes = new Set<InjectorScope>(),
): R3Injector {
const providers = [
additionalProviders || EMPTY_ARRAY,
Expand All @@ -56,6 +56,6 @@ export function createInjectorWithoutInjectorInstances(
providers,
parent || getNullInjector(),
name || null,
scopes
scopes,
);
}
4 changes: 2 additions & 2 deletions src/import/di/inject_switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function getInjectImplementation() {
export function setInjectImplementation(
impl:
| (<T>(token: ProviderToken<T>, flags?: InjectFlags) => T | null)
| undefined
| undefined,
): (<T>(token: ProviderToken<T>, flags?: InjectFlags) => T | null) | undefined {
const previous = _injectImplementation;
_injectImplementation = impl;
Expand All @@ -53,7 +53,7 @@ export function setInjectImplementation(
export function injectRootLimpMode<T>(
token: ProviderToken<T>,
notFoundValue: T | undefined,
flags: InjectFlags
flags: InjectFlags,
): T | null {
const injectableDef: ɵɵInjectableDeclaration<T> | null =
getInjectableDef(token);
Expand Down
4 changes: 2 additions & 2 deletions src/import/di/injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export interface InjectableDecorator {
(
options?: {
providedIn: Type<any> | 'root' | 'platform' | 'any' | null;
} & InjectableProvider
} & InjectableProvider,
): TypeDecorator;
new (): Injectable;
new (
options?: {
providedIn: Type<any> | 'root' | 'platform' | 'any' | null;
} & InjectableProvider
} & InjectableProvider,
): Injectable;
}

Expand Down
2 changes: 1 addition & 1 deletion src/import/di/injection_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class InjectionToken<T> {
options?: {
providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
factory: () => T;
}
},
) {
this.ɵprov = undefined;
if (typeof options == 'number') {
Expand Down
10 changes: 5 additions & 5 deletions src/import/di/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export abstract class Injector {
notFoundValue: undefined,
options: InjectOptions & {
optional?: false;
}
},
): T;
/**
* Retrieves an instance from the injector based on the provided token.
Expand All @@ -71,7 +71,7 @@ export abstract class Injector {
abstract get<T>(
token: ProviderToken<T>,
notFoundValue: null | undefined,
options: InjectOptions
options: InjectOptions,
): T | null;
/**
* Retrieves an instance from the injector based on the provided token.
Expand All @@ -81,7 +81,7 @@ export abstract class Injector {
abstract get<T>(
token: ProviderToken<T>,
notFoundValue?: T,
options?: InjectOptions | InjectFlags
options?: InjectOptions | InjectFlags,
): T;
/**
* Retrieves an instance from the injector based on the provided token.
Expand All @@ -92,7 +92,7 @@ export abstract class Injector {
abstract get<T>(
token: ProviderToken<T>,
notFoundValue?: T,
flags?: InjectFlags
flags?: InjectFlags,
): T;
/**
* @deprecated from v4.0.0 use ProviderToken<T>
Expand Down Expand Up @@ -131,7 +131,7 @@ export abstract class Injector {
parent?: Injector;
name?: string;
},
parent?: Injector
parent?: Injector,
): Injector {
if (Array.isArray(options)) {
return createInjector({ name: '' }, parent, options, '');
Expand Down
36 changes: 18 additions & 18 deletions src/import/di/injector_compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function getCurrentInjector(): Injector | undefined | null {
}

export function setCurrentInjector(
injector: Injector | null | undefined
injector: Injector | null | undefined,
): Injector | undefined | null {
const former = _currentInjector;
_currentInjector = injector;
Expand All @@ -61,11 +61,11 @@ export function setCurrentInjector(
export function injectInjectorOnly<T>(token: ProviderToken<T>): T;
export function injectInjectorOnly<T>(
token: ProviderToken<T>,
flags?: InjectFlags
flags?: InjectFlags,
): T | null;
export function injectInjectorOnly<T>(
token: ProviderToken<T>,
flags = InjectFlags.Default
flags = InjectFlags.Default,
): T | null {
if (_currentInjector === undefined) {
throw new RuntimeError(RuntimeErrorCode.MISSING_INJECTION_CONTEXT, null);
Expand All @@ -75,7 +75,7 @@ export function injectInjectorOnly<T>(
const value = _currentInjector.get(
token,
flags & InjectFlags.Optional ? null : undefined,
flags
flags,
);

return value;
Expand All @@ -95,20 +95,20 @@ export function injectInjectorOnly<T>(
export function ɵɵinject<T>(token: ProviderToken<T>): T;
export function ɵɵinject<T>(
token: ProviderToken<T>,
flags?: InjectFlags
flags?: InjectFlags,
): T | null;

export function ɵɵinject<T>(
token: ProviderToken<T>,
flags?: InjectFlags
flags?: InjectFlags,
): string | null;
export function ɵɵinject<T>(
token: ProviderToken<T>,
flags = InjectFlags.Default
flags = InjectFlags.Default,
): T | null {
return (getInjectImplementation() || injectInjectorOnly)(
resolveForwardRef(token as Type<T>),
flags
flags,
);
}

Expand Down Expand Up @@ -145,7 +145,7 @@ export function inject<T>(token: ProviderToken<T>): T;
*/
export function inject<T>(
token: ProviderToken<T>,
flags?: InjectFlags
flags?: InjectFlags,
): T | null;
/**
* @param token A token that represents a dependency that should be injected.
Expand All @@ -159,7 +159,7 @@ export function inject<T>(
*/
export function inject<T>(
token: ProviderToken<T>,
options: InjectOptions & { optional?: false }
options: InjectOptions & { optional?: false },
): T;
/**
* @param token A token that represents a dependency that should be injected.
Expand All @@ -175,7 +175,7 @@ export function inject<T>(
*/
export function inject<T>(
token: ProviderToken<T>,
options: InjectOptions
options: InjectOptions,
): T | null;
/**
* @param token A token that represents a static attribute on the host node that should be injected.
Expand Down Expand Up @@ -268,7 +268,7 @@ export function inject<T>(
*/
export function inject<T>(
token: ProviderToken<T>,
flags: InjectFlags | InjectOptions = InjectFlags.Default
flags: InjectFlags | InjectOptions = InjectFlags.Default,
) {
// The `as any` here _shouldn't_ be necessary, but without it JSCompiler
// throws a disambiguation error due to the multiple signatures.
Expand All @@ -277,7 +277,7 @@ export function inject<T>(

// Converts object-based DI flags (`InjectOptions`) to bit flags (`InjectFlags`).
export function convertToBitFlags(
flags: InjectOptions | InjectFlags | undefined
flags: InjectOptions | InjectFlags | undefined,
): InjectFlags | undefined {
if (typeof flags === 'undefined' || typeof flags === 'number') {
return flags;
Expand Down Expand Up @@ -340,7 +340,7 @@ export function injectArgs(types: (ProviderToken<any> | any[])[]): any[] {
*/
export function attachInjectFlag(
decorator: any,
flag: InternalInjectFlags | DecoratorFlags
flag: InternalInjectFlags | DecoratorFlags,
): any {
decorator[DI_DECORATOR_FLAG] = flag;
decorator.prototype[DI_DECORATOR_FLAG] = flag;
Expand All @@ -360,7 +360,7 @@ export function catchInjectorError(
e: any,
token: any,
injectorErrorName: string,
source: string | null
source: string | null,
): never {
const tokenPath: any[] = e[NG_TEMP_TOKEN_PATH];
if (token[SOURCE]) {
Expand All @@ -370,7 +370,7 @@ export function catchInjectorError(
'\n' + e.message,
tokenPath,
injectorErrorName,
source
source,
);
e[NG_TOKEN_PATH] = tokenPath;
e[NG_TEMP_TOKEN_PATH] = null;
Expand All @@ -381,7 +381,7 @@ export function formatError(
text: string,
obj: any,
injectorErrorName: string,
source: string | null = null
source: string | null = null,
): string {
text =
text && text.charAt(0) === '\n' && text.charAt(1) == NO_NEW_LINE
Expand All @@ -400,7 +400,7 @@ export function formatError(
':' +
(typeof value === 'string'
? JSON.stringify(value)
: stringify(value))
: stringify(value)),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/import/di/injector_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ export const INJECTOR = new InjectionToken<Injector>(
'',
// Disable tslint because this is const enum which gets inlined not top level prop access.
// tslint:disable-next-line: no-toplevel-property-access
InjectorMarkers.Injector as any // Special value used by Ivy to identify `Injector`.
InjectorMarkers.Injector as any, // Special value used by Ivy to identify `Injector`.
);
6 changes: 3 additions & 3 deletions src/import/di/interface/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export function ɵɵdefineInjector(options: {
* @param type A type which may have its own (non-inherited) `ɵprov`.
*/
export function getInjectableDef<T>(
type: any
type: any,
): ɵɵInjectableDeclaration<T> | null {
return getOwnDefinition(type, NG_PROV_DEF) || null;
}
Expand All @@ -228,7 +228,7 @@ export function isInjectable(type: any): boolean {
*/
function getOwnDefinition<T>(
type: any,
field: string
field: string,
): ɵɵInjectableDeclaration<T> | null {
return type.hasOwnProperty(field) ? type[field] : null;
}
Expand All @@ -242,7 +242,7 @@ function getOwnDefinition<T>(
* scenario if we find the `ɵprov` on an ancestor only.
*/
export function getInheritedInjectableDef<T>(
type: any
type: any,
): ɵɵInjectableDeclaration<T> | null {
const def = type && (type[NG_PROV_DEF] || null);

Expand Down
2 changes: 1 addition & 1 deletion src/import/di/interface/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export interface InternalEnvironmentProviders extends EnvironmentProviders {
}

export function isEnvironmentProviders(
value: Provider | EnvironmentProviders | InternalEnvironmentProviders
value: Provider | EnvironmentProviders | InternalEnvironmentProviders,
): value is InternalEnvironmentProviders {
return value && !!(value as InternalEnvironmentProviders).ɵproviders;
}
Expand Down
6 changes: 3 additions & 3 deletions src/import/di/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const Inject: InjectDecorator = attachInjectFlag(
// Disable tslint because `DecoratorFlags` is a const enum which gets inlined.
// tslint:disable-next-line: no-toplevel-property-access
makeParamDecorator('Inject', (token: any) => ({ token })),
DecoratorFlags.Inject
DecoratorFlags.Inject,
);

/**
Expand Down Expand Up @@ -108,7 +108,7 @@ export const Optional: OptionalDecorator =
// tslint:disable-next-line: no-toplevel-property-access
attachInjectFlag(
makeParamDecorator('Optional'),
InternalInjectFlags.Optional
InternalInjectFlags.Optional,
);

/**
Expand Down Expand Up @@ -206,5 +206,5 @@ export const SkipSelf: SkipSelfDecorator =
// tslint:disable-next-line: no-toplevel-property-access
attachInjectFlag(
makeParamDecorator('SkipSelf'),
InternalInjectFlags.SkipSelf
InternalInjectFlags.SkipSelf,
);
2 changes: 1 addition & 1 deletion src/import/di/null_injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NullInjector implements Injector {
get(token: any, notFoundValue: any = THROW_IF_NOT_FOUND): any {
if (notFoundValue === THROW_IF_NOT_FOUND) {
const error = new Error(
`NullInjectorError: No provider for ${stringify(token)}!`
`NullInjectorError: No provider for ${stringify(token)}!`,
);
error.name = 'NullInjectorError';
throw error;
Expand Down
12 changes: 6 additions & 6 deletions src/import/di/provider_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { INJECTOR_DEF_TYPES } from './internal_tokens';
* referenced in `@Component` in a component injector.
*/
export function makeEnvironmentProviders(
providers: (Provider | EnvironmentProviders)[]
providers: (Provider | EnvironmentProviders)[],
): EnvironmentProviders {
return {
ɵproviders: providers,
Expand All @@ -66,7 +66,7 @@ export type ImportProvidersSource =

type WalkProviderTreeVisitor = (
provider: SingleProvider,
container: Type<unknown> | InjectorType<unknown>
container: Type<unknown> | InjectorType<unknown>,
) => void;

/**
Expand Down Expand Up @@ -136,7 +136,7 @@ export function internalImportProvidersFrom(
if (injectorTypesWithProviders !== undefined) {
processInjectorTypesWithProviders(
injectorTypesWithProviders,
collectProviders
collectProviders,
);
}

Expand All @@ -149,7 +149,7 @@ export function internalImportProvidersFrom(
*/
function processInjectorTypesWithProviders(
typesWithProviders: InjectorTypeWithProviders<unknown>[],
visitor: WalkProviderTreeVisitor
visitor: WalkProviderTreeVisitor,
): void {
for (let i = 0; i < typesWithProviders.length; i++) {
const { ngModule, providers } = typesWithProviders[i];
Expand Down Expand Up @@ -178,13 +178,13 @@ export function isValueProvider(value: SingleProvider): value is ValueProvider {
}

export function isExistingProvider(
value: SingleProvider
value: SingleProvider,
): value is ExistingProvider {
return !!(value && (value as ExistingProvider).useExisting);
}

export function isFactoryProvider(
value: SingleProvider
value: SingleProvider,
): value is FactoryProvider {
return !!(value && (value as FactoryProvider).useFactory);
}
Expand Down
Loading

0 comments on commit d8431c8

Please sign in to comment.