Skip to content

Commit a9d3c4b

Browse files
build: run prettier
1 parent e4a7912 commit a9d3c4b

File tree

3 files changed

+50
-29
lines changed

3 files changed

+50
-29
lines changed

src/dynamic-param-interfaces.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,20 @@ const ignoreDescriptions = <T extends EventParameterDocumentation>(
3737
props: T[],
3838
): Pick<T, Exclude<keyof T, 'description'>>[] =>
3939
_.map(props, p => {
40-
const {
41-
description,
42-
...toReturn
43-
} = p;
40+
const { description, ...toReturn } = p;
4441

4542
return toReturn;
4643
}).sort((a, b) => a.name.localeCompare(b.name));
4744

4845
// Given a parameter create a new interface and return it's name
4946
// IName is the proposed interface name prefix
5047
// backupIName is a slightly longer IName in case IName is already taken
51-
const createParamInterface = (param: ParamInterface, IName = '', backupIName = '', finalBackupIName = ''): string => {
48+
const createParamInterface = (
49+
param: ParamInterface,
50+
IName = '',
51+
backupIName = '',
52+
finalBackupIName = '',
53+
): string => {
5254
let argType = polite(IName) + _.upperFirst(_.camelCase(param.name));
5355
let argName = param.name;
5456
// TODO: Note. It is still possible for even backupIName to be already used
@@ -82,7 +84,10 @@ const createParamInterface = (param: ParamInterface, IName = '', backupIName = '
8284
return createParamInterface(param, backupIName, finalBackupIName);
8385
}
8486
console.error(
85-
argType, IName, backupIName, finalBackupIName,
87+
argType,
88+
IName,
89+
backupIName,
90+
finalBackupIName,
8691
ignoreDescriptions(paramInterfacesToDeclare[argType].properties),
8792
'\n',
8893
ignoreDescriptions(param.properties),

src/master-interfaces.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export const generateMasterInterfaces = (
3838
(tModule, tIndex) =>
3939
index !== tIndex && tModule.name.toLowerCase() === module.name.toLowerCase(),
4040
);
41-
const moduleString = isClass ? ` class ${_.upperFirst(module.name)} extends Electron.${_.upperFirst(module.name)} {}` : '';
41+
const moduleString = isClass
42+
? ` class ${_.upperFirst(module.name)} extends Electron.${_.upperFirst(module.name)} {}`
43+
: '';
4244
if (module.type === 'Structure') {
4345
// We must be a structure or something
4446
return;
@@ -63,9 +65,9 @@ export const generateMasterInterfaces = (
6365
TargetNamespace = RendererNamespace;
6466
}
6567
if (module.process.main && !EMRI[classify(module.name).toLowerCase()]) {
66-
MainInterfaceForRemote.push(` ${classify(module.name)}: ${isClass ? 'typeof ' : ''}${_.upperFirst(
67-
module.name,
68-
)};`)
68+
MainInterfaceForRemote.push(
69+
` ${classify(module.name)}: ${isClass ? 'typeof ' : ''}${_.upperFirst(module.name)};`,
70+
);
6971
}
7072
if (TargetNamespace) {
7173
debug(classify(module.name).toLowerCase(), EMRI[classify(module.name).toLowerCase()]);
@@ -77,10 +79,7 @@ export const generateMasterInterfaces = (
7779
}
7880
});
7981

80-
addToOutput([
81-
...MainInterfaceForRemote,
82-
'}'
83-
])
82+
addToOutput([...MainInterfaceForRemote, '}']);
8483

8584
for (const interfaceKey of interfaceKeys) {
8685
const alias = ` type ${interfaceKey} = Electron.${interfaceKey}`;
@@ -94,8 +93,8 @@ export const generateMasterInterfaces = (
9493
RendererNamespace.push('}');
9594

9695
const withSemicolons = (lines: string[]) => {
97-
return lines.map(l => l.endsWith('{') || l.endsWith('}') ? l : `${l};`);
98-
}
96+
return lines.map(l => (l.endsWith('{') || l.endsWith('}') ? l : `${l};`));
97+
};
9998
addToOutput(['']);
10099
addToOutput(withSemicolons(CommonNamespace));
101100
addToOutput(withSemicolons(MainNamespace));

src/utils.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,21 @@ export const isPrimitive = (type: string) => {
270270
return primitives.indexOf(type.toLowerCase().replace(/\[\]/g, '')) !== -1;
271271
};
272272
export const isBuiltIn = (type: string) => {
273-
const builtIns = ['promise', 'buffer', 'int8array', 'uint8array',
274-
'uint8clampedarray', 'int16array', 'uint16array', 'int32array',
275-
'uint32array', 'float32array', 'float64array', 'bigint64array',
276-
'biguint64array'];
273+
const builtIns = [
274+
'promise',
275+
'buffer',
276+
'int8array',
277+
'uint8array',
278+
'uint8clampedarray',
279+
'int16array',
280+
'uint16array',
281+
'int32array',
282+
'uint32array',
283+
'float32array',
284+
'float64array',
285+
'bigint64array',
286+
'biguint64array',
287+
];
277288
return builtIns.indexOf(type.toLowerCase().replace(/\[\]/g, '')) !== -1;
278289
};
279290
export const isOptional = (param: { required?: boolean; name: string; type: any }) => {
@@ -318,18 +329,19 @@ export const genMethodString = (
318329
return paramInterfaces.createParamInterface(objectParam, _.upperFirst(moduleMethod.name));
319330
}
320331

321-
if (
322-
['set', 'get'].includes(
323-
moduleMethod.name.toLowerCase(),
324-
)
325-
) {
332+
if (['set', 'get'].includes(moduleMethod.name.toLowerCase())) {
326333
return paramInterfaces.createParamInterface(
327334
objectParam,
328335
_.upperFirst(module.name) + _.upperFirst(moduleMethod.name),
329336
);
330337
}
331338

332-
return paramInterfaces.createParamInterface(objectParam, '', _.upperFirst(moduleMethod.name), topLevelModuleMethod ? _.upperFirst(topLevelModuleMethod.name) : '');
339+
return paramInterfaces.createParamInterface(
340+
objectParam,
341+
'',
342+
_.upperFirst(moduleMethod.name),
343+
topLevelModuleMethod ? _.upperFirst(topLevelModuleMethod.name) : '',
344+
);
333345
};
334346
return `${includeType ? '(' : ''}${(moduleMethod.parameters || [])
335347
.map(param => {
@@ -360,7 +372,7 @@ export const genMethodString = (
360372
} as any /* FIXME: */,
361373
true,
362374
'',
363-
moduleMethod
375+
moduleMethod,
364376
),
365377
});
366378
} else if (paramType.type === 'Object' && objectParam.properties) {
@@ -374,9 +386,14 @@ export const genMethodString = (
374386
}
375387
const functionParam = param as DetailedFunctionType;
376388
if (param.type === 'Function' && functionParam.parameters) {
377-
paramType = genMethodString(paramInterfaces, module, functionParam as any /* FIXME: */, true,
389+
paramType = genMethodString(
390+
paramInterfaces,
391+
module,
392+
functionParam as any /* FIXME: */,
393+
true,
378394
'',
379-
moduleMethod);
395+
moduleMethod,
396+
);
380397
}
381398
382399
const name = paramify(param.name);

0 commit comments

Comments
 (0)