eslint-plugin icon indicating copy to clipboard operation
eslint-plugin copied to clipboard

New Rule: `no-unused-vars`

Open mysticatea opened this issue 10 years ago • 3 comments

export default function foo(a) {
    assert(a > 0);

    // do something without a.
}

I want to prevent marking references inside of assert() as used.

mysticatea avatar Sep 23 '15 04:09 mysticatea

And if statements for assertion are the same.

if (foo > 0) { // don't mark `foo` as used
    assert(bar > 0); // don't mark `bar` as used
}

mysticatea avatar Sep 23 '15 04:09 mysticatea

@mysticatea don't allow assert as the only value inside an if/alternative body.

graingert avatar Oct 03 '17 14:10 graingert

While you can of course add rules as you wish, you might want to consider https://github.com/onechiporenko/eslint-plugin-mocha-cleanup/ as a home for such a rule, as it already has rules regarding assertions. (https://github.com/ihordiachenko/eslint-plugin-chai-friendly and https://github.com/Turbo87/eslint-plugin-chai-expect might perhaps be open to it, but they are currently confined to expect and should)

brettz9 avatar Mar 11 '20 03:03 brettz9