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:
142
node_modules/stylelint/lib/rules/stylelint-disable-reason/README.md
generated
vendored
Normal file
142
node_modules/stylelint/lib/rules/stylelint-disable-reason/README.md
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
# stylelint-disable-reason
|
||||
|
||||
***Deprecated: See [CHANGELOG](../../../CHANGELOG.md).***
|
||||
|
||||
Require a reason comment before or after `stylelint-disable` comments.
|
||||
|
||||
```css
|
||||
a {
|
||||
/* stylelint-disable no-browser-hacks */
|
||||
/* Need for IE 6 */ /*←*/
|
||||
_display: block; /*↑*/
|
||||
/* stylelint-enable no-browser-hacks */ /*↑*/
|
||||
} /*↑*/
|
||||
/** ↑
|
||||
* This reason comment */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"always-before"|"always-after"`
|
||||
|
||||
### `"always-before"`
|
||||
|
||||
There *must always* be a reason comment before the `stylelint-disable` comment.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
/* stylelint-disable no-browser-hacks */
|
||||
_display: block;
|
||||
/* stylelint-enable no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
/* stylelint-disable no-browser-hacks */
|
||||
/* Need for IE 6 */
|
||||
_display: block;
|
||||
/* stylelint-enable no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {} /* stylelint-disable-line block-no-empty */
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
_display: block; /* stylelint-disable-line block-no-empty */
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
/* Reason for disable */
|
||||
/* stylelint-disable no-browser-hacks */
|
||||
_display: block;
|
||||
/* stylelint-enable no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {} /* Reason for disable */ /* stylelint-disable-line block-no-empty */
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
_display: block; /* Reason for disable */ /* stylelint-disable-line no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
/* Reason for disable */
|
||||
_display: block; /* stylelint-disable-line no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
### `"always-after"`
|
||||
|
||||
There *must always* be a reason comment after the `stylelint-disable` disable comment.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
/* stylelint-disable no-browser-hacks */
|
||||
_display: block;
|
||||
/* stylelint-enable no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
/* Need for IE 6 */
|
||||
/* stylelint-disable no-browser-hacks */
|
||||
_display: block;
|
||||
/* stylelint-enable no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {} /* stylelint-disable-line block-no-empty */
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
_display: block; /* stylelint-disable-line no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
/* stylelint-disable no-browser-hacks */
|
||||
/* Need for IE 6 */
|
||||
_display: block;
|
||||
/* stylelint-enable no-browser-hacks */
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {} /* stylelint-disable-line block-no-empty */ /* Reason for disable */
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
_display: block; /* stylelint-disable-line no-browser-hacks */ /* Reason for disable */
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
_display: block; /* stylelint-disable-line no-browser-hacks */
|
||||
/* Reason for disable */
|
||||
}
|
||||
```
|
93
node_modules/stylelint/lib/rules/stylelint-disable-reason/index.js
generated
vendored
Normal file
93
node_modules/stylelint/lib/rules/stylelint-disable-reason/index.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict"
|
||||
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
|
||||
const ruleName = "stylelint-disable-reason"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expectedBefore: "Expected comment reason before `stylelint-disable` comment",
|
||||
expectedAfter: "Expected comment reason after `stylelint-disable` comment",
|
||||
})
|
||||
|
||||
const stylelintDisableCommand = "stylelint-disable"
|
||||
const stylelintDisableLineCommand = "stylelint-disable-line"
|
||||
|
||||
const rule = function (expectation) {
|
||||
return function (root, result) {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"always-before",
|
||||
"always-after",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
result.warn((
|
||||
`'${ruleName}' has been deprecated and in 8.0 will be removed.`
|
||||
), {
|
||||
stylelintType: "deprecation",
|
||||
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
|
||||
})
|
||||
|
||||
root.walkComments(function (comment) {
|
||||
if (comment.text.indexOf(stylelintDisableCommand) !== 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (expectation === "always-before") {
|
||||
const prev = comment.prev()
|
||||
const prevIsCommentAndValid = prev && prev.type === "comment" && !isDisableCommand(prev.text)
|
||||
|
||||
let prevDisableLineIsCommentAndValid = false
|
||||
|
||||
if (comment.text.indexOf(stylelintDisableLineCommand) === 0 && !prevIsCommentAndValid && prev) {
|
||||
const friendlyPrev = prev.prev()
|
||||
|
||||
prevDisableLineIsCommentAndValid = friendlyPrev && friendlyPrev.type === "comment" && !isDisableCommand(friendlyPrev.text)
|
||||
}
|
||||
|
||||
if (!prevIsCommentAndValid && !prevDisableLineIsCommentAndValid) {
|
||||
const disabledRanges = result.stylelint.disabledRanges
|
||||
result.stylelint.disabledRanges = false
|
||||
|
||||
report({
|
||||
message: messages.expectedBefore,
|
||||
node: comment,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
result.stylelint.disabledRanges = disabledRanges
|
||||
}
|
||||
} else if (expectation === "always-after") {
|
||||
const next = comment.next()
|
||||
const nextIsCommentAndValid = next && next.type === "comment" && !isDisableCommand(next.text)
|
||||
|
||||
if (!nextIsCommentAndValid) {
|
||||
const disabledRanges = result.stylelint.disabledRanges
|
||||
result.stylelint.disabledRanges = false
|
||||
|
||||
report({
|
||||
message: messages.expectedAfter,
|
||||
node: comment,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
result.stylelint.disabledRanges = disabledRanges
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function isDisableCommand(text) {
|
||||
return text.indexOf(stylelintDisableCommand) === 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user