mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-14 05:43:33 -06:00
Initial commit
This commit is contained in:
96
node_modules/stylelint/lib/rules/unit-blacklist/README.md
generated
vendored
Normal file
96
node_modules/stylelint/lib/rules/unit-blacklist/README.md
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
# unit-blacklist
|
||||
|
||||
Specify a blacklist of disallowed units.
|
||||
|
||||
```css
|
||||
a { width: 100px; }
|
||||
/** ↑
|
||||
* These units */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`array|string`: `["array", "of", "units"]|"unit"`
|
||||
|
||||
Given:
|
||||
|
||||
```js
|
||||
["px", "em", "deg"]
|
||||
```
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { width: 100px; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { font-size: 10em; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transform: rotate(30deg); }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { font-size: 1.2rem; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { line-height: 1.2; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { height: 100vmin; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { animation: animation-name 5s ease; }
|
||||
```
|
||||
|
||||
## Optional secondary options
|
||||
|
||||
### `ignoreProperties: { unit: ["property", "/regex/"] }`
|
||||
|
||||
Ignore units in the values of declarations with the specified properties.
|
||||
|
||||
For example, with `["px", "vmin"]`.
|
||||
|
||||
Given:
|
||||
|
||||
```js
|
||||
{
|
||||
"px": [ "font-size", "/^border/" ],
|
||||
"vmin": [ "width" ]
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { font-size: 13px; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { border-bottom-width: 6px; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { width: 100vmin; }
|
||||
```
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { line-height: 12px; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { -moz-border-radius-topright: 40px; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { height: 100vmin; }
|
||||
```
|
73
node_modules/stylelint/lib/rules/unit-blacklist/index.js
generated
vendored
Normal file
73
node_modules/stylelint/lib/rules/unit-blacklist/index.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict"
|
||||
|
||||
const atRuleParamIndex = require("../../utils/atRuleParamIndex")
|
||||
const declarationValueIndex = require("../../utils/declarationValueIndex")
|
||||
const getUnitFromValueNode = require("../../utils/getUnitFromValueNode")
|
||||
const optionsMatches = require("../../utils/optionsMatches")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const _ = require("lodash")
|
||||
const validateObjectWithStringArrayProps = require("../../utils/validateObjectWithStringArrayProps")
|
||||
const valueParser = require("postcss-value-parser")
|
||||
|
||||
const ruleName = "unit-blacklist"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: unit => `Unexpected unit "${unit}"`,
|
||||
})
|
||||
|
||||
const rule = function (blacklistInput, options) {
|
||||
const blacklist = [].concat(blacklistInput)
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: blacklist,
|
||||
possible: [_.isString],
|
||||
}, {
|
||||
optional: true,
|
||||
actual: options,
|
||||
possible: {
|
||||
ignoreProperties: validateObjectWithStringArrayProps,
|
||||
},
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
function check(node, value, getIndex) {
|
||||
valueParser(value).walk(function (valueNode) {
|
||||
// Ignore wrong units within `url` function
|
||||
if (valueNode.type === "function" && valueNode.value.toLowerCase() === "url") {
|
||||
return false
|
||||
}
|
||||
|
||||
const unit = getUnitFromValueNode(valueNode)
|
||||
|
||||
if (!unit || unit && blacklist.indexOf(unit.toLowerCase()) === -1) {
|
||||
return
|
||||
}
|
||||
|
||||
if (options && optionsMatches(options.ignoreProperties, unit.toLowerCase(), node.prop)) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
index: getIndex(node) + valueNode.sourceIndex,
|
||||
message: messages.rejected(unit),
|
||||
node,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
root.walkAtRules(/^media$/i, atRule => check(atRule, atRule.params, atRuleParamIndex))
|
||||
root.walkDecls(decl => check(decl, decl.value, declarationValueIndex))
|
||||
}
|
||||
}
|
||||
|
||||
rule.primaryOptionArray = true
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user