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

Add ignoreFunctions: [] to unit-disallowed-list #6574

Closed
pinkhominid opened this issue Jan 11, 2023 · 5 comments · Fixed by #6592
Closed

Add ignoreFunctions: [] to unit-disallowed-list #6574

pinkhominid opened this issue Jan 11, 2023 · 5 comments · Fixed by #6592
Labels
good first issue is good for newcomers type: enhancement a new feature that isn't related to rules type: new option a new option for an existing rule

Comments

@pinkhominid
Copy link

pinkhominid commented Jan 11, 2023

What steps are needed to reproduce the bug?

Use CSS functions that include a disallowed unit character inside a function that expects it, like calc.

h2 {
  position: absolute;
  inset-inline-end: calc(50% - 100px);
}

What Stylelint configuration is needed to reproduce the bug?

{
  "rules": {
        "unit-disallowed-list": [
            ["px"],
            {
                ignoreFunctions: ["calc"]
            }
        ],
  }
}

How did you run Stylelint?

stylelint **/*.css

Which version of Stylelint are you using?

14.11.0

What did you expect to happen?

CLI would finish with no errors

What actually happened?

Invalid Option: Invalid option name "ignoreFunctions" for rule "unit-disallowed-list"

Does the bug relate to non-standard syntax?

No

Proposal to fix the bug

A solution similar to #5857

@ybiquitous ybiquitous added type: enhancement a new feature that isn't related to rules type: new option a new option for an existing rule labels Jan 12, 2023
@ybiquitous
Copy link
Member

@pinkhominid Thanks for the proposal. SGTM 👍🏼

I've labeled the issue as ready to implement. Please consider contributing if you have time.

There are steps on how to add a new option in the Developer guide.

@jeddy3 jeddy3 changed the title Add ignoreFunctions: [] to unit-disallowed-list Add ignoreFunctions: [] to unit-disallowed-list Jan 13, 2023
@jeddy3
Copy link
Member

jeddy3 commented Jan 13, 2023

One note: like the ignoreFunctions: [] option in unit-allowed-list this option will ignore all units within the specified functions. It can't be limited to particular units. As such, the config would be:

{
  "rules": {
    "unit-disallowed-list": [ ["px"], { "ignoreFunctions": ["calc"] }]
  }
}

(Which is different from #6574 (comment)).

If you want to ignore specific units, then a custom rule in a plugin is probably a better fit.

@pinkhominid
Copy link
Author

@jeddy3 thanks for the clarification. Ignoring all disallowed units is what we want for our use case. I've updated the config.

@mattxwang
Copy link
Member

Hey all, quickly picked this up and submitted a PR in #6592!

@pinkhominid
Copy link
Author

Thanks @mattxwang!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue is good for newcomers type: enhancement a new feature that isn't related to rules type: new option a new option for an existing rule
Development

Successfully merging a pull request may close this issue.

4 participants