Skip to content
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

Optional-chaining / null coalescing #368

Open
bluefangs opened this issue Oct 12, 2020 · 11 comments
Open

Optional-chaining / null coalescing #368

bluefangs opened this issue Oct 12, 2020 · 11 comments

Comments

@bluefangs
Copy link

  • Operating System (+Version): Ubuntu 20.04
  • VS Code Version: 1.50.0
  • beautify Version: 1.5.0

VS Code settings:

"beautify.config": {
		"indent_size": 4,
		"indent_char": "\t",
	},
"beautify.language": {
		"js": {
			"type": [
				"javascript",
				"json",
				"jsonc"
			],
			"filename": [
				".jshintrc",
				".jsbeautifyrc"
			]
		},
		"css": [
			"css",
			"less",
			"scss"
		],
		"html": [
			"htm",
			"html"
		]
	}

Expected results

When there is chaining or nullish coalescing involved, do not put spaces inbetween '?'

let a = {
    b: {
        c: 1
    }
};
var d = a?.b?.c || 0;

Actual results

Space is added inbetween the '?' causing syntax error.

let a = {
    b: {
        c: 1
    }
};
var d = a ? .b ? .c || 0;

Similar issue : beautifier/js-beautify#1530

Thanks.

@yume-chan
Copy link

I see beautifier/js-beautify#1779 and beautifier/js-beautify#1794 both have been merged, and released in js-beautify 1.11.0

Does it mean this extension need to upgrade its dependency and do a release?

@l246804
Copy link

l246804 commented Jan 25, 2021

Has the problem been solved?

@moscoso
Copy link

moscoso commented Mar 22, 2021

I see that this is closed but 'm still dealing with this issue. When I run the beautify command on a file all of my optional chaining expressesions add a space before and after the ? question mark causing syntax errors

@toferj
Copy link

toferj commented Mar 24, 2021

I am also having this problem using Beautify 1.5.0 in VSCode... How can I fix this other than disabling Beautify?

@moscoso
Copy link

moscoso commented Mar 24, 2021

I am also having this problem using Beautify 1.5.0 in VSCode... How can I fix this other than disabling Beautify?

what i had to do was navigate to the folder where the extension is and run npm update Google what directory vs code is in and then look for a subdirectory of extensions/hookyqr.beautify

@moscoso
Copy link

moscoso commented Mar 24, 2021

The fix to this is just HookyQR updating the beautify-js dependency to a newer version that fixed this issue .... it takes less then 30 seconds

@toferj
Copy link

toferj commented Mar 27, 2021

I appreciate the suggestion, but it's too much trouble. I just bailed on Beautify and switched to Prettier. Seems like maybe Beautify doesn't have it's stuff together. Idk.

@filozof595
Copy link

I'm still heaving this issue. I run the npm update as suggested but id didn't solve the issue.
Does anyone know how to stop Beautify to add space in JS Nullish Coalescing (?? -> ? ?) ?

@alexgritton
Copy link

@moscoso 's solution worked perfectly. I did have to reload vscode for it to work though.

@jasonkneen
Copy link

@moscoso 's solution worked perfectly. I did have to reload vscode for it to work though.

Yep, just drop into ~/.vscode/extensions/hookyqr.beautify-1.5.0, update package.json and run npm update -- I relaunched VScode to be sure and worked perfectly.

@GibranValle
Copy link

@jasonkneen Hey man, thank you, Great Solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants