-
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
[RFC]: Linting Generated Files #6223
Comments
I don't think this is linting, right? That's formatting done by prettier. So reading all the arguments above I would propose:
One thing we can't take into account here is the user's linting rules. We could have done that if we ran the linter as part of the generator. But we can probably use the user's prettier rules. |
Just to outline what i'm thinking of: Option B1Add
This would also include removing BTW – we should also have the lint command include all Of course, new generators and templates would need to be tracked and included in the CI test scripts as they are implemented. Would be cool if we could come up with a configuration framework that shows which generator commands are already covered and which aren't, so new ones also make the CI pipeline fail unless they get included (i.e. into the smoke test pipeline). This option surely requires a larger PR to get rid of each and every linting rule violation in code, templates and generated code first – but once in place we can finally ensure Redwood mainline always contains, respectively creates perfectly formatted, lint-flawless code. Here is a (non-complete) list of issues that we would probably never have to deal with again once such checks are in place, b/c the offending code would never make it through the CI checks:
|
Unfortunately I don't think that's feasible. A lot of them have a bunch of logic in them that makes the syntax invalid js/ts. For example https://github.com/redwoodjs/redwood/blob/main/packages/cli/src/commands/generate/sdl/templates/sdl.ts.template |
Danny note: If taking approach A.1: If lint fails during generate process, the generator will fail without giving a clear understanding of why. If this approach is taken, then we could swallow the error. |
Summary
Should generated files be linted?
(This seems to get into the realm of: prettier vs linter and "... In other words, use Prettier for formatting and linters for catching bugs!".)
A) If so, what approach to take? We currently have two proposed paths forward for this option.
yarn rw lint --fix --path <file>
B) If not - what other approaches should be considered to clean up issues such as #1551, #6097 or #4824?
Motivation
Linting generated files has come up in different ways across multiple issues. A clear path has not been settled on and we are looking for consensus.
Option A (run
lint --fix
on generated files):The 'easy' way is to run
yarn rw lint --fix
on all generated files (with an option to disable). Lint generated files #6218 PR was filed this way to get something going. However, this slows down the cli and goes against [RFC]: CLI Speed Improvement #6027.Clean up inside the framework by running
yarn rw lint --fix
on generators in the CI pipeline. @Philzen proposed this with "If it doesn't come back with exit code 0, the pipeline fails and we have identified a todo 🎉" More detailed entry here: Amend import order in auth templates according to ESLint rules introduced in v2.0 #6059 (comment).Personally, out of these two options, I like something along the lines of the second idea. It feels like good housekeeping to keep the framework clean vs pushing cleanup to the client.
Option B (other options):
Prettier seems to be the answer to the big whitespace issue, not lint. But, as @orta mentions, the files seem to go through prettier and there are still issues?
Originally posted by @cannikin in #6097 (comment)
Originally posted by @orta in #1551 (comment)
Detailed proposal
If Option A, what is the ideal solution, potential problems, gotchas, etc?
If Option B, what are other solutions or ideas?
Selected comments from previous discussions:
Originally posted by @jtoar in #1551 (comment)
Originally posted by @Philzen in #6097 (comment)
Originally posted by @thedavidprice in #4824 (comment)
Originally posted by @thedavidprice in #1551 (comment)
Originally posted by @Tobbe in #6097 (comment)
Are you interested in working on this?
The text was updated successfully, but these errors were encountered: