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

A semicolon is accidentally removed #1356

Closed
1 task done
m-shaka opened this issue Dec 28, 2023 · 2 comments · Fixed by #1357
Closed
1 task done

A semicolon is accidentally removed #1356

m-shaka opened this issue Dec 28, 2023 · 2 comments · Fixed by #1357
Assignees
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@m-shaka
Copy link

m-shaka commented Dec 28, 2023

Environment information

CLI:
  Version:                      1.4.1
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.14.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/9.7.2"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              true
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Configuration

{
	"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
	"organizeImports": {
		"enabled": true
	},
	"linter": {
		"enabled": false,
		"rules": {
			"recommended": true
		}
	},
	"files": {
		"include": [
			"**/*.ts"
		]
	},
	"formatter": {
		"enabled": true
	},
	"javascript": {
		"formatter": {
			"lineWidth": 40,
			"semicolons": "asNeeded"
		}
	}
}

Playground link

https://biomejs.dev/playground/?lineWidth=40&semicolons=as-needed&enabledLinting=false&importSortingEnabled=false&code=ZgB1AG4AYwB0AGkAbwBuACAAZgB1AG4APABUAD4AKAAKAAkAZgBuADoAIAAoAGEAcgBnAHMAOgAgAHsACgAJAAkAYQA6ACAAcwB0AHIAaQBuAGcACgAJAAkAYgA6ACAAcwB0AHIAaQBuAGcACgAJAH0AKQAgAD0APgAgAHYAbwBpAGQALAAKACkAIAB7AAoACQBmAG4AKAB7ACAAYQA6ACAAIgBhACIALAAgAGIAOgAgACIAYgAiACAAfQApAAoAfQAKAAoAZgB1AG4AKAAoAGEAcgBnAHMAOgAgAHsAIABhADoAIABzAHQAcgBpAG4AZwA7ACAAYgA6ACAAcwB0AHIAaQBuAGcAIAB9ACkAIAA9AD4AIAB7AAoACQByAGUAdAB1AHIAbgAgAGEAcgBnAHMACgB9ACkACgA%3D

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Description

fun((args: { a: string; b: string }) => { is formatted to fun((args: { a: string b: string }) => {, which is syntactically broken.
lineWidth setting is 40 and the length of this line is 41. If you rename args to a shorter name like obj, the semicolon won't be removed. If you rename it to a longer name, the line will be line-wrapped.

@faultyserver faultyserver added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Dec 28, 2023
@faultyserver
Copy link
Contributor

faultyserver commented Dec 28, 2023

(I spoke too soon in earlier comments and misunderstood the issue. Correcting now with real information).

Minimal repro, semicolons set to asNeeded and line width 40:

foo((args: {a: string; b: string}) => {
  return a;
})

// Output
foo((args: {a: string b: string}) => {
  return a;
})

Playground Link

The issue here I think is because the if_group_fits_on_line(";") is used even in the flattened case of the best_fitting for the call argument, though I'm not sure why it doesn't get printed, then. Just comparing the IR with Prettier, that's the only difference.

@faultyserver faultyserver added S-Bug-confirmed Status: report has been confirmed as a valid bug and removed S-Bug-confirmed Status: report has been confirmed as a valid bug labels Dec 28, 2023
@faultyserver faultyserver self-assigned this Dec 28, 2023
@m-shaka
Copy link
Author

m-shaka commented Jan 5, 2024

Thank you for your quick fix! @faultyserver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
2 participants