Skip to content

sourceCode.getScope is not a function error #1387

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
alissa-huskey opened this issue May 14, 2025 · 2 comments · Fixed by #1388
Closed

sourceCode.getScope is not a function error #1387

alissa-huskey opened this issue May 14, 2025 · 2 comments · Fixed by #1388

Comments

@alissa-huskey
Copy link

alissa-huskey commented May 14, 2025

I created a repository to reproduce this error here.

Expected behavior

I expected eslint to run on the command line without error.

Actual behavior

It produced the following error:

TypeError: sourceCode.getScope is not a function
Occurred while linting ./index.js:4
Rule: "jsdoc/no-undefined-types"
    at exports.default.iterateAllJsdocs (./node_modules/eslint-plugin-jsdoc/dist/rules/noUndefinedTypes.cjs:199:209)
    at iterate (./node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.cjs:1690:3)
    at callIterator (./node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.cjs:1833:7)
    at *:not(Program) (./node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.cjs:1891:11)
    at ruleErrorHandler (./node_modules/eslint/lib/linter/linter.js:966:28)
    at ./node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (./node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (./node_modules/eslint/lib/linter/node-event-generator.js:290:26)
    at NodeEventGenerator.applySelectors (./node_modules/eslint/lib/linter/node-event-generator.js:317:22)

ESLint Config

module.exports = {
  extends: [
    "plugin:jsdoc/recommended",
  ],
  // the error will occurr if either or both of the following are present
  env: {
    es2021: true
  },
  parserOptions: {
    ecmaVersion: "latest",
  },
};

ESLint sample

/**
 *
 */
doThing = function (a, b) {
  console.log(`Doing a thing: ${a}, ${b}`);
};

Environment

  • Node version: v23.5.0
  • ESLint version v8.0.1
  • eslint-plugin-jsdoc version: 50.6.14
Copy link

🎉 This issue has been resolved in version 50.6.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

@brettz9
Copy link
Collaborator

brettz9 commented May 14, 2025

Thanks for the report. We don't have ESLint 8 running anymore in our CI to detect such errors. This should be fixed in v50.6.15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants