biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
15.61k stars 487 forks source link

📝 CSS legibility for comma-separated features #4328

Open redbmk opened 1 month ago

redbmk commented 1 month ago

Environment information

CLI:
  Version:                      1.9.3
  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:           "v21.5.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "bun/1.1.30"

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

Linter:
  JavaScript enabled:           true
  JSON enabled:                 true
  CSS enabled:                  true
  GraphQL enabled:              false
  Recommended:                  true
  All:                          false
  Enabled rules:
  performance/noDelete
  suspicious/noCatchAssign
  suspicious/noUnsafeNegation
  complexity/useLiteralKeys
  correctness/noUnusedImports
  suspicious/noClassAssign
  complexity/noMultipleSpacesInRegularExpressionLiterals
  a11y/useValidLang
  complexity/noUselessEmptyExport
  suspicious/useNamespaceKeyword
  suspicious/useValidTypeof
  a11y/useValidAriaRole
  correctness/noConstantCondition
  a11y/useAriaActivedescendantWithTabindex
  suspicious/noAssignInExpressions
  style/useDefaultParameterLast
  complexity/noEmptyTypeParameters
  correctness/noConstructorReturn
  style/useSelfClosingElements
  suspicious/noDuplicateParameters
  suspicious/noDuplicateSelectorsKeyframeBlock
  correctness/noUnknownProperty
  style/useTemplate
  correctness/noUnusedLabels
  complexity/noUselessTernary
  correctness/noUnreachableSuper
  suspicious/noCompareNegZero
  suspicious/noExplicitAny
  correctness/noSwitchDeclarations
  a11y/noAutofocus
  correctness/noUnsafeOptionalChaining
  correctness/noConstAssign
  suspicious/noControlCharactersInRegex
  complexity/noUselessTypeConstraint
  style/noVar
  suspicious/noDoubleEquals
  suspicious/noRedundantUseStrict
  style/useLiteralEnumMembers
  suspicious/noGlobalIsNan
  suspicious/noEmptyInterface
  suspicious/noConstEnum
  style/useImportType
  nursery/noDuplicateElseIf
  correctness/noPrecisionLoss
  nursery/noRestrictedImports
  suspicious/noMisleadingCharacterClass
  suspicious/noRedeclare
  correctness/noStringCaseMismatch
  correctness/noSetterReturn
  correctness/noInvalidConstructorSuper
  suspicious/noImplicitAnyLet
  suspicious/noDuplicateObjectKeys
  suspicious/noFallthroughSwitchClause
  complexity/noUselessThisAlias
  correctness/noUnreachable
  a11y/useKeyWithClickEvents
  suspicious/noUnsafeDeclarationMerging
  complexity/noThisInStatic
  complexity/useOptionalChain
  correctness/noInnerDeclarations
  style/noParameterAssign
  suspicious/noDuplicateCase
  a11y/useValidAnchor
  correctness/useArrayLiterals
  complexity/useRegexLiterals
  correctness/noSelfAssign
  correctness/noInvalidBuiltinInstantiation
  style/noUselessElse
  style/useShorthandFunctionType
  suspicious/noShadowRestrictedNames
  correctness/noInvalidDirectionInLinearGradient
  suspicious/noEmptyBlockStatements
  suspicious/noImportantInKeyframe
  a11y/useMediaCaption
  complexity/noUselessLabel
  complexity/noUselessCatch
  correctness/noUnsafeFinally
  a11y/useAriaPropsForRole
  correctness/noNonoctalDecimalEscape
  style/useEnumInitializers
  a11y/useHtmlLang
  suspicious/noDuplicateTestHooks
  complexity/noStaticOnlyClass
  style/useWhile
  complexity/useArrowFunction
  style/noInferrableTypes
  a11y/noNoninteractiveTabindex
  complexity/useSimpleNumberKeys
  correctness/useYield
  a11y/noInteractiveElementToNoninteractiveRole
  style/useNumericLiterals
  correctness/noUnnecessaryContinue
  suspicious/noApproximativeNumericConstant
  suspicious/noImportAssign
  suspicious/noLabelVar
  correctness/noGlobalObjectCalls
  suspicious/useDefaultSwitchClauseLast
  correctness/noEmptyCharacterClassInRegex
  correctness/noUnknownUnit
  a11y/useAltText
  suspicious/noSuspiciousSemicolonInJsx
  a11y/useIframeTitle
  complexity/noBannedTypes
  a11y/noSvgWithoutTitle
  correctness/noVoidElementsWithChildren
  style/useAsConstAssertion
  correctness/useJsxKeyInIterable
  style/useExportType
  complexity/noUselessLoneBlockStatements
  suspicious/noDebugger
  style/noArguments
  a11y/useValidAriaValues
  suspicious/noCommentText
  a11y/useFocusableInteractive
  correctness/noUnmatchableAnbSelector
  suspicious/noGlobalAssign
  suspicious/noDuplicateJsxProps
  suspicious/noMisleadingInstantiator
  a11y/noPositiveTabindex
  correctness/noEmptyPattern
  complexity/noExcessiveNestedTestSuites
  security/noDangerouslySetInnerHtmlWithChildren
  a11y/useKeyWithMouseEvents
  suspicious/noExtraNonNullAssertion
  suspicious/noShorthandPropertyOverrides
  correctness/noRenderReturnValue
  correctness/useExhaustiveDependencies
  security/noGlobalEval
  style/noNonNullAssertion
  a11y/noRedundantRoles
  complexity/useFlatMap
  correctness/noUnusedVariables
  correctness/useHookAtTopLevel
  correctness/useIsNan
  style/useConst
  suspicious/noGlobalIsFinite
  suspicious/noAsyncPromiseExecutor
  suspicious/noDuplicateFontNames
  suspicious/noSelfCompare
  suspicious/noThenProperty
  security/noDangerouslySetInnerHtml
  style/useNodejsImportProtocol
  a11y/noDistractingElements
  suspicious/noArrayIndexKey
  complexity/noWith
  suspicious/useGetterReturn
  suspicious/noDuplicateClassMembers
  complexity/noExtraBooleanCast
  performance/noAccumulatingSpread
  a11y/useValidAriaProps
  a11y/noRedundantAlt
  correctness/noChildrenProp
  correctness/noUnknownFunction
  correctness/noInvalidPositionAtImportRule
  suspicious/noConfusingLabels
  suspicious/noPrototypeBuiltins
  suspicious/noConfusingVoidType
  suspicious/noFocusedTests
  a11y/useButtonType
  a11y/useSemanticElements
  a11y/noAriaUnsupportedElements
  correctness/noInvalidGridAreas
  correctness/noFlatMapIdentity
  a11y/noBlankTarget
  a11y/useHeadingContent
  suspicious/noSparseArray
  correctness/noConstantMathMinMaxClamp
  correctness/useValidForDirection
  correctness/noUnusedPrivateClassMembers
  correctness/noVoidTypeReturn
  correctness/noInvalidUseBeforeDeclaration
  a11y/noAriaHiddenOnFocusable
  a11y/useGenericFontNames
  correctness/noUnknownMediaFeatureName
  a11y/useAnchorContent
  complexity/noUselessRename
  correctness/noInvalidNewBuiltin
  style/useNumberNamespace
  complexity/noUselessConstructor
  a11y/noAccessKey
  correctness/noUnusedFunctionParameters
  style/noUnusedTemplateLiteral
  complexity/noUselessSwitchCase
  style/useExponentiationOperator
  correctness/noUndeclaredVariables
  style/useSingleVarDeclarator
  suspicious/noExportsInTest
  a11y/noNoninteractiveElementToInteractiveRole
  style/noCommaOperator
  suspicious/noDuplicateAtImportRules
  suspicious/useIsArray
  a11y/noHeaderScope
  complexity/noUselessFragments
  suspicious/noMisrefactoredShorthandAssign
  suspicious/noEmptyBlock
  correctness/noNewSymbol
  complexity/noForEach
  suspicious/noFunctionAssign

