-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
ESLint: fix to only apply csf-strict rules on stories files #31963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
ESLint: fix to only apply csf-strict rules on stories files #31963
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
4 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
Hey @valentinpalkovic I saw you had assigned this out, but I see last week it has been marked stale. Is there anything you need from me to address this? |
No. I think we're good, but just busy with the 9.1 release. I am sure that after releasing 9.1, @yannbf will take a look! |
} as const, | ||
overrides: [ | ||
{ | ||
files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there @cylewaitforit, thanks for your contribution!
Won't this block users from specifying their own files to apply these rules? As it now has hardcode file paths? Perhaps we can do differently and leave things as they were, and only move these general, conflicting rules to a new entry that's always added, and has the hardcoded paths:
'react-hooks/rules-of-hooks': 'off',
'import/no-anonymous-default-export': 'off',
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @yannbf, thanks for reviewing. This updates csf-strict to follow the same pattern used by the other configs (see https://github.com/storybookjs/storybook/blob/next/code/lib/eslint-plugin/src/configs/recommended.ts and https://github.com/storybookjs/storybook/blob/next/code/lib/eslint-plugin/src/configs/csf.ts). Users should still have the ability to make any overrides in their own config after extending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yannbf Another option, if you’re concerned about this legacy config, might be to only leave the fix for the Flat Config and instead mark the legacy config options as deprecated for removal in V10 of this storybook eslint plugin.
Overriding files types for a config on the user side is very straight forward in the flat config and can be easily verified with the eslint config inspector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yannbf Are the legacy configs staying in eslint for Storybook 10 or will they be removed?
Closes storybookjs/eslint-plugin-storybook#155
What I did
Updated csf-strict rules to apply on stories files. This is to fix csf-strict from disabling 'react-hooks/rules-of-hooks' and 'import/no-anonymous-default-export' for an entire project.
This updates and moves a PR the was previously opened in the eslint-plugin-storybook repo.
storybookjs/eslint-plugin-storybook#201
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
Updates the ESLint csf-strict configuration to properly scope rules to story files only, fixing incorrect project-wide rule application.
code/lib/eslint-plugin/src/configs/csf-strict.ts
to target only*.stories.*
and*.story.*
files using overridesreact-hooks/rules-of-hooks
andimport/no-anonymous-default-export
rules across entire projects