lo1tuma / eslint-plugin-mocha

ESLint rules for mocha
MIT License
279 stars 61 forks source link

`no-setup-in-describe` triggers on both `describe.each()` and `it.each()` #348

Open maikeru opened 7 months ago

maikeru commented 7 months ago

Thanks for all the hard work on this incredibly useful plugin!

It looks like describe.each() and it.each() aren't handled and trigger the no-setup-in-describe rule when they shouldn't Plain describe() and it() behave as expected (i.e. don't trigger no-setup-in-describe.

Some examples:

import expect from 'expect';

// this triggers no-setup-in-describe
describe.each([['a'], ['b']])('letter %s', letter => {
  it('does something with the letter', () => {
    // meaningless test so that example is runnable
    expect(letter).toEqual(letter);
  });
});

describe('fruit', () => {
  // this also triggers no-setup-in-describe
  it.each([['apples'], ['oranges']])('eats %s', fruit => {
    expect(eats(fruit)).toBe(true);
  });
});

package.json dependencies:

"eslint-plugin-mocha": "^10.3.0",
"expect": "29.6.1",
"mocha": "10.0.0",

Could it be a similar problem to this? https://github.com/lo1tuma/eslint-plugin-mocha/issues/249

lo1tuma commented 7 months ago

🤔 Mocha doesn’t have describe.each() or it.each(), so I think you need to specify additionalCustomNames so the rule knows about it and treats it as a describe or it block, see here.