
Security News
Node.js TSC Votes to Stop Distributing Corepack
Corepack will be phased out from future Node.js releases following a TSC vote.
stylelint-media-use-custom-media
Advanced tools
Media Use Custom Media is a stylelint rule to enforce usage of custom media queries in CSS.
Add stylelint and Media Use Custom Media to your project.
npm install stylelint stylelint-media-use-custom-media --save-dev
Add Media Use Custom Media to your stylelint configuration.
{
"plugins": [
"stylelint-media-use-custom-media"
],
"rules": {
"csstools/media-use-custom-media": "always" || "always-known" || "known" || "never" || "ignore"
}
}
If the first option is "always"
or true
, then Media Use Custom Media
requires all @media
queries to use Custom Media, and the following patterns
are not considered violations:
@media (--sm) {}
@media (--sm), (--md) {}
@media screen and (--sm) {}
While the following patterns are considered violations:
@media (max-width: 40rem) {}
@media (max-width: 40rem), (--md) {}
If the first option is "never"
, then Media Use Custom Media
requires all @media
queries to not use Custom Media, and the following
patterns are not considered violations:
@media (max-width: 40rem) {}
@media screen and (max-width: 40rem) {}
While the following patterns are considered violations:
@media (--md) {}
@media screen and (--md) {}
@media (--md), (max-width: 40rem) {}
If the first option is "known"
, then Media Use Custom Media requires all
@media
queries referencing Custom Media to be known from either
@custom-media
declarations in the file or imported using the second
option. Then the following patterns are not considered violations:
@custom-media --sm (min-width: 40rem);
@media (--sm) {}
@media (--sm), (min-width: 40rem) {}
While the following patterns are considered violations:
@media (--md) {}
@media (--md), (min-width: 40rem) {}
If the first option is "always-known"
, then Media Use Custom Media requires all
@media
queries to use known Custom Media from either @custom-media
declarations in the file or imported using the second option. Then the
following patterns are not considered violations:
@custom-media --sm (min-width: 40rem);
@media (--sm) {}
While the following patterns are considered violations:
@custom-media --sm (min-width: 40rem);
@media (--sm), (min-width: 40rem) {}
@media (--md) {}
If the first option is "ignore"
or null
, then Media Use Custom Media does
nothing.
When the first option is "always-known"
or "known"
, then the second option
can specify sources where Custom Properties should be imported from by using an
importFrom
key. These imports might be CSS, JS, and JSON files, functions,
and directly passed objects.
// .stylelintrc
{
"plugins": [
"stylelint-media-use-custom-media"
],
"rules": {
"csstools/media-use-custom-media": ["known", {
"importFrom": [
"path/to/file.css", // => @custom-media --sm (min-width: 40rem);
"path/to/file.json" // => { "custom-media": { "--sm": "(min-width: 40rem)" } }
]
}
}
}
4.0.0 (Dec 10, 2023)
stylelint
to >=16 (breaking)false
option, use never
insteadFAQs
Enforce usage of custom media queries in CSS
The npm package stylelint-media-use-custom-media receives a total of 6,169 weekly downloads. As such, stylelint-media-use-custom-media popularity was classified as popular.
We found that stylelint-media-use-custom-media demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.
Research
Security News
Research uncovers Black Basta's plans to exploit package registries for ransomware delivery alongside evidence of similar attacks already targeting open source ecosystems.
Security News
Oxlint's beta release introduces 500+ built-in linting rules while delivering twice the speed of previous versions, with future support planned for custom plugins and improved IDE integration.