Skip to content
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

csf-strict config not scoped to story files #133

Open
ahutchings opened this issue Jul 18, 2023 · 0 comments
Open

csf-strict config not scoped to story files #133

ahutchings opened this issue Jul 18, 2023 · 0 comments

Comments

@ahutchings
Copy link

Describe the bug

I enabled the csf-strict config in my project by adding plugin:storybook/csf-strict to the extends array in .eslintrc.js.

When running ESLint, it fails with an exception:

TypeError: Cannot use 'in' operator to search for 'name' in undefined
Occurred while linting <snip>/packages/<snip>/src/index.js:12
    at <snip>/node_modules/eslint-plugin-storybook/dist/rules/no-title-property-in-meta.js:35:127
    at Array.find (<anonymous>)
    at ExportDefaultDeclaration (<snip>/node_modules/eslint-plugin-storybook/dist/rules/no-title-property-in-meta.js:35:51)
    at <snip>/node_modules/eslint/lib/util/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (<snip>/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (<snip>/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (<snip>/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (<snip>/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (<snip>/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)

This filename (src/index.js) doesn't match the patterns used by other configs (like in the csf config) so the csf-strict config must not be inheriting the scoping logic when it extends csf.

To Reproduce
Not sure exactly what syntax repros the error, but to confirm that the csf-strict config runs in non-story files, you can:

  1. Create a project with ESLint and eslint-plugin-storybook, extending the csf-strict config.
  2. Create a file in the project that does match a story file name (example: src/index.js)
  3. Export an anonymous object containing a title field.
  4. See an error due to the failing no-title-property-in-meta rule.

Expected behavior
No failing ESLint rules.

Screenshots
n/a

Additional context

eslint-plugin-storybook version 0.6.12

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

No branches or pull requests

1 participant