mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 21:33:32 -06:00
Initial commit
This commit is contained in:
85
node_modules/stylelint/lib/rules/unit-no-unknown/README.md
generated
vendored
Normal file
85
node_modules/stylelint/lib/rules/unit-no-unknown/README.md
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
# unit-no-unknown
|
||||
|
||||
Disallow unknown units.
|
||||
|
||||
```css
|
||||
a { width: 100pixels; }
|
||||
/** ↑
|
||||
* These units */
|
||||
```
|
||||
|
||||
This rule considers units defined in the CSS Specifications, up to and including Editor's Drafts, to be known.
|
||||
|
||||
## Options
|
||||
|
||||
### `true`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10pixels;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: calc(10px + 10pixels);
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10Px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10pX;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: calc(10px + 10px);
|
||||
}
|
||||
```
|
||||
|
||||
## Optional secondary options
|
||||
|
||||
### `ignoreUnits: ["/regex/", "string"]`
|
||||
|
||||
Given:
|
||||
|
||||
```js
|
||||
["/^my-/", "custom"]
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10custom;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10my-unit;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
width: 10my-other-unit;
|
||||
}
|
||||
```
|
71
node_modules/stylelint/lib/rules/unit-no-unknown/index.js
generated
vendored
Normal file
71
node_modules/stylelint/lib/rules/unit-no-unknown/index.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"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 keywordSets = require("../../reference/keywordSets")
|
||||
const valueParser = require("postcss-value-parser")
|
||||
|
||||
const ruleName = "unit-no-unknown"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: unit => `Unexpected unknown unit "${unit}"`,
|
||||
})
|
||||
|
||||
const rule = function (actual, options) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, { actual }, {
|
||||
actual: options,
|
||||
possible: {
|
||||
ignoreUnits: [_.isString],
|
||||
},
|
||||
optional: true,
|
||||
})
|
||||
|
||||
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) {
|
||||
return
|
||||
}
|
||||
|
||||
if (optionsMatches(options, "ignoreUnits", unit)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (keywordSets.units.has(unit.toLowerCase())) {
|
||||
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.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user