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:
53
node_modules/stylelint/lib/rules/time-min-milliseconds/README.md
generated
vendored
Normal file
53
node_modules/stylelint/lib/rules/time-min-milliseconds/README.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# time-min-milliseconds
|
||||
|
||||
Specify the minimum number of milliseconds for time values.
|
||||
|
||||
```css
|
||||
a { animation: slip-n-slide 150ms linear; }
|
||||
/** ↑
|
||||
* This time */
|
||||
```
|
||||
|
||||
This rule checks positive numbers in `transition-duration`, `transition-delay`, `animation-duration`, `animation-delay`, and those times as they manifest in the `transition` and `animation` shorthands.
|
||||
|
||||
## Options
|
||||
|
||||
`int`: Minimum number of milliseconds for time values.
|
||||
|
||||
For example, with `100`:
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { animation: 80ms; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transition-duration: 0.08s; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transition: background-color 6ms linear; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { animation-delay: 0.01s; }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { animation: 8s; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transition-duration: 0.8s; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { transition: background-color 600ms linear; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { animation-delay: 1s; }
|
||||
```
|
85
node_modules/stylelint/lib/rules/time-min-milliseconds/index.js
generated
vendored
Normal file
85
node_modules/stylelint/lib/rules/time-min-milliseconds/index.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict"
|
||||
|
||||
const _ = require("lodash")
|
||||
const declarationValueIndex = require("../../utils/declarationValueIndex")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const keywordSets = require("../../reference/keywordSets")
|
||||
const postcss = require("postcss")
|
||||
const valueParser = require("postcss-value-parser")
|
||||
|
||||
const ruleName = "time-min-milliseconds"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
expected: time => `Expected a minimum of ${time} milliseconds`,
|
||||
})
|
||||
|
||||
const rule = function (minimum) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, {
|
||||
actual: minimum,
|
||||
possible: _.isNumber,
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkDecls(decl => {
|
||||
const propertyName = postcss.vendor.unprefixed(decl.prop.toLowerCase())
|
||||
|
||||
if (
|
||||
keywordSets.longhandTimeProperties.has(propertyName)
|
||||
&& !isAcceptableTime(decl.value)
|
||||
) {
|
||||
complain(decl)
|
||||
}
|
||||
|
||||
if (keywordSets.shorthandTimeProperties.has(propertyName)) {
|
||||
const valueList = postcss.list.space(decl.value)
|
||||
|
||||
for (const value of valueList) {
|
||||
if (!isAcceptableTime(value)) {
|
||||
complain(decl, decl.value.indexOf(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function isAcceptableTime(time) {
|
||||
const parsedTime = valueParser.unit(time)
|
||||
|
||||
if (!parsedTime) return true
|
||||
|
||||
if (parsedTime.number <= 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (parsedTime.unit.toLowerCase() === "ms" && parsedTime.number < minimum) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (parsedTime.unit.toLowerCase() === "s" && parsedTime.number * 1000 < minimum) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function complain(decl, offset) {
|
||||
offset = offset || 0
|
||||
|
||||
report({
|
||||
result,
|
||||
ruleName,
|
||||
message: messages.expected(minimum),
|
||||
index: declarationValueIndex(decl) + offset,
|
||||
node: decl,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user