jquery/eslint-config-jquery

Add `consistent-return` rule

markelog opened this issue · 5 comments

With treatUndefinedAsUnspecified enabled, see http://eslint.org/docs/rules/consistent-return

Lots of errors with this one on Core

mgol commented

I don't think we can enable this rule, it would require Core API changes. If we disabled treatUndefinedAsUnspecified then perhaps it'd be possible.

I meant treatUndefinedAsUnspecified: true, this, it seems, will adhere to our style a bit better

Yeah, re-read the docs, probably not a good fit, please re-open if you feel differently

mgol commented

Yeah, I agree. I'd expect this rule to have a mode that allows a function to only work in one of two modes:

  1. return something is not allowed, bare return is allowed
  2. return something is allowed but every function execution flow must end with an explicit return something

Such a rule could have an option to allow or disallow return undefined which we'd set to "allow".

I'm quite surprised this rule can't be configured to work in such a way. Do you think it could be extended in ESLint?

Yeah, i think it is worth a discussion at least