Skip to content

mocha/handle-done-callback fails when linting non-js/non-ts files #390

@KristjanTammekivi

Description

@KristjanTammekivi

Hi, my lint command runs lint on files other than code, like markdown, so when using mocha.configs.recommended linting throws an error

TypeError: Error while loading rule 'mocha/handle-done-callback': Cannot destructure property 'globalScope' of 'sourceCode.scopeManager' as it is undefined.
Occurred while linting /home/kristjan/project/CHANGELOG.md
    at findGlobalReferencesByName (file:///home/kristjan/project/node_modules/eslint-plugin-mocha/ast/find-global-references.js:20:13)
    at findMochaVariableCalls (file:///home/kristjan/project/node_modules/eslint-plugin-mocha/ast/find-mocha-variable-calls.js:78:11)
    at findCallsCached (file:///home/kristjan/project/node_modules/eslint-plugin-mocha/ast/mocha-visitors.js:91:17)
    at createMochaVisitors (file:///home/kristjan/project/node_modules/eslint-plugin-mocha/ast/mocha-visitors.js:128:19)
    at Object.create (file:///home/kristjan/project/node_modules/eslint-plugin-mocha/rules/handle-done-callback.js:55:16)
    at createRuleListeners (/home/kristjan/project/node_modules/eslint/lib/linter/linter.js:1134:15)
    at /home/kristjan/project/node_modules/eslint/lib/linter/linter.js:1287:7
    at Array.forEach (<anonymous>)
    at runRules (/home/kristjan/project/node_modules/eslint/lib/linter/linter.js:1203:31)
    at #flatVerifyWithoutProcessors (/home/kristjan/project/node_modules/eslint/lib/linter/linter.js:2282:22)

Workaround for me is to do

    {
        files: ['**/*.{js,mjs,cjs,ts}'],
        ...mocha.configs.recommended
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions