stylelint: Fix `declaration-block-no-redundant-longhand-properties` and `declaration-block-no-shorthand-property-overrides` false negatives for `transition-behavior`

What minimal example or steps are needed to reproduce the bug?

a {
  transition-behavior: foo;
  transition-delay: foo;
  transition-duration: foo;
  transition-property: foo
  transition-timing-function: foo;
}
a {
  transition-behavior: foo;
  transition: foo;
}

Details

The low browser support—under 90%—is not a problem for declaration-block-no-redundant-longhand-properties because we provide the ignoreLonghands option. Nonetheless Id prefer if the issue was labeled status: agreed but held for now.

Do you have a proposal to fix the bug?

Add 'transition-behavior' to this set:

https://github.com/stylelint/stylelint/blob/ee3118d2460cddf469f959b5438d8aeab7e9584e/lib/reference/properties.mjs#L603-L609

Update this resolver:

https://github.com/stylelint/stylelint/blob/ee3118d2460cddf469f959b5438d8aeab7e9584e/lib/rules/declaration-block-no-redundant-longhand-properties/index.mjs#L116-L117

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

@ybiquitous here’s an explanation of the problem.

{
  "rules": {
    "declaration-block-no-redundant-longhand-properties": true
  },
  "fix": true
}
a {
  transition-property: all;
  transition-duration: 0.25s;
  transition-timing-function: ease;
  transition-delay: 0s;
  transition-behavior: allow-discrete;
}
/* becomes */
a {
  transition: all 0.25s ease 0s allow-discrete;
}

On browsers that don’t support transition-behavior the transition property will be dropped altogether because allow-discrete makes it invalid. Since the browser support—in my point of view—is at this stage too low according to caniuse, the option should be used so that it would instead be fixed to:

a {
  transition: all 0.25s ease 0s;
  transition-behavior: allow-discrete;
}

Is that clearer? ignoreLonghands was exactly introduced to handle that kind of cases.

tl;dr: either wait till 2025 to fix this issue or add the option to stylelint-standard-config

@Mouvedia What reason do you think so?

IMO, it seems more reasonable to change the existing logic declaration-block-no-redundant-longhand-properties than adding ignoreLonghands to stylelint-config-standard:

https://github.com/stylelint/stylelint/blob/ee3118d2460cddf469f959b5438d8aeab7e9584e/lib/rules/declaration-block-no-redundant-longhand-properties/index.mjs#L116-L117

See also:

		'declaration-block-no-redundant-longhand-properties': true,

– https://github.com/stylelint/stylelint-config-standard/blob/d319b67e7b8a546bca84c6a909764171df587d7e/index.js#L55