Skip to content

Replace deprecated context.getFilename() in ESLint plugin - #3220

Open
jasontd92 wants to merge 3 commits into
graphile:mainfrom
jasontd92:unstale/eslint-context-filename
Open

jasontd92 wants to merge 3 commits into
graphile:mainfrom
jasontd92:unstale/eslint-context-filename

Conversation

@jasontd92

@jasontd92 jasontd92 commented Oct 21, 2026 •

Copy link
Copy Markdown

Description

eslint-plugin-graphile-export calls context.getFilename() (in
export-subclasses) and context.getPhysicalFilename() (in the
GRAPHILE_ENV=development debug output of export-methods). ESLint deprecated
both in v8.40.0 in favour of the context.filename and
context.physicalFilename properties, and
removed them in v10.0.0
(v8.40.0 release notes).
This is one of the things the plugin needs before it can support ESLint 10.

This PR adds getFilename(context) and getPhysicalFilename(context) helpers
to utils/eslint-plugin-graphile-export/src/utils.ts. They read the properties
when present and fall back to the old methods otherwise, so older ESLint
versions keep working. The three call sites use them:

  • utils/eslint-plugin-graphile-export/src/ExportSubclasses.ts (2 sites)
  • utils/eslint-plugin-graphile-export/src/ExportMethods.ts (1 site)

The peer range is unchanged. A patch changeset is included.

Performance impact

None.

Security impact

None.

Verification

Run in a node:22-bookworm container after yarn --immutable and
yarn build. Each check was run on main first, then again with this change.
Both runs gave the same results:

  • yarn tsc -b in utils/eslint-plugin-graphile-export: passes.
  • eslint --ext .js,.jsx,.ts,.tsx utils grafast/grafast (the repo config,
    which enables the plugin's recommended rules): exit 0, no reports. The
    full yarn eslint . needs more memory than the container had.
  • A throwaway script that runs both rules through ESLint's Linter on
    class MyStep extends Step {} and { plan() {}, notAllowed: 1 } in
    /work/src/MyStep.ts. The "convert to importable" suggestion contains
    "./MyStep.ts", and the development debug message contains
    /work/src/MyStep.ts:3:13.
  • yarn prettier --check on the changed files: passes.

After the change to the helpers (ea94be7), re-run in the same container:

  • yarn tsc -b in utils/eslint-plugin-graphile-export: passes.
  • yarn eslint --ext .js,.jsx,.ts,.tsx utils/eslint-plugin-graphile-export:
    exit 0. The wider utils grafast/grafast run now exits 129 with no output on
    both main and this branch, so it is not counted here.
  • The throwaway script above: same results.
  • The same script with a rule context where filename and physicalFilename
    are undefined and only getFilename() / getPhysicalFilename() exist (as
    on ESLint < 8.40): same results, with the fallback methods called for all
    three sites.
  • yarn prettier --check on the changed files: passes.

Checklist

  • My code matches the project's code style and yarn lint:fix passes. (ESLint and Prettier were run on the scope above, not the full lint:fix.)
  • I've added tests for the new feature, and yarn test passes. (The plugin has no test suite. It was checked with the script above.)
  • I have detailed the new feature in the relevant documentation. (Not applicable.)
  • I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists). (A changeset is included instead.)
  • If this is a breaking change I've explained why. (Not a breaking change.)

Found with unstale, a tool I'm building so nobody has to read every changelog to catch changes like this one. Prepared with AI assistance (Claude Code) and verified as described above.

@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

馃 Changeset detected

Latest commit: 69bf9d7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-graphile-export Patch

Not sure what this means? Click here to learn what changesets are.

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

@benjie benjie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this drops support for earlier ESLint, we should change the peer dependency range, and change this to semver major. TBH I doubt we support back that far in ESLint history anyway...

Seems this could be done in a backwards compatible way though: const getFilename = (context: {filename?: string, getFilename?(): string}) => context.filename ?? context.getFilename?.() for example?

@jasontd92

jasontd92 commented Oct 21, 2026 •

Copy link
Copy Markdown
Author

Done in ea94be7: added getFilename(context) / getPhysicalFilename(context) to src/utils.ts, which return context.filename ?? context.getFilename!() (and the physical equivalent). Older ESLint keeps working, so the peer range and the patch changeset stay as they were. I updated the changeset wording.

Re-verified: yarn tsc -b and yarn eslint on the plugin pass. Both rules give the same output through ESLint 9's Linter, and also with a context that only has getFilename() / getPhysicalFilename() (checked that the fallbacks are hit). Details are in the description.

@benjie benjie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 馃檶

@benjie
benjie enabled auto-merge October 21, 2026 16:10

This branch has not been deployed

No deployments
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