Skip to content

fix: replace deprecated context.getFilename() for ESLint 10 compatibility#105

Open
roli-lpci wants to merge 1 commit into
atfzl:masterfrom
roli-lpci:fix/eslint-10-compat
Open

fix: replace deprecated context.getFilename() for ESLint 10 compatibility#105
roli-lpci wants to merge 1 commit into
atfzl:masterfrom
roli-lpci:fix/eslint-10-compat

Conversation

@roli-lpci
Copy link
Copy Markdown

Summary

Replaces the deprecated context.getFilename() call with context.filename ?? context.getFilename() in lib/core/index.js.

Why

context.getFilename() was deprecated in ESLint v8.40 and removed in ESLint v10, causing TypeError: context.getFilename is not a function. The context.filename property has been available since v8.40, and the ?? fallback preserves backward compatibility with older versions.

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

Testing

All 71 existing tests pass.

Fixes #104

ESLint 10 removed `context.getFilename()` in favor of
`context.filename`. Use nullish coalescing fallback to support
both ESLint 10+ and older versions.

Fixes atfzl#104

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Not ESLint 10 compatible

1 participant