Skip to content

consistent-spacing-between-blocks throws in 11.0.0 #377

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
perrin4869 opened this issue Apr 29, 2025 · 6 comments · Fixed by #379
Closed

consistent-spacing-between-blocks throws in 11.0.0 #377

perrin4869 opened this issue Apr 29, 2025 · 6 comments · Fixed by #379

Comments

@perrin4869
Copy link

After upgrading, I am getting the following error:

TypeError: Cannot read properties of undefined (reading '0')
Occurred while linting /home/perrin4869/services-typescript/services/distid/src/batch.integration.ts:16
Rule: "mocha/consistent-spacing-between-blocks"
    at isFirstStatementInScope (file:///home/perrin4869/services-typescript/node_modules/eslint-plugin-mocha/rules/consistent-spacing-between-blocks.js:6:35)
    at checkCurrentLayer (file:///home/perrin4869/services-typescript/node_modules/eslint-plugin-mocha/rules/consistent-spacing-between-blocks.js:32:22)
    at suite:exit (file:///home/perrin4869/services-typescript/node_modules/eslint-plugin-mocha/rules/consistent-spacing-between-blocks.js:52:17)
    at callVisitorIfExists (file:///home/perrin4869/services-typescript/node_modules/eslint-plugin-mocha/ast/mocha-visitors.js:20:9)
    at callVisitors (file:///home/perrin4869/services-typescript/node_modules/eslint-plugin-mocha/ast/mocha-visitors.js:57:9)
    at CallExpression:exit (file:///home/perrin4869/services-typescript/node_modules/eslint-plugin-mocha/ast/mocha-visitors.js:148:17)
    at ruleErrorHandler (/home/perrin4869/services-typescript/node_modules/eslint/lib/linter/linter.js:1311:33)
    at /home/perrin4869/services-typescript/node_modules/eslint/lib/linter/safe-emitter.js:45:46
    at Array.forEach (<anonymous>)
    at Object.emit (/home/perrin4869/services-typescript/node_modules/eslint/lib/linter/safe-emitter.js:45:26)
@lo1tuma
Copy link
Owner

lo1tuma commented Apr 29, 2025

Any chance you can share the actual code that is causing this error?

@perrin4869
Copy link
Author

It's part of a private repo, so I would have to reproduce it separately. Unfortunately my public repos are still using eslint 8...
I will try to find some time to reproduce it this week

@perrin4869
Copy link
Author

Here is a file that introduces the error:

describe("foo", () => {
    it("bar", () => {}).timeout(30_000);
});

I think it has to do with the timeout call, because removing it fixes the issue

@perrin4869
Copy link
Author

btw, I opened this as a separate issue last year here:
#364

but the following code triggers mocha/no-setup-in-describe (or at least it did in 10.x), and should work on mocha>=11:

describe("my suite", () => {
  before(() => {}).timeout(1000);
});

thought I'd bring it up since it is very similar

@lo1tuma
Copy link
Owner

lo1tuma commented Apr 30, 2025

Thanks, that was indeed to root cause. The issue is fixed now and I will make another release in the next days.
Regarding no-setup-in-describe I haven’t looked into it yet, but I guess it is still an issue.

@maplesteve
Copy link

@lo1tuma Would be great, if you can make the release. We're having several repos, that are stuck since v11 because of this issue. Thanks!

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.

3 participants