-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Generators] generated code should be linted and formatted #1551
Comments
Why do you need that? Isn't the code generated by the generators already in the correct format? |
(replying from phone, so sorry in advance for brevity) basically consistency. ideally whatever is built from generators should respect project's lint defaults (scope/context is this and what follows - #1381 (comment)) hope this helps. have a great weekend |
Agreed! IIRC we already do run everything we generate through prettier. I guess we could look at adding linting as well. But I'll let others chime in with their opinions as well |
@AntonioMeireles I think we should (and do) lint/format everything we generate, but that can happen in the framework as opposed to the redwood app, unless you meant you have different eslint/prettier settings that you want the generators to inherit? |
I do not believe this is this case. Quick search for Given confirmation, this gets a 👍 from me. |
Is there a list things that can be generated? |
+1 defaulting to running lint after generating (with option to disable) @macovedj I just reference these directories within Also this from the
Note: things like |
Typically, I've seen config vary between members on teams, but config would be how you go about utilizing eslint or prettier or something similar right? As far as I know, neither of them expose utilities that would let you format something from within a script... which seems like something you would want/need here. Seems you would want to be able to call some utility that formats at the end of generation scripts. I'm still looking around the internet for exposed utilities, but wondering if this requires a home grown solution. |
@macovedj We already have default config for ESLint and Prettier. So what happens is that the generated code, using templates, sometimes doesn't conform to formatting, which means it immediately has a VS Code warning/error. This is annoying/confusing. What's more, it can't always be fixed within the template. E.g. sometimes a new import is needed — the generator just adds to the bottom of the existing imports but ESLint might get angry 'cause "not grouped correctly!". The solution here is effectively to run:
However, it's probably not as easy as globally running
🤷♂️ |
Given that these errors seem to be mostly prettier errors as far as I've seen, this issue could be reduced in scope to be just prettier which can be guaranteed to avoid the potential for non-autofixable errors. ( Interesting, I read the source code, and found that templated files were ran through prettier ) |
rw lint --fix
at the end
[Hi again!]
... either unconditionally, or at least as an option
All the best, and a great weekend!
The text was updated successfully, but these errors were encountered: