mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-14 05:43:33 -06:00
Initial commit
This commit is contained in:
65
node_modules/stylelint/lib/rules/string-no-newline/README.md
generated
vendored
Normal file
65
node_modules/stylelint/lib/rules/string-no-newline/README.md
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
# string-no-newline
|
||||
|
||||
Disallow (unescaped) newlines in strings.
|
||||
|
||||
```css
|
||||
a {
|
||||
content: "first
|
||||
second"; ↑
|
||||
} ↑
|
||||
/** ↑
|
||||
* The newline here */
|
||||
```
|
||||
|
||||
[The spec](https://www.w3.org/TR/CSS2/syndata.html#strings) says this: "A string cannot directly contain a newline. To include a newline in a string, use an escape representing the line feed character in ISO-10646 (U+000A), such as \"\A\" or \"\00000a\"." And also: "It is possible to break strings over several lines, for aesthetic or other reasons, but in such a case the newline itself has to be escaped with a backslash (\)."
|
||||
|
||||
## Options
|
||||
|
||||
### `true`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
content: "first
|
||||
second";
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
[title="something
|
||||
is probably wrong"] {}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
font-family: "Times
|
||||
New
|
||||
Roman";
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
content: "first\Asecond";
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
content: "first\\nsecond";
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
[title="nothing\
|
||||
is wrong"] {}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
font-family: "Times New Roman";
|
||||
}
|
||||
```
|
46
node_modules/stylelint/lib/rules/string-no-newline/index.js
generated
vendored
Normal file
46
node_modules/stylelint/lib/rules/string-no-newline/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict"
|
||||
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const styleSearch = require("style-search")
|
||||
|
||||
const ruleName = "string-no-newline"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: "Unexpected newline in string",
|
||||
})
|
||||
|
||||
const rule = function (actual) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, { actual })
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
const cssString = root.toString()
|
||||
styleSearch({
|
||||
source: cssString,
|
||||
target: "\n",
|
||||
strings: "only",
|
||||
}, match => {
|
||||
const charBefore = cssString[match.startIndex - 1]
|
||||
let index = match.startIndex
|
||||
if (charBefore === "\\") {
|
||||
return
|
||||
}
|
||||
if (charBefore === "\r") index -= 1
|
||||
report({
|
||||
message: messages.rejected,
|
||||
node: root,
|
||||
index,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user