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,98 @@
# media-query-list-comma-newline-before
Require a newline or disallow whitespace before the commas of media query lists.
```css
@media screen and (color)
, projection and (color) {}
/** ↑
* These commas */
```
## Options
`string`: `"always"|"always-multi-line"|"never-multi-line"`
### `"always"`
There *must always* be a newline before 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-multi-line"`
There *must always* be a newline before the commas in multi-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-multi-line"`
There *must never* be whitespace before the commas in multi-line media query lists.
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) {}
```

View File

@@ -0,0 +1,41 @@
"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-newline-before"
const messages = ruleMessages(ruleName, {
expectedBefore: () => "Expected newline before \",\"",
expectedBeforeMultiLine: () => "Expected newline before \",\" in a multi-line list",
rejectedBeforeMultiLine: () => "Unexpected whitespace before \",\" in a multi-line list",
})
const rule = function (expectation) {
const checker = whitespaceChecker("newline", expectation, messages)
return (root, result) => {
const validOptions = validateOptions(result, ruleName, {
actual: expectation,
possible: [
"always",
"always-multi-line",
"never-multi-line",
],
})
if (!validOptions) {
return
}
mediaQueryListCommaWhitespaceChecker({
root,
result,
locationChecker: checker.beforeAllowingIndentation,
checkedRuleName: ruleName,
})
}
}
rule.ruleName = ruleName
rule.messages = messages
module.exports = rule