mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 21:33:32 -06:00
Initial commit
This commit is contained in:
84
node_modules/stylelint/lib/rules/comment-whitespace-inside/README.md
generated
vendored
Normal file
84
node_modules/stylelint/lib/rules/comment-whitespace-inside/README.md
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
# comment-whitespace-inside
|
||||
|
||||
Require or disallow whitespace on the inside of comment markers.
|
||||
|
||||
```css
|
||||
/* comment */
|
||||
/** ↑ ↑
|
||||
* The space inside these two markers */
|
||||
```
|
||||
|
||||
Any number of asterisks are allowed at the beginning or end of the comment. So `/** comment **/` is treated the same way as `/* comment */`.
|
||||
|
||||
**Caveat:** Comments within *selector and value lists* are currently ignored.
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"always"|"never"`
|
||||
|
||||
### `"always"`
|
||||
|
||||
There *must always* be whitespace inside the markers.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
/*comment*/
|
||||
```
|
||||
|
||||
```css
|
||||
/*comment */
|
||||
```
|
||||
|
||||
```css
|
||||
/** comment**/
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
/* comment */
|
||||
```
|
||||
|
||||
```css
|
||||
/** comment **/
|
||||
```
|
||||
|
||||
```css
|
||||
/**
|
||||
* comment
|
||||
*/
|
||||
```
|
||||
|
||||
```css
|
||||
/* comment
|
||||
*/
|
||||
```
|
||||
|
||||
### `"never"`
|
||||
|
||||
There *must never* be whitespace on the inside the markers.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
/* comment */
|
||||
```
|
||||
|
||||
```css
|
||||
/*comment */
|
||||
```
|
||||
|
||||
```css
|
||||
/** comment**/
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
/*comment*/
|
||||
```
|
||||
|
||||
```css
|
||||
/****comment****/
|
||||
```
|
96
node_modules/stylelint/lib/rules/comment-whitespace-inside/index.js
generated
vendored
Executable file
96
node_modules/stylelint/lib/rules/comment-whitespace-inside/index.js
generated
vendored
Executable file
@@ -0,0 +1,96 @@
|
||||
"use strict"
|
||||
|
||||
const isWhitespace = require("../../utils/isWhitespace")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
|
||||
const ruleName = "comment-whitespace-inside"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expectedOpening: "Expected whitespace after \"/*\"",
|
||||
rejectedOpening: "Unexpected whitespace after \"/*\"",
|
||||
expectedClosing: "Expected whitespace before \"*/\"",
|
||||
rejectedClosing: "Unexpected whitespace before \"*/\"",
|
||||
})
|
||||
|
||||
const rule = function (expectation) {
|
||||
return function (root, result) {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"always",
|
||||
"never",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkComments(function (comment) {
|
||||
if (
|
||||
comment.raws.inline
|
||||
|| comment.inline
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
const rawComment = comment.toString()
|
||||
const firstFourChars = rawComment.substr(0, 4)
|
||||
|
||||
// Return early if sourcemap or copyright comment
|
||||
if (/^\/\*[#!]\s/.test(firstFourChars)) {
|
||||
return
|
||||
}
|
||||
|
||||
const leftMatches = rawComment.match(/(^\/\*+)(\s)?/)
|
||||
const rightMatches = rawComment.match(/(\s)?(\*+\/)$/)
|
||||
const opener = leftMatches[1]
|
||||
const leftSpace = leftMatches[2] || ""
|
||||
const rightSpace = rightMatches[1] || ""
|
||||
const closer = rightMatches[2]
|
||||
|
||||
if (
|
||||
expectation === "never"
|
||||
&& leftSpace !== ""
|
||||
) {
|
||||
complain(messages.rejectedOpening, opener.length)
|
||||
}
|
||||
|
||||
if (
|
||||
expectation === "always"
|
||||
&& !isWhitespace(leftSpace)
|
||||
) {
|
||||
complain(messages.expectedOpening, opener.length)
|
||||
}
|
||||
|
||||
if (
|
||||
expectation === "never"
|
||||
&& rightSpace !== ""
|
||||
) {
|
||||
complain(messages.rejectedClosing, comment.toString().length - closer.length - 1)
|
||||
}
|
||||
|
||||
if (
|
||||
expectation === "always"
|
||||
&& !isWhitespace(rightSpace)
|
||||
) {
|
||||
complain(messages.expectedClosing, comment.toString().length - closer.length - 1)
|
||||
}
|
||||
|
||||
function complain(message, index) {
|
||||
report({
|
||||
message,
|
||||
index,
|
||||
result,
|
||||
ruleName,
|
||||
node: comment,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user