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:
53
node_modules/stylelint/lib/rules/media-feature-parentheses-space-inside/README.md
generated
vendored
Normal file
53
node_modules/stylelint/lib/rules/media-feature-parentheses-space-inside/README.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# media-feature-parentheses-space-inside
|
||||
|
||||
Require a single space or disallow whitespace on the inside of the parentheses within media features.
|
||||
|
||||
```css
|
||||
@media ( max-width: 300px ) {}
|
||||
/** ↑ ↑
|
||||
* The space inside these two parentheses */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"always"|"never"`
|
||||
|
||||
### `"always"`
|
||||
|
||||
There *must always* be a single space inside the parentheses.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
@media (max-width: 300px) {}
|
||||
```
|
||||
|
||||
```css
|
||||
@media (max-width: 300px ) {}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
@media ( max-width: 300px ) {}
|
||||
```
|
||||
|
||||
### `"never"`
|
||||
|
||||
There *must never* be whitespace on the inside the parentheses.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
@media ( max-width: 300px ) {}
|
||||
```
|
||||
|
||||
```css
|
||||
@media ( max-width: 300px) {}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
@media (max-width: 300px) {}
|
||||
```
|
87
node_modules/stylelint/lib/rules/media-feature-parentheses-space-inside/index.js
generated
vendored
Normal file
87
node_modules/stylelint/lib/rules/media-feature-parentheses-space-inside/index.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict"
|
||||
|
||||
const atRuleParamIndex = require("../../utils/atRuleParamIndex")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const _ = require("lodash")
|
||||
const styleSearch = require("style-search")
|
||||
|
||||
const ruleName = "media-feature-parentheses-space-inside"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expectedOpening: "Expected single space after \"(\"",
|
||||
rejectedOpening: "Unexpected whitespace after \"(\"",
|
||||
expectedClosing: "Expected single space before \")\"",
|
||||
rejectedClosing: "Unexpected whitespace before \")\"",
|
||||
})
|
||||
|
||||
const rule = function (expectation) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"always",
|
||||
"never",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkAtRules(/^media$/i, atRule => {
|
||||
// If there are comments in the params, the complete string
|
||||
// will be at atRule.raws.params.raw
|
||||
const params = _.get(atRule, "raws.params.raw", atRule.params)
|
||||
const indexBoost = atRuleParamIndex(atRule)
|
||||
|
||||
styleSearch({ source: params, target: "(" }, match => {
|
||||
const nextCharIsSpace = params[match.startIndex + 1] === " "
|
||||
if (nextCharIsSpace && expectation === "never") {
|
||||
report({
|
||||
message: messages.rejectedOpening,
|
||||
node: atRule,
|
||||
index: match.startIndex + 1 + indexBoost,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
}
|
||||
if (!nextCharIsSpace && expectation === "always") {
|
||||
report({
|
||||
message: messages.expectedOpening,
|
||||
node: atRule,
|
||||
index: match.startIndex + 1 + indexBoost,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
styleSearch({ source: params, target: ")" }, match => {
|
||||
const prevCharIsSpace = params[match.startIndex - 1] === " "
|
||||
if (prevCharIsSpace && expectation === "never") {
|
||||
report({
|
||||
message: messages.rejectedClosing,
|
||||
node: atRule,
|
||||
index: match.startIndex - 1 + indexBoost,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
}
|
||||
if (!prevCharIsSpace && expectation === "always") {
|
||||
report({
|
||||
message: messages.expectedClosing,
|
||||
node: atRule,
|
||||
index: match.startIndex - 1 + indexBoost,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user