Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consistent-return #60

Open
SimonLab opened this issue Sep 20, 2016 · 5 comments
Open

consistent-return #60

SimonLab opened this issue Sep 20, 2016 · 5 comments

Comments

@SimonLab
Copy link
Member

http://eslint.org/docs/rules/consistent-return

consistent-return: [2, { "treatUndefinedAsUnspecified": true }]

Consistency is good!

@jrans
Copy link
Member

jrans commented Sep 22, 2016

@SimonLab do we really want to not be able to do this:

function bar(condition) {
    if (condition) {
        return undefined;
    }
    return true;
}

"treatUndefinedAsUnspecified": true stops this

jrans added a commit that referenced this issue Sep 22, 2016
@nelsonic
Copy link
Member

hmm... happy to enforce this until/unless it becomes onerous.
I personally _always_ return something; but I don't know if it's necessary ...
Agree that "consistency is good." 👍

@SimonLab
Copy link
Member Author

SimonLab commented Oct 3, 2016

Just one thing which feels strange with this rule is to add a return in front of an async function:

'use strict';

var fs = require('fs');

module.exports = function (err) {
  if (err) {
    return new Error('error');
  }

  return fs.writeFile('./myfile', 'the content', function (error) {
    console.log(error);
  });
};

When using multiple async functions it started to look a bit weird.
I'm tempted to disable this rule. @jrans @eliasCodes @Shouston3 @nelsonic any thoughts on this?

@SimonLab SimonLab reopened this Oct 3, 2016
@samhstn
Copy link
Member

samhstn commented Oct 3, 2016

Agreed @SimonLab I think this should be disabled:

consistent-return: "off"

@jrans
Copy link
Member

jrans commented Oct 4, 2016

I'm undecided, I've outlined the modification I'd make but will let you guys decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants