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,45 @@
# at-rule-blacklist
Specify a blacklist of disallowed at-rules.
```css
@keyframes name {}
/** ↑
* At-rules like this */
```
## Options
`array|string`: `["array", "of", "unprefixed", "at-rules"]|"at-rule"`
Given:
```js
["extend", "keyframes"]
```
The following patterns are considered warnings:
```css
a { @extend placeholder; }
```
```css
@keyframes name {
from { top: 10px; }
to { top: 20px; }
}
```
```css
@-moz-keyframes name {
from { top: 10px; }
to { top: 20px; }
}
```
The following patterns are *not* considered warnings:
```css
@import "path/to/file.css";
```

View File

@@ -0,0 +1,48 @@
"use strict"
const _ = require("lodash")
const postcss = require("postcss")
const report = require("../../utils/report")
const ruleMessages = require("../../utils/ruleMessages")
const validateOptions = require("../../utils/validateOptions")
const ruleName = "at-rule-blacklist"
const messages = ruleMessages(ruleName, {
rejected: name => `Unexpected at-rule "${name}"`,
})
const rule = function (blacklistInput) {
// To allow for just a string as a parameter (not only arrays of strings)
const blacklist = [].concat(blacklistInput)
return (root, result) => {
const validOptions = validateOptions(result, ruleName, {
actual: blacklist,
possible: [_.isString],
})
if (!validOptions) {
return
}
root.walkAtRules(atRule => {
const name = atRule.name
if (blacklist.indexOf(postcss.vendor.unprefixed(name).toLowerCase()) === -1) {
return
}
report({
message: messages.rejected(name),
node: atRule,
result,
ruleName,
})
})
}
}
rule.primaryOptionArray = true
rule.ruleName = ruleName
rule.messages = messages
module.exports = rule