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

function-no-unknown: fix linear xywh light-dark false positives #7226

Closed
Mouvedia opened this issue Oct 11, 2023 · 7 comments · Fixed by #7242
Closed

function-no-unknown: fix linear xywh light-dark false positives #7226

Mouvedia opened this issue Oct 11, 2023 · 7 comments · Fixed by #7242
Labels
status: wip is being worked on by someone type: bug a problem with a feature or rule

Comments

@Mouvedia
Copy link
Contributor

Mouvedia commented Oct 11, 2023

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

:root {
  color-scheme: light dark;

  --text-color: light-dark(#777, #000);
}

What minimal configuration is needed to reproduce the bug?

{
  "rules": {
    "function-no-unknown": true
  }
}

How did you run Stylelint?

https://stylelint.io/demo

See also

https://drafts.csswg.org/css-color-5/#light-dark
mdn/browser-compat-data#20935

Do you have a proposal to fix the bug?

  1. either update https://github.com/niksy/css-functions-list/blob/master/index.json
  2. or add an exception
@ybiquitous ybiquitous added status: ready to implement is ready to be worked on by someone upstream relates to an upstream package labels Oct 11, 2023
@ybiquitous
Copy link
Member

@Mouvedia Good catch. I think sending a PR to css-functions-list is better.

@Mouvedia Mouvedia self-assigned this Oct 11, 2023
Mouvedia added a commit to Mouvedia/css-functions-list that referenced this issue Oct 11, 2023
- webkit-gradient
- color-stop
- from
- to
- light-dark

stylelint/stylelint#5960
stylelint/stylelint#7226
@Mouvedia Mouvedia added status: blocked is blocked by another issue or pr and removed status: ready to implement is ready to be worked on by someone labels Oct 12, 2023
@niksy
Copy link

niksy commented Oct 12, 2023

Since this is currently in draft stage and it’s not documented on MDN, css-functions-list doesn’t include it. I could probably add mdn/browser-compat-data as new data source, but light-dark will eventually be documented on MDN.

@Mouvedia Mouvedia added status: ready to implement is ready to be worked on by someone and removed status: blocked is blocked by another issue or pr labels Oct 12, 2023
@Mouvedia Mouvedia removed their assignment Oct 12, 2023
@ybiquitous ybiquitous added type: bug a problem with a feature or rule and removed upstream relates to an upstream package labels Oct 13, 2023
@ybiquitous
Copy link
Member

@Mouvedia @niksy Thanks for addressing this issue.

Until a reflection to mdn/browser-compat-data and a new version of css-functions-list is published, we can just add an exception to the functionsList below:

const functionsList = [
...JSON.parse(fs.readFileSync(functionsListPath.toString(), 'utf8')),
// #5960
'-webkit-gradient',
'color-stop',
'from',
'to',
];

@Mouvedia Mouvedia added the good first issue is good for newcomers label Oct 13, 2023
@Mouvedia Mouvedia added status: wip is being worked on by someone and removed status: ready to implement is ready to be worked on by someone good first issue is good for newcomers labels Oct 13, 2023
@niksy
Copy link

niksy commented Oct 15, 2023

After additional consideration, I’ve decided to add those functions. -webkit-gradient is added manually, and light-dark is now pulled from mdn/browser-compat-data.

If you’re familiar with additional resources, I can add them so we don’t have to add exceptions manually.

Available in https://github.com/niksy/css-functions-list/releases/tag/v3.2.1

@Mouvedia Mouvedia added status: ready to implement is ready to be worked on by someone and removed status: wip is being worked on by someone labels Oct 15, 2023
@Mouvedia
Copy link
Contributor Author

Mouvedia commented Oct 15, 2023

  • update css-function-list dependency to 3.2.1
    which also adds 2 missing functions: linear and xywh
  • remove this line and only this line
    i.e. the inner functions color-stop, from, to are still not included
  • add changeset

Thanks @niksy

@Mouvedia Mouvedia changed the title Fix function-no-unknown light-dark false positive function-no-unknown: fix linear xywh light-dark false positives Oct 15, 2023
@niksy
Copy link

niksy commented Oct 15, 2023

OK, will try to manually add those 3 also, so Stylelint doesn’t need to have special cases.

Can you give me more information on to and from functions? Is there any (legacy) spec mentioning them?

@Mouvedia
Copy link
Contributor Author

Mouvedia commented Oct 15, 2023

OK, will try to manually add those 3 also, so Stylelint doesn’t need to have special cases.

IMHO you can wait; a commit will do.
i.e. it doesn't warrant a new version unless it adds experimental functions like 3.2.1 did

Can you give me more information on to and from functions?

see #5960 (comment)

Is there any (legacy) spec mentioning them?

Not really but adding -webkit-gradient without them is incomplete/absurd from an user perspective but it's not a big deal for Stylelint because we already have them listed as exceptions.
ref https://developer.apple.com/library/archive/documentation/InternetWeb/Conceptual/SafariVisualEffectsProgGuide/Gradients/Gradient.html#//apple_ref/doc/uid/TP40008032-CH10-SW34

@ybiquitous ybiquitous added status: wip is being worked on by someone and removed status: ready to implement is ready to be worked on by someone labels Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wip is being worked on by someone type: bug a problem with a feature or rule
3 participants