mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Initial commit
This commit is contained in:
41
node_modules/stylelint/lib/rules/media-feature-name-whitelist/README.md
generated
vendored
Normal file
41
node_modules/stylelint/lib/rules/media-feature-name-whitelist/README.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# media-feature-name-whitelist
|
||||
|
||||
Specify a whitelist of allowed media feature names.
|
||||
|
||||
```css
|
||||
@media (min-width: 700px) {}
|
||||
/** ↑
|
||||
* These media feature names */
|
||||
```
|
||||
|
||||
**Caveat:** Media feature names within a range context are currently ignored.
|
||||
|
||||
## Options
|
||||
|
||||
`array|string|regex`: `["array", "of", "unprefixed", "media-features" or "regex"]|"media-feature"|/regex/`
|
||||
|
||||
Given:
|
||||
|
||||
```js
|
||||
["max-width", "/^my-/"]
|
||||
```
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
@media (min-width: 50em) {}
|
||||
```
|
||||
|
||||
```css
|
||||
@media print and (min-resolution: 300dpi) {}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
@media (max-width: 50em) {}
|
||||
```
|
||||
|
||||
```css
|
||||
@media (my-width: 50em) {}
|
||||
```
|
58
node_modules/stylelint/lib/rules/media-feature-name-whitelist/index.js
generated
vendored
Normal file
58
node_modules/stylelint/lib/rules/media-feature-name-whitelist/index.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict"
|
||||
|
||||
const atRuleParamIndex = require("../../utils/atRuleParamIndex")
|
||||
const isCustomMediaQuery = require("../../utils/isCustomMediaQuery")
|
||||
const isRangeContextMediaFeature = require("../../utils/isRangeContextMediaFeature")
|
||||
const isStandardSyntaxMediaFeatureName = require("../../utils/isStandardSyntaxMediaFeatureName")
|
||||
const matchesStringOrRegExp = require("../../utils/matchesStringOrRegExp")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const _ = require("lodash")
|
||||
const mediaParser = require("postcss-media-query-parser").default
|
||||
|
||||
const ruleName = "media-feature-name-whitelist"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: name => `Unexpected media feature name "${name}"`,
|
||||
})
|
||||
|
||||
const rule = function (whitelist) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: whitelist,
|
||||
possible: [_.isString],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkAtRules(/^media$/i, atRule => {
|
||||
mediaParser(atRule.params).walk(/^media-feature$/i, mediaFeatureNode => {
|
||||
const parent = mediaFeatureNode.parent,
|
||||
sourceIndex = mediaFeatureNode.sourceIndex,
|
||||
value = mediaFeatureNode.value
|
||||
|
||||
if (isRangeContextMediaFeature(parent.value) || !isStandardSyntaxMediaFeatureName(value) || isCustomMediaQuery(value)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (matchesStringOrRegExp(value.toLowerCase(), whitelist)) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
index: atRuleParamIndex(atRule) + sourceIndex,
|
||||
message: messages.rejected(value),
|
||||
node: atRule,
|
||||
ruleName,
|
||||
result,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user