Skip to content

Commit

Permalink
[JS] eslint: prefer template literals
Browse files Browse the repository at this point in the history
Change-Id: I26d14f896464b9acf286855241155cec13a5a61e
  • Loading branch information
Max van gen Hassend authored and Max van gen Hassend committed Jun 6, 2018
1 parent 72e8f98 commit 4a8e97b
Show file tree
Hide file tree
Showing 87 changed files with 547 additions and 701 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -72,6 +72,7 @@ module.exports = {
"prefer-arrow-callback": "error", "prefer-arrow-callback": "error",
"prefer-const": "error", "prefer-const": "error",
"prefer-destructuring": "off", "prefer-destructuring": "off",
"prefer-template": "error",
"prefer-spread": "error", "prefer-spread": "error",
"promise/always-return": "off", "promise/always-return": "off",
"promise/no-return-wrap": "error", "promise/no-return-wrap": "error",
Expand Down
5 changes: 3 additions & 2 deletions javascript/libjoynr-js/src/main/js/global/JoynrPersist.js
Expand Up @@ -76,8 +76,9 @@ JoynrPersist.prototype = {
return fs.lstatSync(filePath).isDirectory(); return fs.lstatSync(filePath).isDirectory();
}); });
throw new Error( throw new Error(
"joynr configuration error: Persistency subdirectory must not include other subdirectories. Directories found: " + `joynr configuration error: Persistency subdirectory must not include other subdirectories. Directories found: ${JSON.stringify(
JSON.stringify(subDirectories) subDirectories
)}`
); );
} else { } else {
throw e; throw e;
Expand Down
Expand Up @@ -88,7 +88,7 @@ if (global.window !== undefined) {
}, },
_wrapFunction(cb, ...args) { _wrapFunction(cb, ...args) {
this._promiseChain = this._promiseChain.then(() => cb(...args)).catch(e => { this._promiseChain = this._promiseChain.then(() => cb(...args)).catch(e => {
log.error(`failure executing ${cb} with args ${JSON.stringify(args)} error: ` + e); log.error(`failure executing ${cb} with args ${JSON.stringify(args)} error: ${e}`);
}); });
} }
}; };
Expand Down
2 changes: 1 addition & 1 deletion javascript/libjoynr-js/src/main/js/global/WebSocket.js
Expand Up @@ -30,7 +30,7 @@ if (typeof TextDecoder !== "function") {
const log = LoggingManager.getLogger("joynr.messaging.websocket.WebSocket"); const log = LoggingManager.getLogger("joynr.messaging.websocket.WebSocket");
const fileReader = new FileReader(); const fileReader = new FileReader();
fileReader.onError = function(error) { fileReader.onError = function(error) {
log.error("Decoding of binary message failed: " + error); log.error(`Decoding of binary message failed: ${error}`);
}; };
const textDecoder = new TextDecoder(); const textDecoder = new TextDecoder();
const textEncoder = new TextEncoder(); const textEncoder = new TextEncoder();
Expand Down
Expand Up @@ -144,7 +144,7 @@ CapabilitiesRegistrar.prototype.registerProvider = function registerProvider(


if (missingImplementations.length > 0) { if (missingImplementations.length > 0) {
throw new Error( throw new Error(
"provider: " + domain + "/" + provider.interfaceName + " is missing: " + missingImplementations.toString() `provider: ${domain}/${provider.interfaceName} is missing: ${missingImplementations.toString()}`
); );
} }


Expand Down Expand Up @@ -192,12 +192,9 @@ CapabilitiesRegistrar.prototype.registerProvider = function registerProvider(


function registerProviderFinished() { function registerProviderFinished() {
log.info( log.info(
"Provider registered: participantId: " + `Provider registered: participantId: ${participantId}, domain: ${domain}, interfaceName: ${
participantId +
", domain: " +
domain +
", interfaceName: " +
provider.interfaceName provider.interfaceName
}`
); );
return participantId; return participantId;
} }
Expand Down Expand Up @@ -237,12 +234,9 @@ CapabilitiesRegistrar.prototype.unregisterProvider = function unregisterProvider


return Promise.all([discoveryStubPromise, messageRouterPromise]).then(() => { return Promise.all([discoveryStubPromise, messageRouterPromise]).then(() => {
log.info( log.info(
"Provider unregistered: participantId: " + `Provider unregistered: participantId: ${participantId}, domain: ${domain}, interfaceName: ${
participantId +
", domain: " +
domain +
", interfaceName: " +
provider.interfaceName provider.interfaceName
}`
); );
}); });
}; };
Expand Down
Expand Up @@ -43,7 +43,7 @@ function ParticipantIdStorage(persistency, uuid) {
* @returns {String} the retrieved or generated participantId * @returns {String} the retrieved or generated participantId
*/ */
ParticipantIdStorage.prototype.getParticipantId = function getParticipantId(domain, provider) { ParticipantIdStorage.prototype.getParticipantId = function getParticipantId(domain, provider) {
const key = "joynr.participant." + domain + "." + provider.interfaceName; const key = `joynr.participant.${domain}.${provider.interfaceName}`;
let participantId = this._persistency.getItem(key); let participantId = this._persistency.getItem(key);
if (!participantId) { if (!participantId) {
participantId = this._uuid(); participantId = this._uuid();
Expand Down
Expand Up @@ -66,7 +66,7 @@ function discoverStaticCapabilities(capabilities, domains, interfaceName, discov
} }
} catch (e) { } catch (e) {
deferred.pending = false; deferred.pending = false;
deferred.reject(new Error("Exception while arbitrating: " + e)); deferred.reject(new Error(`Exception while arbitrating: ${e}`));
} }
} }


Expand Down Expand Up @@ -245,14 +245,9 @@ Arbitrator.prototype.startArbitration = function startArbitration(settings) {
delete that._pendingArbitrations[deferred.id]; delete that._pendingArbitrations[deferred.id];


if (deferred.incompatibleVersionsFound.length > 0) { if (deferred.incompatibleVersionsFound.length > 0) {
const message = const message = `no compatible provider found within discovery timeout for domains "${JSON.stringify(
'no compatible provider found within discovery timeout for domains "' + settings.domains
JSON.stringify(settings.domains) + )}", interface "${settings.interfaceName}" with discoveryQos "${JSON.stringify(settings.discoveryQos)}"`;
'", interface "' +
settings.interfaceName +
'" with discoveryQos "' +
JSON.stringify(settings.discoveryQos) +
'"';
startArbitrationDeferred.reject( startArbitrationDeferred.reject(
new NoCompatibleProviderFoundException({ new NoCompatibleProviderFoundException({
detailMessage: message, detailMessage: message,
Expand All @@ -263,15 +258,11 @@ Arbitrator.prototype.startArbitration = function startArbitration(settings) {
} else { } else {
startArbitrationDeferred.reject( startArbitrationDeferred.reject(
new DiscoveryException({ new DiscoveryException({
detailMessage: detailMessage: `no provider found within discovery timeout for domains "${JSON.stringify(
'no provider found within discovery timeout for domains "' + settings.domains
JSON.stringify(settings.domains) + )}", interface "${settings.interfaceName}" with discoveryQos "${JSON.stringify(
'", interface "' + settings.discoveryQos
settings.interfaceName + )}"${deferred.errorMsg !== undefined ? `. Error: ${deferred.errorMsg}` : ""}`
'" with discoveryQos "' +
JSON.stringify(settings.discoveryQos) +
'"' +
(deferred.errorMsg !== undefined ? ". Error: " + deferred.errorMsg : "")
}) })
); );
} }
Expand Down
Expand Up @@ -121,7 +121,7 @@ function CapabilityDiscovery(
}) })
}) })
.catch(error => { .catch(error => {
throw new Error("Failed to create global capabilities directory proxy: " + error); throw new Error(`Failed to create global capabilities directory proxy: ${error}`);
}); });
} }


