apache / apache/netbeans

Don't format when there are syntax errors

Open
#5,305 1 comment 0 reactions 1 assignee Claimed by @lkishalmi View on GitHub
Editor JavaScript JSON kind:feature PHP
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### 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
````json
{
"name": "smth",
"version": "0.0.0"
"scripts": {
"dev": "vite",
"build": "vite build"
"serve": "vite preview"
}
}
````

JavaScript
````JavaScript
function tst() {
le test = 2;

function () {
() => {
}
}
````

PHP
```php

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.