Skip to content

Commit

Permalink
chore(fmt): prettier and lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduy1407 committed Dec 5, 2023
1 parent 0a53487 commit 6c39639
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 53 deletions.
5 changes: 4 additions & 1 deletion src/compiler/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export class Cache implements d.Cache {
private logger: d.Logger;
private buildCacheDir: string;

constructor(private config: d.Config, private cacheFs: InMemoryFileSystem) {
constructor(
private config: d.Config,
private cacheFs: InMemoryFileSystem,
) {
this.sys = config.sys;
this.logger = config.logger;
}
Expand Down
87 changes: 45 additions & 42 deletions src/compiler/config/outputs/validate-custom-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,53 @@ export const validateCustomElement = (
): ReadonlyArray<OutputTargetDistCustomElements | OutputTargetDistTypes | OutputTargetCopy> => {
const defaultDir = 'dist';

return userOutputs.filter(isOutputTargetDistCustomElements).reduce((outputs, o) => {
const outputTarget = {
...o,
dir: getAbsolutePath(config, o.dir || join(defaultDir, 'components')),
};
if (!isBoolean(outputTarget.empty)) {
outputTarget.empty = true;
}
if (!isBoolean(outputTarget.externalRuntime)) {
outputTarget.externalRuntime = true;
}
if (!isBoolean(outputTarget.generateTypeDeclarations)) {
outputTarget.generateTypeDeclarations = true;
}
// Export behavior must be defined on the validated target config and must
// be one of the export behavior valid values
if (
outputTarget.customElementsExportBehavior == null ||
!CustomElementsExportBehaviorOptions.includes(outputTarget.customElementsExportBehavior)
) {
outputTarget.customElementsExportBehavior = 'default';
}
return userOutputs.filter(isOutputTargetDistCustomElements).reduce(
(outputs, o) => {
const outputTarget = {
...o,
dir: getAbsolutePath(config, o.dir || join(defaultDir, 'components')),
};
if (!isBoolean(outputTarget.empty)) {
outputTarget.empty = true;
}
if (!isBoolean(outputTarget.externalRuntime)) {
outputTarget.externalRuntime = true;
}
if (!isBoolean(outputTarget.generateTypeDeclarations)) {
outputTarget.generateTypeDeclarations = true;
}
// Export behavior must be defined on the validated target config and must
// be one of the export behavior valid values
if (
outputTarget.customElementsExportBehavior == null ||
!CustomElementsExportBehaviorOptions.includes(outputTarget.customElementsExportBehavior)
) {
outputTarget.customElementsExportBehavior = 'default';
}

// unlike other output targets, Rindo does not allow users to define the output location of types at this time
if (outputTarget.generateTypeDeclarations) {
const typesDirectory = getAbsolutePath(config, join(defaultDir, 'types'));
outputs.push({
type: DIST_TYPES,
dir: outputTarget.dir,
typesDir: typesDirectory,
});
}
// unlike other output targets, Rindo does not allow users to define the output location of types at this time
if (outputTarget.generateTypeDeclarations) {
const typesDirectory = getAbsolutePath(config, join(defaultDir, 'types'));
outputs.push({
type: DIST_TYPES,
dir: outputTarget.dir,
typesDir: typesDirectory,
});
}

outputTarget.copy = validateCopy(outputTarget.copy, []);
outputTarget.copy = validateCopy(outputTarget.copy, []);

if (outputTarget.copy.length > 0) {
outputs.push({
type: COPY,
dir: config.rootDir,
copy: [...outputTarget.copy],
});
}
outputs.push(outputTarget);
if (outputTarget.copy.length > 0) {
outputs.push({
type: COPY,
dir: config.rootDir,
copy: [...outputTarget.copy],
});
}
outputs.push(outputTarget);

return outputs;
}, [] as (OutputTargetDistCustomElements | OutputTargetCopy | OutputTargetDistTypes)[]);
return outputs;
},
[] as (OutputTargetDistCustomElements | OutputTargetCopy | OutputTargetDistTypes)[],
);
};
5 changes: 4 additions & 1 deletion src/sys/node/node-lazy-require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export class NodeLazyRequire implements d.LazyRequire {
* @param nodeResolveModule an object which wraps up module resolution functionality
* @param lazyDependencies the dependency requirements we want to enforce here
*/
constructor(private nodeResolveModule: NodeResolveModule, private lazyDependencies: LazyDependencies) {}
constructor(
private nodeResolveModule: NodeResolveModule,
private lazyDependencies: LazyDependencies,
) {}

/**
* Ensure that a dependency within our supported range is installed in the
Expand Down
5 changes: 4 additions & 1 deletion src/sys/node/node-worker-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export class NodeWorkerController extends EventEmitter implements d.WorkerMainCo
useForkedWorkers: boolean;
mainThreadRunner: { [fnName: string]: (...args: any[]) => Promise<any> };

constructor(public forkModulePath: string, maxConcurrentWorkers: number) {
constructor(
public forkModulePath: string,
maxConcurrentWorkers: number,
) {
super();
const osCpus = cpus().length;

Expand Down
5 changes: 4 additions & 1 deletion src/sys/node/node-worker-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export class NodeWorkerMain extends EventEmitter {
successfulMessage = false;
totalTasksAssigned = 0;

constructor(public id: number, forkModulePath: string) {
constructor(
public id: number,
forkModulePath: string,
) {
super();
this.fork(forkModulePath);
}
Expand Down
5 changes: 4 additions & 1 deletion src/testing/puppeteer/puppeteer-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export class E2EElement extends MockHTMLElement implements pd.E2EElementInternal
this._queuedActions.push(action);
}

constructor(private _page: pd.E2EPageInternal, private _elmHandle: puppeteer.ElementHandle) {
constructor(
private _page: pd.E2EPageInternal,
private _elmHandle: puppeteer.ElementHandle,
) {
super(null, null);
_page._e2eElements.push(this);
}
Expand Down
15 changes: 9 additions & 6 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,15 @@ export const fromEntries = <V>(entries: IterableIterator<[string, V]>) => {
* every `key` in `keys`
*/
export const pluck = (obj: { [key: string]: any }, keys: string[]) => {
return keys.reduce((final, key) => {
if (obj[key]) {
final[key] = obj[key];
}
return final;
}, {} as { [key: string]: any });
return keys.reduce(
(final, key) => {
if (obj[key]) {
final[key] = obj[key];
}
return final;
},
{} as { [key: string]: any },
);
};

const isDefined = (v: any): v is NonNullable<typeof v> => v !== null && v !== undefined;
Expand Down

0 comments on commit 6c39639

Please sign in to comment.