-
-
Notifications
You must be signed in to change notification settings - Fork 29
Implement gren format --validate #143
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
Conversation
terminal/src/Format.hs
Outdated
| validateFiles :: [FilePath] -> Task.Task Exit.Format () | ||
| validateFiles paths = do | ||
| validationResults <- mapM validateFile paths | ||
| when (any (== False) validationResults) $ | ||
| Task.throw Exit.FormatValidateNotCorrectlyFormatted |
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.
Currently I check all files before throwing an error so you get a full report.
Is it better to just throw on first invalid file?
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.
Personally, I think checking all files is good. I often use gren format --validate in CI settings, so I don't necessarily care about how long the validation takes.
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.
Yeah, checking all seems best, given that this ought to be fast even with lots of files.
|
Tagging @avh4 for review. |
robinheghan
left a comment
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.
terminal/src/Format.hs
Outdated
| validateExistingFile path = do | ||
| putStr ("Validating " ++ path) | ||
| original <- File.readUtf8 path | ||
| case formatByteString Parse.Application original of |
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.
Similar to how formatFile does it, when inputs is Project projectType paths (line 152 above), we should use that projectType instead of Parse.Application. That allows special core modules to be parsed properly. (If you try it on the gren/core library, you should see the problem.)
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.
I think we need to fix https://github.com/gren-lang/compiler/pull/143/files#r987541415 (the comment above about "projectType") but otherwise this looks great!
Implemented a flag to



gren formatthat checks if files are formatted without modifying them: