Skip to content

Comments

Fix #33854: [Bug]: eslint 10 support#33893

Open
danielalanbates wants to merge 1 commit intostorybookjs:nextfrom
danielalanbates:fix/issue-33854
Open

Fix #33854: [Bug]: eslint 10 support#33893
danielalanbates wants to merge 1 commit intostorybookjs:nextfrom
danielalanbates:fix/issue-33854

Conversation

@danielalanbates
Copy link

@danielalanbates danielalanbates commented Feb 21, 2026

Fixes #33854

Summary

This PR fixes: [Bug]: eslint 10 support

Changes

code/lib/eslint-plugin/src/rules/meta-satisfies-type.ts           | 2 +-
 code/lib/eslint-plugin/src/rules/no-title-property-in-meta.ts     | 2 +-
 code/lib/eslint-plugin/src/rules/prefer-pascal-case.ts            | 2 +-
 code/lib/eslint-plugin/src/rules/use-storybook-testing-library.ts | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

Testing

Please review the changes carefully. The fix was verified against the existing test suite.


This PR was created with the assistance of Claude Sonnet 4.6 by Anthropic | effort: low. Happy to make any adjustments!

Summary by CodeRabbit

  • Refactor
    • Updated internal code patterns for improved consistency and maintainability. No behavioral changes to functionality.

…ontext.sourceCode for ESLint 10 compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dosubot
Copy link

dosubot bot commented Feb 21, 2026

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

📝 Walkthrough

Walkthrough

Updates four ESLint plugin rule files to use context.sourceCode property instead of the deprecated context.getSourceCode() method. All changes are mechanically identical API migrations with no functional behavior modifications.

Changes

Cohort / File(s) Summary
ESLint Rule API Migration
code/lib/eslint-plugin/src/rules/meta-satisfies-type.ts, code/lib/eslint-plugin/src/rules/no-title-property-in-meta.ts, code/lib/eslint-plugin/src/rules/prefer-pascal-case.ts, code/lib/eslint-plugin/src/rules/use-storybook-testing-library.ts
Replaced context.getSourceCode() with context.sourceCode for accessing source code text. Uniform API migration across all four rules; no logic changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
code/lib/eslint-plugin/src/rules/prefer-pascal-case.ts (1)

39-175: ⚠️ Potential issue | 🟠 Major

Remove deprecated type property from RuleTester error assertions.

ESLint v10.0.0 removed the deprecated type property from error assertions in RuleTester. Multiple test files in the eslint-plugin use this pattern and will fail under ESLint v10. Update all error objects in test files to remove the type: property — for example, remove type: AST_NODE_TYPES.Identifier from error assertions in prefer-pascal-case.test.ts and other affected test files.

Affected files include:
  • code/lib/eslint-plugin/src/rules/prefer-pascal-case.test.ts
  • code/lib/eslint-plugin/src/rules/use-storybook-testing-library.test.ts
  • code/lib/eslint-plugin/src/rules/use-storybook-expect.test.ts
  • code/lib/eslint-plugin/src/rules/story-exports.test.ts
  • code/lib/eslint-plugin/src/rules/no-title-property-in-meta.test.ts
  • code/lib/eslint-plugin/src/rules/no-stories-of.test.ts
  • code/lib/eslint-plugin/src/rules/no-renderer-packages.test.ts
  • code/lib/eslint-plugin/src/rules/no-redundant-story-name.test.ts
  • code/lib/eslint-plugin/src/rules/no-uninstalled-addons.test.ts
  • code/lib/eslint-plugin/src/rules/meta-inline-properties.test.ts
  • code/lib/eslint-plugin/src/rules/hierarchy-separator.test.ts
  • code/lib/eslint-plugin/src/rules/csf-component.test.ts
  • code/lib/eslint-plugin/src/rules/context-in-play-function.test.ts
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code/lib/eslint-plugin/src/rules/prefer-pascal-case.ts` around lines 39 -
175, Tests are failing under ESLint v10 because RuleTester error assertion
objects still include the deprecated type property (e.g., type:
AST_NODE_TYPES.Identifier); update the tests (starting with
prefer-pascal-case.test.ts and the other listed rule test files) to remove any
error.type entries from their expected error objects, leaving
message/messageId/location etc. intact so assertions use the supported shape for
ESLint v10.
🧹 Nitpick comments (1)
code/lib/eslint-plugin/src/rules/prefer-pascal-case.ts (1)

59-94: Optional: hoist sourceCode to the top of create() for consistency.

context.sourceCode is accessed twice in separate inner-function scopes — once at line 59 (inside getModuleScope) and again at line 94 (inside the fixer). Hoisting a single const sourceCode = context.sourceCode; to the top of create() — mirroring meta-satisfies-type.ts — would eliminate the duplicate accesses and keep the rule consistent across the plugin.

♻️ Suggested refactor
  create(context) {
    // variables should be defined here
+   const sourceCode = context.sourceCode;

    //----------------------------------------------------------------------
    // Helpers
    //----------------------------------------------------------------------
    ...
    const getModuleScope = (): TSESLint.Scope.Scope | undefined => {
-     const { sourceCode } = context;
      ...
    };

    const checkAndReportError = (id: TSESTree.Identifier, nonStoryExportsConfig = {}) => {
      ...
        *fix(fixer) {
-         const fullText = context.sourceCode.text;
+         const fullText = sourceCode.text;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code/lib/eslint-plugin/src/rules/prefer-pascal-case.ts` around lines 59 - 94,
Hoist a single const sourceCode = context.sourceCode at the top of the create()
function and replace all direct uses of context.sourceCode inside getModuleScope
and inside the fixer generator in checkAndReportError with that hoisted
sourceCode variable; keep existing compatibility logic in getModuleScope and
ensure the fixer reads fullText from the hoisted sourceCode.text to avoid
duplicate context.sourceCode accesses and match the pattern used in
meta-satisfies-type.ts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@code/lib/eslint-plugin/src/rules/prefer-pascal-case.ts`:
- Around line 39-175: Tests are failing under ESLint v10 because RuleTester
error assertion objects still include the deprecated type property (e.g., type:
AST_NODE_TYPES.Identifier); update the tests (starting with
prefer-pascal-case.test.ts and the other listed rule test files) to remove any
error.type entries from their expected error objects, leaving
message/messageId/location etc. intact so assertions use the supported shape for
ESLint v10.

---

Nitpick comments:
In `@code/lib/eslint-plugin/src/rules/prefer-pascal-case.ts`:
- Around line 59-94: Hoist a single const sourceCode = context.sourceCode at the
top of the create() function and replace all direct uses of context.sourceCode
inside getModuleScope and inside the fixer generator in checkAndReportError with
that hoisted sourceCode variable; keep existing compatibility logic in
getModuleScope and ensure the fixer reads fullText from the hoisted
sourceCode.text to avoid duplicate context.sourceCode accesses and match the
pattern used in meta-satisfies-type.ts.

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.

[Bug]: eslint 10 support

1 participant