mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Initial commit
This commit is contained in:
68
node_modules/stylelint/lib/rules/no-eol-whitespace/README.md
generated
vendored
Normal file
68
node_modules/stylelint/lib/rules/no-eol-whitespace/README.md
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
# no-eol-whitespace
|
||||
|
||||
Disallow end-of-line whitespace.
|
||||
|
||||
```css
|
||||
a { color: pink; }···
|
||||
/** ↑
|
||||
* This whitespace */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### `true`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { color: pink; }·
|
||||
```
|
||||
|
||||
```css
|
||||
a { color: pink; }····
|
||||
```
|
||||
|
||||
Comment strings are also checked -- so the following is a warning:
|
||||
|
||||
```css
|
||||
/* something····
|
||||
* something else */
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
/* something
|
||||
* something else */
|
||||
```
|
||||
|
||||
## Optional secondary options
|
||||
|
||||
### `ignore: ["empty-lines"]`
|
||||
|
||||
#### `"empty-lines"`
|
||||
|
||||
Allow end-of-line whitespace for lines that are only whitespace, "empty" lines.
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
color: pink;
|
||||
··
|
||||
background: orange;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
····
|
||||
```
|
||||
|
||||
```css
|
||||
a { color: pink; }
|
||||
····
|
||||
```
|
72
node_modules/stylelint/lib/rules/no-eol-whitespace/index.js
generated
vendored
Normal file
72
node_modules/stylelint/lib/rules/no-eol-whitespace/index.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict"
|
||||
|
||||
const isOnlyWhitespace = require("../../utils/isOnlyWhitespace")
|
||||
const optionsMatches = require("../../utils/optionsMatches")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const styleSearch = require("style-search")
|
||||
|
||||
const ruleName = "no-eol-whitespace"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: "Unexpected whitespace at end of line",
|
||||
})
|
||||
|
||||
const whitespacesToReject = new Set([
|
||||
" ",
|
||||
"\t",
|
||||
])
|
||||
|
||||
const rule = function (on, options) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: on,
|
||||
}, {
|
||||
optional: true,
|
||||
actual: options,
|
||||
possible: {
|
||||
ignore: ["empty-lines"],
|
||||
},
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
const rootString = root.toString()
|
||||
styleSearch({
|
||||
source: rootString,
|
||||
target: [
|
||||
"\n",
|
||||
"\r",
|
||||
],
|
||||
comments: "check",
|
||||
}, match => {
|
||||
// If the character before newline is not whitespace, ignore
|
||||
if (!whitespacesToReject.has(rootString[match.startIndex - 1])) {
|
||||
return
|
||||
}
|
||||
|
||||
if (optionsMatches(options, "ignore", "empty-lines")) {
|
||||
// If there is only whitespace between the previous newline and
|
||||
// this newline, ignore
|
||||
const lineBefore = rootString.substring(match.startIndex + 1, rootString.lastIndexOf("\n", match.startIndex - 1))
|
||||
if (isOnlyWhitespace(lineBefore)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
report({
|
||||
message: messages.rejected,
|
||||
node: root,
|
||||
index: match.startIndex - 1,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user