Skip to content

Commit 7176d85

Browse files
authored
Merge pull request #38 from LinusU/prefer-const
Prefer const over let
2 parents 6f82b03 + 5ab02fb commit 7176d85

6 files changed

Lines changed: 12 additions & 15 deletions

File tree

lib/render/engineScript.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = function (inputs, callback, done) {
3636

3737
let isFromCache = true
3838

39-
let engine = (template) => {
39+
const engine = (template) => {
4040
const key = template + ':' + inputs.engine
4141

4242
if (!compiledCache.get(key)) {
@@ -56,9 +56,6 @@ module.exports = function (inputs, callback, done) {
5656
inputs.parentModuleDirectory
5757
]
5858

59-
let consoleFromSandbox
60-
let consoleMessages = []
61-
6259
function respondWrap (rawErr, content) {
6360
let err
6461

@@ -146,8 +143,8 @@ module.exports = function (inputs, callback, done) {
146143
}
147144
)
148145

149-
consoleMessages = messages
150-
consoleFromSandbox = consoleSandbox
146+
const consoleMessages = messages
147+
const consoleFromSandbox = consoleSandbox
151148

152149
let templateHelpers = inputs.template.helpers
153150
let originalTemplateHelpersStr
@@ -166,7 +163,7 @@ module.exports = function (inputs, callback, done) {
166163

167164
templateHelpers = {}
168165

169-
for (let fn in sandboxContext) {
166+
for (const fn in sandboxContext) {
170167
if (typeof sandboxContext[fn] === 'function') {
171168
templateHelpers[fn] = sandboxContext[fn]
172169
}

lib/render/safeSandbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports = (_sandbox, options = {}) => {
111111
return result
112112
}
113113

114-
for (let name in sandbox) {
114+
for (const name in sandbox) {
115115
vm._internal.Contextify.globalValue(sandbox[name], name)
116116
}
117117

lib/store/collection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module.exports = (entitySet, provider, model) => ({
131131
return docs.map((doc) => {
132132
const newDoc = Object.assign({}, doc)
133133

134-
for (let prop in newDoc) {
134+
for (const prop in newDoc) {
135135
if (!prop) {
136136
continue
137137
}
@@ -158,7 +158,7 @@ module.exports = (entitySet, provider, model) => ({
158158
return docs.map((doc) => {
159159
const newDoc = Object.assign({}, doc)
160160

161-
for (let prop in newDoc) {
161+
for (const prop in newDoc) {
162162
if (!prop) {
163163
continue
164164
}

lib/store/documentStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function typeDefToJSONSchema (model, def) {
248248
const propDef = def[key]
249249
const collectionTypeRegExp = /^Collection\((\S+)\)$/
250250
let type = propDef.type
251-
let extraSchema = propDef.schema
251+
const extraSchema = propDef.schema
252252
let isCollection = false
253253

254254
if (propDef == null || type == null) {

test/render/engineTest.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const safeSandboxPath = path.join(__dirname, '../../lib/render/safeSandbox')
66

77
describe('engine', () => {
88
describe('engine with dedicated-process strategy', () => {
9-
let scriptManager = ScriptManager({ strategy: 'dedicated-process' })
9+
const scriptManager = ScriptManager({ strategy: 'dedicated-process' })
1010

1111
beforeEach((done) => {
1212
scriptManager.ensureStarted(done)
@@ -17,7 +17,7 @@ describe('engine', () => {
1717
})
1818

1919
describe('engine with http-server strategy', () => {
20-
let scriptManager = ScriptManager({ strategy: 'http-server' })
20+
const scriptManager = ScriptManager({ strategy: 'http-server' })
2121

2222
beforeEach((done) => {
2323
scriptManager.ensureStarted(done)
@@ -29,7 +29,7 @@ describe('engine', () => {
2929
})
3030

3131
describe('engine with in-process strategy', function () {
32-
let scriptManager = ScriptManager({ strategy: 'in-process' })
32+
const scriptManager = ScriptManager({ strategy: 'in-process' })
3333

3434
beforeEach((done) => {
3535
scriptManager.ensureStarted(done)

test/reporterTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('reporter', () => {
7676
}
7777
})
7878
stdMocks.restore()
79-
let stdoutContent = stdMocks.flush()
79+
const stdoutContent = stdMocks.flush()
8080
stdoutContent.stdout.length.should.be.eql(0)
8181

8282
const allTransportsAreSilent = Object.keys(reporter.logger.transports).every(function (transportName) {

0 commit comments

Comments
 (0)