Initial commit

This commit is contained in:
Patrick Marsceill
2017-03-09 13:16:08 -05:00
commit b7b0d0d7bf
4147 changed files with 401224 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
# value-no-vendor-prefix
Disallow vendor prefixes for values.
```css
a { display: -webkit-flex; }
/** ↑
* These prefixes */
```
This rule will only warn for prefixed *standard* values, and not for prefixed *proprietary* or *unknown* ones.
## Options
### `true`
The following patterns are considered warnings:
```css
a { display: -webkit-flex; }
```
```css
a { max-width: -moz-max-content; }
```
```css
a { background: -webkit-linear-gradient(bottom, #000, #fff); }
```
The following patterns are *not* considered warnings:
```css
a { display: flex; }
```
```css
a { max-width: max-content; }
```
```css
a { background: linear-gradient(bottom, #000, #fff); }
```

View File

@@ -0,0 +1,61 @@
"use strict"
const isAutoprefixable = require("../../utils/isAutoprefixable")
const isStandardSyntaxDeclaration = require("../../utils/isStandardSyntaxDeclaration")
const isStandardSyntaxProperty = require("../../utils/isStandardSyntaxProperty")
const report = require("../../utils/report")
const ruleMessages = require("../../utils/ruleMessages")
const validateOptions = require("../../utils/validateOptions")
const styleSearch = require("style-search")
const ruleName = "value-no-vendor-prefix"
const messages = ruleMessages(ruleName, {
rejected: value => `Unexpected vendor-prefix "${value}"`,
})
const valuePrefixes = [
"-webkit-",
"-moz-",
"-ms-",
"-o-",
]
const rule = function (actual) {
return (root, result) => {
const validOptions = validateOptions(result, ruleName, { actual })
if (!validOptions) {
return
}
root.walkDecls(decl => {
if (!isStandardSyntaxDeclaration(decl) || !isStandardSyntaxProperty(decl.prop) || decl.value[0] !== "-") {
return
}
const prop = decl.prop,
value = decl.value
// Search the full declaration in order to get an accurate index
styleSearch({ source: value.toLowerCase(), target: valuePrefixes }, match => {
const fullIdentifier = /^(-[a-z-]+)\b/i.exec(value.slice(match.startIndex))[1]
if (!isAutoprefixable.propertyValue(prop, fullIdentifier)) {
return
}
report({
message: messages.rejected(fullIdentifier),
node: decl,
index: prop.length + (decl.raws.between || "").length + match.startIndex,
result,
ruleName,
})
})
})
}
}
rule.ruleName = ruleName
rule.messages = messages
module.exports = rule