Expand Down Expand Up @@ -149,8 +149,9 @@ function CapabilityDiscovery(
globalAddress = Typing.augmentTypes(JSON.parse(globalDiscoveryEntry.address)); globalAddress = Typing.augmentTypes(JSON.parse(globalDiscoveryEntry.address));
} catch (e) { } catch (e) {
log.error( log.error(
"unable to use global discoveryEntry with unknown address type: " + `unable to use global discoveryEntry with unknown address type: ${
globalDiscoveryEntry.address globalDiscoveryEntry.address
}`
); );
continue; continue;
} }
Expand Down Expand Up @@ -221,7 +222,7 @@ function CapabilityDiscovery(
}); });
}) })
.catch(error => { .catch(error => {
throw new Error('Error calling operation "add" of GlobalCapabilitiesDirectory because: ' + error); throw new Error(`Error calling operation "add" of GlobalCapabilitiesDirectory because: ${error}`);
}); });
} }


Expand Down Expand Up @@ -363,7 +364,7 @@ function CapabilityDiscovery(
} }
return lookupGlobalCapabilities(domains, interfaceName, TTL_30DAYS_IN_MS, globalCapabilities); return lookupGlobalCapabilities(domains, interfaceName, TTL_30DAYS_IN_MS, globalCapabilities);
default: default:
log.error("unknown discoveryScope value: " + discoveryQos.discoveryScope.value); log.error(`unknown discoveryScope value: ${discoveryQos.discoveryScope.value}`);
} }
}; };


