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:
113
node_modules/stylelint/lib/rules/selector-pseudo-element-colon-notation/README.md
generated
vendored
Normal file
113
node_modules/stylelint/lib/rules/selector-pseudo-element-colon-notation/README.md
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
# selector-pseudo-element-colon-notation
|
||||
|
||||
Specify single or double colon notation for applicable pseudo-elements.
|
||||
|
||||
```css
|
||||
a::before { color:pink; }
|
||||
/** ↑
|
||||
* This notation */
|
||||
```
|
||||
|
||||
The `::` notation was chosen for *pseudo-elements* to establish a discrimination between *pseudo-classes* (which subclass existing elements) and *pseudo-elements* (which are elements not represented in the document tree).
|
||||
|
||||
However, for compatibility with existing style sheets, user agents also accept the previous one-colon notation for *pseudo-elements* introduced in CSS levels 1 and 2 (namely, `:first-line`, `:first-letter`, `:before` and `:after`).
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"single"|"double"`
|
||||
|
||||
### `"single"`
|
||||
|
||||
Applicable pseudo-elements *must always* use the single colon notation.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a::before { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a::after { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a::first-letter { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a::first-line { color: pink; }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a:before { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a:after { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a:first-letter { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a:first-line { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
input::placeholder { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
li::marker { font-variant-numeric: tabular-nums; }
|
||||
```
|
||||
|
||||
### `"double"`
|
||||
|
||||
Applicable pseudo-elements *must always* use the double colon notation.
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a:before { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a:after { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a:first-letter { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a:first-line { color: pink; }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a::before { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a::after { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a::first-letter { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
a::first-line { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
input::placeholder { color: pink; }
|
||||
```
|
||||
|
||||
```css
|
||||
li::marker { font-variant-numeric: tabular-nums; }
|
||||
```
|
67
node_modules/stylelint/lib/rules/selector-pseudo-element-colon-notation/index.js
generated
vendored
Normal file
67
node_modules/stylelint/lib/rules/selector-pseudo-element-colon-notation/index.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict"
|
||||
|
||||
const isStandardSyntaxRule = require("../../utils/isStandardSyntaxRule")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const _ = require("lodash")
|
||||
const keywordSets = require("../../reference/keywordSets")
|
||||
const styleSearch = require("style-search")
|
||||
|
||||
const ruleName = "selector-pseudo-element-colon-notation"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: q => `Expected ${q} colon pseudo-element notation`,
|
||||
})
|
||||
|
||||
const rule = function (expectation) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"single",
|
||||
"double",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkRules(rule => {
|
||||
if (!isStandardSyntaxRule(rule)) {
|
||||
return
|
||||
}
|
||||
const selector = rule.selector
|
||||
|
||||
// get out early if no pseudo elements or classes
|
||||
if (selector.indexOf(":") === -1) {
|
||||
return
|
||||
}
|
||||
|
||||
// match only level 1 and 2 pseudo elements
|
||||
const pseudoElementsWithColons = _.toArray(keywordSets.levelOneAndTwoPseudoElements).map(x => `:${x}`)
|
||||
styleSearch({ source: selector.toLowerCase(), target: pseudoElementsWithColons }, match => {
|
||||
const prevCharIsColon = selector[match.startIndex - 1] === ":"
|
||||
|
||||
if (expectation === "single" && !prevCharIsColon) {
|
||||
return
|
||||
}
|
||||
if (expectation === "double" && prevCharIsColon) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
message: messages.expected(expectation),
|
||||
node: rule,
|
||||
index: match.startIndex,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user