mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 13:23:32 -06:00
Initial commit
This commit is contained in:
33
node_modules/stylelint/lib/rules/custom-media-pattern/README.md
generated
vendored
Normal file
33
node_modules/stylelint/lib/rules/custom-media-pattern/README.md
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# custom-media-pattern
|
||||
|
||||
Specify a pattern for custom media query names.
|
||||
|
||||
```css
|
||||
@custom-media --foo (max-width: 30em);
|
||||
/** ↑
|
||||
* The pattern of this */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`regex|string`
|
||||
|
||||
A string will be translated into a RegExp like so `new RegExp(yourString)` — so be sure to escape properly.
|
||||
|
||||
Given the string:
|
||||
|
||||
```js
|
||||
"foo-.+"
|
||||
```
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
@custom-media --bar (min-width: 30em);
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
@custom-media --foo-bar (min-width: 30em);
|
||||
```
|
54
node_modules/stylelint/lib/rules/custom-media-pattern/index.js
generated
vendored
Normal file
54
node_modules/stylelint/lib/rules/custom-media-pattern/index.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict"
|
||||
|
||||
const _ = require("lodash")
|
||||
const atRuleParamIndex = require("../../utils/atRuleParamIndex")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
|
||||
const ruleName = "custom-media-pattern"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: "Expected custom media query name to match specified pattern",
|
||||
})
|
||||
|
||||
const rule = function (pattern) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: pattern,
|
||||
possible: [
|
||||
_.isRegExp,
|
||||
_.isString,
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
const regexpPattern = _.isString(pattern) ? new RegExp(pattern) : pattern
|
||||
|
||||
root.walkAtRules(atRule => {
|
||||
if (atRule.name.toLowerCase() !== "custom-media") {
|
||||
return
|
||||
}
|
||||
|
||||
const customMediaName = atRule.params.match(/^--(\S+)\b/)[1]
|
||||
|
||||
if (regexpPattern.test(customMediaName)) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
message: messages.expected,
|
||||
node: atRule,
|
||||
index: atRuleParamIndex(atRule),
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user