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:
83
node_modules/stylelint/lib/rules/function-whitespace-after/README.md
generated
vendored
Normal file
83
node_modules/stylelint/lib/rules/function-whitespace-after/README.md
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
# function-whitespace-after
|
||||
|
||||
Require or disallow whitespace after functions.
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1) scale(3); }
|
||||
/** ↑
|
||||
* This space */
|
||||
```
|
||||
|
||||
This rule does not check for space immediately after `)` if the very next character is `,`, `)`, or `}`, allowing some of the patterns exemplified below.
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"always"|"never"`
|
||||
|
||||
### `"always"`
|
||||
|
||||
There *must always* be whitespace after the function.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1)scale(3); }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1) scale(3); }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1) scale(3); }
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
transform:
|
||||
translate(1, 1)
|
||||
scale(3);
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
/* notice the two closing parentheses without a space between */
|
||||
a { top: calc(1 * (1 + 3)); }
|
||||
```
|
||||
|
||||
```css
|
||||
/* notice the ), with no space after the closing parenthesis */
|
||||
a { padding: calc(1 * 2px), calc(2 * 5px); }
|
||||
```
|
||||
|
||||
```scss
|
||||
/* notice the )}, with no space after the closing parenthesis */
|
||||
a {
|
||||
max-height: #{($line-height) * ($lines-to-show)}em;
|
||||
}
|
||||
```
|
||||
|
||||
```less
|
||||
/* notice the )}, with no space after the closing parenthesis */
|
||||
a {
|
||||
max-height: ((@line-height) * (@lines-to-show))em;
|
||||
}
|
||||
```
|
||||
|
||||
### `"never"`
|
||||
|
||||
There *must never* be whitespace after the function.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1) scale(3); }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1)scale(3); }
|
||||
```
|
90
node_modules/stylelint/lib/rules/function-whitespace-after/index.js
generated
vendored
Normal file
90
node_modules/stylelint/lib/rules/function-whitespace-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict"
|
||||
|
||||
const isWhitespace = require("../../utils/isWhitespace")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const styleSearch = require("style-search")
|
||||
|
||||
const ruleName = "function-whitespace-after"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: "Expected whitespace after \")\"",
|
||||
rejected: "Unexpected whitespace after \")\"",
|
||||
})
|
||||
|
||||
const ACCEPTABLE_AFTER_CLOSING_PAREN = new Set([
|
||||
")",
|
||||
",",
|
||||
"}",
|
||||
":",
|
||||
undefined,
|
||||
])
|
||||
|
||||
const rule = function (expectation) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"always",
|
||||
"never",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkDecls(decl => {
|
||||
const declString = decl.toString()
|
||||
|
||||
styleSearch({
|
||||
source: declString,
|
||||
target: ")",
|
||||
functionArguments: "only",
|
||||
}, match => {
|
||||
checkClosingParen(declString, match.startIndex, decl)
|
||||
})
|
||||
})
|
||||
|
||||
function checkClosingParen(source, index, node) {
|
||||
const nextChar = source[index + 1]
|
||||
if (expectation === "always") {
|
||||
// Allow for the next character to be a single empty space,
|
||||
// another closing parenthesis, a comma, or the end of the value
|
||||
if (nextChar === " ") {
|
||||
return
|
||||
}
|
||||
if (nextChar === "\n") {
|
||||
return
|
||||
}
|
||||
if (source.substr(index + 1, 2) === "\r\n") {
|
||||
return
|
||||
}
|
||||
if (ACCEPTABLE_AFTER_CLOSING_PAREN.has(nextChar)) {
|
||||
return
|
||||
}
|
||||
report({
|
||||
message: messages.expected,
|
||||
node,
|
||||
index: index + 1,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
} else if (expectation === "never") {
|
||||
if (isWhitespace(nextChar)) {
|
||||
report({
|
||||
message: messages.rejected,
|
||||
node,
|
||||
index: index + 1,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user