mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-14 13:53:32 -06:00
Initial commit
This commit is contained in:
73
node_modules/stylelint/lib/rules/declaration-block-trailing-semicolon/README.md
generated
vendored
Normal file
73
node_modules/stylelint/lib/rules/declaration-block-trailing-semicolon/README.md
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# declaration-block-trailing-semicolon
|
||||
|
||||
Require or disallow a trailing semicolon within declaration blocks.
|
||||
|
||||
```css
|
||||
a { background: orange; color: pink; }
|
||||
/** ↑
|
||||
* This semicolon */
|
||||
```
|
||||
|
||||
The trailing semicolon is the *last* semicolon in a declaration block and it is optional.
|
||||
|
||||
This rule will ignore Less mixins, trailing `//` comments, and declaration blocks containing nested (at-)rules.
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"always"|"never"`
|
||||
|
||||
### `"always"`
|
||||
|
||||
There *must always* be a trailing semicolon.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { color: pink }
|
||||
```
|
||||
|
||||
```css
|
||||
a { background: orange; color: pink }
|
||||
```
|
||||
|
||||
```css
|
||||
a { @include foo }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { background: orange; color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { @include foo; }
|
||||
```
|
||||
|
||||
### `"never"`
|
||||
|
||||
There *must never* be a trailing semicolon.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { background: orange; color: pink; }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { color: pink }
|
||||
```
|
||||
|
||||
```css
|
||||
a { background: orange; color: pink }
|
||||
```
|
77
node_modules/stylelint/lib/rules/declaration-block-trailing-semicolon/index.js
generated
vendored
Normal file
77
node_modules/stylelint/lib/rules/declaration-block-trailing-semicolon/index.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict"
|
||||
|
||||
const hasBlock = require("../../utils/hasBlock")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
|
||||
const ruleName = "declaration-block-trailing-semicolon"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: "Expected a trailing semicolon",
|
||||
rejected: "Unexpected trailing semicolon",
|
||||
})
|
||||
|
||||
const rule = function (expectation) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"always",
|
||||
"never",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkAtRules(atRule => {
|
||||
if (atRule.parent === root) {
|
||||
return
|
||||
}
|
||||
if (atRule !== atRule.parent.last) {
|
||||
return
|
||||
}
|
||||
if (hasBlock(atRule)) {
|
||||
return
|
||||
}
|
||||
checkLastNode(atRule)
|
||||
})
|
||||
|
||||
root.walkDecls(decl => {
|
||||
if (decl !== decl.parent.last) {
|
||||
return
|
||||
}
|
||||
checkLastNode(decl)
|
||||
})
|
||||
|
||||
function checkLastNode(node) {
|
||||
let message
|
||||
|
||||
if (expectation === "always") {
|
||||
if (node.parent.raws.semicolon) {
|
||||
return
|
||||
}
|
||||
message = messages.expected
|
||||
}
|
||||
if (expectation === "never") {
|
||||
if (!node.parent.raws.semicolon) {
|
||||
return
|
||||
}
|
||||
message = messages.rejected
|
||||
}
|
||||
|
||||
report({
|
||||
message,
|
||||
node,
|
||||
index: node.toString().trim().length - 1,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user