Skip to content

Commit 71e8a04

Browse files
jbottiglierobcoe
authored andcommitted
refactor: updates var usage to let (#321)
1 parent 74a040a commit 71e8a04

11 files changed

+96
-85
lines changed

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "standard",
3+
"rules": {
4+
"no-var": "error"
5+
}
6+
}

command.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var defaults = require('./defaults')
1+
let defaults = require('./defaults')
22

33
module.exports = require('yargs')
44
.usage('Usage: $0 [options]')

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module.exports = function standardVersion (argv) {
1111
let pkg
1212
bump.pkgFiles.forEach((filename) => {
1313
if (pkg) return
14-
var pkgPath = path.resolve(process.cwd(), filename)
14+
let pkgPath = path.resolve(process.cwd(), filename)
1515
try {
16-
var data = fs.readFileSync(pkgPath, 'utf8')
16+
let data = fs.readFileSync(pkgPath, 'utf8')
1717
pkg = JSON.parse(data)
1818
} catch (err) {}
1919
})

lib/lifecycles/bump.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ const semver = require('semver')
1414
const stringifyPackage = require('stringify-package')
1515
const writeFile = require('../write-file')
1616

17-
var configsToUpdate = {}
17+
let configsToUpdate = {}
1818

1919
function Bump (args, version) {
2020
// reset the cache of updated config files each
2121
// time we perform the version bump step.
2222
configsToUpdate = {}
2323

2424
if (args.skip.bump) return Promise.resolve()
25-
var newVersion = version
25+
let newVersion = version
2626
return runLifecycleScript(args, 'prerelease')
2727
.then(runLifecycleScript.bind(this, args, 'prebump'))
2828
.then((stdout) => {
@@ -31,7 +31,7 @@ function Bump (args, version) {
3131
})
3232
.then((release) => {
3333
if (!args.firstRelease) {
34-
var releaseType = getReleaseType(args.prerelease, release.releaseType, version)
34+
let releaseType = getReleaseType(args.prerelease, release.releaseType, version)
3535
newVersion = semver.valid(releaseType) || semver.inc(version, releaseType, args.prerelease)
3636
updateConfigs(args, newVersion)
3737
} else {
@@ -100,7 +100,7 @@ function isInPrerelease (version) {
100100
return Array.isArray(semver.prerelease(version))
101101
}
102102

103-
var TypeList = ['major', 'minor', 'patch'].reverse()
103+
let TypeList = ['major', 'minor', 'patch'].reverse()
104104

105105
/**
106106
* extract the in-pre-release type in target version
@@ -109,8 +109,8 @@ var TypeList = ['major', 'minor', 'patch'].reverse()
109109
* @return {string}
110110
*/
111111
function getCurrentActiveType (version) {
112-
var typelist = TypeList
113-
for (var i = 0; i < typelist.length; i++) {
112+
let typelist = TypeList
113+
for (let i = 0; i < typelist.length; i++) {
114114
if (semver[typelist[i]](version)) {
115115
return typelist[i]
116116
}
@@ -163,13 +163,13 @@ function updateConfigs (args, newVersion) {
163163
Object.keys(configsToUpdate).forEach(function (configPath) {
164164
try {
165165
if (dotgit.ignore(configPath)) return
166-
var stat = fs.lstatSync(configPath)
166+
let stat = fs.lstatSync(configPath)
167167
if (stat.isFile()) {
168-
var data = fs.readFileSync(configPath, 'utf8')
169-
var indent = detectIndent(data).indent
170-
var newline = detectNewline(data)
171-
var config = JSON.parse(data)
172-
var filename = path.basename(configPath)
168+
let data = fs.readFileSync(configPath, 'utf8')
169+
let indent = detectIndent(data).indent
170+
let newline = detectNewline(data)
171+
let config = JSON.parse(data)
172+
let filename = path.basename(configPath)
173173
checkpoint(args, 'bumping version in ' + filename + ' from %s to %s', [config.version, newVersion])
174174
config.version = newVersion
175175
writeFile(args, configPath, stringifyPackage(config, indent, newline))

lib/lifecycles/changelog.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ module.exports = function (args, newVersion) {
2020
function outputChangelog (args, newVersion) {
2121
return new Promise((resolve, reject) => {
2222
createIfMissing(args)
23-
var header = '# Change Log\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n'
24-
var oldContent = args.dryRun ? '' : fs.readFileSync(args.infile, 'utf-8')
23+
let header = '# Change Log\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n'
24+
let oldContent = args.dryRun ? '' : fs.readFileSync(args.infile, 'utf-8')
2525
// find the position of the last release and remove header:
2626
const changelogSectionRegExp = /<a name=|##? \[?[0-9]+\.[0-9]+\.[0-9]+\]?/
2727
if (oldContent.search(changelogSectionRegExp) !== -1) {
2828
oldContent = oldContent.substring(oldContent.search(changelogSectionRegExp))
2929
}
30-
var content = ''
31-
var context
30+
let content = ''
31+
let context
3232
if (args.dryRun) context = { version: newVersion }
33-
var changelogStream = conventionalChangelog({
33+
let changelogStream = conventionalChangelog({
3434
debug: args.verbose && console.info.bind(console, 'conventional-changelog'),
3535
preset: args.preset || 'angular',
3636
tagPrefix: args.tagPrefix

lib/lifecycles/commit.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ module.exports = function (args, newVersion) {
1818
}
1919

2020
function execCommit (args, newVersion) {
21-
var msg = 'committing %s'
22-
var paths = [args.infile]
23-
var verify = args.verify === false || args.n ? '--no-verify ' : ''
24-
var toAdd = ''
21+
let msg = 'committing %s'
22+
let paths = [args.infile]
23+
let verify = args.verify === false || args.n ? '--no-verify ' : ''
24+
let toAdd = ''
2525
// commit any of the config files that we've updated
2626
// the version # for.
2727
Object.keys(bump.getUpdatedConfigs()).forEach(function (p) {

lib/lifecycles/tag.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function (newVersion, pkgPrivate, args) {
1717
}
1818

1919
function execTag (newVersion, pkgPrivate, args) {
20-
var tagOption
20+
let tagOption
2121
if (args.sign) {
2222
tagOption = '-s '
2323
} else {
@@ -26,7 +26,7 @@ function execTag (newVersion, pkgPrivate, args) {
2626
checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion])
2727
return runExec(args, 'git tag ' + tagOption + args.tagPrefix + newVersion + ' -m "' + formatCommitMessage(args.message, newVersion) + '"')
2828
.then(() => {
29-
var message = 'git push --follow-tags origin master'
29+
let message = 'git push --follow-tags origin master'
3030
if (pkgPrivate !== true) {
3131
message += ' && npm publish'
3232
if (args.prerelease !== undefined) {

lib/run-lifecycle-hook.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const runExec = require('./run-exec')
55

66
module.exports = function (args, hookName, newVersion, hooks, cb) {
77
if (!hooks[hookName]) return Promise.resolve()
8-
var command = hooks[hookName] + ' --new-version="' + newVersion + '"'
8+
let command = hooks[hookName] + ' --new-version="' + newVersion + '"'
99
checkpoint(args, 'Running lifecycle hook "%s"', [hookName])
1010
checkpoint(args, '- hook command: "%s"', [command], chalk.blue(figures.info))
1111
return runExec(args, command)

lib/run-lifecycle-script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const runExec = require('./run-exec')
66
module.exports = function (args, hookName) {
77
const scripts = args.scripts
88
if (!scripts || !scripts[hookName]) return Promise.resolve()
9-
var command = scripts[hookName]
9+
let command = scripts[hookName]
1010
checkpoint(args, 'Running lifecycle script "%s"', [hookName])
1111
checkpoint(args, '- execute command: "%s"', [command], chalk.blue(figures.info))
1212
return runExec(args, command)

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "replacement for `npm version` with automatic CHANGELOG generation",
55
"bin": "bin/cli.js",
66
"scripts": {
7-
"pretest": "standard",
7+
"pretest": "eslint .",
88
"coverage": "nyc report --reporter=text-lcov | coveralls",
99
"test": "nyc mocha --timeout=20000 test.js",
1010
"release": "bin/cli.js"
@@ -54,11 +54,16 @@
5454
"devDependencies": {
5555
"chai": "^3.5.0",
5656
"coveralls": "^3.0.1",
57+
"eslint": "^5.16.0",
58+
"eslint-config-standard": "^12.0.0",
59+
"eslint-plugin-import": "^2.16.0",
60+
"eslint-plugin-node": "^8.0.1",
61+
"eslint-plugin-promise": "^4.0.1",
62+
"eslint-plugin-standard": "^4.0.0",
5763
"mocha": "^5.2.0",
5864
"mock-git": "^1.0.3",
5965
"mockery": "^2.0.0",
6066
"nyc": "^13.3.0",
61-
"shelljs": "^0.7.8",
62-
"standard": "^12.0.1"
67+
"shelljs": "^0.7.8"
6368
}
6469
}

0 commit comments

Comments
 (0)