Skip to content

fix: use context.filename instead of deprecated getFilename() for ESLint 10 compat#451

Closed
jacknus wants to merge 1 commit intots-safeql:mainfrom
jacknus:fix/eslint-10-getfilename-compat
Closed

fix: use context.filename instead of deprecated getFilename() for ESLint 10 compat#451
jacknus wants to merge 1 commit intots-safeql:mainfrom
jacknus:fix/eslint-10-getfilename-compat

Conversation

@jacknus
Copy link
Copy Markdown

@jacknus jacknus commented Mar 11, 2026

Summary

  • shouldLintFile() in check-sql.utils.ts called params.getFilename(), which was deprecated in ESLint 8.40 and removed in ESLint 10
  • Replaced with params.filename (the property equivalent, available since ESLint 8.40)
  • The rest of the rule already used context.filename correctly (e.g. check-sql.rule.ts:515-516)

Test plan

  • TypeScript compilation passes
  • Build succeeds
  • Verify ESLint 10 no longer crashes with TypeError: params.getFilename is not a function

Fixes crash: TypeError: Error while loading rule '@ts-safeql/check-sql': params.getFilename is not a function

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated internal file handling mechanism in the SQL linting rule.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 11, 2026

⚠️ No Changeset found

Latest commit: 313e6b7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 11, 2026

@jacknus is attempting to deploy a commit to the newbie012's projects Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR fixes an ESLint 10 compatibility crash by replacing the removed getFilename() method with the filename property in the shouldLintFile utility. The one-line change in check-sql.utils.ts is correct, minimal, and consistent with how context.filename is already used in check-sql.rule.ts.

  • Replaces params.getFilename() (deprecated in ESLint 8.40, removed in ESLint 10) with params.filename in shouldLintFile
  • No other call sites of getFilename remain in the codebase
  • The RuleContext type (TSESLint.RuleContext) exposes filename as a property, so this is type-safe
  • No tests exist specifically for shouldLintFile, so no test updates are required

Confidence Score: 5/5

  • This PR is safe to merge — it is a one-line, low-risk fix that resolves a real runtime crash in ESLint 10.
  • The change is a single property access substitution (getFilename()filename) that directly matches the existing pattern used elsewhere in the same file's consuming rule. The fix is well-scoped, type-safe, and directly addresses the reported crash.
  • No files require special attention.

Important Files Changed

Filename Overview
packages/eslint-plugin/src/rules/check-sql.utils.ts Replaces the deprecated params.getFilename() call with params.filename property in shouldLintFile to fix ESLint 10 compatibility; change is minimal and consistent with how context.filename is already used elsewhere in the rule.

Sequence Diagram

sequenceDiagram
    participant ESLint as ESLint (v8.40+ / v10)
    participant Rule as check-sql.rule.ts
    participant Utils as check-sql.utils.ts

    ESLint->>Rule: create(context)
    Rule->>Utils: shouldLintFile(context)
    Note over Utils: ESLint <8.40: context.getFilename()<br/>ESLint ≥8.40 / v10: context.filename ✅
    Utils-->>Rule: true / false
    alt file should be linted
        Rule->>Rule: proceed with SQL checking
    else skip
        Rule-->>ESLint: return {}
    end
Loading

Last reviewed commit: 313e6b7

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

Single-line change in the shouldLintFile function replaces params.getFilename() method call with params.filename property access to retrieve the filename, updating compatibility with ESLint's RuleContext interface.

Changes

Cohort / File(s) Summary
Filename Property Access
packages/eslint-plugin/src/rules/check-sql.utils.ts
Changed filename retrieval from method call getFilename() to property access filename in shouldLintFile function.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Poem

🐰 A tiny hop, one line so small,
From method call to property's call,
ESLint's dance renewed once more,
The rabbit hops through version's door! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing a deprecated ESLint method with its modern equivalent for ESLint 10 compatibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jacknus jacknus closed this Mar 16, 2026
@karlhorky
Copy link
Copy Markdown
Collaborator

karlhorky commented Mar 25, 2026

@jacknus why did you close this?

Edit: oh sorry, just saw the new PR by @Newbie012 which achieves the same thing:

@jacknus
Copy link
Copy Markdown
Author

jacknus commented Mar 25, 2026

@jacknus why did you close this?

Edit: oh sorry, just saw the new PR by @Newbie012 which achieves the same thing:

Didn't have time to test it all the way through so I thought i might as well close it to avoid you guys spending time on something half finished ✌️

Edit - yeah then i saw @Newbie012 did something to fix this - so just waiting for an updated release to test it out :-)

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.

2 participants