Eslint: Fix ESLint 10 compatibility in eslint-plugin-storybook rules#33884
Conversation
…precated alternatives Co-authored-by: valentinpalkovic <5889929+valentinpalkovic@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughUpdates five ESLint rule implementations to use modern property access patterns instead of deprecated methods: replacing Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes ✨ Finishing Touches
Comment |
|
View your CI Pipeline Execution ↗ for commit b196790
☁️ Nx Cloud last updated this comment at |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 535 | 535 | 0 |
| Self size | 648 KB | 648 KB | 🎉 -125 B 🎉 |
| Dependency size | 59.87 MB | 59.91 MB | 🚨 +36 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 92 | 92 | 0 |
| Self size | 1.12 MB | 1.12 MB | 🎉 -41 B 🎉 |
| Dependency size | 22.46 MB | 22.50 MB | 🚨 +39 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 124 | 124 | 0 |
| Self size | 30 KB | 30 KB | 🚨 +37 B 🚨 |
| Dependency size | 23.75 MB | 23.79 MB | 🚨 +39 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 82 | 82 | 0 |
| Self size | 35 KB | 35 KB | 🚨 +14 B 🚨 |
| Dependency size | 20.25 MB | 20.29 MB | 🚨 +39 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 274 | 274 | 0 |
| Self size | 24 KB | 24 KB | 🎉 -5 B 🎉 |
| Dependency size | 44.54 MB | 44.57 MB | 🚨 +36 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 58 | 57 | 🎉 -1 🎉 |
| Self size | 1.19 MB | 1.23 MB | 🚨 +37 KB 🚨 |
| Dependency size | 13.20 MB | 12.94 MB | 🎉 -264 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
Eslint: Fix ESLint 10 compatibility in eslint-plugin-storybook rules (cherry picked from commit 60996ad)
|
the peer dependency says Also, the compat table in the readme of the package does not mention ESLint 10. |
ESLint 10 removed several deprecated
contextmethods, causing runtime crashes (TypeError: context.getSourceCode is not a function) in multipleeslint-plugin-storybookrules.Changes
Replaced removed
contextmethods with their direct property equivalents across 5 rules:context.getSourceCode()context.sourceCodecontext.getFilename()context.filenameAffected rules:
meta-satisfies-typeno-title-property-in-metause-storybook-testing-librarydefault-exportsprefer-pascal-caseBoth replacements were introduced in ESLint 8.25–8.40, so this is backward-compatible with ESLint 8, 9, and 10. The
prefer-pascal-caserule already usedcontext.sourceCodefor scope handling — this change makes the rest of the codebase consistent.Original prompt
This section details on the original issue you should resolve
<issue_title>[Bug]: eslint 10 support</issue_title>
<issue_description>### Describe the bug
Summary
storybook/meta-satisfies-typecrashes under ESLint 10.0.0.Error
TypeError: context.getSourceCode is not a functionExpected behavior
Rule should execute without runtime errors on ESLint 10.
Environment
Workaround
Rule currently disabled.
Reproduction link
n/a
Reproduction steps
System
Additional context
No response</issue_description>
<agent_instructions>Make sure to support Eslint 9 as well.
Here is the migration guide:
Migrate to v10.x
ESLint v10.0.0 is a major release of ESLint, and as such, has several breaking changes that you need to be aware of. This guide is intended to walk you through the breaking changes.
The lists below are ordered roughly by the number of users each change is expected to affect, where the first items are expected to affect the most users.
Table of Contents
Breaking changes for users
Node.js < v20.19, v21, v23 are no longer supported
eslint:recommended has been updated
New configuration file lookup algorithm
Old config format no longer supported
JSX references are now tracked
eslint-env comments are reported as errors
Jiti < v2.2.0 are no longer supported
POSIX character classes in glob patterns
stylish formatter now uses native styleText instead of chalk
Deprecated options of the radix rule
no-shadow-restricted-names now reports globalThis by default
func-names schema is stricter
allowConstructorFlags option of no-invalid-regexp now accepts only unique items
name property added to ESLint core configs
Breaking changes for plugin developers
Node.js < v20.19, v21, v23 are no longer supported
Old config format no longer supported
JSX references are now tracked
Removal of type property in errors of invalid RuleTester cases
Program AST node range spans entire source text
Fixer methods now require string text arguments
New requirements for ScopeManager implementations
Removal of deprecated context members
Removal of deprecated SourceCode methods
Prohibiting errors or output of valid RuleTester test cases
POSIX character classes in glob patterns
Breaking changes for integration developers
Node.js < v20.19, v21, v23 are no longer supported
New configuration file lookup algorithm
Old config format no longer supported
Removal of nodeType property in LintMessage objects
POSIX character classes in glob patterns
Node.js < v20.19, v21, v23 are no longer supported
ESLint is officially dropping support for these versions of Node.js starting with ESLint v10.0.0. ESLint now supports the following versions of Node.js:
Node.js v20.19.0 and above
Node.js v22.13.0 and above
Node.js v24 and above
To address: Make sure you upgrade to at least Node.js v20.19.0 when using ESLint v10.0.0. One important thing to double check is the Node.js version supported by your editor when using ESLint via editor integrations. If you are unable to upgrade, we recommend continuing to use ESLint v9 until you are able to upgrade Node.js.
Related issue(s): #19969
eslint:recommended has been updated
Three new rules have been enabled in eslint:recommended:
no-unassigned-vars
no-useless-assignment
preserve-caught-error
To address: Fix errors or disable these rules.
Related issue(s): #19966
New configuration file lookup algorithm
In ESLint v9, the alternate config lookup behavior could be enabled with the v10_config_lookup_from_file feature flag. This behavior made ESLint locate eslint.config.* by starting from the directory of each linted file and searching up towards the filesystem root. In ESLint v10.0.0, this behavior is now the...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Summary by CodeRabbit