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

Selector indentation after CSS comment wrap #4575

Closed
1 task done
fregante opened this issue Nov 18, 2024 · 2 comments · Fixed by #4614
Closed
1 task done

Selector indentation after CSS comment wrap #4575

fregante opened this issue Nov 18, 2024 · 2 comments · Fixed by #4614
Assignees
Labels
A-Formatter Area: formatter L-CSS Language: CSS S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@fregante
Copy link

Environment information

CLI:
  Version:                      1.9.4
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v23.1.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.9.0"

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

Formatter:
  Format with errors:           true
  Indent style:                 Tab
  Indent width:                 2
  Line ending:                  Lf
  Line width:                   80
  Attribute position:           Auto
  Bracket spacing:              BracketSpacing(true)
  Ignore:                       []
  Include:                      []

JavaScript Formatter:
  Enabled:                      false
  JSX quote style:              Double
  Quote properties:             AsNeeded
  Trailing commas:              All
  Semicolons:                   Always
  Arrow parentheses:            Always
  Bracket spacing:              unset
  Bracket same line:            false
  Quote style:                  Double
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Attribute position:           unset

JSON Formatter:
  Enabled:                      false
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Trailing Commas:              unset

CSS Formatter:
  Enabled:                      true
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Quote style:                  Single

GraphQL Formatter:
  Enabled:                      true
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Bracket spacing:              unset
  Quote style:                  unset

Workspace:
  Open Documents:               0

Configuration

{
	"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
	"vcs": {
		"enabled": true,
		"clientKind": "git",
		"useIgnoreFile": true
	},
	"formatter": {
		"enabled": true,
		"formatWithErrors": true,
		"indentStyle": "tab"
	},
	"javascript": {
		"formatter": {
			"enabled": false
		}
	},
	"json": {
		"formatter": {
			"enabled": false
		}
	},
	"css": {
		"formatter": {
			"enabled": true,
			"quoteStyle": "single"
		},
		"linter": {
			"enabled": true
		}
	},
	"graphql": {
		"formatter": {
			"enabled": true
		}
	}
}

Playground link

https://biomejs.dev/playground/?indentStyle=space&files.main.css=LwAqACAAcwBvAG0AZQAgAG0AZQBkAGkAdQBtACAAbABvAG4AZwAgAGMAbwBtAG0AZQBuAHQAIAAqAC8ACgAuAHMAbwBtAGUAIABzAGUAbABlAGMAdABvAHIAIAB7AAoAIAAgAGIAYQBjAGsAZwByAG8AdQBuAGQAOgAgAHIAZQBkADsACgB9AAoACgAvACoAIABzAG8AbQBlACAAbQBlAGQAaQB1AG0AIABsAG8AbgBnACAAYwBvAG0AbQBlAG4AdAAgACoALwAKAC4AbABpAG4AZQAxACAAcwBlAGwAZQBjAHQAbwByACwACgAvACoAIABzAG8AbQBlACAAbQBlAGQAaQB1AG0AIABsAG8AbgBnACAAYwBvAG0AbQBlAG4AdAAgACoALwAKAC4AbABpAG4AZQAyACAAcwBlAGwAZQBjAHQAbwByACAAewAKACAAIABiAGEAYwBrAGcAcgBvAHUAbgBkADoAIAByAGUAZAA7AAoAfQA%3D

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@fregante fregante added the S-Needs triage Status: this issue needs to be triaged label Nov 18, 2024
@fregante
Copy link
Author

Weird, your formatter bug report template doesn't have an "explanation/description" field.

In short, this piece of CSS ends up being indented badly due to the comment, but only for the second selector:

/* some medium long comment */
.line1 selector,
/* some medium long comment */
.line2 selector {
  background: red;
}

Is indented as

/* some medium long comment */
.line1 selector,
/* some medium long comment */
  .line2
  selector {
  background: red;
}

I assume it's because the comment is being considered "part of the selector", so indenting the second line makes sense (ish). But this logic only applies to the second selector in the selector list.

I expect both selectors to have the same exact indentation (the input CSS is already "correctly indented" IMHO)

Note that Prettier does not support indentation at all in this case:

@ematipico ematipico added A-Formatter Area: formatter L-CSS Language: CSS S-Bug-confirmed Status: report has been confirmed as a valid bug labels Nov 18, 2024
@github-actions github-actions bot removed the S-Needs triage Status: this issue needs to be triaged label Nov 18, 2024
@fireairforce
Copy link
Member

i'd like to fix this~

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

Successfully merging a pull request may close this issue.

3 participants