mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-14 05:43:33 -06:00
Initial commit
This commit is contained in:
62
node_modules/stylelint/lib/rules/block-closing-brace-empty-line-before/README.md
generated
vendored
Normal file
62
node_modules/stylelint/lib/rules/block-closing-brace-empty-line-before/README.md
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# block-closing-brace-empty-line-before
|
||||
|
||||
Require or disallow an empty line before the closing brace of blocks.
|
||||
|
||||
```css
|
||||
a {
|
||||
color: pink;
|
||||
/* ← */
|
||||
} /* ↑ */
|
||||
/** ↑
|
||||
* This line */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"always-multi-line"|"never"`
|
||||
|
||||
### `always-multi-line`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
color: pink;
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
color: pink;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a { color: pink; }
|
||||
```
|
||||
|
||||
### `never`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
color: pink;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
color: pink;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a { color: pink; }
|
||||
```
|
89
node_modules/stylelint/lib/rules/block-closing-brace-empty-line-before/index.js
generated
vendored
Normal file
89
node_modules/stylelint/lib/rules/block-closing-brace-empty-line-before/index.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
"use strict"
|
||||
|
||||
const blockString = require("../../utils/blockString")
|
||||
const hasBlock = require("../../utils/hasBlock")
|
||||
const hasEmptyBlock = require("../../utils/hasEmptyBlock")
|
||||
const hasEmptyLine = require("../../utils/hasEmptyLine")
|
||||
const isSingleLineString = require("../../utils/isSingleLineString")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
|
||||
const ruleName = "block-closing-brace-empty-line-before"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: "Expected empty line before closing brace",
|
||||
rejected: "Unexpected empty line before closing brace",
|
||||
})
|
||||
|
||||
const rule = function (expectation) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"always-multi-line",
|
||||
"never",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
// Check both kinds of statements: rules and at-rules
|
||||
root.walkRules(check)
|
||||
root.walkAtRules(check)
|
||||
|
||||
function check(statement) {
|
||||
// Return early if blockless or has empty block
|
||||
if (
|
||||
!hasBlock(statement)
|
||||
|| hasEmptyBlock(statement)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
// Get whitespace after ""}", ignoring extra semicolon
|
||||
const before = (statement.raws.after || "").replace(/;+/, "")
|
||||
if (before === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
// Calculate index
|
||||
const statementString = statement.toString()
|
||||
let index = statementString.length - 1
|
||||
if (statementString[index - 1] === "\r") {
|
||||
index -= 1
|
||||
}
|
||||
|
||||
// Set expectation
|
||||
const expectEmptyLineBefore = expectation === "always-multi-line"
|
||||
&& !isSingleLineString(blockString(statement))
|
||||
? true
|
||||
: false
|
||||
|
||||
// Check for at least one empty line
|
||||
const hasEmptyLineBefore = hasEmptyLine(before)
|
||||
|
||||
// Return if the expectation is met
|
||||
if (expectEmptyLineBefore === hasEmptyLineBefore) {
|
||||
return
|
||||
}
|
||||
|
||||
const message = expectEmptyLineBefore
|
||||
? messages.expected
|
||||
: messages.rejected
|
||||
|
||||
report({
|
||||
message,
|
||||
result,
|
||||
ruleName,
|
||||
node: statement,
|
||||
index,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user