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,117 @@
# media-query-list-comma-space-after
Require a single space or disallow whitespace after the commas of media query lists.
```css
@media screen and (color), projection and (color) {}
/** ↑
* These commas */
```
## Options
`string`: `"always"|"never"|"always-single-line"|"never-single-line"`
### `"always"`
There *must always* be a single space after the commas.
The following patterns are considered warnings:
```css
@media screen and (color),projection and (color) {}
```
```css
@media screen and (color)
,projection and (color) {}
```
The following patterns are *not* considered warnings:
```css
@media screen and (color), projection and (color) {}
```
```css
@media screen and (color)
, projection and (color) {}
```
### `"never"`
There *must never* be whitepace after the commas.
The following patterns are considered warnings:
```css
@media screen and (color), projection and (color) {}
```
```css
@media screen and (color)
, projection and (color) {}
```
The following patterns are *not* considered warnings:
```css
@media screen and (color),projection and (color) {}
```
```css
@media screen and (color)
,projection and (color) {}
```
### `"always-single-line"`
There *must always* be a single space after the commas in single-line media query lists.
The following patterns are considered warnings:
```css
@media screen and (color),projection and (color) {}
```
The following patterns are *not* considered warnings:
```css
@media screen and (color), projection and (color) {}
```
```css
@media screen and (color)
, projection and (color) {}
```
```css
@media screen and (color)
,projection and (color) {}
```
### `"never-single-line"`
There *must never* be whitepace after the commas in single-line media query lists.
The following patterns are considered warnings:
```css
@media screen and (color), projection and (color) {}
```
The following patterns are *not* considered warnings:
```css
@media screen and (color),projection and (color) {}
```
```css
@media screen and (color)
,projection and (color) {}
```
```css
@media screen and (color)
, projection and (color) {}
```

View File

@@ -0,0 +1,43 @@
"use strict"
const ruleMessages = require("../../utils/ruleMessages")
const validateOptions = require("../../utils/validateOptions")
const whitespaceChecker = require("../../utils/whitespaceChecker")
const mediaQueryListCommaWhitespaceChecker = require("../mediaQueryListCommaWhitespaceChecker")
const ruleName = "media-query-list-comma-space-after"
const messages = ruleMessages(ruleName, {
expectedAfter: () => "Expected single space after \",\"",
rejectedAfter: () => "Unexpected whitespace after \",\"",
expectedAfterSingleLine: () => "Expected single space after \",\" in a single-line list",
rejectedAfterSingleLine: () => "Unexpected whitespace after \",\" in a single-line list",
})
const rule = function (expectation) {
const checker = whitespaceChecker("space", expectation, messages)
return (root, result) => {
const validOptions = validateOptions(result, ruleName, {
actual: expectation,
possible: [
"always",
"never",
"always-single-line",
"never-single-line",
],
})
if (!validOptions) {
return
}
mediaQueryListCommaWhitespaceChecker({
root,
result,
locationChecker: checker.after,
checkedRuleName: ruleName,
})
}
}
rule.ruleName = ruleName
rule.messages = messages
module.exports = rule