src: implement standard.js linting

In addition:

* moved module.exports to the bottom
* no single-line if statements
* no if statements without a {
* const for requires
* array declarations get spaces inside [ ]
* 'use strict' in all .js files

PR-URL: https://github.com/nodejs/node-gyp/pull/1794
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: João Reis <reis@janeasystems.com>
This commit is contained in:
Rod Vagg 2019-06-22 13:10:59 +10:00
parent 7e8127068f
commit e40c99e283
No known key found for this signature in database
GPG key ID: C273792F7D83545D
28 changed files with 739 additions and 661 deletions

View file

@ -1,8 +1,4 @@
module.exports = exports = findVisualStudio
module.exports.test = {
VisualStudioFinder: VisualStudioFinder,
findVisualStudio: findVisualStudio
}
'use strict'
const log = require('npmlog')
const execFile = require('child_process').execFile
@ -132,9 +128,13 @@ VisualStudioFinder.prototype = {
var ps = path.join(process.env.SystemRoot, 'System32',
'WindowsPowerShell', 'v1.0', 'powershell.exe')
var csFile = path.join(__dirname, 'Find-VisualStudio.cs')
var psArgs = ['-ExecutionPolicy', 'Unrestricted', '-NoProfile',
'-Command', '&{Add-Type -Path \'' + csFile + '\';' +
'[VisualStudioConfiguration.Main]::PrintJson()}']
var psArgs = [
'-ExecutionPolicy',
'Unrestricted',
'-NoProfile',
'-Command',
'&{Add-Type -Path \'' + csFile + '\';' + '[VisualStudioConfiguration.Main]::PrintJson()}'
]
this.log.silly('Running', ps, psArgs)
var child = execFile(ps, psArgs, { encoding: 'utf8' },
@ -188,7 +188,9 @@ VisualStudioFinder.prototype = {
// Remove future versions or errors parsing version number
vsInfo = vsInfo.filter((info) => {
if (info.versionYear) { return true }
if (info.versionYear) {
return true
}
this.addLog(`unknown version "${info.version}" found at "${info.path}"`)
return false
})
@ -415,3 +417,9 @@ VisualStudioFinder.prototype = {
return true
}
}
module.exports = findVisualStudio
module.exports.test = {
VisualStudioFinder: VisualStudioFinder,
findVisualStudio: findVisualStudio
}