diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 0000000000..659dce8810 --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,5 @@ +--- + env: + node: true + rules: + no-unused-vars: error diff --git a/bin/node-gyp.js b/bin/node-gyp.js index 0cc3517748..a8fd9bc529 100755 --- a/bin/node-gyp.js +++ b/bin/node-gyp.js @@ -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') diff --git a/lib/build.js b/lib/build.js index 81494d65aa..b8389bcd7b 100644 --- a/lib/build.js +++ b/lib/build.js @@ -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' @@ -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 @@ -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)) } @@ -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) { diff --git a/lib/configure.js b/lib/configure.js index 2cf4c443ce..47a77e637c 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -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) @@ -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 @@ -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') @@ -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 { @@ -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() diff --git a/lib/install.js b/lib/install.js index fa0fef6fe0..eea7618a01 100644 --- a/lib/install.js +++ b/lib/install.js @@ -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') @@ -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 { @@ -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) @@ -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) @@ -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) diff --git a/lib/list.js b/lib/list.js index cda4fd2f2f..90f6447180 100644 --- a/lib/list.js +++ b/lib/list.js @@ -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) { diff --git a/lib/node-gyp.js b/lib/node-gyp.js index b35a5ebe44..8dd551bf3d 100644 --- a/lib/node-gyp.js +++ b/lib/node-gyp.js @@ -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') diff --git a/lib/remove.js b/lib/remove.js index 213af2b9d3..46a1a3d4c2 100644 --- a/lib/remove.js +++ b/lib/remove.js @@ -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) diff --git a/package.json b/package.json index a8e5fe9f27..69b450fbaf 100644 --- a/package.json +++ b/package.json @@ -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-*" } } diff --git a/test/test-configure-python.js b/test/test-configure-python.js index f235bdbba1..07cdce2b17 100644 --- a/test/test-configure-python.js +++ b/test/test-configure-python.js @@ -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, {}) } } diff --git a/test/test-find-accessible-sync.js b/test/test-find-accessible-sync.js index d336243dd0..114403e278 100644 --- a/test/test-find-accessible-sync.js +++ b/test/test-find-accessible-sync.js @@ -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 diff --git a/test/test-find-python.js b/test/test-find-python.js index 2d9f171c57..2db9ee4b97 100644 --- a/test/test-find-python.js +++ b/test/test-find-python.js @@ -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)) } }) @@ -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)) } }) @@ -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)) } }) @@ -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)) } }) @@ -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)) } }) @@ -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)) } })