-
Notifications
You must be signed in to change notification settings - Fork 8
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
Admin-Generator: Fix problems when formatting Source Code #3566
base: next
Are you sure you want to change the base?
Admin-Generator: Fix problems when formatting Source Code #3566
Conversation
409b0dd
to
b163a16
Compare
I'm sorry but I don't understand the problem. I don't know what you mean by that "keyword: project service" Is this a new problem you have with all generated files? Or this this a problem you run into when the generator generates (for whatever reason) invalid code? |
Let me explain how I understood the problem:
![]() As far as I see it happens only when the problematic file is not available on the disk. That's why I introduced the workaround that the file (with generated source code, but not formatted) will be written to the disk at the given path before linting. If the file is available on the disk, the |
Ok, I understand the problem now - and can reproduce it. Very strange. I don't understand the solution, but at least it is a working solution. |
@@ -11,10 +11,24 @@ export async function writeGenerated(filePath: string, contents: string): Promis | |||
cwd: process.cwd(), | |||
fix: true, | |||
}); | |||
|
|||
// Write not linted generated code into file. This is necessary to avoid linting errors like: Parsing error: file/path/file.tsx was not found by the project service. | |||
await fs.writeFile(filePath, contents); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await fs.writeFile(filePath, contents); | |
await fs.writeFile(filePath, header + contents); |
(was also wrong in line 33)
const output = lintResult[0] && lintResult[0].output ? lintResult[0].output : lintResult[0].source; | ||
await fs.writeFile(filePath, output ?? contents); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the unlinted file is already written above, no need to fallback to contents (which was missing header)
const output = lintResult[0] && lintResult[0].output ? lintResult[0].output : lintResult[0].source; | |
await fs.writeFile(filePath, output ?? contents); | |
const lintOutput = lintResult[0] && lintResult[0].output ? lintResult[0].output : lintResult[0].source; | |
if (lintOutput) { | |
await fs.writeFile(filePath, lintOutput); | |
} |
alternatively you could switch from eslint.lintText to eslint.lintFiles
depends on: #3564
Description
Fix eslint formatting problems in Admin Generator
While formatting generated code during writing to the disk, ESLint fails with an error, which will lead to the fact that not ESLint-formatted code will be generated by admin-generator. This produces invalid code and will fail in lint step.
This fix is necessary, because if not fixed not valid source code will be generated.

Further information