Skip to content
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

no-setup-in-describe aggressively pops its nesting #172

Closed
joovel opened this issue Jul 9, 2018 · 0 comments · Fixed by #196
Closed

no-setup-in-describe aggressively pops its nesting #172

joovel opened this issue Jul 9, 2018 · 0 comments · Fixed by #196

Comments

@joovel
Copy link

joovel commented Jul 9, 2018

Code:

'use strict';

const {omit, assign, each} = require('lodash/fp');

const arrowCurriedFunc = arg1 => arg2 => true;

describe(__filename, () => {
  it('should not fail linting', () =>
    each(arrowCurriedFunc)([
      omit('val1')('x'),
      omit('val2')('x'),
      omit('val3')('x'),
      assign({}, {some: 'value'})
    ])
  );
});

Reported error:
13:7 error Unexpected function call in describe block mocha/no-setup-in-describe

It appears that the handling of CallExpression:exit on each of the omit secondary calls pops a function off the stack, so that by the time the parser reaches the assign, it thinks it's in the describe block.

I think a better process for this would be for the process to stash the call it encounters in the describe block. If it's an acceptable function (hook or test), then save that callee and skip everything until it reaches the exit of that call function. Managing a full stack is tricky and I think more work than we want.

lo1tuma added a commit that referenced this issue Jul 8, 2019
There was one call of `astUtils.isDescribe` which has been called
without the second parameter which caused the function to accept
`undefined` as a valid alias for suite function names. Additionally
there are cases where we don’t get a node name for `CallExpressions`
(e.g. `foo()()`). So in such cases the extracted node name is
`undefined` and `isDescribe` will return true due to the above mentioned
bug.

Fixes: #172
lo1tuma added a commit that referenced this issue Jul 8, 2019
Fix no-setup-in-describe to correctly detect describe calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant