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:
44
node_modules/stylelint/lib/rules/declaration-block-single-line-max-declarations/README.md
generated
vendored
Normal file
44
node_modules/stylelint/lib/rules/declaration-block-single-line-max-declarations/README.md
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# declaration-block-single-line-max-declarations
|
||||
|
||||
Limit the number of declaration within a single line declaration block.
|
||||
|
||||
```css
|
||||
a { color: pink; top: 0; }
|
||||
/** ↑ ↑
|
||||
* The number of these declarations */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`int`: Maximum number of declarations allowed.
|
||||
|
||||
For example, with `1`:
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { color: pink; top: 3px; }
|
||||
```
|
||||
|
||||
```css
|
||||
a,
|
||||
b { color: pink; top: 3px; }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a,
|
||||
b { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
color: pink;
|
||||
top: 3px;
|
||||
}
|
||||
```
|
54
node_modules/stylelint/lib/rules/declaration-block-single-line-max-declarations/index.js
generated
vendored
Normal file
54
node_modules/stylelint/lib/rules/declaration-block-single-line-max-declarations/index.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict"
|
||||
|
||||
const beforeBlockString = require("../../utils/beforeBlockString")
|
||||
const blockString = require("../../utils/blockString")
|
||||
const isSingleLineString = require("../../utils/isSingleLineString")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const _ = require("lodash")
|
||||
|
||||
const ruleName = "declaration-block-single-line-max-declarations"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: quantity => `Expected no more than ${quantity} declaration(s)`,
|
||||
})
|
||||
|
||||
const rule = function (quantity) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: quantity,
|
||||
possible: [_.isNumber],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkRules(rule => {
|
||||
if (!isSingleLineString(blockString(rule))) {
|
||||
return
|
||||
}
|
||||
if (!rule.nodes) {
|
||||
return
|
||||
}
|
||||
|
||||
const decls = rule.nodes.filter(node => node.type === "decl")
|
||||
|
||||
if (decls.length <= quantity) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
message: messages.expected(quantity),
|
||||
node: rule,
|
||||
index: beforeBlockString(rule, { noRawBefore: true }).length,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user