Apply prefer-const lint rule

This commit is contained in:
Zaid Abdulla committed 2018-08-25 16:14:34 -07:00
1 parent b43088c03c
commit 09e6a360af
26 files changed
+217 -215

No files matched your search

+18 -18
View File
@@ -56,7 +56,7 @@ function runExtension(sessionContext, key, extCall, callback) {
const callbacks = re[key];
delete re[key];
if (!err && !fault) sessionContext.extensionsCache[key] = res;
for (let c of callbacks) c(err, fault);
for (const c of callbacks) c(err, fault);
});
}
}
@@ -83,7 +83,7 @@ class SandboxDate {
let offset = 0;
if (variance)
offset = scheduling.variance(state.sessionContext.deviceId, variance);
let cron = scheduling.parseCron(intervalOrCron);
const cron = scheduling.parseCron(intervalOrCron);
t = scheduling.cron(t, cron, offset)[0];
} else if (intervalOrCron) {
throw new Error("Invalid Date.now() argument");
@@ -105,7 +105,7 @@ random.seed = function(s) {
class ParameterWrapper {
constructor(path, attributes, unpacked, unpackedRevision) {
for (let attrName of attributes) {
for (const attrName of attributes) {
Object.defineProperty(this, attrName, {
get: function() {
if (state.uncommitted) commit();
@@ -121,7 +121,7 @@ class ParameterWrapper {
if (!unpacked.length) return UNDEFINED;
let attr = state.sessionContext.deviceData.attributes.get(
const attr = state.sessionContext.deviceData.attributes.get(
unpacked[0],
state.revision
)[attrName];
@@ -183,7 +183,7 @@ class ParameterWrapper {
);
}
for (let p of unpacked)
for (const p of unpacked)
yield new ParameterWrapper(p, attributes, [p], state.revision);
};
}
@@ -195,12 +195,12 @@ function declare(path, timestamps, values) {
if (!values) values = {};
let parsedPath = common.parsePath(path);
const parsedPath = common.parsePath(path);
let declaration = [parsedPath, 1];
let attrs = {};
const declaration = [parsedPath, 1];
const attrs = {};
for (let attrName in values) {
for (const attrName in values) {
if (!timestamps[attrName]) timestamps[attrName] = 1;
if (attrName === "path") {
@@ -214,7 +214,7 @@ function declare(path, timestamps, values) {
}
}
for (let attrName in timestamps) {
for (const attrName in timestamps) {
if (attrName === "path") {
declaration[1] = timestamps.path;
} else {
@@ -251,8 +251,8 @@ function commit() {
function ext() {
++state.extCounter;
let extCall = Array.from(arguments).map(String);
let key = `${state.revision}: ${JSON.stringify(extCall)}`;
const extCall = Array.from(arguments).map(String);
const key = `${state.revision}: ${JSON.stringify(extCall)}`;
if (key in state.sessionContext.extensionsCache)
return state.sessionContext.extensionsCache[key];
@@ -296,7 +296,7 @@ function errorToFault(err) {
if (!err.name) return { code: "script", message: `${err}` };
let fault = {
const fault = {
code: `script.${err.name}`,
message: err.message,
detail: {
@@ -308,7 +308,7 @@ function errorToFault(err) {
if (err.stack) {
fault.detail.stack = err.stack;
// Trim the stack trace at the self-executing anonymous wrapper function
let stackTrimIndex = fault.detail.stack.match(
const stackTrimIndex = fault.detail.stack.match(
/\s+at\s[^\s]+\s+at\s[^\s]+\s\(vm\.js.+\)/
);
if (stackTrimIndex)
@@ -339,7 +339,7 @@ function run(
extCounter: extCounter
};
for (let n of Object.keys(context)) delete context[n];
for (const n of Object.keys(context)) delete context[n];
Object.assign(context, globals);
@@ -354,8 +354,8 @@ function run(
else return void callback(null, errorToFault(err));
}
let _state = state;
let args = Array.from(arguments);
const _state = state;
const args = Array.from(arguments);
// Need to maintain a counter of ext() calls to avoid calling certain
// functions (e.g. log()) multiple times as calling ext() results in
@@ -363,7 +363,7 @@ function run(
args[6] = 0 - (state.extCounter - extCounter);
let counter = 3;
for (let key of Object.keys(_state.extensions)) {
for (const key of Object.keys(_state.extensions)) {
counter += 2;
runExtension(
_state.sessionContext,