Skip to content

fix(eslint-plugin-tsdoc): replace deprecated ESLint APIs for v10 compatibility#461

Merged
iclanton merged 1 commit intomicrosoft:mainfrom
roli-lpci:fix/eslint-10-compat
Feb 25, 2026
Merged

fix(eslint-plugin-tsdoc): replace deprecated ESLint APIs for v10 compatibility#461
iclanton merged 1 commit intomicrosoft:mainfrom
roli-lpci:fix/eslint-10-compat

Conversation

@roli-lpci
Copy link
Copy Markdown
Contributor

Summary

Replaces two deprecated ESLint context method calls with their modern property equivalents, fixing the TypeError: context.getSourceCode is not a function crash when using eslint-plugin-tsdoc with ESLint 10.

What changed

Line Before After
38 context.getCwd?.() context.cwd ?? context.getCwd?.()
112 context.getSourceCode() context.sourceCode ?? context.getSourceCode()

Why

  • context.getSourceCode() was deprecated in ESLint v8.40 and removed in ESLint v10.
  • context.getCwd() was deprecated in ESLint v8.40 and removed in ESLint v10.
  • The ?? fallback pattern ensures backward compatibility with all ESLint versions the plugin currently supports.

Reference: https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/

Fixes #455

…atibility

Replace `context.getSourceCode()` with `context.sourceCode ?? context.getSourceCode()`
and `context.getCwd?.()` with `context.cwd ?? context.getCwd?.()` to support ESLint 10
while maintaining backward compatibility with older versions.

Fixes microsoft#455

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@roli-lpci
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@iclanton iclanton merged commit 0fe359e into microsoft:main Feb 25, 2026
6 checks passed
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 this pull request may close these issues.

ESLint 10 support in eslint-plugin-tsdoc

2 participants