Eslint-plugin-jsdoc: Implicit return is undetected

Created on 16 Jan 2019  路  11Comments  路  Source: gajus/eslint-plugin-jsdoc

screen shot 2019-01-16 at 2 30 51 pm

As you can see, implicit returns are not properly detected. It is saying that there is a @returns but there shouldn't be. This is incorrect as the implicit return does not require a return keyword (seems like this is what is being detected) to work properly.

Any ideas on where this could be fixed? I can make a PR but some direction would be helpful

enhancement released

Most helpful comment

Yeah the code just looks for any "return" keyword in the code body. I will see if I can refactor that to be a little more accurate.

There are features in eslint that handle implicit return, so I'm sure their code should help indicate a potential solution: https://eslint.org/docs/rules/arrow-body-style

All 11 comments

In #147 pull request i split rule, you need disable require-returns-check and this error not appear.
If you enable require-returns if exist return string in content of { } the error appear.

Wait merge and try if work.

@ptkdev that PR is merged. So I don鈥檛 think it has fixed it.

Looking at the source, just doing "index of return" is never going to work when there is an implicit return

This is currently not being checked. PR is welcome.

In v4.0.0 only solution for ignore this bug is set require-returns-check on false and warning not appear.
I don't know how detect implicit returns with eslint api. Imho this is hard.

We need new rule: require-returns-implicit or fix require-returns-check

I will see if I can get it to work. Or at least improve the current return detect as it also detects deep returns that are not at the top level

Or at least improve the current return detect as it also detects deep returns that are not at the top level

If thats really the case, then I would appreciate if you create an issue for it.

If thats really the case, then I would appreciate if you create an issue for it.

That's actually the issue that led me here. The following block fails the require-returns rule:

 removeItem(itemForRemoval) {
    const newItems = this.Items.filter(
      ({ label, index }) => {
        return label !== itemForRemoval.label;
      }
    );
    this.saveItems(newItems);
  }

Edit: I created issue #151 to address this.

Yeah the code just looks for any "return" keyword in the code body. I will see if I can refactor that to be a little more accurate.

There are features in eslint that handle implicit return, so I'm sure their code should help indicate a potential solution: https://eslint.org/docs/rules/arrow-body-style

For jsdoc/require-returns, please detect implicit returns, and also, don't apply the rule to constructors which have docs, since they can't return anything.

Opened https://github.com/gajus/eslint-plugin-jsdoc/pull/155 for people who are watching this and looking for a fix

:tada: This issue has been resolved in version 4.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings