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:
109
node_modules/stylelint/lib/rules/unit-case/README.md
generated
vendored
Normal file
109
node_modules/stylelint/lib/rules/unit-case/README.md
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
# unit-case
|
||||
|
||||
Specify lowercase or uppercase for units.
|
||||
|
||||
```css
|
||||
a { width: 10px; }
|
||||
/** ↑
|
||||
* These units */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`string`: `"lower"|"upper"`
|
||||
|
||||
### `"lower"`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10PX;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10Px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10pX;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10PIXEL;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: calc(10PX * 2);
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: calc(10px * 2);
|
||||
}
|
||||
```
|
||||
|
||||
### `"upper"`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10Px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10pX;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10pixel;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: calc(10px * 2);
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10PX;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: calc(10PX * 2);
|
||||
}
|
||||
```
|
66
node_modules/stylelint/lib/rules/unit-case/index.js
generated
vendored
Normal file
66
node_modules/stylelint/lib/rules/unit-case/index.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict"
|
||||
|
||||
const atRuleParamIndex = require("../../utils/atRuleParamIndex")
|
||||
const declarationValueIndex = require("../../utils/declarationValueIndex")
|
||||
const getUnitFromValueNode = require("../../utils/getUnitFromValueNode")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const valueParser = require("postcss-value-parser")
|
||||
|
||||
const ruleName = "unit-case"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: (actual, expected) => `Expected "${actual}" to be "${expected}"`,
|
||||
})
|
||||
|
||||
const rule = function (expectation) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: [
|
||||
"lower",
|
||||
"upper",
|
||||
],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
function check(node, value, getIndex) {
|
||||
valueParser(value).walk(valueNode => {
|
||||
// Ignore wrong units within `url` function
|
||||
if (valueNode.type === "function" && valueNode.value.toLowerCase() === "url") {
|
||||
return false
|
||||
}
|
||||
|
||||
const unit = getUnitFromValueNode(valueNode)
|
||||
|
||||
if (!unit) {
|
||||
return
|
||||
}
|
||||
|
||||
const expectedUnit = expectation === "lower" ? unit.toLowerCase() : unit.toUpperCase()
|
||||
|
||||
if (unit === expectedUnit) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
index: getIndex(node) + valueNode.sourceIndex,
|
||||
message: messages.expected(unit, expectedUnit),
|
||||
node,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
root.walkAtRules(/^media$/i, atRule => check(atRule, atRule.params, atRuleParamIndex))
|
||||
root.walkDecls(decl => check(decl, decl.value, declarationValueIndex))
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user