-
Notifications
You must be signed in to change notification settings - Fork 7
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
Feature Request: Ignore and warn unrecognized syntax and continue formatting the text #37
Comments
Unfortunately this would be pretty difficult to implement. It's not so much a problem with the prettier plugin, but rather with the parser. Also, while this might not be common behavior of many formatters, it's how the core Prettier itself works. When you give it syntactically incorrect JavaScript, it will fail to format it. |
But the right to determine whether the syntax is correct is in your hands, isn't it?
From the log I can see that you listed some acceptable keywords, which did not include the actual keyword encountered so the error. I wonder if there should be an inner logical structure like CASE-WHEN? Then you can just add an ELSE branch to handle all the cases that are not in the list: no processing, output as-is. Don't let Prettier know there may be syntax errors. |
Correct. I also maintain the parser. Regarding the specific error. It would be helpful if you provided the actual code that's causing you problems. Also, please state which SQL dialect you're using - it's hard for me to guess. The
While it's true that this plugin doesn't yet support these ignore comments, I should point out that even in official Prettier, these comments only work when the parser is able to fully parse the code. |
I want to CREATE PROCEDURE for MariaDB. But as I understand it, from what you're saying, plugins of Prettier family are either fully applicable or not applicable at all, impossible to be in a state of partially applicable for a while… Long code with just one unsupported keyword disables the entire formatter… extremely unrobust… |
Yes, that's the downside of this architecture. That's why the support of MariaDB is also labeled "Experimental! expect crashes". There are other SQL formatting tools out there which don't have this limitation. |
Describe the Feature
Provides an extension option to ignore unrecognized syntax instead of reporting an error.
Why do you want this feature?
I know that there are many common PROCEDURE syntax that the extension will not support in a short time. But can we ignore and warn these unsupported syntax for a while, instead of just reporting an error and giving up formatting the whole text?
In any case, you are a code formatter, not a syntax checker. As far as I know, the general practice in the field of code formatters is that you should not require the code to be completely well-formed, but to format those well-formed parts as much as possible.
I think you can just skip and warn when you encounter syntax that you don't recognize and start over from the next semicolon. Would this logic be difficult to implement?
The text was updated successfully, but these errors were encountered: