-
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
Lint generated files #6218
Lint generated files #6218
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 2466a05. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 14 targets
Sent with 💌 from NxCloud. |
✅ Deploy Preview for redwoodjs-docs canceled.
|
|
||
// const filename = path.basename(target) | ||
// const targetDir = target.replace(filename, '') | ||
execa('yarn rw lint --fix --path ', [`./${path.relative(base, target)}`], { |
Check warning
Code scanning / CodeQL
Unsafe shell command constructed from library input
Thanks for getting started on this PR @pantheredeye @Philzen outlined a different approach here: #6059 (comment) IIRC The reason he preferred doing it that way was concerns about speed. Adding linting to every generator command execution would slow the command down. And so it was better to make sure they just output correct code in the first place. Do you have any thoughts on that @pantheredeye? And @Philzen, please do jump in here if you have anything more to add |
@Tobbe I had speed concerns, also. Especially around scaffolding. I like @Philzen's approach of attempting to address in the CI pipeline, before things ever go to main. It feels cleaner to address linting issues before code ever hits the main branch. This approach would provide better speed for developers using the generators. I noticed his CI comment here: #6097 (comment), but had not noticed the comment you linked, which details his idea a little more in-depth. In the issue you linked, Phil mentioned getting an RFC going for linting in the CI pipeline. How about I start an RFC for addressing linting issues, mention both approaches, and see what the team at-large suggests? I am happy to help out however you suggest. I am willing to give the CI approach a go, with some guidance. |
@pantheredeye Thanks for linking that comment. I knew he had written that somewhere. For some reason I missed it when skimming over his recent PRs and comments... An RFC mentioning both approaches sounds good! Please do that 🙂 That will also be a good place to document the core-team's decision on this. Thanks for moving forward with this! |
That's exactly how i feel! Thanks for the RFC. I curated i list of issues and PRs that would all be prevented by following that approach, which i'm going to add to the issue. Cheers! |
I'm going to close this one in favor of #6223 |
For [Generators] generated code should be linted and formatted #1551
and perhaps [Bug]: Scaffold generator creates a big block of whitespace in Form component #6097
and touches this: Generated Content has Lint Issues #4824
✅ What it does
Adds args -l --lint : "Lint Generated Files" : default: true to generator cli
Runs lint --fix on generated files.
Currently only works on "Directives."
I wanted to get the PR started to see if this was the route to go with this. Beyond the technical implementation, there is this nagging question surfaced in the issues linked above, which is summed up by @thedavidprice:
Approach:
I copied the writeFilesTask and made lintFilesTask, which calls lintFile (which is a copy of writeFile).
This is exported and called as a task in the Directives generator file.
🔮 What needs to be verified
Is this the approach to take?
I feel like it is still linting even after it says it is done. I do not know how to check to see if this is the case.
Is there a better way to call or abstract the writeFilesTask/lintFilesTask.
Confirm if we want to run lint files after every generator.
🚧 What is left to do
Add linting task to other appropriate generator files
Add testing?
👏 Credits