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:
47
node_modules/stylelint/lib/rules/selector-pseudo-class-blacklist/README.md
generated
vendored
Normal file
47
node_modules/stylelint/lib/rules/selector-pseudo-class-blacklist/README.md
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# selector-pseudo-class-blacklist
|
||||
|
||||
Specify a blacklist of disallowed pseudo-class selectors.
|
||||
|
||||
```css
|
||||
a:hover {}
|
||||
/** ↑
|
||||
* These pseudo-class selectors */
|
||||
```
|
||||
|
||||
This rule ignores selectors that use variable interpolation e.g. `:#{$variable} {}`.
|
||||
|
||||
## Options
|
||||
|
||||
`array|string|regex`: `["array", "of", "unprefixed", "pseudo-classes" or "regex"]|"pseudo-class"|/regex/`
|
||||
|
||||
If a string is surrounded with `"/"` (e.g. `"/^nth-/"`), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: `/^nth-/` will match `nth-child`, `nth-last-child`, `nth-of-type`, etc.
|
||||
|
||||
Given:
|
||||
|
||||
```js
|
||||
["hover", "/^nth-/"]
|
||||
```
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a:hover {}
|
||||
```
|
||||
|
||||
```css
|
||||
a:nth-of-type(5) {}
|
||||
```
|
||||
|
||||
```css
|
||||
a:nth-child(2) {}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a:focus {}
|
||||
```
|
||||
|
||||
```css
|
||||
a:first-of-type {}
|
||||
```
|
71
node_modules/stylelint/lib/rules/selector-pseudo-class-blacklist/index.js
generated
vendored
Normal file
71
node_modules/stylelint/lib/rules/selector-pseudo-class-blacklist/index.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict"
|
||||
|
||||
const isStandardSyntaxSelector = require("../../utils/isStandardSyntaxSelector")
|
||||
const matchesStringOrRegExp = require("../../utils/matchesStringOrRegExp")
|
||||
const parseSelector = require("../../utils/parseSelector")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const _ = require("lodash")
|
||||
const postcss = require("postcss")
|
||||
|
||||
const ruleName = "selector-pseudo-class-blacklist"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: selector => `Unexpected pseudo-class "${selector}"`,
|
||||
})
|
||||
|
||||
const rule = function (blacklist) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: blacklist,
|
||||
possible: [_.isString],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkRules(rule => {
|
||||
const selector = rule.selector
|
||||
|
||||
if (!isStandardSyntaxSelector(selector)) {
|
||||
return
|
||||
}
|
||||
if (selector.indexOf(":") === -1) {
|
||||
return
|
||||
}
|
||||
|
||||
parseSelector(selector, result, rule, selectorTree => {
|
||||
selectorTree.walkPseudos(pseudoNode => {
|
||||
const value = pseudoNode.value
|
||||
|
||||
// Ignore pseudo-elements
|
||||
|
||||
if (value.slice(0, 2) === "::") {
|
||||
return
|
||||
}
|
||||
|
||||
const name = value.slice(1)
|
||||
|
||||
if (!matchesStringOrRegExp(postcss.vendor.unprefixed(name).toLowerCase(), blacklist)) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
index: pseudoNode.sourceIndex,
|
||||
message: messages.rejected(name),
|
||||
node: rule,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.primaryOptionArray = true
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user