Skip to content

Commit

Permalink
Add ESLint no-unused-vars rule
Browse files Browse the repository at this point in the history
- Uses `.eslintrc.yaml` for configuration
- `npm run lint` is part of `npm test`

PR-URL: #1497
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: João Reis <[email protected]>
  • Loading branch information
maclover7 authored Aug 2, 2018
1 parent 6b0f4ae commit b2e5cf0
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
env:
node: true
rules:
no-unused-vars: error
2 changes: 1 addition & 1 deletion bin/node-gyp.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (prog.todo.length === 0) {
} else {
console.log('%s', prog.usage())
}
return process.exit(0)
process.exit(0)
}

log.info('it worked if it ends with', 'ok')
Expand Down
9 changes: 3 additions & 6 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
module.exports = exports = build

var fs = require('graceful-fs')
, rm = require('rimraf')
, path = require('path')
, glob = require('glob')
, log = require('npmlog')
, which = require('which')
, exec = require('child_process').exec
, processRelease = require('./process-release')
, win = process.platform === 'win32'

exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module'
Expand All @@ -25,8 +23,7 @@ function build (gyp, argv, callback) {
})
}

var release = processRelease(argv, gyp, process.version, process.release)
, makeCommand = gyp.opts.make || process.env.MAKE || platformMake
var makeCommand = gyp.opts.make || process.env.MAKE || platformMake
, command = win ? 'msbuild' : makeCommand
, jobs = gyp.opts.jobs || process.env.JOBS
, buildType
Expand Down Expand Up @@ -132,7 +129,7 @@ function build (gyp, argv, callback) {
var cmd = 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s'
if (process.arch !== 'ia32')
cmd += ' /reg:32'
exec(cmd, function (err, stdout, stderr) {
exec(cmd, function (err, stdout) {
if (err) {
return callback(new Error(err.message + '\n' + notfoundErr))
}
Expand Down Expand Up @@ -162,7 +159,7 @@ function build (gyp, argv, callback) {
;(function verifyMsbuild () {
if (!msbuilds.length) return callback(new Error(notfoundErr))
msbuildPath = path.resolve(msbuilds.pop().path, 'msbuild.exe')
fs.stat(msbuildPath, function (err, stat) {
fs.stat(msbuildPath, function (err) {
if (err) {
if (err.code == 'ENOENT') {
if (msbuilds.length) {
Expand Down
10 changes: 5 additions & 5 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function configure (gyp, argv, callback) {
// into devdir. Otherwise only install if they're not already there.
gyp.opts.ensure = gyp.opts.tarball ? false : true

gyp.commands.install([ release.version ], function (err, version) {
gyp.commands.install([ release.version ], function (err) {
if (err) return callback(err)
log.verbose('get node dir', 'target node version installed:', release.versionDir)
nodeDir = path.resolve(gyp.devDir, release.versionDir)
Expand Down Expand Up @@ -188,7 +188,7 @@ function configure (gyp, argv, callback) {
if (!name) return runGyp()
var fullPath = path.resolve(name)
log.verbose(name, 'checking for gypi file: %s', fullPath)
fs.stat(fullPath, function (err, stat) {
fs.stat(fullPath, function (err) {
if (err) {
if (err.code == 'ENOENT') {
findConfigs() // check next gypi filename
Expand Down Expand Up @@ -275,7 +275,7 @@ function configure (gyp, argv, callback) {
var gyp_script = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
var addon_gypi = path.resolve(__dirname, '..', 'addon.gypi')
var common_gypi = path.resolve(nodeDir, 'include/node/common.gypi')
fs.stat(common_gypi, function (err, stat) {
fs.stat(common_gypi, function (err) {
if (err)
common_gypi = path.resolve(nodeDir, 'common.gypi')

Expand Down Expand Up @@ -329,7 +329,7 @@ function configure (gyp, argv, callback) {
})
}

function onCpExit (code, signal) {
function onCpExit (code) {
if (code !== 0) {
callback(new Error('`gyp` failed with exit code: ' + code))
} else {
Expand Down Expand Up @@ -500,7 +500,7 @@ PythonFinder.prototype = {
}
var pythonPath = this.resolve(rootDir, 'Python27', 'python.exe')
this.log.verbose('ensuring that file exists:', pythonPath)
this.stat(pythonPath, function (err, stat) {
this.stat(pythonPath, function (err) {
if (err) {
if (err.code == 'ENOENT') {
this.failNoPython()
Expand Down
9 changes: 3 additions & 6 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ exports.usage = 'Install node development files for the specified node version.'
var fs = require('graceful-fs')
, osenv = require('osenv')
, tar = require('tar')
, rm = require('rimraf')
, path = require('path')
, crypto = require('crypto')
, log = require('npmlog')
Expand All @@ -33,7 +32,7 @@ function install (fs, gyp, argv, callback) {
if (err) {
log.warn('install', 'got an error, rolling back install')
// roll-back the install if anything went wrong
gyp.commands.remove([ release.versionDir ], function (err2) {
gyp.commands.remove([ release.versionDir ], function () {
callback(err)
})
} else {
Expand Down Expand Up @@ -75,7 +74,7 @@ function install (fs, gyp, argv, callback) {
// check if it is already installed, and only install when needed
if (gyp.opts.ensure) {
log.verbose('install', '--ensure was passed, so won\'t reinstall if already installed')
fs.stat(devDir, function (err, stat) {
fs.stat(devDir, function (err) {
if (err) {
if (err.code == 'ENOENT') {
log.verbose('install', 'version not already installed, continuing with install', release.version)
Expand Down Expand Up @@ -146,7 +145,7 @@ function install (fs, gyp, argv, callback) {

// checks if a file to be extracted from the tarball is valid.
// only .h header files and the gyp files get extracted
function isValid (path, entry) {
function isValid (path) {
var isValid = valid(path)
if (isValid) {
log.verbose('extracted file from tarball', path)
Expand Down Expand Up @@ -265,8 +264,6 @@ function install (fs, gyp, argv, callback) {

function downloadShasums(done) {
log.verbose('check download content checksum, need to download `SHASUMS256.txt`...')
var shasumsPath = path.resolve(devDir, 'SHASUMS256.txt')

log.verbose('checksum url', release.shasumsUrl)
try {
var req = download(gyp, process.env, release.shasumsUrl)
Expand Down
1 change: 0 additions & 1 deletion lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports = exports = list
exports.usage = 'Prints a listing of the currently installed node development files'

var fs = require('graceful-fs')
, path = require('path')
, log = require('npmlog')

function list (gyp, args, callback) {
Expand Down
3 changes: 1 addition & 2 deletions lib/node-gyp.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

module.exports = exports = gyp

var fs = require('graceful-fs')
, path = require('path')
var path = require('path')
, nopt = require('nopt')
, log = require('npmlog')
, child_process = require('child_process')
Expand Down
2 changes: 1 addition & 1 deletion lib/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function remove (gyp, argv, callback) {
log.verbose('remove', 'removing development files for version:', version)

// first check if its even installed
fs.stat(versionPath, function (err, stat) {
fs.stat(versionPath, function (err) {
if (err) {
if (err.code == 'ENOENT') {
callback(null, 'version was already uninstalled: ' + version)
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@
"node": ">= 4.0.0"
},
"devDependencies": {
"tape": "~4.2.0",
"babel-eslint": "^8.2.5",
"bindings": "~1.2.1",
"eslint": "^5.0.1",
"nan": "^2.0.0",
"require-inject": "~1.3.0"
"require-inject": "~1.3.0",
"tape": "~4.2.0"
},
"scripts": {
"test": "tape test/test-*"
"lint": "eslint bin lib test",
"test": "npm run lint && tape test/test-*"
}
}
4 changes: 2 additions & 2 deletions test/test-configure-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var gyp = require('../lib/node-gyp')
var requireInject = require('require-inject')
var configure = requireInject('../lib/configure', {
'graceful-fs': {
'openSync': function (file, mode) { return 0; },
'closeSync': function (fd) { },
'openSync': function () { return 0; },
'closeSync': function () { },
'writeFile': function (file, data, cb) { cb() },
'stat': function (file, cb) { cb(null, {}) }
}
Expand Down
2 changes: 1 addition & 1 deletion test/test-find-accessible-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var path = require('path')
var requireInject = require('require-inject')
var configure = requireInject('../lib/configure', {
'graceful-fs': {
'closeSync': function (fd) { return undefined },
'closeSync': function () { return undefined },
'openSync': function (path) {
if (readableFiles.some(function (f) { return f === path} )) {
return 0
Expand Down
12 changes: 6 additions & 6 deletions test/test-find-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ test('find python - python too old', function (t) {
}
f.checkPython()

function done(err, python) {
function done(err) {
t.ok(/is not supported by gyp/.test(err))
}
})
Expand All @@ -108,7 +108,7 @@ test('find python - python too new', function (t) {
}
f.checkPython()

function done(err, python) {
function done(err) {
t.ok(/is not supported by gyp/.test(err))
}
})
Expand All @@ -123,7 +123,7 @@ test('find python - no python', function (t) {
}
f.checkPython()

function done(err, python) {
function done(err) {
t.ok(/Can't find Python executable/.test(err))
}
})
Expand Down Expand Up @@ -170,7 +170,7 @@ test('find python - no python2, no python, unix', function (t) {
}
f.checkPython()

function done(err, python) {
function done(err) {
t.ok(/Can't find Python executable/.test(err))
}
})
Expand Down Expand Up @@ -271,7 +271,7 @@ test('find python - python 3, use python launcher, python 2 too old',
}
f.checkPython()

function done(err, python) {
function done(err) {
t.ok(/is not supported by gyp/.test(err))
}
})
Expand Down Expand Up @@ -333,7 +333,7 @@ test('find python - no python, no python launcher, bad guess', function (t) {
}
f.checkPython()

function done(err, python) {
function done(err) {
t.ok(/Can't find Python executable/.test(err))
}
})

0 comments on commit b2e5cf0

Please sign in to comment.