Workspace:
  Open Documents:               0

Configuration

No response

Playground link

https://biomejs.dev/playground/?indentStyle=space&files.main.css=LgBjAGwAYQBzAHMAIAB7AAoAIAAgAGIAbwB4AC0AcwBoAGEAZABvAHcAOgAgAAoAIAAgACAAIAAwACAAMgBwAHgAIAAyAHAAeAAgADAAIAByAGcAYgAoADEAMAAgADEAOAAgADMAMAAgAC8AIAAxADIAJQApACwACgAgACAAIAAgADAAIAAwACAAMgBwAHgAIAAwACAAcgBnAGIAKAAxADAAIAAxADgAIAAzADAAIAAvACAAMQA2ACUAKQA7AAoAIAAgACAAIAAKACAAIAB0AHIAYQBuAHMAaQB0AGkAbwBuADoAIAB3AGkAZAB0AGgAIAAxAHMALAAgAGIAYQBjAGsAZwByAG8AdQBuAGQALQBjAG8AbABvAHIAIABnAHIAZQBlAG4AOwAKACAAIAAKACAAIABmAG8AbgB0AC0AZgBlAGEAdAB1AHIAZQAtAHMAZQB0AHQAaQBuAGcAcwA6ACAAIgBjAGwAaQBnACIAIABvAGYAZgAsACAAIgBsAGkAZwBhACIAIABvAGYAZgA7AAoAfQAKAAoALgBsAG8AbgBnAGUAcgAtAGIAbwB4AHMAaABhAGQAbwB3ACAAewAKACAAIABiAG8AeAAtAHMAaABhAGQAbwB3ADoAIAAKACAAIAAgACAAMQAwAHAAeAAgADEAMABwAHgAIAAxADAAcAB4ACAAMQAwAHAAeAAgAHIAZwBiACgAMQAwACAAMQA4ACAAMwAwACAALwAgADEAMgAlACkALAAKACAAIAAgACAAMQAwAHAAeAAgADEAMABwAHgAIAAxADAAcAB4ACAAMQAwAHAAeAAgAHIAZwBiACgAMQAwACAAMQA4ACAAMwAwACAALwAgADEANgAlACkAOwAKAH0A

Code of Conduct

redbmk commented 1 month ago

It seems like prettier is more legible in general. For something like box-shadow, biome splits based on line-length whereas prettier is splitting on the comma.

e.g.

.prettier {
  box-shadow:
    10px 10px 10px 10px rgb(10 18 30 / 12%),
    10px 10px 10px 10px rgb(10 18 30 / 16%);
}

.biome {
  box-shadow: 10px 10px 10px 10px rgb(10 18 30 / 12%), 10px 10px 10px 10px
    rgb(10 18 30 / 16%);
}

Even in the case where it all fits on one line, I find it easier to read the multiline version like it works in prettier:


.prettier {
  box-shadow:
    0 2px 2px 0 rgb(10 18 30 / 12%),
    0 0 2px 0 rgb(10 18 30 / 16%);
}

.biome {
  box-shadow: 0 2px 2px 0 rgb(10 18 30 / 12%), 0 0 2px 0 rgb(10 18 30 / 16%);
}
eryue0220 commented 1 month ago

I could try to solve this.