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:
68
node_modules/stylelint/lib/rules/font-family-no-duplicate-names/README.md
generated
vendored
Normal file
68
node_modules/stylelint/lib/rules/font-family-no-duplicate-names/README.md
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
# font-family-no-duplicate-names
|
||||
|
||||
Disallow duplicate font family names.
|
||||
|
||||
```css
|
||||
a { font-family: serif, serif; }
|
||||
/** ↑ ↑
|
||||
* These font family names */
|
||||
```
|
||||
|
||||
This rule checks the `font` and `font-family` properties.
|
||||
|
||||
This rule ignores `$sass`, `@less`, and `var(--custom-property)` variable syntaxes.
|
||||
|
||||
**Caveat:** This rule will stumble on *unquoted* multi-word font names and *unquoted* font names containing escape sequences. Wrap these font names in quotation marks, and everything should be fine.
|
||||
|
||||
## Options
|
||||
|
||||
### `true`
|
||||
|
||||
The following patterns are considered warnings:
|
||||
|
||||
```css
|
||||
a { font-family: 'Times', Times, serif; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { font: 1em "Arial", 'Arial', sans-serif; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif, sans-serif; }
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
a { font-family: Times, serif; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { font: 1em "Arial", "sans-serif", sans-serif; }
|
||||
```
|
||||
|
||||
```css
|
||||
a { font: normal 14px/32px -apple-system, BlinkMacSystemFont, sans-serif; }
|
||||
```
|
||||
|
||||
## Optional secondary options
|
||||
|
||||
### `ignoreFontFamilyNames: ["/regex/", "string"]`
|
||||
|
||||
Given:
|
||||
|
||||
```js
|
||||
["/^My Font /", "monospace"]
|
||||
```
|
||||
|
||||
The following patterns are *not* considered warnings:
|
||||
|
||||
```css
|
||||
font-family: monospace, monospace
|
||||
```
|
||||
|
||||
```css
|
||||
font-family: "My Font Family", "My Font Family", monospace
|
||||
```
|
||||
|
83
node_modules/stylelint/lib/rules/font-family-no-duplicate-names/index.js
generated
vendored
Normal file
83
node_modules/stylelint/lib/rules/font-family-no-duplicate-names/index.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"use strict"
|
||||
|
||||
const declarationValueIndex = require("../../utils/declarationValueIndex")
|
||||
const findFontFamily = require("../../utils/findFontFamily")
|
||||
const report = require("../../utils/report")
|
||||
const ruleMessages = require("../../utils/ruleMessages")
|
||||
const validateOptions = require("../../utils/validateOptions")
|
||||
const keywordSets = require("../../reference/keywordSets")
|
||||
const _ = require("lodash")
|
||||
const optionsMatches = require("../../utils/optionsMatches")
|
||||
|
||||
const ruleName = "font-family-no-duplicate-names"
|
||||
|
||||
const messages = ruleMessages(ruleName, {
|
||||
rejected: name => `Unexpected duplicate name ${name}`,
|
||||
})
|
||||
|
||||
const isFamilyNameKeyword = node => !node.quote && keywordSets.fontFamilyKeywords.has(node.value.toLowerCase())
|
||||
|
||||
const rule = function (actual, options) {
|
||||
return (root, result) => {
|
||||
const validOptions = validateOptions(result, ruleName, { actual }, {
|
||||
actual: options,
|
||||
possible: {
|
||||
ignoreFontFamilyNames: [_.isString],
|
||||
},
|
||||
optional: true,
|
||||
})
|
||||
if (!validOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
root.walkDecls(/^font(-family)?$/i, decl => {
|
||||
const keywords = new Set()
|
||||
const familyNames = new Set()
|
||||
|
||||
const fontFamilies = findFontFamily(decl.value)
|
||||
|
||||
if (fontFamilies.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
fontFamilies.forEach(fontFamilyNode => {
|
||||
const family = fontFamilyNode.value.trim()
|
||||
|
||||
if (optionsMatches(options, "ignoreFontFamilyNames", fontFamilyNode.value.trim())) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isFamilyNameKeyword(fontFamilyNode)) {
|
||||
if (keywords.has(family.toLowerCase())) {
|
||||
complain(messages.rejected(family), declarationValueIndex(decl) + fontFamilyNode.sourceIndex, decl)
|
||||
return
|
||||
}
|
||||
|
||||
keywords.add(family)
|
||||
return
|
||||
}
|
||||
|
||||
if (familyNames.has(family)) {
|
||||
complain(messages.rejected(family), declarationValueIndex(decl) + fontFamilyNode.sourceIndex, decl)
|
||||
return
|
||||
}
|
||||
|
||||
familyNames.add(family)
|
||||
})
|
||||
})
|
||||
|
||||
function complain(message, index, decl) {
|
||||
report({
|
||||
result,
|
||||
ruleName,
|
||||
message,
|
||||
node: decl,
|
||||
index,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule.ruleName = ruleName
|
||||
rule.messages = messages
|
||||
module.exports = rule
|
Reference in New Issue
Block a user