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:
60
node_modules/stylelint/lib/rules/max-empty-lines/README.md
generated
vendored
Normal file
60
node_modules/stylelint/lib/rules/max-empty-lines/README.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# max-empty-lines
|
||||
|
||||
Limit the number of adjacent empty lines.
|
||||
|
||||
```css
|
||||
a {}
|
||||
/* ← */
|
||||
/* ← */
|
||||
a {} /* ↑ */
|
||||
/** ↑
|
||||
* These lines */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`int`: Maximum number of characters allowed.
|
||||
|
||||
For example, with `2`:
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {}
|
||||
|
||||
|
||||
|
||||
b {}
|
||||
```
|
||||
|
||||
Comment strings are also checked -- so the following is a warning:
|
||||
|
||||
```css
|
||||
/**
|
||||
* Call me Ishmael.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Some years ago -- never mind how log precisely -- ...
|
||||
*/
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {}
|
||||
b {}
|
||||
```
|
||||
|
||||
```css
|
||||
a {}
|
||||
|
||||
b {}
|
||||
```
|
||||
|
||||
```css
|
||||
a {}
|
||||
|
||||
|
||||
b {}
|
||||
```
|
73
node_modules/stylelint/lib/rules/max-empty-lines/index.js
generated
vendored
Normal file
73
node_modules/stylelint/lib/rules/max-empty-lines/index.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict"
|
||||
|
||||
const _ = require("lodash")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const styleSearch = require("style-search")
|
||||
|
||||
const ruleName = "max-empty-lines"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: max => `Expected no more than ${max} empty line(s)`,
|
||||
})
|
||||
|
||||
const rule = function (max) {
|
||||
const maxAdjacentNewlines = max + 1
|
||||
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: max,
|
||||
possible: _.isNumber,
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
const rootString = root.toString()
|
||||
const repeatLFNewLines = _.repeat("\n", maxAdjacentNewlines)
|
||||
const repeatCRLFNewLines = _.repeat("\r\n", maxAdjacentNewlines)
|
||||
|
||||
styleSearch({ source: rootString, target: "\n" }, match => {
|
||||
checkMatch(rootString, match.endIndex, root)
|
||||
})
|
||||
|
||||
// We must check comments separately in order to accommodate stupid
|
||||
// `//`-comments from SCSS, which postcss-scss converts to `/* ... */`,
|
||||
// which adds to extra characters at the end, which messes up our
|
||||
// warning position
|
||||
root.walkComments(comment => {
|
||||
const source = (comment.raws.left || "") + comment.text + (comment.raws.right || "")
|
||||
styleSearch({ source, target: "\n" }, match => {
|
||||
checkMatch(source, match.endIndex, comment, 2)
|
||||
})
|
||||
})
|
||||
|
||||
function checkMatch(source, matchEndIndex, node) {
|
||||
const offset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0
|
||||
|
||||
let violationIndex = false
|
||||
if (source.substr(matchEndIndex, maxAdjacentNewlines) === repeatLFNewLines) {
|
||||
violationIndex = matchEndIndex + maxAdjacentNewlines
|
||||
} else if (source.substr(matchEndIndex, maxAdjacentNewlines * 2) === repeatCRLFNewLines) {
|
||||
violationIndex = matchEndIndex + maxAdjacentNewlines * 2
|
||||
}
|
||||
|
||||
if (!violationIndex) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
message: messages.expected(max),
|
||||
node,
|
||||
index: violationIndex + offset,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user