Closed Philzen closed 1 month ago
@Philzen Thanks for taking the time to report! ... and I see you have a PR in! 🙌 I know @arimendelow has been working on Storybook updates here #11581 I'll get him to review your stuff.
Ha, this is interesting — @Philzen, just reviewed your other PR and left a comment on it.
A short term fix here, of course, is to just ignore ESLint on this line, such that your imports aren't reordered.
@ahaywood, do you think it's worth adding a note in #11581 to be careful when reordering any Redwood-generated imports? I feel like trying to include something about this in the docs would be confusing without the proper context.
@Philzen, if you want to open a PR for fixing this, I'd be happy to review it! As you can see from your own excellent investigation, all that needs to happen here is removing createAuth
from the original import so that we can replace it with the mocked version.
@ahaywood pls note the other PR was completely unrelated to this issue.
do you think it's worth adding a note in https://github.com/redwoodjs/redwood/pull/11581 to be careful when reordering any Redwood-generated imports?
@arimendelow i found https://github.com/redwoodjs/redwood/blob/main/packages/eslint-config/README.md very helpful for this (which is to from the docs) (my two cents would be that a json config with "$schema": "https://json.schemastore.org/eslintrc.json"
gives much superior documentation and code completion than the js file – even when annotated with a JSDoc type import).
Everyone having ever tried to extend an already extensive ruleset such as @redwoodjs/eslint-config
gets the drift pretty quickly that there be dragons :D And i understand that a least since the decoupling of auth.ts
from the auth-packages (i remember that happening somewhat around v4.x) these are free for customizations, so any kind of additional imports may appear there all the time.
So therefore IMHO the regex is simply making an assumption here that it shouldn't rely on. I'm no RegEx guru, but played around with it a bit and believe the change proposed in #11593 seems to do the trick, kindly take a gander.
Left a comment on your PR! Looks mostly good to me :) Thanks for putting that together so quickly!
These are all great points 😄 I'm no RegEx guru either, hence us winding up here in the first place — your proposal is certainly an improvement.
What's not working?
Having recently upgraded our stack to RW 7.7.4 and also migrated storybook to Vite, i today found that it suddenly stopped rendering any stories whatsoever, throwing:
After some headscratching about the sudden breakage i realized we had a change to
auth.ts
import order – before it was:which worked fine, but now (b/c we added an eslint rule to sort them alphabetically to get nicer, deterministic import diffs) it is
and breaks when starting storybook-vite.
After some digging, i assume the culprit is this RegEx:
https://github.com/redwoodjs/redwood/blob/62509c9e8ca8eb6553addeadfa58126c470fb6d1/packages/storybook/src/plugins/mock-auth.ts#L14
How do we reproduce the bug?
Apparently it happens when
createAuth
is followed by a comma, as in a list of named imports.What's your environment? (If it applies)
Are you interested in working on this?