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:
93
node_modules/stylelint/lib/rules/declaration-property-value-blacklist/README.md
generated
vendored
Normal file
93
node_modules/stylelint/lib/rules/declaration-property-value-blacklist/README.md
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
# declaration-property-value-blacklist
|
||||
|
||||
Specify a blacklist of disallowed property and value pairs within declarations.
|
||||
|
||||
```css
|
||||
a { text-transform: uppercase; }
|
||||
/** ↑ ↑
|
||||
* These properties and these values */
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
`object`: `{
|
||||
"unprefixed-property-name": ["array", "of", "values"],
|
||||
"unprefixed-property-name": ["/regex/", "non-regex"]
|
||||
}`
|
||||
|
||||
If a property name is surrounded with `"/"` (e.g. `"/^animation/"`), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: `/^animation/` will match `animation`, `animation-duration`, `animation-timing-function`, etc.
|
||||
|
||||
The same goes for values. Keep in mind that a regular expression value is matched against the entire value of the declaration, not specific parts of it. For example, a value like `"10px solid rgba( 255 , 0 , 0 , 0.5 )"` will *not* match `"/^solid/"` (notice beginning of the line boundary) but *will* match `"/\\s+solid\\s+/"` or `"/\\bsolid\\b/"`.
|
||||
|
||||
Be careful with regex matching not to accidentally consider quoted string values and `url()` arguments. For example, `"/red/"` will match value such as `"1px dotted red"` as well as `"\"foo\""` and `"white url(/mysite.com/red.png)"`.
|
||||
|
||||
Given:
|
||||
|
||||
```js
|
||||
{
|
||||
"transform": ["/scale3d/", "/rotate3d/", "/translate3d/"],
|
||||
"position": ["fixed"],
|
||||
"color": ["/^green/"],
|
||||
"/^animation/": ["/ease/"]
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { position: fixed; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transform: scale3d(1, 2, 3); }
|
||||
```
|
||||
|
||||
```css
|
||||
a { -webkit-transform: scale3d(1, 2, 3); }
|
||||
```
|
||||
|
||||
```css
|
||||
a { color: green; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { animation: foo 2s ease-in-out; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { animation-timing-function: ease-in-out; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { -webkit-animation-timing-function: ease-in-out; }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { position: relative; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transform: scale(2); }
|
||||
```
|
||||
|
||||
```css
|
||||
a { -webkit-transform: scale(2); }
|
||||
```
|
||||
|
||||
```css
|
||||
a { color: lightgreen; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { animation: foo 2s linear; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { animation-timing-function: linear; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { -webkit-animation-timing-function: linear; }
|
||||
```
|
53
node_modules/stylelint/lib/rules/declaration-property-value-blacklist/index.js
generated
vendored
Normal file
53
node_modules/stylelint/lib/rules/declaration-property-value-blacklist/index.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict"
|
||||
|
||||
const _ = require("lodash")
|
||||
const matchesStringOrRegExp = require("../../utils/matchesStringOrRegExp")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const postcss = require("postcss")
|
||||
|
||||
const ruleName = "declaration-property-value-blacklist"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: (property, value) => `Unexpected value "${value}" for property "${property}"`,
|
||||
})
|
||||
|
||||
const rule = function (blacklist) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: blacklist,
|
||||
possible: [_.isObject],
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkDecls(decl => {
|
||||
const prop = decl.prop,
|
||||
value = decl.value
|
||||
|
||||
const unprefixedProp = postcss.vendor.unprefixed(prop)
|
||||
const propBlacklist = _.find(blacklist, (list, propIdentifier) => matchesStringOrRegExp(unprefixedProp, propIdentifier))
|
||||
|
||||
if (_.isEmpty(propBlacklist)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!matchesStringOrRegExp(value, propBlacklist)) {
|
||||
return
|
||||
}
|
||||
|
||||
report({
|
||||
message: messages.rejected(prop, value),
|
||||
node: decl,
|
||||
result,
|
||||
ruleName,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user