wbyoung / avn

Automatic Version Switching for Node
MIT License
1.14k stars 54 forks source link

avn-nvm jshint failures #66

Closed duckontheweb closed 6 years ago

duckontheweb commented 6 years ago

Please describe your issue clearly and also include all details below.

Details

I'm getting a number of jshint failures when running the tests for avn-nvm, all of them in /index.js (see below for full details). Would you like me to clean these up before submitting any PRs related to #43?

xpects valid type instead of  String  at ./index.js :
    15 | * @private
    16 | * @function
    17 | * @param { String } command
-------------------^
    18 | * @return { Promise }
    19 | */

Expects valid type instead of  Promise  at ./index.js :
    16 | * @function
    17 | * @param { String } command
    18 | * @return { Promise }
--------------------^
    19 | */
    20 |var nvmCommand = function(command) {

Missing space before opening round brace at ./index.js :
    18 | * @return { Promise }
    19 | */
    20 |var nvmCommand = function(command) {
---------------------------------^
    21 |  return new Promise(function(resolve, reject) {
    22 |    var stdout, stderr;

Missing space before opening round brace at ./index.js :
    19 | */
    20 |var nvmCommand = function(command) {
    21 |  return new Promise(function(resolve, reject) {
-------------------------------------^
    22 |    var stdout, stderr;
    23 |    var cmd = child.spawn(process.env.SHELL,

Missing space before opening round brace at ./index.js :
    24 |      ['-c', 'source $NVM_DIR/nvm.sh; nvm ' + command]);
    25 |
    26 |    cmd.stdout.pipe(concat(function(data) {
-------------------------------------------^
    27 |      stdout = data;
    28 |    }));

Missing space before opening round brace at ./index.js :
    28 |    }));
    29 |
    30 |    cmd.stderr.pipe(concat(function(data) {
-------------------------------------------^
    31 |      stderr = data;
    32 |    }));

Missing space before opening round brace at ./index.js :
    32 |    }));
    33 |
    34 |    cmd.on('close', function(code) {
------------------------------------^
    35 |      if (code === 0) { resolve({ stdout: stdout, stderr: stderr }); }
    36 |      else {

Missing space before opening round brace at ./index.js :
    50 | * @return {Array.<String>}
    51 | */
    52 |var parseVersions = function(output) {
------------------------------------^
    53 |  var string = output.stdout.toString()
    54 |    .replace(/\x1b[^m]*m/g, '')

Missing space before opening round brace at ./index.js :
    55 |    .replace(/^->/gm, '');
    56 |  return string.split('\n')
    57 |  .map(function(line) { return line.trim(); })
-----------------------^
    58 |  .filter(function(line) { return line && !line.match(/current|system|->/); });
    59 |};

Missing space before opening round brace at ./index.js :
    56 |  return string.split('\n')
    57 |  .map(function(line) { return line.trim(); })
    58 |  .filter(function(line) { return line && !line.match(/current|system|->/); });
--------------------------^
    59 |};
    60 |

Missing space before opening round brace at ./index.js :
    66 | * @return {Promise}
    67 | */
    68 |var listVersions = function() {
-----------------------------------^
    69 |  // find all of the versions of node installed by nvm.
    70 |  return Promise.resolve()

Missing space before opening round brace at ./index.js :
    69 |  // find all of the versions of node installed by nvm.
    70 |  return Promise.resolve()
    71 |  .then(function() { return nvmCommand('list'); })
------------------------^
    72 |  .then(parseVersions);
    73 |};

Missing space before opening round brace at ./index.js :
    80 | * @return {Promise}
    81 | */
    82 |var versionName = function(version) {
----------------------------------^
    83 |  var match = version.match(VERSION_REGEX);
    84 |  return match ? match[1] : null;

Missing space before opening round brace at ./index.js :
    93 | * @return {String}
    94 | */
    95 |var versionNumber = function(version) {
------------------------------------^
    96 |  var match = version.match(VERSION_REGEX);
    97 |  return match ? match[2] : version;

Missing space before opening round brace at ./index.js :
   105 | * @return {String}
   106 | */
   107 |var findVersion = function(versions, matching) {
----------------------------------^
   108 |  var highestMatch = null;
   109 |

Missing space before opening round brace at ./index.js :
   111 |  var mNumber = versionNumber(matching);
   112 |
   113 |  versions.forEach(function(v) {
-----------------------------------^
   114 |    var vName = versionName(v);
   115 |    var vNumber = versionNumber(v);

Missing space before opening round brace at ./index.js :
   131 | * @return {Promise}
   132 | */
   133 |var installedVersion = function(matching) {
---------------------------------------^
   134 |  return Promise.resolve()
   135 |  .then(function() { return listVersions(); })

Missing space before opening round brace at ./index.js :
   133 |var installedVersion = function(matching) {
   134 |  return Promise.resolve()
   135 |  .then(function() { return listVersions(); })
------------------------^
   136 |  .then(function(versions) {
   137 |    return findVersion(versions, matching);

Missing space before opening round brace at ./index.js :
   134 |  return Promise.resolve()
   135 |  .then(function() { return listVersions(); })
   136 |  .then(function(versions) {
------------------------^
   137 |    return findVersion(versions, matching);
   138 |  });

Missing space before opening round brace at ./index.js :
   145 | * @return {Promise}
   146 | */
   147 |var match = function(version) {
----------------------------^
   148 |  return Promise.resolve()
   149 |  .then(function() { return installedVersion(version); })

Missing space before opening round brace at ./index.js :
   147 |var match = function(version) {
   148 |  return Promise.resolve()
   149 |  .then(function() { return installedVersion(version); })
------------------------^
   150 |  .then(function(use) {
   151 |    var command = util.format('nvm use %s > /dev/null;', use);

Missing space before opening round brace at ./index.js :
   148 |  return Promise.resolve()
   149 |  .then(function() { return installedVersion(version); })
   150 |  .then(function(use) {
------------------------^
   151 |    var command = util.format('nvm use %s > /dev/null;', use);
   152 |    var result = { version: use, command: command };
ljharb commented 6 years ago

(avn may want to move to eslint; jshint isn't up to par anymore)

duckontheweb commented 6 years ago

Sorry, I misinterpreted this. It's actually jscs that is raising the errors.

duckontheweb commented 6 years ago

It looks like all of the issues being caught by jscs run counter to the overall coding style of that plugin. Since jshint is running against this code already, maybe it makes sense to just turn off jscs and only use jshint (or update to eslint).

ljharb commented 6 years ago

jscs is also deprecated; its team and rules were absorbed into eslint over a year ago.

duckontheweb commented 6 years ago

@wbyoung if this is something you want to do I can put in another PR once I’m done with the alias work

Sent with GitHawk

wbyoung commented 6 years ago

@duckontheweb yes, it'd be great to have avn, avn-nvm, and avn-n updated to ESLint. Along the same lines, I've also been thinking about using babel to allow async/await and clean up the code base.

If you're interested in making those changes, the help would be much appreciated! 😄

duckontheweb commented 6 years ago

Definitely. I'll open up separate issues for each of these.

wbyoung commented 6 years ago

Resolved by https://github.com/wbyoung/avn-nvm/commit/fd47799dda5d359989b1fd233466966c253b5226, but @duckontheweb is also working on transitioning to ESLint.

See #67.