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,35 @@
# selector-no-vendor-prefix
Disallow vendor prefixes for selectors.
```css
input::-moz-placeholder {}
/** ↑
* These prefixes */
```
This rule does not blanketly condemn vendor prefixes. Instead, it uses [Autoprefixer's](https://github.com/postcss/autoprefixer) up-to-date data (from [caniuse.com](http://caniuse.com/)) to know whether a vendor prefix should cause a warning or not. *If you've included a vendor prefixed selector that has a standard alternative, one that Autoprefixer could take care of for you, this rule will warn about it*. If, however, you use a non-standard vendor-prefixed selector, one that Autoprefixer would ignore and could not provide, this rule will ignore it.
## Options
### `true`
The following patterns are considered warnings:
```css
input::-moz-placeholder {}
```
```css
:-webkit-full-screen a {}
```
The following patterns are *not* considered warnings:
```css
input::placeholder {}
```
```css
:full-screen a {}
```

View File

@@ -0,0 +1,52 @@
"use strict"
const isAutoprefixable = require("../../utils/isAutoprefixable")
const isStandardSyntaxRule = require("../../utils/isStandardSyntaxRule")
const isStandardSyntaxSelector = require("../../utils/isStandardSyntaxSelector")
const parseSelector = require("../../utils/parseSelector")
const report = require("../../utils/report")
const ruleMessages = require("../../utils/ruleMessages")
const validateOptions = require("../../utils/validateOptions")
const ruleName = "selector-no-vendor-prefix"
const messages = ruleMessages(ruleName, {
rejected: selector => `Unexpected vendor-prefix "${selector}"`,
})
const rule = function (actual) {
return (root, result) => {
const validOptions = validateOptions(result, ruleName, { actual })
if (!validOptions) {
return
}
root.walkRules(rule => {
if (!isStandardSyntaxRule(rule)) {
return
}
const selector = rule.selector
if (!isStandardSyntaxSelector(selector)) {
return
}
parseSelector(selector, result, rule, selectorTree => {
selectorTree.walkPseudos(pseudoNode => {
if (isAutoprefixable.selector(pseudoNode.value)) {
report({
result,
ruleName,
message: messages.rejected(pseudoNode.value),
node: rule,
index: (rule.raws.before || "").length + pseudoNode.sourceIndex,
})
}
})
})
})
}
}
rule.ruleName = ruleName
rule.messages = messages
module.exports = rule