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:
240
node_modules/stylelint/lib/rules/declaration-empty-line-before/README.md
generated
vendored
Normal file
240
node_modules/stylelint/lib/rules/declaration-empty-line-before/README.md
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
# declaration-empty-line-before
|
||||
|
||||
Require or disallow an empty line before declarations.
|
||||
|
||||
```css
|
||||
a {
|
||||
--foo: pink;
|
||||
/* ← */
|
||||
top: 15px; /* ↑ */
|
||||
} /* ↑ */
|
||||
/** ↑
|
||||
* This line */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"always"|"never"`
|
||||
|
||||
### `"always"`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
--foo: pink;
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
bottom: 15px;
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
--foo: pink;
|
||||
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
|
||||
bottom: 15px;
|
||||
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
### `"never"`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
--foo: pink;
|
||||
|
||||
bottom: 15px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
|
||||
bottom: 15px;
|
||||
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
--foo: pink;
|
||||
bottom: 15px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
bottom: 15px;
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
## Optional secondary options
|
||||
|
||||
### `except: ["after-comment", "after-declaration", "first-nested"]`
|
||||
|
||||
#### `"after-comment"`
|
||||
|
||||
Reverse the primary option for declarations that come after a comment.
|
||||
|
||||
For example, with `"always"`:
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
/* comment */
|
||||
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
/* comment */
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
#### `"after-declaration"`
|
||||
|
||||
Reverse the primary option for declarations that come after another declaration.
|
||||
|
||||
For example, with `"always"`:
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
|
||||
bottom: 15px;
|
||||
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
|
||||
bottom: 15px;
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
#### `"first-nested"`
|
||||
|
||||
Reverse the primary option for declarations that are nested and the first child of their parent node.
|
||||
|
||||
For example, with `"always"`:
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
|
||||
bottom: 15px;
|
||||
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
bottom: 15px;
|
||||
|
||||
top: 5px;
|
||||
}
|
||||
```
|
||||
|
||||
### `ignore: ["after-comment", "after-declaration", "inside-single-line-block"]`
|
||||
|
||||
#### `"after-comment"`
|
||||
|
||||
Ignore declarations that are preceded by comments.
|
||||
|
||||
For example, with `"always"`:
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
/* comment */
|
||||
bottom: 15px;
|
||||
}
|
||||
```
|
||||
|
||||
#### `"after-declaration"`
|
||||
|
||||
Ignore declarations that are preceded by declarations, to allow for multiple declaration sets in the same block.
|
||||
|
||||
For example, with `"always"`:
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
|
||||
bottom: 15px;
|
||||
top: 15px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
|
||||
bottom: 15px;
|
||||
|
||||
top: 15px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
|
||||
color: orange;
|
||||
text-decoration: none;
|
||||
|
||||
bottom: 15px;
|
||||
top: 15px;
|
||||
}
|
||||
```
|
||||
|
||||
#### `"inside-single-line-block"`
|
||||
|
||||
Ignore declarations that are inside single-line blocks.
|
||||
|
||||
For example, with `"always"`:
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { bottom: 15px; top: 5px; }
|
||||
```
|
135
node_modules/stylelint/lib/rules/declaration-empty-line-before/index.js
generated
vendored
Normal file
135
node_modules/stylelint/lib/rules/declaration-empty-line-before/index.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
"use strict"
|
||||
|
||||
const blockString = require("../../utils/blockString")
|
||||
const hasEmptyLine = require("../../utils/hasEmptyLine")
|
||||
const isCustomProperty = require("../../utils/isCustomProperty")
|
||||
const isSingleLineString = require("../../utils/isSingleLineString")
|
||||
const isStandardSyntaxDeclaration = require("../../utils/isStandardSyntaxDeclaration")
|
||||
const optionsMatches = require("../../utils/optionsMatches")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
|
||||
const ruleName = "declaration-empty-line-before"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: "Expected empty line before declaration",
|
||||
rejected: "Unexpected empty line before declaration",
|
||||
})
|
||||
|
||||
const rule = function (expectation, options) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"always",
|
||||
"never",
|
||||
],
|
||||
}, {
|
||||
actual: options,
|
||||
possible: {
|
||||
except: [
|
||||
"first-nested",
|
||||
"after-comment",
|
||||
"after-declaration",
|
||||
],
|
||||
ignore: [
|
||||
"after-comment",
|
||||
"after-declaration",
|
||||
"inside-single-line-block",
|
||||
],
|
||||
},
|
||||
optional: true,
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkDecls(decl => {
|
||||
const prop = decl.prop,
|
||||
parent = decl.parent
|
||||
|
||||
if (!isStandardSyntaxDeclaration(decl)) {
|
||||
return
|
||||
}
|
||||
if (isCustomProperty(prop)) {
|
||||
return
|
||||
}
|
||||
|
||||
// Optionally ignore the node if a comment precedes it
|
||||
if (
|
||||
optionsMatches(options, "ignore", "after-comment")
|
||||
&& decl.prev()
|
||||
&& decl.prev().type === "comment"
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
// Optionally ignore the node if a declaration precedes it
|
||||
if (
|
||||
optionsMatches(options, "ignore", "after-declaration")
|
||||
&& decl.prev()
|
||||
&& decl.prev().type === "decl"
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
// Optionally ignore nodes inside single-line blocks
|
||||
if (
|
||||
optionsMatches(options, "ignore", "inside-single-line-block")
|
||||
&& isSingleLineString(blockString(parent))
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
let expectEmptyLineBefore = expectation === "always"
|
||||
? true
|
||||
: false
|
||||
|
||||
// Optionally reverse the expectation for the first nested node
|
||||
if (
|
||||
optionsMatches(options, "except", "first-nested")
|
||||
&& decl === parent.first
|
||||
) {
|
||||
expectEmptyLineBefore = !expectEmptyLineBefore
|
||||
}
|
||||
|
||||
// Optionally reverse the expectation if a comment precedes this node
|
||||
if (
|
||||
optionsMatches(options, "except", "after-comment")
|
||||
&& decl.prev()
|
||||
&& decl.prev().type === "comment"
|
||||
) {
|
||||
expectEmptyLineBefore = !expectEmptyLineBefore
|
||||
}
|
||||
|
||||
// Optionally reverse the expectation if a declaration precedes this node
|
||||
if (
|
||||
optionsMatches(options, "except", "after-declaration")
|
||||
&& decl.prev()
|
||||
&& decl.prev().prop
|
||||
&& isStandardSyntaxDeclaration(decl.prev())
|
||||
&& !isCustomProperty(decl.prev().prop)
|
||||
) {
|
||||
expectEmptyLineBefore = !expectEmptyLineBefore
|
||||
}
|
||||
|
||||
// Check for at least one empty line
|
||||
const hasEmptyLineBefore = hasEmptyLine(decl.raws.before)
|
||||
|
||||
// Return if the expectation is met
|
||||
if (expectEmptyLineBefore === hasEmptyLineBefore) {
|
||||
return
|
||||
}
|
||||
|
||||
const message = expectEmptyLineBefore
|
||||
? messages.expected
|
||||
: messages.rejected
|
||||
report({ message, node: decl, result, ruleName })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user