Sometimes it happens, when I have a long file, removing lnes and some other stuff and call format the file, it looks weird. This sometimes happens, when you removed an open bracket but not the closed one, or removing a comma but it is needed, etc. Smth like that. That mostly happens in JS, TS, PHP and JSON files.
So here I would suggest to not format the file if we have any syntax issues. VS Code doesn't format if we have problems, WebStorm does and make it as it looks correct.
function tst() {
le test = 2;
function () {
() => {
}
}
PHP
<?php
class test {
private tets() {
echo "";
}
}
TypeScript
export default class DatabaseConfiguration {
public a: string;
public b: string;
public constructor(configuration: any)
this.a = configuration.a;
this.b = configuration.b;
}
}
Use case/motivation
I don't want this whole formatting, when I'm not finish with developing, but most of the time I hit format to see whether everything is fine or not. And when I know, that there is smth to format it should format but with errors it should not format, so this will be an indicator for me to fix them first. Maybe this should be an option like "Format on syntax errors" but I don't see it, that we need this. So whether we should fix the formatting to do it correct or we should prevent formatting on errors.
Description
Sometimes it happens, when I have a long file, removing lnes and some other stuff and call format the file, it looks weird. This sometimes happens, when you removed an open bracket but not the closed one, or removing a comma but it is needed, etc. Smth like that. That mostly happens in JS, TS, PHP and JSON files.
So here I would suggest to not format the file if we have any syntax issues. VS Code doesn't format if we have problems, WebStorm does and make it as it looks correct.
Take my example snippets and try it by your own.
JSON
JavaScript
PHP
TypeScript
Use case/motivation
I don't want this whole formatting, when I'm not finish with developing, but most of the time I hit format to see whether everything is fine or not. And when I know, that there is smth to format it should format but with errors it should not format, so this will be an indicator for me to fix them first. Maybe this should be an option like "Format on syntax errors" but I don't see it, that we need this. So whether we should fix the formatting to do it correct or we should prevent formatting on errors.
Related issues
No response
Are you willing to submit a pull request?
No
Code of Conduct
Yes