Expand Down Expand Up @@ -409,9 +410,7 @@ function CapabilityDiscovery(
promise = addGlobal(discoveryEntry); promise = addGlobal(discoveryEntry);
} }
} else { } else {
promise = Promise.reject( promise = Promise.reject(new Error(`Encountered unknown ProviderQos scope "${discoveryEntry.qos.scope}"`));
new Error('Encountered unknown ProviderQos scope "' + discoveryEntry.qos.scope + '"')
);
} }
return promise; return promise;
}; };
Expand All @@ -431,7 +430,7 @@ function CapabilityDiscovery(
return globalCapabilitiesDirectoryProxy.touch({ clusterControllerId }); return globalCapabilitiesDirectoryProxy.touch({ clusterControllerId });
}) })
.catch(error => { .catch(error => {
throw new Error('Error calling operation "touch" of GlobalCapabilitiesDirectory because: ' + error); throw new Error(`Error calling operation "touch" of GlobalCapabilitiesDirectory because: ${error}`);
}); });
}; };


Expand All @@ -454,7 +453,7 @@ function CapabilityDiscovery(
}); });
}) })
.catch(error => { .catch(error => {
throw new Error('Error calling operation "remove" of GlobalCapabilitiesDirectory because: ' + error); throw new Error(`Error calling operation "remove" of GlobalCapabilitiesDirectory because: ${error}`);
}); });
} }


Expand All @@ -481,9 +480,9 @@ function CapabilityDiscovery(
}); });
if (discoveryEntries === undefined || discoveryEntries.length !== 1) { if (discoveryEntries === undefined || discoveryEntries.length !== 1) {
log.warn( log.warn(
"remove(): no capability entry found in local capabilities store for participantId " + `remove(): no capability entry found in local capabilities store for participantId ${
participantId + participantId
". Trying to remove the capability from global directory" }. Trying to remove the capability from global directory`
); );
promise = removeParticipantIdFromGlobalCapabilitiesDirectory(participantId); promise = removeParticipantIdFromGlobalCapabilitiesDirectory(participantId);
} else if (discoveryEntries[0].qos.scope === ProviderScope.LOCAL || discoveryEntries.length < 1) { } else if (discoveryEntries[0].qos.scope === ProviderScope.LOCAL || discoveryEntries.length < 1) {
Expand All @@ -492,7 +491,7 @@ function CapabilityDiscovery(
promise = removeParticipantIdFromGlobalCapabilitiesDirectory(participantId); promise = removeParticipantIdFromGlobalCapabilitiesDirectory(participantId);
} else { } else {
promise = Promise.reject( promise = Promise.reject(
new Error('Encountered unknown ProviderQos scope "' + discoveryEntries[0].qos.scope + '"') new Error(`Encountered unknown ProviderQos scope "${discoveryEntries[0].qos.scope}"`)
); );
} }
return promise; return promise;
Expand Down

0 comments on commit 4a8e97b

Please sign in to comment.