mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-12 21:03:32 -06:00
Initial commit
This commit is contained in:
127
node_modules/stylelint/lib/rules/function-parentheses-newline-inside/README.md
generated
vendored
Normal file
127
node_modules/stylelint/lib/rules/function-parentheses-newline-inside/README.md
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
# function-parentheses-newline-inside
|
||||
|
||||
Require a newline or disallow whitespace on the inside of the parentheses of functions.
|
||||
|
||||
```css
|
||||
a {
|
||||
transform: translate(
|
||||
1, /* ↑ */
|
||||
1 /* ↑ */
|
||||
); /* ↑ */
|
||||
} /* ↑ */
|
||||
/** ↑ ↑
|
||||
* The newline inside these two parentheses */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"always"|"always-multi-line"|"never-multi-line"`
|
||||
|
||||
### `"always"`
|
||||
|
||||
There *must always* be a newline inside the parentheses.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1); }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transform: translate(1,
|
||||
1
|
||||
); }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
transform: translate(
|
||||
1, 1
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
transform: translate(
|
||||
1,
|
||||
1
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### `"always-multi-line"`
|
||||
|
||||
There *must always* be a newline inside the parentheses of multi-line functions.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { transform: translate(1,
|
||||
1) }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1) }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transform: translate( 1, 1 ) }
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
transform: translate(
|
||||
1, 1
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
transform: translate(
|
||||
1,
|
||||
1
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### `"never-multi-line"`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
transform: translate(
|
||||
1, 1
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
transform: translate(
|
||||
1,
|
||||
1
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { transform: translate(1, 1) }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transform: translate( 1, 1 ) }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transform: translate(1,
|
||||
1) }
|
||||
```
|
104
node_modules/stylelint/lib/rules/function-parentheses-newline-inside/index.js
generated
vendored
Normal file
104
node_modules/stylelint/lib/rules/function-parentheses-newline-inside/index.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
"use strict"
|
||||
|
||||
const declarationValueIndex = require("../../utils/declarationValueIndex")
|
||||
const isSingleLineString = require("../../utils/isSingleLineString")
|
||||
const isStandardSyntaxFunction = require("../../utils/isStandardSyntaxFunction")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const valueParser = require("postcss-value-parser")
|
||||
|
||||
const ruleName = "function-parentheses-newline-inside"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expectedOpening: "Expected newline after \"(\"",
|
||||
expectedClosing: "Expected newline before \")\"",
|
||||
expectedOpeningMultiLine: "Expected newline after \"(\" in a multi-line function",
|
||||
rejectedOpeningMultiLine: "Unexpected whitespace after \"(\" in a multi-line function",
|
||||
expectedClosingMultiLine: "Expected newline before \")\" in a multi-line function",
|
||||
rejectedClosingMultiLine: "Unexpected whitespace before \")\" in a multi-line function",
|
||||
})
|
||||
|
||||
const rule = function (expectation) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"always",
|
||||
"always-multi-line",
|
||||
"never-multi-line",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkDecls(decl => {
|
||||
if (decl.value.indexOf("(") === -1) {
|
||||
return
|
||||
}
|
||||
|
||||
valueParser(decl.value).walk(valueNode => {
|
||||
if (valueNode.type !== "function") {
|
||||
return
|
||||
}
|
||||
|
||||
if (!isStandardSyntaxFunction(valueNode)) {
|
||||
return
|
||||
}
|
||||
|
||||
const functionString = valueParser.stringify(valueNode)
|
||||
const isMultiLine = !isSingleLineString(functionString)
|
||||
function containsNewline(str) {
|
||||
return str.indexOf("\n") !== -1
|
||||
}
|
||||
|
||||
// Check opening ...
|
||||
|
||||
const openingIndex = valueNode.sourceIndex + valueNode.value.length + 1
|
||||
|
||||
if (expectation === "always" && !containsNewline(valueNode.before)) {
|
||||
complain(messages.expectedOpening, openingIndex)
|
||||
}
|
||||
|
||||
if (isMultiLine && expectation === "always-multi-line" && !containsNewline(valueNode.before)) {
|
||||
complain(messages.expectedOpeningMultiLine, openingIndex)
|
||||
}
|
||||
|
||||
if (isMultiLine && expectation === "never-multi-line" && valueNode.before !== "") {
|
||||
complain(messages.rejectedOpeningMultiLine, openingIndex)
|
||||
}
|
||||
|
||||
// Check closing ...
|
||||
|
||||
const closingIndex = valueNode.sourceIndex + functionString.length - 2
|
||||
|
||||
if (expectation === "always" && !containsNewline(valueNode.after)) {
|
||||
complain(messages.expectedClosing, closingIndex)
|
||||
}
|
||||
|
||||
if (isMultiLine && expectation === "always-multi-line" && !containsNewline(valueNode.after)) {
|
||||
complain(messages.expectedClosingMultiLine, closingIndex)
|
||||
}
|
||||
|
||||
if (isMultiLine && expectation === "never-multi-line" && valueNode.after !== "") {
|
||||
complain(messages.rejectedClosingMultiLine, closingIndex)
|
||||
}
|
||||
})
|
||||
|
||||
function complain(message, offset) {
|
||||
report({
|
||||
ruleName,
|
||||
result,
|
||||
message,
|
||||
node: decl,
|
||||
index: declarationValueIndex(decl) + offset,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user