question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-global-function-names does not allow using CSS math functions

See original GitHub issue

This code causes the error Expected math.min instead of min scss/no-global-function-names

.foo {
  width: min(300px, 30%);
}

Same with the max() function Expected math.max instead of max scss/no-global-function-names

.foo {
  width: max(300px, 30%);
}

.stylelintrc.js

module.exports = {
  'plugins': [
    'stylelint-scss',
  ],
  'rules': {
    'scss/no-global-function-names': true,
  },
};
"stylelint": "13.7.0",
"stylelint-scss": "3.18.0"

https://caniuse.com/#feat=css-math-functions

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

2reactions
johncrimcommented, Dec 9, 2021

Please reopen this issue:

Using “stylelint-scss”: “4.0.1”, this bug is now fixed in most places where I was seeing it, but I’m still seeing a few of these errors. Eg:

 45:19  ✖  Expected math.min instead of min  scss/no-global-function-names
 54:18  ✖  Expected math.min instead of min  scss/no-global-function-names

For

      max-height: min(800px, 70vh);
      max-width: min(800px, 90vw);

I don’t know why these aren’t ignored, while all my other uses of min/max that were previously causing this lint error are now working fine.

Here’s an example that is still failing with stylelint-scss 4.0.1:

.SectionGrid {
  $sectionMaxWidth: 60ch;

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15ch, min(#{ $sectionMaxWidth }, 88vw)));

  max-width: min(1400px, 88vw);
  > section {
    grid-column: unset;
    max-width: min(#{ $sectionMaxWidth }, 88vw);
  }
}

All 3 of the min() functions are failing scss/no-global-function-names.

2reactions
kristerkaricommented, Nov 22, 2021

@Donov4n As a workaround you could add comments before and after your code to disable the rule for a single block of code, e.g.

// stylelint-disable scss/no-global-function-names
.foo {
  width: min(300px, 30%);
}
// stylelint-enable scss/no-global-function-names

More info: https://stylelint.io/user-guide/ignore-code/

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS math functions min(), max() and clamp() - CanIUse
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Practical Uses of CSS Math Functions: calc, clamp, min, max
Review the four best supported CSS math functions, and see how they can be used in both practical and unexpected ways, such as...
Read more >
CSS Math Functions - W3Schools
The CSS math functions allow mathematical expressions to be used as property values. Here, we will explain the calc() , max() and min()...
Read more >
stylelint-scss | Yarn - Package Manager
A collection of SCSS specific linting rules for Stylelint (in a form of a ... Moreover, it introduces some specific rules that can...
Read more >
CSS Functional Notation - CSS: Cascading Style Sheets | MDN
In some functional notations multiple arguments are separated by commas, ... The math functions allow CSS numeric values to be written as ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found