mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Prevent default parameters for objects
This commit is contained in:
parent
98f5d8fb73
commit
c2a84b6592
@ -238,6 +238,7 @@ const configs = antfu(
|
||||
'unicorn/no-lonely-if': 'error',
|
||||
'unicorn/no-negated-condition': 'error',
|
||||
'unicorn/no-nested-ternary': 'error',
|
||||
'unicorn/no-object-as-default-parameter': 'error',
|
||||
'unicorn/no-process-exit': 'error',
|
||||
'unicorn/no-thenable': 'error',
|
||||
'unicorn/no-useless-fallback-in-spread': 'error',
|
||||
@ -269,9 +270,6 @@ const configs = antfu(
|
||||
'unicorn/require-array-join-separator': 'error',
|
||||
'unicorn/require-number-to-fixed-digits-argument': 'error',
|
||||
|
||||
// Might want to enable these
|
||||
'unicorn/no-object-as-default-parameter': 'off',
|
||||
|
||||
'unused-imports/no-unused-vars': [
|
||||
'error',
|
||||
{ args: 'after-used', vars: 'all', ignoreRestSiblings: true },
|
||||
|
@ -38,9 +38,9 @@ export class BaseServerFactory implements HttpServerFactory {
|
||||
private readonly configurator: ServerConfigurator;
|
||||
private readonly options: BaseServerFactoryOptions;
|
||||
|
||||
public constructor(configurator: ServerConfigurator, options: BaseServerFactoryOptions = { https: false }) {
|
||||
public constructor(configurator: ServerConfigurator, options?: BaseServerFactoryOptions) {
|
||||
this.configurator = configurator;
|
||||
this.options = { ...options };
|
||||
this.options = { https: false, ...options };
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ const PREFIX_LOCK = '__L__';
|
||||
|
||||
export interface RedisSettings {
|
||||
/* Override default namespacePrefixes (used to prefix keys in Redis) */
|
||||
namespacePrefix: string;
|
||||
namespacePrefix?: string;
|
||||
/* Username used for AUTH on the Redis server */
|
||||
username?: string;
|
||||
/* Password used for AUTH on the Redis server */
|
||||
@ -74,12 +74,13 @@ export class RedisLocker implements ReadWriteLocker, ResourceLocker, Initializab
|
||||
public constructor(
|
||||
redisClient = '127.0.0.1:6379',
|
||||
attemptSettings: AttemptSettings = {},
|
||||
redisSettings: RedisSettings = { namespacePrefix: '' },
|
||||
redisSettings?: RedisSettings,
|
||||
) {
|
||||
redisSettings = { namespacePrefix: '', ...redisSettings };
|
||||
const { namespacePrefix, ...options } = redisSettings;
|
||||
this.redis = this.createRedisClient(redisClient, options);
|
||||
this.attemptSettings = { ...attemptDefaults, ...attemptSettings };
|
||||
this.namespacePrefix = namespacePrefix;
|
||||
this.namespacePrefix = namespacePrefix!;
|
||||
|
||||
// Register lua scripts
|
||||
for (const [ name, script ] of Object.entries(REDIS_LUA_SCRIPTS)) {
|
||||
|
@ -23,10 +23,10 @@ export function getTemplateFilePath(template?: Template): string | undefined {
|
||||
/**
|
||||
* Reads the template and returns it as a string.
|
||||
*/
|
||||
export async function readTemplate(template: Template = { templateString: '' }): Promise<string> {
|
||||
export async function readTemplate(template?: Template): Promise<string> {
|
||||
// The template has already been given as a string
|
||||
if (typeof template === 'object' && 'templateString' in template) {
|
||||
return template.templateString;
|
||||
if (typeof template === 'undefined' || (typeof template === 'object' && 'templateString' in template)) {
|
||||
return template?.templateString ?? '';
|
||||
}
|
||||
// The template needs to be read from disk
|
||||
return fsPromises.readFile(getTemplateFilePath(template)!, 'utf8');
|
||||
|
Loading…
x
Reference in New Issue
Block a user