Skip to content

[no-void-expression] Invalid entry on ROADMAP #1871

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

Closed
neurolag opened this issue Apr 8, 2020 · 2 comments · Fixed by #2124
Closed

[no-void-expression] Invalid entry on ROADMAP #1871

neurolag opened this issue Apr 8, 2020 · 2 comments · Fixed by #2124
Labels
documentation Documentation ("docs") that needs adding/updating package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@neurolag
Copy link
Contributor

neurolag commented Apr 8, 2020

Hey guys
I just noticed that the alternative listed for the no-void-expression, which, according to the ROADMAP.md-file, is no-void doesn't do the same thing like it's tslint-counterpart.

While tslint's no-void-expression tries to prevent users from assigning, returning or using the result of a void expression, eslint's no-void bans the void-keyword.

tslint's no-void-expression

tslint.json:

    "rules": {
        "no-void-expression": [
            true,
            "ignore-arrow-function-shorthand"
        ]
    }

Example of bad code for tslint's no-void-expression

tes.ts:

function test(): void { }
console.log(test()); // bad
let x = test(); // bad
function test2() { return test(); } // bad

Example for good code for tslint's no-void-expression

test.ts:

function test(): void { }
test(); // good

eslint's no-void

Example of bad code for eslint's no-void

function test(): void
{
    return void 0; // bad
}

Example of good code for eslint's no-void

function test(): void
{
    return undefined; // good
}

function test2(): void
{
    return; // good
}
@neurolag neurolag added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 8, 2020
@bradzacher
Copy link
Member

NGL the tslint rule is terribly named. No doubt that's why the original author of the roadmap got confused. The fact nobody's picked up on it in 16 months (bradzacher/eslint-plugin-typescript#228) shows that either nobody really uses the rule, or nobody understands the difference...

Happy to accept a PR to fix this!

@bradzacher bradzacher added documentation Documentation ("docs") that needs adding/updating and removed triage Waiting for team members to take a look labels Apr 8, 2020
@neurolag
Copy link
Contributor Author

neurolag commented Apr 8, 2020

I got confused myself, tbh - I had to fiddle around for about 20 minutes to find out what it's actually made for 😅
That's why I tried to provide some sort of example code

ianbollinger added a commit to ianbollinger/typescript-eslint that referenced this issue May 28, 2020
…t#1871)

The migration guide suggested migrating from TSLint's
`no-void-expression` rule to ESLint's `no-void` rule despite the rules
being unrelated (while having confusingly similar names.) This removes
the link to `no-void` and fixes typescript-eslint#1871.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Documentation ("docs") that needs adding/updating package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants