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:
53
node_modules/stylelint/lib/rules/time-no-imperceptible/README.md
generated
vendored
Normal file
53
node_modules/stylelint/lib/rules/time-no-imperceptible/README.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# time-no-imperceptible
|
||||
|
||||
***Deprecated: Instead use the [`time-min-milliseconds`](../time-min-milliseconds/README.md) rule with `100` as its primary option.***
|
||||
|
||||
Disallow `animation` and `transition` less than or equal to 100ms.
|
||||
|
||||
```css
|
||||
a { animation: slip-n-slide 150ms linear; }
|
||||
/** ↑
|
||||
* This time */
|
||||
```
|
||||
|
||||
This rule checks `transition-duration`, `transition-delay`, `animation-duration`, `animation-delay`, and those times as they manifest in the `transition` and `animation` shorthands.
|
||||
|
||||
## Options
|
||||
|
||||
### `true`
|
||||
|
||||
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: horse-dance 1s linear 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: horse-dance 1s linear 1.3s; }
|
||||
```
|
79
node_modules/stylelint/lib/rules/time-no-imperceptible/index.js
generated
vendored
Normal file
79
node_modules/stylelint/lib/rules/time-no-imperceptible/index.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict"
|
||||
|
||||
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-no-imperceptible"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: time => `Unexpected time value "${time}" less than or equal to 100ms`,
|
||||
})
|
||||
|
||||
const MINIMUM_MILLISECONDS = 100
|
||||
|
||||
const rule = function (actual) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, { actual })
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
result.warn((
|
||||
`'${ruleName}' has been deprecated and in 8.0 will be removed. Instead use 'time-min-milliseconds' with '100' as its primary option.`
|
||||
), {
|
||||
stylelintType: "deprecation",
|
||||
stylelintReference: `https://stylelint.io/user-guide/rules/${ruleName}/`,
|
||||
})
|
||||
|
||||
root.walkDecls(decl => {
|
||||
if (keywordSets.longhandTimeProperties.has(postcss.vendor.unprefixed(decl.prop.toLowerCase()))) {
|
||||
if (isImperceptibleTime(decl.value)) {
|
||||
complain(messages.rejected(decl.value), decl)
|
||||
}
|
||||
}
|
||||
|
||||
if (keywordSets.shorthandTimeProperties.has(postcss.vendor.unprefixed(decl.prop.toLowerCase()))) {
|
||||
const valueList = postcss.list.space(decl.value)
|
||||
for (const value of valueList) {
|
||||
if (isImperceptibleTime(value)) {
|
||||
complain(messages.rejected(value), decl, decl.value.indexOf(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function isImperceptibleTime(time) {
|
||||
const parsedTime = valueParser.unit(time)
|
||||
if (!parsedTime) return false
|
||||
const absoluteTime = Math.abs(parsedTime.number)
|
||||
if (parsedTime.unit.toLowerCase() === "ms" && absoluteTime <= MINIMUM_MILLISECONDS) {
|
||||
return true
|
||||
}
|
||||
if (parsedTime.unit.toLowerCase() === "s" && absoluteTime * 1000 <= MINIMUM_MILLISECONDS) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function complain(message, decl) {
|
||||
const offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0
|
||||
|
||||
report({
|
||||
result,
|
||||
ruleName,
|
||||
message,
|
||||
index: declarationValueIndex(decl) + offset,
|
||||
node: decl,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user