stylelint-config-standard icon indicating copy to clipboard operation
stylelint-config-standard copied to clipboard

Enable `camelCaseSvgKeywords` option for `value-keyword-case`

Open rohm1 opened this issue 2 years ago • 13 comments

What steps are needed to reproduce the bug?

* {
	text-rendering: optimizeLegibility;
}

What Stylelint configuration is needed to reproduce the bug?

{
  "extends": [
    "stylelint-config-standard"
  ]
}

How did you run Stylelint?

Demo website: https://stylelint.io/demo/#N4Igxg9gJgpiBcIBUACYAdAdugLjmAHjgLQBOMmspAlpgObwoQAOO1AttQF4wAyMdagCNqAG2o4AngG4sAXxAAaEADMxMAHIBDdnESEdzUTAB0YAM7ml4CJjV0EIDJhQp0IQvkrn3jANpYrq7u5lLG4pgkkHbUdMShWpRapFDugSgAuvLW0fYAYhCk7Fo4jgBW5rbWsMxWiM7BIKGS4bQ4vm4goiUwoe6K6SFhMBFRtvbxOIlQyakInd34fSDZckA

Which version of Stylelint or dependencies are you using?

latest

What did you expect to happen?

No problems to be reported

What actually happened?

Error: Expected "optimizeLegibility" to be "optimizelegibility" (value-keyword-case)

Does the bug relate to non-standard syntax?

no

Proposal to fix the bug

Possibly related to stylelint/stylelint#6517

rohm1 avatar Jun 02 '23 06:06 rohm1

@rohm1 Thanks for the report. But I believe this is not a bug. You can avoid the error by the camelCaseSvgKeywords option:

{
  "rules": {
    "value-keyword-case": ["lower", {"camelCaseSvgKeywords": true}]
  }
}

See also this demo.

ybiquitous avatar Jun 02 '23 07:06 ybiquitous

@ybiquitous thanks, but this is at least a default config bug. I should not have to configure anything for standard CSS properties and values.

rohm1 avatar Jun 02 '23 07:06 rohm1

Make sense. Let's move this into the standard config repo and continue discussing.

Ref: https://github.com/stylelint/stylelint-config-standard/blob/5aa5dd57ac814edd98c656da35f2ccc99a64d433/index.js#L111

ybiquitous avatar Jun 02 '23 07:06 ybiquitous

Revisit old issues:

  • https://github.com/stylelint/stylelint/issues/1089
  • https://github.com/stylelint/stylelint/issues/4884
  • https://github.com/stylelint/stylelint/issues/5863

ybiquitous avatar Jun 02 '23 07:06 ybiquitous

Just to confirm, are both valid, e.g., optimizeLegibility and optimizelegibility?

ybiquitous avatar Jun 02 '23 07:06 ybiquitous

Not sure, the specs make only mention of the camel case option (https://svgwg.org/svg2-draft/painting.html#TextRenderingProperty). But both Firefox and Chrome seem to accept camel case and lowercase.

rohm1 avatar Jun 05 '23 05:06 rohm1

Umm, if we enable camelCaseSvgKeywords, the following valid CSS using the currentcolor keyword will be reported:

a {
  color: currentcolor;
/*       ^ Expected "currentcolor" to be "currentColor"
 */
}

See this demo.

What do you think?

ybiquitous avatar Jun 05 '23 05:06 ybiquitous

Looks like this is wrong: https://github.com/stylelint/stylelint/blob/main/lib/reference/keywords.js#L265 currentcolor is expected to be camel case but the spec you mention states lowercase.

rohm1 avatar Jun 05 '23 05:06 rohm1

Does the SVG spec support currentColor, right?

ybiquitous avatar Jun 05 '23 06:06 ybiquitous

The link you provided is CSS Color Module Level 4 (https://www.w3.org/TR/css-color-4/#currentcolor-color), keyword is only mentioned in lowercase. In CSS Color Module Level 3 (https://www.w3.org/TR/css-color-3/#currentcolor) keyword is written in camel case, and references SVG 1.0 specifications which also use camel case. Finaly, SVG2 draft also mentions the keyword in camel case: https://svgwg.org/svg2-draft/painting.html#ColorProperty.

To summarize:

  • CSS3, SVG1 and SVG2: currentColor
  • CSS4: currentcolor

rohm1 avatar Jun 07 '23 05:06 rohm1

Umm..., it seems we cannot enable camelCaseSvgKeywords until fixing the problem. 🤔

ybiquitous avatar Jun 07 '23 08:06 ybiquitous

The CSS color 4 tests are all using currentColor:

https://github.com/web-platform-tests/wpt/blob/master/css/css-color/currentcolor-001.html https://github.com/web-platform-tests/wpt/blob/master/css/css-color/currentcolor-002.html https://github.com/web-platform-tests/wpt/blob/master/css/css-color/currentcolor-003.html

Mouvedia avatar Jul 09 '23 02:07 Mouvedia

I came across this issue, and trying to trace down any upstream issue I found https://github.com/w3c/csswg-drafts/issues/4599 which points over that the values are case insensitive https://drafts.csswg.org/css-values-4/#keywords, so fixing them to the camelCase should be safe

nschonni avatar Aug 05 '23 18:08 nschonni