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:
54
node_modules/stylelint/lib/rules/declaration-block-no-shorthand-property-overrides/README.md
generated
vendored
Normal file
54
node_modules/stylelint/lib/rules/declaration-block-no-shorthand-property-overrides/README.md
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
# declaration-block-no-shorthand-property-overrides
|
||||
|
||||
Disallow shorthand properties that override related longhand properties.
|
||||
|
||||
```css
|
||||
a { background-repeat: repeat; background: green; }
|
||||
/** ↑
|
||||
* This overrides the longhand property before it */
|
||||
```
|
||||
|
||||
In almost every case, this is just an authorial oversight. For more about this behavior, see [MDN's documentation of shorthand properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties).
|
||||
|
||||
## Options
|
||||
|
||||
### `true`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a {
|
||||
padding-left: 10px;
|
||||
padding: 20px;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
transition-property: opacity;
|
||||
transition: opacity 1s linear;
|
||||
}
|
||||
```
|
||||
|
||||
```css
|
||||
a {
|
||||
border-top-width: 1px;
|
||||
top: 0;
|
||||
bottom: 3px;
|
||||
border: 2px solid blue;
|
||||
}
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { padding: 10px; padding-left: 20px; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transition-property: opacity; } a { transition: opacity 1s linear; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transition-property: opacity; -webkit-transition: opacity 1s linear; }
|
||||
```
|
57
node_modules/stylelint/lib/rules/declaration-block-no-shorthand-property-overrides/index.js
generated
vendored
Normal file
57
node_modules/stylelint/lib/rules/declaration-block-no-shorthand-property-overrides/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
"use strict"
|
||||
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const shorthandData = require("../../reference/shorthandData")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
|
||||
const ruleName = "declaration-block-no-shorthand-property-overrides"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: (shorthand, original) => `Unexpected shorthand "${shorthand}" after "${original}"`,
|
||||
})
|
||||
|
||||
const rule = function (actual) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, { actual })
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkRules(check)
|
||||
root.walkAtRules(check)
|
||||
|
||||
function check(statement) {
|
||||
const declarations = {}
|
||||
// Shallow iteration so nesting doesn't produce
|
||||
// false positives
|
||||
statement.each(node => {
|
||||
if (node.type !== "decl") {
|
||||
return
|
||||
}
|
||||
const prop = node.prop
|
||||
|
||||
const overrideables = shorthandData[prop.toLowerCase()]
|
||||
if (!overrideables) {
|
||||
declarations[prop.toLowerCase()] = prop
|
||||
return
|
||||
}
|
||||
overrideables.forEach(longhandProp => {
|
||||
if (!declarations.hasOwnProperty(longhandProp)) {
|
||||
return
|
||||
}
|
||||
report({
|
||||
ruleName,
|
||||
result,
|
||||
node,
|
||||
message: messages.rejected(prop, declarations[longhandProp]),
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user